启用 Flash 加密 和 安全启动后芯片一直重启

YangGuoxin
Posts: 2
Joined: Tue Jul 25, 2023 7:29 am

启用 Flash 加密 和 安全启动后芯片一直重启

Postby YangGuoxin » Fri Dec 08, 2023 9:09 am

未启用安全功能芯片正常,之后启用加密烧写密钥摘要和Flash 机密密钥,烧写加密后的bootload、partition、app,然后就炸了,芯片一直重启,希望各位大侠救救
以下是 summary

Code: Select all

espefuse.py v2.9-dev
Connecting....
EFUSE_NAME             Description = [Meaningful Value] [Readable/Writeable] (Hex Value)
----------------------------------------------------------------------------------------
Efuse fuses:
WR_DIS                 Efuse write disable mask                          = 384 R/W (0x180)
RD_DIS                 Efuse read disablemask                            = 3 R/W (0x3)
CODING_SCHEME          Efuse variable block length scheme                = 0 R/W (0x0)
KEY_STATUS             Usage of efuse block 3 (reserved)                 = 0 R/W (0x0)

Config fuses:
XPD_SDIO_FORCE         Ignore MTDI pin (GPIO12) for VDD_SDIO on reset    = 0 R/W (0x0)
XPD_SDIO_REG           If XPD_SDIO_FORCE, enable VDD_SDIO reg on reset   = 0 R/W (0x0)
XPD_SDIO_TIEH          If XPD_SDIO_FORCE & XPD_SDIO_REG, 1=3.3V 0=1.8V   = 0 R/W (0x0)
CLK8M_FREQ             8MHz clock freq override                          = 50 R/W (0x32)
SPI_PAD_CONFIG_CLK     Override SD_CLK pad (GPIO6/SPICLK)                = 0 R/W (0x0)
SPI_PAD_CONFIG_Q       Override SD_DATA_0 pad (GPIO7/SPIQ)               = 0 R/W (0x0)
SPI_PAD_CONFIG_D       Override SD_DATA_1 pad (GPIO8/SPID)               = 0 R/W (0x0)
SPI_PAD_CONFIG_HD      Override SD_DATA_2 pad (GPIO9/SPIHD)              = 0 R/W (0x0)
SPI_PAD_CONFIG_CS0     Override SD_CMD pad (GPIO11/SPICS0)               = 0 R/W (0x0)
DISABLE_SDIO_HOST      Disable SDIO host                                 = 0 R/W (0x0)

Security fuses:
FLASH_CRYPT_CNT        Flash encryption mode counter                     = 1 R/W (0x1)
UART_DOWNLOAD_DIS      Disable UART download mode (ESP32 rev3 only)      = 0 R/W (0x0)
FLASH_CRYPT_CONFIG     Flash encryption config (key tweak bits)          = 15 R/W (0xf)
CONSOLE_DEBUG_DISABLE  Disable ROM BASIC interpreter fallback            = 1 R/W (0x1)
ABS_DONE_0             secure boot enabled for bootloader                = 1 R/W (0x1)
ABS_DONE_1             secure boot abstract 1 locked                     = 0 R/W (0x0)
JTAG_DISABLE           Disable JTAG                                      = 0 R/W (0x0)
DISABLE_DL_ENCRYPT     Disable flash encryption in UART bootloader       = 0 R/W (0x0)
DISABLE_DL_DECRYPT     Disable flash decryption in UART bootloader       = 0 R/W (0x0)
DISABLE_DL_CACHE       Disable flash cache in UART bootloader            = 0 R/W (0x0)
BLK1                   Flash encryption key
  = ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? -/-
BLK2                   Secure boot key
  = ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? -/-
BLK3                   Variable Block 3
  = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 R/W

Calibration fuses:
BLK3_PART_RESERVE      BLOCK3 partially served for ADC calibration data  = 0 R/W (0x0)
ADC_VREF               Voltage reference calibration                     = 1128 R/W (0x4)

Identity fuses:
MAC                    Factory MAC Address
  = 08:3a:8d:ab:94:80 (CRC 0x9f OK) R/W
CHIP_VER_REV1          Silicon Revision 1                                = 1 R/W (0x1)
CHIP_VER_REV2          Silicon Revision 2                                = 0 R/W (0x0)
CHIP_VERSION           Reserved for future chip versions                 = 2 R/W (0x2)
CHIP_PACKAGE           Chip package identifier                           = 1 R/W (0x1)

Flash voltage (VDD_SDIO) determined by GPIO12 on reset (High for 1.8V, Low/NC for 3.3V).
烧录之后 monitor 显示

Code: Select all

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

doedow
Posts: 1
Joined: Mon Oct 09, 2023 11:02 am

Re: 启用 Flash 加密 和 安全启动后芯片一直重启

Postby doedow » Mon Jan 01, 2024 2:43 pm

最近正在研究如何保護我的代碼,到處爬了半天的也不知道該怎樣打開eFuse或者說該打開哪一個。
只知道一不小心我的模組就會變成一塊磚,也就不敢隨便弄。

我是個菜鳥玩家,我不需要去逆向讀出我寫進去的代碼,但我肯定會不斷的修改、更新和寫入。
都說天下沒有不能破解的鎖,就看要花多大的價錢。
我的代碼估計不值一塊兩毛五,更沒人會花錢去破解。
但在怎麼窮也想套件衣服,總不想隨便就讓人看光光。
在這樣的條件下,可能只需要設個間單的密碼.....好吧,像證書那麼長的密碼。
寫進去的東西該怎麼加密的就自動加密,該怎樣保護就怎樣保護。
其他甚麼防止寫入的那些高級玩意,太高級了還會不小心變成一塊磚的恐怖設置,估計我這輩子都用不到。
所以能不能請大佬們幫幫忙弄個低級別的保護?只要不被讀出或者讀出的是亂碼。
然後任我隨便折騰,想怎麼寫就怎麼寫,不要變成一塊磚。
感謝。

ESP_WangYX
Posts: 97
Joined: Mon Jun 28, 2021 12:48 pm

Re: 启用 Flash 加密 和 安全启动后芯片一直重启

Postby ESP_WangYX » Tue Jan 02, 2024 3:19 am

可以尝试下面的步骤进行修复:
1)运行 idf.py bootloader
2)运行idf.py build
3)断开ESP32与PC的 USB 连接,执行idf.py encrypted-flash monitor,此时因为断开了连接,必然无法烧录,但是可以看到提示的 esptoolpy 命令。copy esptool.py 命令。
4)打开串口,修改 esptool.py 命令,开启 secure boot 后默认不会自动烧录 bootlaoder.bin,所以修改上述步骤3提示的 esptool.py 烧录命令,使之同时烧录 bootloader.bin,类似:

Code: Select all

esptool.py esp32 -p /dev/ttyUSB0 -b 460800 --before=default_reset --after=no_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB --encrypt 0x1000 bootloader/bootloader.bin 0x20000 flash_encryption.bin 0xa000 partition_table/partition-table.bin
5)重启设备。

Who is online

Users browsing this forum: No registered users and 121 guests