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.
Bootloader documentation
Re: Bootloader documentation
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.
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 57 guests