Skip to content

Fix ESP32 repeater boot crash-loop on blank/first-boot flash - #3314

Open
szmidtpiotr wants to merge 1 commit into
meshcore-dev:mainfrom
szmidtpiotr:fix/heltec-v4-repeater-spiffs-crash-loop
Open

Fix ESP32 repeater boot crash-loop on blank/first-boot flash#3314
szmidtpiotr wants to merge 1 commit into
meshcore-dev:mainfrom
szmidtpiotr:fix/heltec-v4-repeater-spiffs-crash-loop

Conversation

@szmidtpiotr

Copy link
Copy Markdown

Summary

Fixes #2506 ("Constant rebooting when the repeater is started on Heltec V4 with MeshCore V1.15.0").

SPIFFS.begin(true) in examples/simple_repeater/main.cpp never 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 into SPIFFS.begin() can itself fail on the first attempt. The code previously proceeded regardless, leaving fs/IdentityStore/CommonCLI/ClientACL/RegionMap all 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 as StoreProhibited/IllegalInstruction exceptions, 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 explicit SPIFFS.format() followed by SPIFFS.begin(), and halt() 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):

  • Built heltec_v4_repeater via PlatformIO from this branch.
  • Full chip 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.
  • Same erase + reflash with this patch applied: device boots cleanly, generates/prints its Repeater ID, completes 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

  • CI build passes for the heltec_v4_repeater (and other ESP32 repeater/room-server/companion) environments
  • Maintainer confirms this doesn't regress the normal (non-blank-flash) boot path

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constant rebooting when the repeater is started on Heltec V4 with MeshCore V1.15.0

1 participant