ESP32 bin tool dump util ...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

ESP32 bin tool dump util ...

Postby kolban » Sat Feb 24, 2018 3:12 pm

I'm studying the file structure that is generated by esptool when it converts a compile ELF formatted executable into the format required for flashing to the ESP32. To that end, I needed a simple program to "examine" what was there.

Here is a link to my effort. https://github.com/nkolban/esp32-snippe ... derExamine

It is a Linux C source file that can be compiled with

gcc main.cpp

When run and supplied the name of an ESP32 bin file, it dumps the content ... here is an example:

Code: Select all

Dump of ESP32 binary file: app-template.bin
magic: 0xe9, segment_count: 7, entry_addr: 0x40080cc4 - Internal SRAM 0 (128K)

Seg | Start      | End        | Length            | Area
----+------------+------------+-------------------+-------------------------------
  0 | 0x3f400020 | 0x3f403c14 |  15348 (0x003bf4) | External Memory (Data)
  1 | 0x3ffb0000 | 0x3ffb1714 |   5908 (0x001714) | Internal SRAM 2 (200K)
  2 | 0x40080000 | 0x40080400 |   1024 (0x000400) | Internal SRAM 0 (128K)
  3 | 0x40080400 | 0x40087dec |  31212 (0x0079ec) | Internal SRAM 0 (128K)
  4 | 0x400c0000 | 0x400c0000 |      0 (0x000000) | RTC FAST Memory (8K)
  5 | 0x00000000 | 0x00002ed4 |  11988 (0x002ed4) | Un-described
  6 | 0x400d0018 | 0x400e1128 |  69904 (0x011110) | External Memory (Instruction)
Sharing in case it might be useful to others.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

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

Re: ESP32 bin tool dump util ...

Postby ESP_igrr » Sun Feb 25, 2018 7:17 am

By the way, esptool.py has image_info command which does the same job. If you're missing something in the output of that command, please open an issue in esptool repo.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32 bin tool dump util ...

Postby kolban » Sun Feb 25, 2018 3:53 pm

Thank you sir. I did not know that feature was present. Unfortunately when I tried to run it this morning, it failed with the story described in this Github issue:

https://github.com/espressif/esptool/issues/258
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: ESP32 bin tool dump util ...

Postby ESP_Angus » Mon Feb 26, 2018 12:21 am

Sorry Neil, I forgot to mention the workaround in that issue - which is to run "esptool.py --chip esp32 image_info blah.bin".

You can also use xtensa-esp32-elf-objdump to look around at the contents/layout of the ELF file itself. This is very similar information to the .bin layout (as the ELF sections are converted to segments in the .bin file). Although ELF supports some additional features which are not used on the ESP32.

objdump has a lot of options. Running "objdump -h project.elf" to dump section headers is a good place to start.

Docs: https://sourceware.org/binutils/docs/bi ... jdump.html

The linker .map file (in the build directory) is also a goldmine of information, although it's a bit of an information firehose as well...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32 bin tool dump util ...

Postby kolban » Mon Feb 26, 2018 3:50 am

Thank you both. For part of the project I am working on, I need to be able to work with ESP32 Image "bin" files ... i.e. the output generated by esptool elf2image. My goal wasn't to decompose the ELF image but the bin file. However, as you both have said, it would have been just as useful to use the "image_info" feature of esptool which continues to shine in its applicability.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

DGrafflin
Posts: 7
Joined: Tue Jan 16, 2024 3:59 pm

Re: ESP32 bin tool dump util ...

Postby DGrafflin » Wed Jan 31, 2024 12:24 pm

Thanks. you rock!! looking forward to scrutenizing your book. :D

Who is online

Users browsing this forum: No registered users and 27 guests