Bootloader documentation

JosuGZ
Posts: 48
Joined: Tue Jan 14, 2020 9:47 am

Bootloader documentation

Postby JosuGZ » Wed Dec 01, 2021 7:43 pm

Hi, where can I find documentation about the bootloader?

I want to try a bit of bare metal programming in Rust. So far I have found this, which is interesting but only for an ESP32-C3 rev 3.

I would like to know more about how the room bootloader loads the program, and if it is possible, how to do direct boot on the other chips.

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

Re: Bootloader documentation

Postby ESP_igrr » Wed Dec 01, 2021 8:16 pm

Hi JosuGZ,

The ROM bootloader on ESP chips is capable of loading the application stored in a certain format in flash into RAM.

The very brief description of the format is available here: https://github.com/espressif/esptool/wi ... 2861d181cd (Note: esptool Wiki is being migrated to the new documentation site, so I'm linking to an older version of the page, which has since been removed. We will have a new page about ESP binary image format soon.)

Since you are working with Rust, you might be able to use this part of espflash source code as a reference: https://github.com/esp-rs/espflash/blob ... tloader.rs.

The bootloader reads the binary image header, verifies it, then proceeds to load each section of the image into RAM. Once all the sections are loaded, the bootloader verifies the checksum and if it matches, jumps to the entry point address obtained from the binary image header. (The process is slightly more complicated in the case when Secure Boot is used.)

If you want to write a bare metal program, make sure you can generate an ELF file with code/data sections located in IRAM/DRAM parts of the internal memory, then pass this ELF file to espflash or esptool — it should generate the binary image for you.

Regarding direct boot, it is a new feature added in ESP32-C3 rev. 3 and ESP32-S3. The ROM code in older chips such as ESP32, ESP32-S2 doesn't implement direct boot.

Who is online

Users browsing this forum: No registered users and 28 guests