Flashing plain text image after enabling flash encryption

afcec1
Posts: 23
Joined: Tue Oct 08, 2019 1:48 pm

Flashing plain text image after enabling flash encryption

Postby afcec1 » Fri Jul 23, 2021 6:46 am

Hi,

I was making some initial tests with flash encryption in DEVELOPMENT MODE (no secure boot). When I finished, I just disabled flash encryption in menuconfig and then tried to flash again a new firmware version. Unfortunately this is the oputput I get from by board:

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

I have read several posts but I do not know exactly how to recover my boards and be able to get my plain text image running again with flash encryption disabled. I have also checked the efuses and these are their values:

Security fuses:
FLASH_CRYPT_CNT Flash encryption mode counter = 1 R/W (0x1)
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 = 0 R/W (0x0)
ABS_DONE_1 secure boot abstract 1 locked = 0 R/W (0x0)
JTAG_DISABLE Disable JTAG = 1 R/W (0x1)
DISABLE_DL_ENCRYPT Disable flash encryption in UART bootloader = 0 R/W (0x0)
DISABLE_DL_DECRYPT Disable flash decryption in UART bootloader = 1 R/W (0x1)
DISABLE_DL_CACHE Disable flash cache in UART bootloader = 1 R/W (0x1)
BLK1 Flash encryption key
= ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? -/-

What can I do? Thanks!

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Flashing plain text image after enabling flash encryption

Postby WiFive » Fri Jul 23, 2021 10:41 am

Either disable encryption (on the chip, not in the project) using espefuse.py or flash using the encrypt option

afcec1
Posts: 23
Joined: Tue Oct 08, 2019 1:48 pm

Re: Flashing plain text image after enabling flash encryption

Postby afcec1 » Mon Jul 26, 2021 6:50 am

WiFive wrote: Either disable encryption (on the chip, not in the project) using espefuse.py or flash using the encrypt option
Thanks WiFive, yes, that is exactly what I was looking for (disable encryption on the chip) but unfortunately "burn_efuse" with value 0 for DISABLE_DL_ENCRYPT and DISABLE_DL_DECRYPT return "New value is not accepted for this efuse (will always burn 0->1)".

Could you please elaborate a little bit more your explanation?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Flashing plain text image after enabling flash encryption

Postby WiFive » Mon Jul 26, 2021 8:47 am

To disable encryption you change FLASH_CRYPT_CNT

afcec1
Posts: 23
Joined: Tue Oct 08, 2019 1:48 pm

Re: Flashing plain text image after enabling flash encryption

Postby afcec1 » Mon Jul 26, 2021 9:13 am

I forgot to mention it but I also tried to set FLASH_CRYPT_CNT to 0 but this is the output, so I cancelled the operation:

espefuse.py -p COM6 burn_efuse FLASH_CRYPT_CNT 0
espefuse.py v2.8
Connecting....
WARNING: New value contains some bits that cannot be cleared (value will be 0x1)
Burning efuse FLASH_CRYPT_CNT (Flash encryption mode counter) 0x1 -> 0x1. This is an irreversible operation.
Type 'BURN' (all capitals) to continue.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Flashing plain text image after enabling flash encryption

Postby WiFive » Mon Jul 26, 2021 10:33 am

You have to set it to 3. If you don't supply a value it should automatically increment it.

afcec1
Posts: 23
Joined: Tue Oct 08, 2019 1:48 pm

Re: Flashing plain text image after enabling flash encryption

Postby afcec1 » Mon Jul 26, 2021 10:42 am

It worked! thanks

Who is online

Users browsing this forum: Bing [Bot] and 169 guests