Invalid magic byte on secure boot with custom partition table offset
Posted: Fri May 10, 2024 2:45 pm
Hello. I have an ESP-WROOM-32 ESP32 I'm trying to enable Secure Boot v2 on.
I've gone through menuconfig and selected "Enable secure boot version 2"
When I try to flash I get an error saying the bootloader is too large:
I followed the suggestion of reducing verbose level but it didn't reduce the size enough
So my next step was to move the partition table offset to make room for the bootloader
By default, it was set to 0x8000, I increased it to 0x9600
Now the flashing process succeeds, but the device constantly error with this:
If I disable Secure Boot entirely, everything works again.
What am I missing? Thanks
I've gone through menuconfig and selected "Enable secure boot version 2"
When I try to flash I get an error saying the bootloader is too large:
[100/101] cmd.exe /C "cd /D D:\Dev\esp-idf\hello_world\build\bootloader\esp-idf\esptool_py && D:\Software\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe D:/Software/Espressif/frameworks/esp-idf-v5.2.1/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 D:/Dev/esp-idf/hello_world/build/bootloader/bootloader.bin"
FAILED: esp-idf/esptool_py/CMakeFiles/bootloader_check_size D:/Dev/esp-idf/hello_world/build/bootloader/esp-idf/esptool_py/CMakeFiles/bootloader_check_size
cmd.exe /C "cd /D D:\Dev\esp-idf\hello_world\build\bootloader\esp-idf\esptool_py && D:\Software\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe D:/Software/Espressif/frameworks/esp-idf-v5.2.1/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 D:/Dev/esp-idf/hello_world/build/bootloader/bootloader.bin"
Error: Bootloader binary size 0x8560 bytes is too large for partition table offset 0x8000. Bootloader binary can be maximum 0x7000 (28672) bytes unless the partition table offset is increased in the Partition Table section of the project configuration menu.
I followed the suggestion of reducing verbose level but it didn't reduce the size enough
So my next step was to move the partition table offset to make room for the bootloader
By default, it was set to 0x8000, I increased it to 0x9600
Now the flashing process succeeds, but the device constantly error with this:
I (60) boot: ESP-IDF v5.2.1 2nd stage bootloader
I (60) boot: compile time Apr 29 2024 17:14:56
I (60) boot: Multicore bootloader
I (65) boot: chip revision: v3.1
I (69) boot.esp32: SPI Speed : 40MHz
I (74) boot.esp32: SPI Mode : DIO
I (78) boot.esp32: SPI Flash Size : 4MB
I (83) boot: Enabling RNG early entropy source...
I (88) boot: Partition Table:
I (92) boot: ## Label Usage Type ST Offset Length
I (99) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (106) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (114) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (122) boot: 3 factory factory app 00 00 00010000 00100000
I (129) boot: 4 ota_0 OTA app 00 10 00110000 00100000
I (137) boot: 5 ota_1 OTA app 00 11 00210000 00100000
I (144) boot: End of partition table
I (149) boot: Defaulting to factory image
E (153) esp_image: image at 0x10000 has invalid magic byte (nothing flashed here?)
E (161) boot: Factory app partition is not bootable
E (167) esp_image: image at 0x110000 has invalid magic byte (nothing flashed here?)
E (175) boot: OTA app partition slot 0 is not bootable
E (181) esp_image: image at 0x210000 has invalid magic byte (nothing flashed here?)
E (189) boot: OTA app partition slot 1 is not bootable
E (195) boot: No bootable app partitions in the partition table
If I disable Secure Boot entirely, everything works again.
What am I missing? Thanks