Coredump to flash issues

sorenhl
Posts: 22
Joined: Sun Jun 03, 2018 9:34 pm

Coredump to flash issues

Postby sorenhl » Tue Jun 26, 2018 9:00 pm

Hi there,

I am having trouble with the coredump to flash, it works when I do dump over uART.
My partition table is the following (I use ESP-WROOM-32 with 16MB external flash, but I could not get it to work with my other clean 4MB ESP-WROOM-32 either):

Code: Select all

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x400000,
app1,     app,  ota_1,   0x410000,0x400000,
eeprom,   data, 0x99,    0x810000,0x1000,
spiffs,   data, spiffs,  0x811000,0x7DF600,
coredump, data, coredump, 0xFF0600, 0xFA00,
The message I get when I try to crash the ESP is the following:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (LoadProhibited)
. Exception was unhandled.
Register dump:
PC      : 0x400014e8  PS      : 0x00060930  A0      : 0x80001459  A1      : 0x3ffcf630  
A2      : 0xfffffffe  A3      : 0xfffffffc  A4      : 0x000000ff  A5      : 0x0000ff00  
A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x8008531e  A9      : 0x3ffcf600  
A10     : 0x3ffce4d4  A11     : 0x00000006  A12     : 0x3ffae720  A13     : 0x00000000  
A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x00000019  EXCCAUSE: 0x0000001c  
EXCVADDR: 0xfffffffc  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  

Backtrace: 0x400014e8:0x3ffcf630 0x40001456:0x3ffcf640 0x40001445:0x3ffcf660 0x4012baf5:0x3ffcf680 0x401303ae:0x3ffcf6b0 0x401305c3:0x3ffcf6e0

[0;31mE (10531) esp_core_dump: Failed to erase flash (258)![0m
[0;31mE (10536) esp_core_dump: Failed to prepare core dump (258)![0m
Rebooting...
Any idea?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Coredump to flash issues

Postby ESP_igrr » Wed Jun 27, 2018 12:59 am

Can you try making SPIFFS and core dump partitions aligned to 4kB and see if that helps?

sorenhl
Posts: 22
Joined: Sun Jun 03, 2018 9:34 pm

Re: Coredump to flash issues

Postby sorenhl » Wed Jun 27, 2018 8:30 am

Can you try making SPIFFS and core dump partitions aligned to 4kB and see if that helps?
I will try this tonight and post the results, thank you :)

sorenhl
Posts: 22
Joined: Sun Jun 03, 2018 9:34 pm

Re: Coredump to flash issues

Postby sorenhl » Wed Jun 27, 2018 4:15 pm

Can you try making SPIFFS and core dump partitions aligned to 4kB and see if that helps?
I just came home but looking at the partition table the SPIFFS and coredump is already alligned with 4kB if my math is right:
0x811000 / 0x1000 = 0x414 (8458240 / 8096 = 1044)
0xFF0600 / 0x1000 = 0x810 (16713216 / 8096 = 2064)

Any other ideas?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Coredump to flash issues

Postby ESP_igrr » Thu Jun 28, 2018 2:09 am

0x811000 / 0x1000 = 0x811
0xFF0600 / 0x1000 = 0xFF0 with 0x600 remainder

As a rule of thumb, both offset and size values of each partitions should have 3 zeroes at the end, when written in hexadecimal.

sorenhl
Posts: 22
Joined: Sun Jun 03, 2018 9:34 pm

Re: Coredump to flash issues

Postby sorenhl » Thu Jun 28, 2018 7:16 pm

You are totally right, I now alligned it with 4k (thank you for the 3x zero tip) and now it seems to be storing the information succesfully - at least it does not complain when I force it to crash and the memory gets populated.

Now the table last entries in the partitition file looks like this:

Code: Select all

spiffs,   data, spiffs,  0x811000,0x7DF000,
coredump, data, coredump, 0xFF0000, 0x10000,
The goal is to let the device upload the coredump to my server, so I can analyze when customers run into trouble, but one step at a time.

Analyzing it directly
UPDATE:
I noticed that I used the wrong offset, so now using the following command I can successfully read the coredump :)

Code: Select all

./espcoredump.py -p /dev/ttyS2 info_corefile myprogram.elf -o 16711680
Reading the memory for remote debugging
As I want to be able to debug this remotely, my thought was to upload the partition data,and load it with espcoredump.py. To test this theory out, my idea was to use the esptool.py to read the flash (./esptool.py -p /dev/ttyS2 -b 460800 read_flash 0xFF0000 0x10000).

When trying to read this I got an error stating that "growing up stacks" are not supported. I then found this quote somewhere on github:
Note that you should remove the first 4 bytes from the raw data read from flash to use that python script.
Then I tried to use a hex editor to edit the memory dump and bingo! Works using:

Code: Select all

./espcoredump.py info_corefile myprogram.elf -c coredump.bin -t raw
Hopefully this can help somebody else who is new to, just like me :)

zhivko
Posts: 23
Joined: Tue Dec 01, 2015 12:02 pm

Re: Coredump to flash issues

Postby zhivko » Fri Feb 22, 2019 9:43 pm

Is it possible to write coredump to SPIFF file in case coredump partition contains data?

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: Coredump to flash issues

Postby ESP_Sprite » Mon Feb 25, 2019 2:40 am

Not at the moment. Also: You probably don't want to do that. A panic means the system is in an unknown state; you're taking a pretty big risk assuming SPIFFS plus all layers under it (plus maybe even FreeRTOS) still work.

Who is online

Users browsing this forum: No registered users and 76 guests