invalid header after running secure boot

aygh4266
Posts: 19
Joined: Mon Mar 04, 2024 10:33 am

invalid header after running secure boot

Postby aygh4266 » Tue Aug 13, 2024 1:04 pm

Hello everyone,

so I have enabled the Secure Boot sucessfully, generated the private signing key using OpenSSL. So after running the command , it stays in the bootloader. So I ran the command idf.py monitor, but it gives me an invalid header.

First and second output

Code: Select all

[esptool.py -p COM4 -b 1152000 --before default_reset --after no_reset --chip esp32s3 write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x10000 build/partition_table/partition-table.bin
0x20000 build/app-template.bin
esptool.py v4.7.0
Serial port COM4
Connecting....
Chip is ESP32-S3 (QFN56) (revision v0.1)
Features: WiFi, BLE, Embedded Flash 8MB (GD)
Crystal is 40MHz
MAC: f4:12:fa:87:c4:d8
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 1152000
Changed.
Configuring flash size...
Auto-detected Flash size: 8MB
Flash will be erased from 0x00010000 to 0x00010fff...
Flash will be erased from 0x00020000 to 0x000b0fff...
Compressed 3072 bytes to 128...
Wrote 3072 bytes (128 compressed) at 0x00010000 in 0.0 seconds (effective 588.2 kbit/s)...
Hash of data verified.
Compressed 593920 bytes to 334892...
Wrote 593920 bytes (334892 compressed) at 0x00020000 in 4.7 seconds (effective 1010.6 kbit/s)...
Hash of data verified.

Leaving...
Staying in bootloader/]


Second output:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa
invalid header: 0x020150aa]]

aliarifat794
Posts: 124
Joined: Sun Jun 23, 2024 6:18 pm

Re: invalid header after running secure boot

Postby aliarifat794 » Tue Aug 13, 2024 3:37 pm

The binary file (app-template.bin) can be corrupted or incorrectly generated.

aygh4266
Posts: 19
Joined: Mon Mar 04, 2024 10:33 am

Re: invalid header after running secure boot

Postby aygh4266 » Wed Aug 14, 2024 1:47 pm

aliarifat794 wrote:
Tue Aug 13, 2024 3:37 pm
The binary file (app-template.bin) can be corrupted or incorrectly generated.
So I have tried to generate the signing manually using espsecure.py and the binary file has been succssefully signed. The binary file have been built using idf.py build. I have verified the appended signature using espsecure.py and it has been verified successfully. I don't understand the problem why it still doesn't work.

I have checked the public key digest in eFuse and it's been writte in BLOCK0 so it should be OK. But running the command idf.py monitor gives me after all this an invalid header

aygh4266
Posts: 19
Joined: Mon Mar 04, 2024 10:33 am

Re: invalid header after running secure boot

Postby aygh4266 » Fri Aug 16, 2024 1:59 pm

Solved the problem

the signed bootloader image must be flashed into the address 0x0. using the esptool.py write_flash --force 0x0 bootloader.bin fixed the problem

Who is online

Users browsing this forum: No registered users and 99 guests