The ESP32 flash command, as executed by the Arduino IDE, seems to flash two bootloader files: one at offset 0xe000
and another at offset 0x1000
. I wonder what these two bootloader files actually do, and why there are two of them. Below I give some more context.
1. Arduino IDE flash procedure for ESP32 projects
After building the .elf
file, the Arduino IDE launches a command to convert it into a binary:
python esptool.py --chip esp32 elf2image
--flash_mode dio
--flash_freq 80m
--flash_size 4MB
-o /tmp/arduino_build_852524/WiFiScan.ino.bin
/tmp/arduino_build_852524/WiFiScan.ino.elf
Finally, this WiFiScan.ino.bin
file is flashed to the board, alongside two bootloader files and the partitions table:
python esptool.py --chip esp32
--port /dev/ttyUSB0
--baud 921600
--before default_reset
--after hard_reset write_flash
-z
--flash_mode dio
--flash_freq 80m
--flash_size detect
0xe000 ~/.arduino15/packages/esp32/hardware/esp32/1.0.6/tools/partitions/boot_app0.bin
0x1000 ~/.arduino15/packages/esp32/hardware/esp32/1.0.6/tools/sdk/bin/bootloader_dio_80m.bin
0x10000 /tmp/arduino_build_852524/WiFiScan.ino.bin
0x8000 /tmp/arduino_build_852524/WiFiScan.ino.partitions.bin
The default partitions table, as used by Arduino IDE, looks like this (in csv format):
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000,0x140000,
spiffs, data, spiffs, 0x290000,0x170000,
The two bootloader files being flashed are:
# flashed at 0xe000
~/.arduino15/packages/esp32/hardware/esp32/1.0.6/tools/partitions/boot_app0.bin
and:
# flashed at 0x1000
~/.arduino15/packages/esp32/hardware/esp32/1.0.6/tools/sdk/bin/bootloader_dio_80m.bin
I wonder what these two bootloader files are actually doing. It’s also interesting to observe their locations. The first one, boot_app0.bin
is located in a folder named 'partitions'
. It sits there alongside several partition .csv
files. Why?
The other one, bootloader_dio_80m.bin
is located in a folder named 'sdk/bin/'
and sits alongside other files that all start their name with the 'bootloader_'
prefix: