Page 2 of 2

Re: ESP Coredump in Flash Cannot be Read

Posted: Mon Aug 11, 2025 10:25 am
by NevynSelby
Tried this on a few boards, all ESP32 and I get the same results.

Regards,
Mark

Re: ESP Coredump in Flash Cannot be Read

Posted: Tue Aug 12, 2025 1:23 am
by Sprite
You gotta be a bit more verbose than that. What tools are you using, and what version? What operating system? How did you create those coredumps? How are you invoking those tools and what error are you seeing? What development boards, and what chip is on them?

Re: ESP Coredump in Flash Cannot be Read

Posted: Tue Aug 12, 2025 6:57 pm
by NevynSelby
What tools are you using, and what version?
ESP IDF, v5.5-1-gb66b5448e0-dirty

Application is built using:

Code: Select all

idf.py build flash monitor
What operating system?
MacOS, latest version, fully patched.
What development boards, and what chip is on them?
ESP-WROVER-KIT (ESP32-D0WDQ6 (revision v1.0))
ESP32 DevKit (ESP32-D0WD-V3 (revision v3.0))
ESP32 Pico Kit ESP32-PICO-D4 (revision v1.0)
How did you create those coredumps?
From a code perspective I am forcing an application fault. I have used the getting started/hello world example. I have turned code dump on, sdkconfig is:

Code: Select all

CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=y
# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set
# CONFIG_ESP_COREDUMP_ENABLE_TO_NONE is not set
# CONFIG_ESP_COREDUMP_DATA_FORMAT_BIN is not set
CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=y
# CONFIG_ESP_COREDUMP_CHECKSUM_CRC32 is not set
CONFIG_ESP_COREDUMP_CHECKSUM_SHA256=y
# CONFIG_ESP_COREDUMP_CAPTURE_DRAM is not set
CONFIG_ESP_COREDUMP_CHECK_BOOT=y
CONFIG_ESP_COREDUMP_ENABLE=y
CONFIG_ESP_COREDUMP_LOGS=y
CONFIG_ESP_COREDUMP_MAX_TASKS_NUM=32
# CONFIG_ESP_COREDUMP_FLASH_NO_OVERWRITE is not set
CONFIG_ESP_COREDUMP_STACK_SIZE=4096
In the application I have used two methods of causing the application to fault:

[*] asserrt(0)
[*] *((uint32_t *) 0) = 0;
How are you invoking those tools and what error are you seeing?
So application output:

Code: Select all

I (187) esp_core_dump_flash: Init core dump to flash
I (192) esp_core_dump_flash: Found partition 'coredump' @ 10000 65536 bytes
I (210) esp_core_dump_flash: Core dump data checksum is correct
I (211) esp_core_dump_flash: Found core dump 7744 bytes in flash @ 0x10000
I (213) main_task: Started on CPU0
I (223) main_task: Calling app_main()
Hello world!
This is esp32 chip with 2 CPU core(s), WiFi/BTBLE, silicon revision v3.0, 4MB external flash
Minimum free heap size: 297072 bytes
Restarting in 100 seconds...
Restarting in 99 seconds...
Restarting in 98 seconds...
Restarting in 97 seconds...
Restarting in 96 seconds...
Restarting in 95 seconds...
Restarting in 94 seconds...
Restarting in 93 seconds...
Restarting in 92 seconds...
Restarting in 91 seconds...
Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x400d4e8d  PS      : 0x00060830  A0      : 0x800e2ba3  A1      : 0x3ffb57d0  
--- 0x400d4e8d: app_main at /Users/markstevens/Public/CoreDumpTest/main/hello_world_main.c:49
A2      : 0x00000003  A3      : 0x3f401cd1  A4      : 0x3f401d19  A5      : 0x000000df  
A6      : 0x3f401cd1  A7      : 0x0000005a  A8      : 0x00000000  A9      : 0x3ffb57b0  
A10     : 0x00000064  A11     : 0x0000005b  A12     : 0x3f403b75  A13     : 0x3f403b4b  
A14     : 0x3f4056a9  A15     : 0x3f4056ae  SAR     : 0x00000004  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffe  
--- 0x400014fd: strlen in ROM
--- 0x4000150d: strlen in ROM


Backtrace: 0x400d4e8a:0x3ffb57d0 0x400e2ba0:0x3ffb5810 0x4008513d:0x3ffb5840
--- 0x400d4e8a: app_main at /Users/markstevens/Public/CoreDumpTest/main/hello_world_main.c:49
--- 0x400e2ba0: main_task at /Users/markstevens/esp/esp-idf/components/freertos/app_startup.c:208
--- 0x4008513d: vPortTaskWrapper at /Users/markstevens/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139




ELF file SHA256: 81631309cda357fa

