Fix ESP32 repeater boot crash-loop on blank/first-boot flash - #3314
Open
szmidtpiotr wants to merge 1 commit into
Open
Fix ESP32 repeater boot crash-loop on blank/first-boot flash#3314szmidtpiotr wants to merge 1 commit into
szmidtpiotr wants to merge 1 commit into
Conversation
SPIFFS.begin(true) in the repeater's setup() ignored its return value. On a freshly erased flash the initial mount can fail, and the format-on-fail path built into SPIFFS.begin() can itself fail on the first attempt. Previously the code carried on regardless, leaving fs/IdentityStore/CommonCLI/ClientACL/RegionMap all operating against a non-functional filesystem. Reads against SPIFFS in that state don't fail cleanly - they can return stale/garbage data - which corrupts node prefs/ACL/region state and crashes shortly after boot (StoreProhibited / IllegalInstruction, register contents matching raw erased-flash bytes). The device then reboots into the same broken state, producing a permanent crash-loop. Fix: check SPIFFS.begin(true)'s return value; on failure, retry with an explicit SPIFFS.format() + SPIFFS.begin(), and halt with a clear log message if it still fails, instead of silently continuing with a broken filesystem. Verified on physical Heltec V4 (ESP32-S3, 2MB PSRAM/16MB flash) hardware: full chip erase + reflash of the repeater firmware previously crash-looped every boot; with this fix the device boots cleanly and stably from blank flash. Fixes meshcore-dev#2506
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #2506 ("Constant rebooting when the repeater is started on Heltec V4 with MeshCore V1.15.0").
SPIFFS.begin(true)inexamples/simple_repeater/main.cppnever checked its return value. On a freshly erased/first-boot flash, the initial SPIFFS mount can fail, and the format-on-mount-fail path built intoSPIFFS.begin()can itself fail on the first attempt. The code previously proceeded regardless, leavingfs/IdentityStore/CommonCLI/ClientACL/RegionMapall operating against a non-functional filesystem object. Reads against SPIFFS in that broken state don't fail cleanly — they can return stale/garbage data — which corrupts node prefs/ACL/region state in memory and crashes shortly after boot (observed asStoreProhibited/IllegalInstructionexceptions, with register contents matching raw erased-flash byte patterns, e.g.0xff/0xff00/0xff0000/0xff000000). The device then reboots into the same broken state, producing a permanent crash-loop that only a full erase-and-reflash without hitting the same race would clear (unreliable in practice).Fix
Check
SPIFFS.begin(true)'s return value. On failure, retry once with an explicitSPIFFS.format()followed bySPIFFS.begin(), andhalt()with a clear debug log message if it still fails — instead of silently continuing with a broken filesystem.This only changes the ESP32 failure path; the working case (mount succeeds first try) is untouched.
Testing
Reproduced and verified the fix on physical hardware — a Heltec V4 (ESP32-S3, 2MB PSRAM / 16MB flash):
heltec_v4_repeatervia PlatformIO from this branch.erase_flash+ reflash on the unpatched firmware (v1.14.1 through v1.17.1 all reproduce): device crash-loops every boot on the blank flash, matching the symptoms in Constant rebooting when the repeater is started on Heltec V4 with MeshCore V1.15.0 #2506.MyMesh::begin(), sends the boot advertisement, and runs stably (verified over multiple clean test windows with the serial port in raw/no-echo mode to rule out host-side artifacts).Test plan
heltec_v4_repeater(and other ESP32 repeater/room-server/companion) environments