Rebuilding doesn't help, it reproduces on different devices (so, for example if someone pushes the code in crashing state - all developers, even with different host OS, will have bootloop on their devices)
Instructions in disassembly look completely correct and are the same in normal and bootlooping firmwares.
After investigation we found out that the size of the .flash.text block of the firmware matters. So, to fix this bootloop usually is enough to add a string to the source code, for example LOGI("crashfix", "crashfix"); line. This .flash.text block lies before instructions, so it moves them.
Here is some statistics of movi.n a3, 0 address:
0x4200b589, 0x4200b669, 0x4200b689 - LoadProhibited crash
0x4200b665, 0x4200b591 - works OK
Currently it's just an annoying ritual - to add/remove log line if firmware crashes, but last time it became worse – simple one-line log didn't fix it and only removing a bunch of logs helped. I will post here more info, once it reproduces again. And we haven't encountered this problem on ESP-IDF 4.*.* but that may be also due to the small firmware size at that moment.
So, currently I don't know if it's something wrong with our setup (we are not doing anything fancy), or toolchain or hardware bug. Any ideas and information are really appreciated.
Example of disassembly:
- ...
- Disassembly of section .flash.text:
- 42000020 <_stext>:
- 42000020: 3fca1a24
- 42000024: 3c0e0120
- ...
- s_psram_ctx.is_initialised = true;
- 4200b661: d4e831 l32r a3, 42000a04 <_stext+0x9e4> (3fca22c4 <s_psram_ctx>)
- 4200b664: 180c movi.n a8, 1
- 4200b666: 004382 s8i a8, a3, 0
- uint32_t psram_physical_size = 0;
- 4200b669: 030c movi.n a3, 0 <--------------- PC
- 4200b66b: 0139 s32i.n a3, a1, 0
Code: Select all
...
I (490) cpu_start: Multicore app
I (490) octal_psram: vendor id : 0x0d (AP)
I (490) octal_psram: dev id : 0x02 (generation 3)
I (493) octal_psram: density : 0x03 (64 Mbit)
I (499) octal_psram: good-die : 0x01 (Pass)
I (504) octal_psram: Latency : 0x01 (Fixed)
I (509) octal_psram: VCC : 0x01 (3V)
I (514) octal_psram: SRF : 0x01 (Fast Refresh)
I (520) octal_psram: BurstType : 0x01 (Hybrid Wrap)
I (526) octal_psram: BurstLen : 0x01 (32 Byte)
I (531) octal_psram: Readlatency : 0x02 (10 cycles@Fixed)
I (538) octal_psram: DriveStrength: 0x00 (1/1)
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
0x4200b669: esp_psram_init at C:/Users/.../esp/v5.1.4/esp-idf/components/esp_psram/esp_psram.c:135
PC : 0x4200b669 PS : 0x00060f30 A0 : 0x80376109 A1 : 0x3fceb2a0
A2 : 0x00000000 A3 : 0x3fca22c4 A4 : 0x00000001 A5 : 0x50000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000001 A9 : 0x3fceb280
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000028 A13 : 0x3fca8294
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x80376441 LBEG : 0x40056f08 LEND : 0x40056f12 LCOUNT : 0x00000000
0x40056f08: __memcpy_aux in ROM
0x40056f12: __memcpy_aux in ROM
Backtrace: 0x4200b666:0x3fceb2a0 0x40376106:0x3fceb2e0 0x403cd9b4:0x3fceb340 0x403cddf9:0x3fceb380 0x403c9971:0x3fceb4b0 0x40045c01:0x3fceb570 0x40043ab6:0x3fceb6f0 0x40034c45:0x3fceb710
0x4200b666: esp_psram_init at C:/Users/.../esp/v5.1.4/esp-idf/components/esp_psram/esp_psram.c:133
0x40376106: call_start_cpu0 at C:/Users/.../esp/v5.1.4/esp-idf/components/esp_system/port/cpu_start.c:473
0x40045c01: ets_run_flash_bootloader in ROM
0x40043ab6: main in ROM
0x40034c45: .stack_ok in ROM
Chip: ESP32-S3, rev. 0.2
Board: ESP32-S3-WROOM-1
RAM: 8MB, Octal
Flash: 16MB
ESP-IDF: 5.1.4, 5.3.1
Framework: ESP-IDF
Language: C++
Host OS: Linux, Windows
Code: Select all
Total sizes:
Used static IRAM: 99994 bytes ( 262246 remain, 27.6% used)
.text size: 98967 bytes
.vectors size: 1027 bytes
Used stat D/IRAM: 62772 bytes ( 283084 remain, 18.1% used)
.data size: 21276 bytes
.bss size: 41496 bytes
Used Flash size : 1147203 bytes
.text: 889375 bytes
.rodata: 257572 bytes
Total image size: 1268473 bytes (.bin may be padded larger)