Page 1 of 1

App Image Format Documentation

Posted: Tue Jul 18, 2023 7:42 pm
by Graggi
Hi,

I'm trying to analyse some ESP32 binaries, and could not find any documentation about the image format besides the explanation of the header fields in the ESP-IDF Programming Guide [1], not even the name of the format (it's a modified version of .elf). Or formats, as reading Esptool's code [2] shows it's actually more than one.

Regards

[1] https://docs.espressif.com/projects/esp ... ormat.html
[2] https://github.com/espressif/esptool/bl ... n_image.py

Re: App Image Format Documentation

Posted: Wed Jul 19, 2023 12:36 am
by ESP_Sprite
That description is terse, but accurate. What information specifically are you missing? (And note that aside from having segments, the format has very little to do with ELF and is not derived from it, it's a custom format.)

Re: App Image Format Documentation

Posted: Wed Jul 19, 2023 5:55 am
by ESP_igrr

Re: App Image Format Documentation

Posted: Wed Jul 19, 2023 7:04 pm
by Graggi
ESP_Sprite wrote: That description is terse, but accurate. What information specifically are you missing? (And note that aside from having segments, the format has very little to do with ELF and is not derived from it, it's a custom format.)

For example, segment placement. There's a talk about "Extracting an ELF From an ESP32" [1] on Youtube, that claims on the slide shown from 24:25 to 24:51, that multiple flash segments must not be placed within the same 64kB flash mapping region. I couldn't find any information that confirms or denies this behaviour. Now I'm wondering what other information might be missing in the above linked documentation.

[1] https://www.youtube.com/watch?v=w4_3vwN_2dI

Re: App Image Format Documentation

Posted: Thu Jul 20, 2023 1:37 am
by ESP_Sprite
That's more a practical limit of the ESP32 MMU rather than the flash format. The logic there is that the MMU can map flash blocks to memory space, but those blocks are 64K in size with the physical address also aligned to 64K. That means mapping multiple segments to the same 64K block only works if the virtual addresses they're mapped to also are consecutive, and in that case it makes more sense to merge the segments. So in practice, multiple segments in a 64K mapping is an error.