Keep the flasher watchdog-reset config0 value an unsigned u32#1616
Merged
Conversation
(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.
Contributor
There was a problem hiding this comment.
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
wdtConfig0bitmask to an unsigned u32 via>>> 0before callingloader.writeReg. - Expand the existing comment to document the JavaScript signed-bitwise behavior and why the cast is present.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1616 +/- ##
=======================================
Coverage 99.54% 99.54%
=======================================
Files 226 226
Lines 17884 17884
=======================================
Hits 17803 17803
Misses 81 81
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
(1 << 31)evaluates to a negative signed int32 in JavaScript, so thewdtConfig0write in the flasher'swatchdogReset(theESP32-S2/S3/C2/C3 RTC-WDT reset path) was passing a negative value where
the ROM expects the unsigned value. Masking with
>>> 0keeps it anunsigned u32 and documents why in the comment.
No behaviour change:
loader.writeRegcoerces to u32 on the wire eitherway. 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