flash加密开发模式ota自定义密钥加密固件失败提示Mismatch chip id, expected 0, found 16916

jerryc
Posts: 2
Joined: Fri Apr 11, 2025 3:53 am

flash加密开发模式ota自定义密钥加密固件失败提示Mismatch chip id, expected 0, found 16916

Postby jerryc » Fri Apr 11, 2025 5:05 am

关于硬件部分,esp 32e wroom
关于软件部分,idf 5.4.0

关于开发环境:
使用的操作系统, Windows
IDE,VS Code

烧录过程如下:

------------------------------------------------------------------------------------
生成密钥
espsecure.py generate_flash_encryption_key key.bin
设置允许加密
Enable flash encryption on boot (READ DOCS FIRST)
选择模式
Enable usage mode - 开发模式 development
开启安全启动
Enable hardware Secure Boot in bootloader
boot version
Select secure boot version - 1(只有1)
bl烧录模式
Secure bootloader mode - refreshable
bl分区偏移
Offset of partition table - 0xd000
选择分区模式
Partition Table - custom partition table csv
新建分区表
# Name ,Type,SubType,Offset,Size,Flags
nvs, data, nvs, 0xE000, 0x4000,
otadata, data, ota, 0x12000, 0x2000,
phy_int, data, phy, 0x14000, 0x1000,
ota_0, app, ota_0, 0x20000, 0x1A0000,
ota_1, app, ota_1, 0x1C0000,0x1A0000
关闭nvs加密
Enable NVS encryption
生成 Secure Boot V1 签名 Key
espsecure.py generate_signing_key secure_boot_signing_key.pem --version 1 --scheme ecdsa256
构建固件
build
加密bootloader、partition table、bin
espsecure.py encrypt_flash_data --keyfile key.bin --address 0x1000 -o key_bootloader.bin build/bootloader/bootloader.bin
espsecure.py encrypt_flash_data --keyfile key.bin --address 0xd000 -o key_partition-table.bin build/partition_table/partition-table.bin
espsecure.py encrypt_flash_data --keyfile key.bin --address 0x20000 -o key_myapp.bin build/myapp.bin
烧录 Flash 加密秘钥到 eFuse 中
espefuse.py --port COM10 burn_key flash_encryption key.bin
写 eFuse 中的 Flash 加密控制位来使能 Flash 加密
espefuse.py --port COM10 burn_efuse FLASH_CRYPT_CONFIG 0xF FLASH_CRYPT_CNT 1
烧录固件
esptool.py -b 460800 --before default_reset --after no_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 key_bootloader.bin 0xd000 key_partition-table.bin 0x20000 key_myapp.bin
------------------------------------------------------------------------------------
然后myapp代码里面有官方的simple ota例子,会ota刚生成的key_myapp.bin,然后就报错Mismatch chip id, expected 0, found 16916

因为ota会写到第二个ota分区,尝试过用
espsecure.py encrypt_flash_data --keyfile key.bin --address 0x1C0000 -o key_myapp.bin build/myapp.bin
这个固件不行

请教下,ota是只能用明文固件吗?还是可以ota自定义密钥加密过的固件?可以的话该怎么解决我上面的问题,万分谢谢!!!

Who is online

Users browsing this forum: Google [Bot] and 3 guests