I (10290) esp_core_dump_flash: Save core dump to flash...
I (10295) esp_core_dump_common: Backing up stack @ 0x3ffb5650 and use core dump stack @ 0x3ffb3d40
I (10304) esp_core_dump_flash: Erase flash 8192 bytes @ 0x10000
I (10431) esp_core_dump_flash: Write end offset 0x1e40, check sum length 32
I (10432) esp_core_dump_common: Core dump used 1280 bytes on stack. 2900 bytes left free.
I (10435) esp_core_dump_common: Restoring stack @ 0x3ffb5650
I (10440) esp_core_dump_flash: Core dump has been saved to flash.
CPU halted.
So from the above it looks like the application is generating a valid code dump.

Running the command:

Code: Select all

parttool.py --port /dev/tty.usbserial-0001 read_partition --partition-name coredump --output coredump.bin
Generates the following output:

Code: Select all

esptool.py v4.9.0
Serial port /dev/tty.usbserial-0001
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting.......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
WARNING: Detected crystal freq 41.01MHz is quite different to normalized freq 40MHz. Unsupported crystal in use?
Crystal is 40MHz
MAC: e0:5a:1b:77:8c:6c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
3072 (100 %)
3072 (100 %)
Read 3072 bytes at 0x00008000 in 0.3 seconds (86.5 kbit/s)...
Hard resetting via RTS pin...
Running /Users/markstevens/.espressif/python_env/idf5.5_py3.12_env/bin/python /Users/markstevens/esp/esp-idf/components/esptool_py/esptool/esptool.py --port /dev/tty.usbserial-0001 read_flash 65536 65536 coredump.bin...
esptool.py v4.9.0
Serial port /dev/tty.usbserial-0001
Connecting......
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e0:5a:1b:77:8c:6c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
65536 (100 %)
65536 (100 %)
Read 65536 bytes at 0x00010000 in 5.9 seconds (88.6 kbit/s)...
Hard resetting via RTS pin...
Read partition 'coredump' contents from device at offset 0x10000 to file 'coredump.bin'
Running

Code: Select all

esp-coredump --chip esp32 info_corefile coredump.bin
generates a traceback culminating in the error

Code: Select all

    raise ConstError(f"parsing expected {repr(self.value)} but parsed {repr(obj)}", path=path)
construct.core.ConstError: Error in path (parsing) -> elf_header -> e_ident -> EI_MAG
parsing expected b'\x7fELF' but parsed b'@\x1e\x00\x00'
Running the command with the WROVER-KIT

Code: Select all

idf.py coredump-info
generates:

Code: Select all

Executing action: coredump-info
Serial port /dev/cu.usbserial-101
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
WARNING:root:The core dump image offset is not specified. Use partition offset: 0x10000.
Failed to load core dump: esptool script execution failed with error 2, failed command was: '['/Users/markstevens/.espressif/python_env/idf5.5_py3.12_env/bin/python', '-m', 'esptool', '-c', 'auto', '-p', '/dev/cu.usbserial-101', '-b', '460800', 'read_flash', '65536', '7744', '/var/folders/m4/sw8tgkhs20549s7f__sz62l40000gn/T/tmp6m5tbcol']'

┌────── Additional information about the error: 
│   
│   esptool.py v4.9.0
│   Serial port /dev/cu.usbserial-101
│   Connecting.......
│   Detecting chip type... Unsupported detection protocol, switching and trying again...
│   Connecting....
│   Detecting chip type... ESP32
│   Chip is ESP32-D0WDQ6 (revision v1.0)
│   Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, BLK3 partially reserved, Coding Scheme 3/4
│   Crystal is 40MHz
│   MAC: 84:0d:8e:18:5b:08
│   Uploading stub...
│   Running stub...
│   Stub running...
│   Changing baud rate to 460800
│   Changed.
│   Configuring flash size...

│   A fatal error occurred: Corrupt data, expected 0x1000 bytes but received 0xfed bytes

│   
└────── end of additional information about the error.
One thing I have noticed is that the DevKit sometimes generates a message about serial noise but the WROVER-KIT never does.

I have also tried different serial ports and I get consistent results.

Regards,
Mark

Re: ESP Coredump in Flash Cannot be Read

Posted: Thu Aug 14, 2025 11:05 pm
by cdollar
I usually use espcoredump.py (from $IDF_PATH/components/espcoredump/espcoredump.py) for decoding a coredump that I've read from flash. You'll need to have the .efl (not the .bin that you flash to the device, but the .elf that gets built the same time as the .bin) of the firmware that was flashed to the crashed device for this to work.

Code: Select all

espcoredump.py info_corefile -t raw -c /path/to/coredump.bin /path/to/firmware.elf

Re: ESP Coredump in Flash Cannot be Read

Posted: Sat Aug 16, 2025 10:01 am
by NevynSelby
Got it working, thanks for the help.