Skip to content

Keep the flasher watchdog-reset config0 value an unsigned u32#1616

Merged
bdraco merged 1 commit into
mainfrom
flasher-wdt-u32
Jun 20, 2026
Merged

Keep the flasher watchdog-reset config0 value an unsigned u32#1616
bdraco merged 1 commit into
mainfrom
flasher-wdt-u32

Conversation

@bdraco

@bdraco bdraco commented Jun 20, 2026

Copy link
Copy Markdown
Member

What does this implement/fix?

(1 << 31) evaluates to a negative signed int32 in JavaScript, so the
wdtConfig0 write in the flasher's watchdogReset (the
ESP32-S2/S3/C2/C3 RTC-WDT reset path) was passing a negative value where
the ROM expects the unsigned value. Masking with >>> 0 keeps it an
unsigned u32 and documents why in the comment.

No behaviour change: loader.writeReg coerces to u32 on the wire either
way. Readability only, mirroring the same nit fixed in the dashboard's
copy (esphome/dashboard#923) and the canonical frontend source
(esphome/device-builder-frontend#912).

Types of changes

  • Refactor (no behaviour change) — refactor

(1 << 31) is a negative signed int32 in JS, so the wdtConfig0 write in
watchdogReset passed a negative value. Mask with >>> 0 to keep it the
unsigned value the ROM expects, and note why in the comment. No
behaviour change (writeReg coerces to u32 anyway); readability only.
Copilot AI review requested due to automatic review settings June 20, 2026 00:52
@bdraco bdraco added the refactor Code refactor with no user-visible behaviour change label Jun 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the flasher’s ESP32 RTC watchdog-reset register write to keep the computed wdtConfig0 value explicitly unsigned in JavaScript, avoiding the “negative int32” representation that results from (1 << 31) and clarifying intent in-code.

Changes:

  • Cast the wdtConfig0 bitmask to an unsigned u32 via >>> 0 before calling loader.writeReg.
  • Expand the existing comment to document the JavaScript signed-bitwise behavior and why the cast is present.

@bdraco bdraco enabled auto-merge (squash) June 20, 2026 00:54
@codspeed-hq

codspeed-hq Bot commented Jun 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks


Comparing flasher-wdt-u32 (dab67d1) with main (ec128fc)

Open in CodSpeed

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (ec128fc) to head (dab67d1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1616   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files         226      226           
  Lines       17884    17884           
=======================================
  Hits        17803    17803           
  Misses         81       81           
Flag Coverage Δ
py3.12 99.51% <ø> (ø)
py3.14 99.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco bdraco merged commit 5d7b1c3 into main Jun 20, 2026
25 checks passed
@bdraco bdraco deleted the flasher-wdt-u32 branch June 20, 2026 00:55
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

refactor Code refactor with no user-visible behaviour change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants