This is my process:
Erase all content flash of module
Code: Select all
make -j8 erase_flash
Code: Select all
make menuconfig
-Then I compile (please note I have a factory APP and 1 OTA partition so this step is done for two project folders)
Code: Select all
make -j8 clean
Code: Select all
make -j8 all
-Pre-generate encryption KEY
Code: Select all
espsecure.py generate_flash_encryption_key My_encryption_key.bin
-Encrpyt all file to flash (bootloader, partition table, firmware, firmware_factory) using pre-generated KEY
Code: Select all
espsecure.py encrypt_flash_data --keyfile My_encryption_key.bin --address 0x1000 -o bootloader-encrypted.bin C:/msys32/home/Davide/esp/Avior_ESP32_WiFi/build/bootloader/bootloader.bin
espsecure.py encrypt_flash_data --keyfile My_encryption_key.bin --address 0x8000 -o my_partition_table-encrypted.bin C:/msys32/home/Davide/esp/Avior_ESP32_WiFi/build/my_partition_table.bin
espsecure.py encrypt_flash_data --keyfile My_encryption_key.bin --address 0x60000 -o Avior_ESP32_WiFi_v2-encrypted.bin C:/msys32/home/Davide/esp/Avior_ESP32_WiFi/build/Avior_ESP32_WiFi_v2.bin
espsecure.py encrypt_flash_data --keyfile My_encryption_key.bin --address 0x10000 -o Avior_ESP32_WiFi_OTAfactory-encrypted.bin C:/msys32/home/Davide/esp/Avior_ESP32_WiFi_OTAfactory/build/Avior_ESP32_WiFi_OTAfactory.bin
- Fuse the pre-generated KEY to device
Code: Select all
espefuse.py --port COM17 burn_key flash_encryption AVIOR_encryption_key.bin
- program flash with pre-encrypted files (please note bootloader-encpyted file is 27.856 bytes so it is below the limit of 0x7000 bytes).
Code: Select all
esptool.py --chip esp32 --port COM17 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader-encrypted.bin 0x8000 my_partition_table-encrypted.bin 0x10000 Avior_ESP32_WiFi_OTAfactory-encrypted.bin 0x60000 Avior_ESP32_WiFi_v2-encrypted.bin
- program fuse FLASH_CRYPT_CNT
Code: Select all
espefuse.py --port COM17 burn_efuse FLASH_CRYPT_CNT
After reset I get 4 times the below debug, but PRO_CPU and APP_CPU are not started and my program is not executed
Code: Select all
I (14) boot: ESP-IDF v3.1 2nd stage bootloader
I (14) boot: compile time 11:46:04
I (14) boot: Enabling RNG early entropy source...
D (15) boot: magic e9
D (17) boot: segments 04
D (19) boot: spi_mode 02
D (21) boot: spi_speed 00
D (23) boot: spi_size 02
I (26) boot: SPI Speed : 40MHz
I (29) boot: SPI Mode : DIO
I (32) boot: SPI Flash Size : 4MB
D (35) bootloader_flash: mmu set paddr=00000000 count=1
D (40) boot: mapped partition table 0x8000 at 0x3f408000
D (45) flash_parts: partition table verified, 8 entries
I (50) boot: Partition Table:
I (53) boot: ## Label Usage Type ST Offset Length
D (59) boot: load partition table entry 0x3f408000
D (63) boot: type=1 subtype=2
I (66) boot: 0 nvs WiFi data 01 02 00009000 00004000
D (73) boot: load partition table entry 0x3f408020
D (77) boot: type=1 subtype=0
I (80) boot: 1 otadata OTA data 01 00 0000d000 00002000
D (86) boot: load partition table entry 0x3f408040
D (91) boot: type=0 subtype=0
I (94) boot: 2 factory factory app 00 00 00010000 00050000
D (100) boot: load partition table entry 0x3f408060
D (105) boot: type=0 subtype=10
I (108) boot: 3 ota_0 OTA app 00 10 00060000 001f0000
D (114) boot: load partition table entry 0x3f408080
D (119) boot: type=1 subtype=82
I (122) boot: 4 sys Unknown data 01 82 00250000 00050000
D (128) boot: load partition table entry 0x3f4080a0
D (133) boot: type=1 subtype=82
I (136) boot: 5 users Unknown data 01 82 002a0000 000b0000
D (142) boot: load partition table entry 0x3f4080c0
D (147) boot: type=1 subtype=82
I (150) boot: 6 rules Unknown data 01 82 00350000 000b0000
I (156) boot: End of partition table
D (160) boot: OTA data offset 0xd000
D (163) bootloader_flash: mmu set paddr=00000000 count=1
D (168) boot: OTA sequence values A 0xbcca56f6 B 0xaaf631d5
E (173) boot: ota data partition invalid, falling back to factory
D (179) boot: Trying partition index -1 offs 0x10000 size 0x50000
D (185) esp_image: reading image header @ 0x10000
D (189) bootloader_flash: mmu set block paddr=0x00010000 (was 0xffffffff)
D (196) esp_image: image header: 0xe9 0x09 0x02 0x02 40080fc4
I (201) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x0b180 ( 45440) map
D (209) bootloader_flash: mmu set paddr=00010000 count=1
D (224) bootloader_flash: mmu set block paddr=0x00010000 (was 0xffffffff)
I (224) esp_image: segment 1: paddr=0x0001b1a8 vaddr=0x3ffb0000 size=0x02134 ( 8500) load
D (229) bootloader_flash: mmu set paddr=00010000 count=1
D (236) bootloader_flash: mmu set block paddr=0x00010000 (was 0xffffffff)
I (240) esp_image: segment 2: paddr=0x0001d2e4 vaddr=0x3ffb2134 size=0x00000 ( 0) load
D (248) bootloader_flash: mmu set paddr=00010000 count=1
D (253) bootloader_flash: mmu set block paddr=0x00010000 (was 0xffffffff)
I (260) esp_image: segment 3: paddr=0x0001d2ec vaddr=0x40080000 size=0x00400 ( 1024) load
D (268) bootloader_flash: mmu set paddr=00010000 count=1
D (273) bootloader_flash: mmu set block paddr=0x00010000 (was 0xffffffff)
I (279) esp_image: segment 4: paddr=0x0001d6f4 vaddr=0x40080400 size=0x0291c ( 10524) load
D (287) bootloader_flash: mmu set paddr=00010000 count=2
D (295) bootloader_flash: mmu set block paddr=0x00020000 (was 0xffffffff)
I (299) esp_image: segment 5: paddr=0x00020018 vaddr=0x400d0018 size=0x21da4 (138660) map
D (307) bootloader_flash: mmu set paddr=00020000 count=3
D (341) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
I (341) esp_image: segment 6: paddr=0x00041dc4 vaddr=0x40082d1c size=0x06890 ( 26768) load
D (344) bootloader_flash: mmu set paddr=00040000 count=1
D (355) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
I (356) esp_image: segment 7: paddr=0x0004865c vaddr=0x400c0000 size=0x00000 ( 0) load
D (364) bootloader_flash: mmu set paddr=00040000 count=1
D (369) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
I (375) esp_image: segment 8: paddr=0x00048664 vaddr=0x50000000 size=0x00000 ( 0) load
D (383) bootloader_flash: mmu set paddr=00040000 count=1
D (388) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
D (395) esp_image: Calculated hash: 9d0aa322
D (399) bootloader_flash: mmu set paddr=00040000 count=1
I (406) boot: Loaded app from partition at offset 0x10000
I (409) boot: Checking flash encryption...
I (413) flash_encrypt: flash encryption is enabled (3 plaintext flashes left)
I (420) boot: Disabling RNG early entropy source...
D (424) boot: Mapping segment 0 as IROM
D (428) boot: Mapping segment 5 as DROM
D (431) boot: calling set_cache_and_start_app
D (435) boot: configure drom and irom and start
D (440) boot: start: 0x40080fc4
If I disable flash-encryption everything works.
I'm using v3.1
Code: Select all
git rev-parse HEAD
22da5f6de9ff3657fa7613fc06ad2eca1d1fe14a
Where am I wrong?
Thanks