Burn the secure boot key:
Code: Select all
espefuse.py burn_key secure_boot_v1 ../keys/secure-bootloader-key-256.bin --force-write-always --port=/dev/ttyACM0
Connecting.....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting......
Detecting chip type... ESP32
espefuse.py v4.1
=== Run "burn_key" command ===
Burn keys to blocks:
- BLOCK2 -> [63 e5 23 e9 3c e7 65 9f e2 0e ca ea 88 71 4c cb 7d 97 1c 1a b5 f2 25 39 3a df bb 4c 38 97 b3 4c]
Reversing the byte order
BLOCK2 is read-protected. Burn in this case may damage an already written value. Skipped because '--force-write-always' option.
BLOCK2 is write-protected. Burn is not possible. Skipped because '--force-write-always' option.
Disabling read to key block
Disabling write to key block
Burn keys in efuse blocks.
The key block will be read and write protected
Check all blocks for burn...
idx, BLOCK_NAME, Conclusion
[00] BLOCK0 is not empty
(written ): 0x000003f4f0100000000010380000a200000734865dadf9e007f30180
(to write): 0x00000000000000000000000000000000000000000000000000020100
All wr_data bits are set in the written block, continue with EMPTY_BLOCK.
BLOCK2 is read-protected. Burn in this case may damage an already written value. Skipped because '--force-write-always' option.
BLOCK2 is write-protected. Burn is not possible. Skipped because '--force-write-always' option.
[02] BLOCK2 is empty, will burn the new value
.
This is an irreversible operation!
Type 'BURN' (all capitals) to continue.
BURN
BLOCK2 (['secure_boot_v1', 'secure_boot_v2']) is read-protected. Read back the burn value is not possible.
Read all '0'
Reading updated efuses...
Successful
Burn the flash encryption key:
Code: Select all
espefuse.py burn_key flash_encryption ../keys/flash_encription_key.bin --force-write-always --port=/dev/ttyACM0
Connecting.....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
espefuse.py v4.1
=== Run "burn_key" command ===
Burn keys to blocks:
- BLOCK1 -> [d0 b0 b8 52 f1 4f 32 a7 5f e4 0b 4d 84 f5 4e 2b 91 1b 6c 73 17 b9 b1 c6 45 96 5c 22 d4 81 09 55]
Reversing the byte order
BLOCK1 is read-protected. Burn in this case may damage an already written value. Skipped because '--force-write-always' option.
BLOCK1 is write-protected. Burn is not possible. Skipped because '--force-write-always' option.
Disabling read to key block
Disabling write to key block
Burn keys in efuse blocks.
The key block will be read and write protected
Check all blocks for burn...
idx, BLOCK_NAME, Conclusion
[00] BLOCK0 is not empty
(written ): 0x000003f4f0100000000010380000a200000734865dadf9e007f30180
(to write): 0x00000000000000000000000000000000000000000000000000010080
All wr_data bits are set in the written block, continue with EMPTY_BLOCK.
BLOCK1 is read-protected. Burn in this case may damage an already written value. Skipped because '--force-write-always' option.
BLOCK1 is write-protected. Burn is not possible. Skipped because '--force-write-always' option.
[01] BLOCK1 is empty, will burn the new value
.
This is an irreversible operation!
Type 'BURN' (all capitals) to continue.
BURN
BLOCK1 (['flash_encryption']) is read-protected. Read back the burn value is not possible.
Read all '0'
Reading updated efuses...
Successful
Encrypt the image of bootloader with its digest:
Code: Select all
espsecure.py encrypt_flash_data --keyfile ../keys/flash_encription_key.bin --address 0x0 --output bootloader-reflash-digest.enc.bin bootloader-reflash-digest.bin
espsecure.py v4.1
Using 256-bit key
Flash the image:
Code: Select all
esptool.py --chip esp32 --port=/dev/ttyACM0 --baud=460800 --before=default_reset --after=no_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x0 bootloader-reflash-digest.enc.bin --force
esptool.py v4.1
Serial port /dev/ttyACM0
Connecting....
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 34:86:5d:ad:f9:e0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x0000bfff...
Compressed 46592 bytes to 44873...
Wrote 46592 bytes (44873 compressed) at 0x00000000 in 1.4 seconds (effective 271.6 kbit/s)...
Hash of data verified.
Leaving...
Staying in bootloader.
Monitoring:
Code: Select all
make monitor BAUD=115200 PORT=/dev/ttyACM0
pyserial-miniterm --raw /dev/ttyACM0 115200
--- Miniterm on /dev/ttyACM0 115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
ets Jul 29 2019 12:21:46
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
invalid header: 0xf3a2770d
ets Jul 29 2019 12:21:46