Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32-Arduino Sketch and Encryption with ESP-idf #5645

Closed
Mos135 opened this issue Sep 8, 2021 · 29 comments
Closed

ESP32-Arduino Sketch and Encryption with ESP-idf #5645

Mos135 opened this issue Sep 8, 2021 · 29 comments
Labels
Area: ESP-IDF related ESP-IDF related issues Resolution: Expired More info wasn't provided

Comments

@Mos135
Copy link

Mos135 commented Sep 8, 2021

Hi
I have written a complicated project with Arduino-IDE for ESP32, GPS and Display modules and it was working perfect.
After that I have decided to enable encryption and protection, to protect my program. but I find out that it is not possible to enable it through Arduino-IDE. I read many forums and have tried to use ESP-idf
but the problem was, I got many errors from other module's libraries, while I didn't have the same problem with Arduino-IDE.
then I have tried to compile my code with Arduino-IDE and only write the encrypted flash in the app partition and I got the error that it can not initialize EEPROM and SPIFF.
then I have tried to find out what the problem is. I write a simple code to use SPIFF and EEPROM. when I compile it in ESP-idf and then encrypt it and write it to the flash, it works perfectly and I get this message:

I (0) cpu_start: App cpu up.
I (145) cpu_start: Pro cpu start user code
I (145) cpu_start: cpu freq: 160000000
I (145) cpu_start: Application information:
I (150) cpu_start: Project name: main
I (154) cpu_start: App version: 1
I (159) cpu_start: Compile time: Aug 27 2021 14:32:23
I (165) cpu_start: ELF file SHA256: c81c9b73a2a94ecd...
I (171) cpu_start: ESP-IDF: v4.3-dirty
I (176) heap_init: Initializing. RAM available for dynamic allocation:
I (183) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (189) heap_init: At 3FFB3840 len 0002C7C0 (177 KiB): DRAM
I (196) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (202) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (208) heap_init: At 4008BB88 len 00014478 (81 KiB): IRAM
I (216) spi_flash: detected chip: generic
I (219) spi_flash: flash io: dio
W (224) flash_encrypt: Flash encryption mode is DEVELOPMENT (not secure)
I (233) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (261) nvs: NVS partition "nvs" is encrypted.
�EEPROM is Empty
EEPROM was initialised
SPIFFS mounted
Flash encryption enabled

but when I compile it with Arduino-IDE and then encrypt it and write it to the app partition, I got this error.

entry 0x400805e8
�failed to initialise EEPROM
EEPROM is Empty
failed to initialise EEPROM
EEPROM is Empty
E (4004) SPIFFS: spiffs partition could not be found
An Error has occurred while mounting SPIFFS
Flash encryption enabled

can anyone help about this issue?
please note that when I disable encryption, in both situation code works perfectly. also for my original project.

@chegewara
Copy link
Contributor

What bootloader do you flash with encryption enabled?

@Mos135
Copy link
Author

Mos135 commented Sep 8, 2021

What bootloader do you flash with encryption enabled?

bootloader from ESP-idf after enabling encryption

@chegewara
Copy link
Contributor

Did you try this scenario:

  • enable encryption with esp-idf,
  • flash bootloader from esp-idf,
  • flash non encrypted binary from arduino

As far as i remember esp32 should encrypt binary on first run. This is only theory i remember from other issues and topics on forum.

@me-no-dev
Copy link
Member

Arduino itself is not geared towards encryption. You need to use it as IDF component if you want such features.
SPIFFS on other hand can not be encrypted. You need to use FATFS is you want to encrypt the file system as well.
I can not comment on the EEPROM failure. It's in NVS and could be the same or similar issue.

@Mos135
Copy link
Author

Mos135 commented Sep 13, 2021

Did you try this scenario:

  • enable encryption with esp-idf,
  • flash bootloader from esp-idf,
  • flash non encrypted binary from arduino

As far as i remember esp32 should encrypt binary on first run. This is only theory i remember from other issues and topics on forum.

I have Done so but have same error:
entry 0x400805e8
E (260) partition: No MState: restoring default values !
failed to initialise EEPROM
EEPROM is Empty !!
failed to initialise EEPROM
EEPROM is Empty !!
E (2265) partition: No MD5 found in partition table
E (2266) partition: load_partitions returned 0x105
E (2266) SPIFFS: spiffs partition could not be found
An Error has occurred while mounting SPIFFS

@Mos135
Copy link
Author

Mos135 commented Sep 16, 2021

I have found the problem:
I was always changing the partition table for the nvs and partition table locations.
after changing all to the default partition table and adding nvs_key location everything working fine!!

@mrdc
Copy link

mrdc commented Sep 21, 2021

@Mos135

Hi, can you explain in brief your steps to make encryption work for projects which use Arduino?

@Mos135
Copy link
Author

Mos135 commented Sep 21, 2021

1- Using a simple project from ESP-IDF (for example Hello-World)

2- adding Arduino Components as following:

https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html

3- adding suitable sdkconfig from Arduino folder to the project folder (from ..\components\arduino\tools\sdk\esp32 for ESP32)

4- adding customized partition.csv as follow to the project:

Name, Type, SubType, Offset, Size, Flags

nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
nvs_key, data, nvs_keys,0x285000,0x1000,
spiffs, data, spiffs, 0x290000,0x170000,

5- enabling the encryption and customized partition table by

idf.py menuconfig

6- building the projekt by:

idf.py build

7- copying the built partition-table.bin (from ..\build\partition_table) , the built bootloader.bin (from ..\build\bootloader) and ota_data_initial.bin (from ..\build) to the esptool folder (..\esp-idf\components\esptool_py\esptool)

8- convert the Arduino sketch to binary by: Arduino IDE-> Sketch-> Export compiled binary (rename it as main.bin)

9- copying the main.bin to the esptool folder

10- creating own key

espsecure.py generate_flash_encryption_key my_flash_encryption_key.bin

11 - write the key in the module

espefuse.py --port PORT burn_key flash_encryption my_flash_encryption_key.bin

12- write all the files to the module:

esptool.py -p PORT -b 921600 --before default_reset --after no_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 bootloader.bin 0x8000 partition-table.bin 0xe000 ota_data_initial.bin 0x10000 main.bin 0x290000 spiffs.bin

13- it will encrypt the flash and restart

to rewrite the module for development, use the development mode in step 5 and encrypt the main.bin file:

espsecure.py encrypt_flash_data --keyfile my_flash_encryption_key.bin --address 0x10000 --output main_en.bin main.bin

and write this part only:

esptool.py -p PORT -b 921600 write_flash --flash_mode dio 0x10000 main_en.bin

for me it works perfectly

@pedros89
Copy link

pedros89 commented Oct 31, 2021

Very nice exmplanation @Mos135 , you really are making thing easy.
Could you kindly explain how you managed to add arduino as IDF component in first place. I am struggling for 2 days and two nights to do so with all the IDF version and I have not managed to build a sketch

Could you kindly exapand a bit this two very generic points, which versions did you use? At the moment seems to me that everything I try to use arduino as IDF component produce errors.

2- adding Arduino Components as following:

https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html

3- adding suitable sdkconfig from Arduino folder to the project folder (from ..\components\arduino\tools\sdk\esp32 for ESP32)

thank you

@pedros89
Copy link

pedros89 commented Nov 4, 2021

After many efforts I've succesfully built the Arduino as ESP32 component (see guide here)

I had also to install python2 (see guide) to generate the key.bin file to avoid an error ocurring using python3 (see Git thread)
To generate the key python2 some submodules are needed but can be installed as follow:

python2 -m pip install cryptography
python2 -m pip install ecdsa
python2 -m pip install pyserial

Up to here everything was fine. I did everything as sketchily exmpained by @Mos135 and I managed to connect to ESP32 and write the key and the bins but analyzing the serial monitor on the COM I got the following error at the very end


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:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download


image

Unfortunately in menuconfig I had to change debug level of bootloader from info to none to avoid this size error to reduce the size of the Bootloader so it could build with crypto enable. So I don't have more debugging information.

FINAL SOLUTION
After days of trials I have realized that the easiest solution to achieve Arduino Flash Encryption is just to do as explained in this post:
#1387 (comment)
Basically with esp idf you just need to create a bootloader that suits your esp32 (select the flash frequency and the flash size) with the crypt flag enabled as relase (and ‘none’ set as bootloader log info) and replace the file in the Arduino bootloader folder you find at:
C:\Users\YOURUSER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\tools\sdk\esp32\bin
Upload your sketch with Arduino as normal and after wait 2min 30s and you will see the flash will be encrypted with a randomly generated key.
Be careful when you do the bootloader file renaming, make sure you always restore the old bootloader when you have done with the encrytion of your esp32 boards.
To check if the flash is encrypted include the following condition in your Arduino project in the setup function.

#include “esp_flash_encrypt.h” //encryption check

if(esp_flash_encryption_enabled()==true){
    Serial.println("Flash encryption enabled");
  } else {
    Serial.println("Flash encryption disabled");
  }

I attach to this post a bootloader set fot 16MB of flash and Flash Frequency of 40MHz.

bootloader_dio_40mENCRYPT.zip

@VojtechBartoska
Copy link
Contributor

Hello @Mos135, can we close this as solved?

@VojtechBartoska VojtechBartoska added the Resolution: Awaiting response Waiting for response of author label Apr 7, 2022
@VojtechBartoska
Copy link
Contributor

Hello,

as there was no answer in more than 14 days, I'm closing the issue as expired to keep our backlog manageable.

If it's still needed, please reopen the issue.

Thanks for understanding.

@simogaspa84
Copy link

if(esp_flash_encryption_enabled()==true){
Serial.println("Flash encryption enabled");
} else {
Serial.println("Flash encryption disabled");
}

Hi.. I need i bootloader for my specs..

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

Name, Type, SubType, Offset, Size, Flags

nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1D0000,
app1, app, ota_1, 0x1E0000,0x1D0000,
spiffs, data, spiffs, 0x3B0000,0x50000,

is it the procedure complicated?

Can you guide me ?

Thanks a lot for your help

@pedros89
Copy link

pedros89 commented Jan 16, 2023

Basically with esp Idf, I suggest you to use ESP-IDF 5.0 CMD console you just need to create an encrypted project and copy the bootloader programmed to suit your needs
-select the flash frequency 40 MHz and the flash size 4MB
-the crypt flag enabled as release (and ‘none’ set as bootloader log info)
-replace the file in the Arduino bootloader folder you find at:
C:\Users\YOURUSER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\tools\sdk\esp32\bin

If you do not much about esp menuconfig look at this video or similar ones to get familiar for the IDF menuconfig settings console in Windows (or choose another video if you are on Linux) From menuconfig you can configure an IDF project with encrypted bootloader, after you have to use the command build like in the video, just copy paste that bootloader that will be created in the project folder in your Arduino folder where the esp bootloaders are and you are done. Just be very careful because you will not be able to reflash the esp anymore. You will brick them. So make a back up of the original bootloader and use the encrypted bootloader with care.

video link menuconfig

@simogaspa84
Copy link

Hi @pedros89 ..
is it possible to encrypt also NVS partition... I need to create a new bootloader that is able to encrypt the app partition and also the nvs partition where the data are stored..
Do you know if it is possible ?

Thanks a lot

@pedros89
Copy link

Hi @pedros89 .. is it possible to encrypt also NVS partition... I need to create a new bootloader that is able to encrypt the app partition and also the nvs partition where the data are stored.. Do you know if it is possible ?

Thanks a lot

Sorry, from my experience only esp app partition will be encrypted with the randomly generated key by the bootloader. I am not sure about NVS partition, but I think it will not. I'm still using the old esp Virtual EEPROM library and the 4KB allocated are not encrypted in my case. Also SPIFFs partition is not encrypted with this method. I don't know how to encrypt those. If you want you can save sensible information (text or numbers) as encrypted with RC4 or similar methods and use an unique key you have in flash to decrypt when you retrieve the info, in this way is like having it encrypted.

@simogaspa84
Copy link

Hi @pedros89 .. thanks for your suggestion.. when i create the custom bootloader with the menuconfig do I hvae also to change the partion table to be used ? I need a special one which is set in this file ..

Name, Type, SubType, Offset, Size, Flags

nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1D0000,
app1, app, ota_1, 0x1E0000,0x1D0000,
spiffs, data, spiffs, 0x3B0000,0x50000,

@pedros89
Copy link

pedros89 commented Jan 17, 2023

Hi @pedros89 .. thanks for your suggestion.. when i create the custom bootloader with the menuconfig do I have also to change the partion table to be used ? I need a special one which is set in this file ..

Name, Type, SubType, Offset, Size, Flags

nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, app0, app, ota_0, 0x10000, 0x1D0000, app1, app, ota_1, 0x1E0000,0x1D0000, spiffs, data, spiffs, 0x3B0000,0x50000,

yes of course if you have a custom partition you have to modify the .csv
like thay say here on idf website
custom partition table

@simogaspa84
Copy link

simogaspa84 commented Jan 17, 2023

Hi again @pedros89 ..
So i import the csv file inside the esp-idf framework and i also change here

image

Thanks a lot for your support

@whoim2
Copy link

whoim2 commented Nov 7, 2023

Hi all! I'm trying to repeat the encryption procedure for the Lolin S2 mini board.
What was done:

  • installed idf tools
  • hello_world example copied to desktop
  • via ifd.py target esp32s2 set
  • enter the menuconfig with setting parameters as in the screenshots
  • default.csv from AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\tools\partitions folder was loaded into the project directory as partitions.csv
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000
otadata,  data, ota,     0xe000,  0x2000
app0,     app,  ota_0,   0x10000, 0x140000
app1,     app,  ota_1,   0x150000,0x140000
spiffs,   data, spiffs,  0x290000,0x160000
coredump, data, coredump,0x3F0000,0x10000
  • commas at the end of each line were removed, otherwise there was an error
  • idf.py build

Before that, I uploaded the flash files that the Arduino uses to a my directory and wrote a cmd file for the firmware (use parameters from arduino log window), checked that the board was being flashed and the program was working.

esptool.exe --chip esp32s2 --port COM%PORT% --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 myfile.bin

Screenshot_6

I replaced the bootloader with the one generated above in idf tools. It is flashed, I perform a reset (automatically impossible for this board) and wait, up to 10 minutes. Nothing changes, rebooting the board does not launch the program. What could I have missed?

Arduino settings:

Screenshot_5

menuconfig

Screenshot_4
Screenshot_1
Screenshot_2
Screenshot_3

@pedros89
Copy link

pedros89 commented Nov 7, 2023

  • Try not to use your customised directory but the Arduino uploading arrow copying the code in Arduino IDE and uploading it (of course replace the bootloader in the Arduino bootloader folder first like stated in the guides above)

  • Or use Arduino directory as below that in my case works.

esptool.exe --chip esp32 --port COM11 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0xe000 C:\Users\YOUR_USER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0/tools/partitions/boot_app0.bin 0x1000 C:\Users\YOUR_USER\AppData\Local\Temp\arduino_build_WHATEVER_NUMBER/MYFIRMWARE.ino.bootloader.bin 0x10000 C:\Users\YOUR_USER\AppData\Local\Temp\arduino_build_WHATEVER_NUMBER/MYFIRMWARE.ino.bin 0x8000 C:\Users\YOUR_USER\AppData\Local\Temp\arduino_build_WHATEVER_NUMBER/MYFIRMWARE.ino.partitions.bin

  • Or you can also try to upload using the flash_download_tool_v3.8.5 (be careful as some other newer versions did not work for me)

  • You should manage to upload everything with one of the methods above and if at the end you have the hard resetting message it means the encrypted bootloader is uploaded, but the firmware is not encrypted yet.

  • Remove power to your board.

  • Give power to the board again and the encryption process starts automatically. Wait 5 min to be safe, In my case it takes 2 and 1/2 minutes. It is nice to put a blinking LED in your loop every few seconds so you know that when the led starts blinking on your board the firmware is running, as simple as digitalWrite(6, !digitalRead(6));

  • to see if the encryption happened correctly give the following command

espefuse.py -p COM11 summary

If you find 128 with many question marks as key, as in the picture it means the chip is encrypted
image

  • if you find the message wrong header reading esp serial monitor it means the encryption process was interrupted and the esp is bricked, so careful

By the way it is weird that commas at the end of each line were removed in the partition .csv as default partition schemes have it.

@whoim2
Copy link

whoim2 commented Nov 9, 2023

By the way it is weird that commas at the end of each line were removed in the partition .csv as default partition schemes have it.

Thanks for the answer! I don’t think it’s a directory issue, I copied the same files that would interfere with the Arduino theme and used the command line from their Arduino log when flashing the firmware. The process is completely identical only The sketch does not compile, it was exported earlier. Everything works with the Arduino bootloader. I can't view the bootloader messages because The port is USB (not uart/usbbrigde) and disappears after flashing and resetting. No signs of work. The firmware lights up the LED at startup. This doesn't happen. I can flash the original bootloader since I did not exclude this possibility when setting up a new bootloader and chose development. I'll try to replace the bootloader in the Arduino, ok. But I don't think this will help. The busy ones had to be deleted because esptools showed a csv partitions file error.

@whoim2
Copy link

whoim2 commented Nov 9, 2023

My problem is solved in this checkbox. We need to take it off.
After that, I uploaded the binaries via esptool.exe (as I described earlier, in my directory), the bootloader encrypted the partition and rebooted the board, everything worked.
Thanks.

Screenshot_1

Addition:
I chose the development version and left the permission to upload via USB. Last time this allowed me to return to the Arduino bootloader, now after flashing the firmware with a regular bootloader the sketch does not work. When re-downloading with a bootloader that encrypts, the sketch also does not work, I waited a long time.
As far as I understand, if the key is registered in the fuse, you can’t download anything else via USB, only OTG. I have a download port, but I can't download anything else, the sketch doesn't work. As I understand it, the board is bricked :)
In other words, if you flash it twice in the same way via USB, the board will be lost if you don’t know how to get permission to work via fuse back. If anyone can tell me, thanks.

@DxrMorgan
Copy link

12- write all the files to the module:

why write not sign files? it dont need!

where set fuse for encrypt mechanism?

it not full description! and with mistakes!

@pedros89
Copy link

pedros89 commented Nov 9, 2023

My problem is solved in this checkbox. We need to take it off. After that, I uploaded the binaries via esptool.exe (as I described earlier, in my directory), the bootloader encrypted the partition and rebooted the board, everything worked. Thanks.

Screenshot_1

Addition: I chose the development version and left the permission to upload via USB. Last time this allowed me to return to the Arduino bootloader, now after flashing the firmware with a regular bootloader the sketch does not work. When re-downloading with a bootloader that encrypts, the sketch also does not work, I waited a long time. As far as I understand, if the key is registered in the fuse, you can’t download anything else via USB, only OTG. I have a download port, but I can't download anything else, the sketch doesn't work. As I understand it, the board is bricked :) In other words, if you flash it twice in the same way via USB, the board will be lost if you don’t know how to get permission to work via fuse back. If anyone can tell me, thanks.

Good that you got it sorted. I did not remember about that checkbox, infact, I did not touch anything, I left everything on default in menuconfig except selecting the flash frequency and the flash size with the crypt flag enabled as release and ‘none’ set as bootloader log info .

I confirm that if you have the bootloader with the encryption in developer mode, before uploading a new firmware via USB you need to burn an efuse with the following command
espefuse.py -p COM7 burn_efuse FLASH_CRYPT_CNT
More details in the idf guide
Burn efuse guide
You can burn up to 3 times, on the fourth you will brick the esp.

On the other hand if you are working in release mode only OTA updates are possible to update the firmware, no more USB

At the end of the encryption process you can also try to read the flash and see if it is encrypted with this command

Read Falsh
2MB of flash
esptool.py -p COM7 -b 460800 read_flash 0 0x200000 flash_contents.bin
and read 4MB of flash
esptool.py -p COM10 -b 460800 read_flash 0 0x400000 flash_contents.bin

@whoim2
Copy link

whoim2 commented Nov 9, 2023

Read Falsh 2MB of flash esptool.py -p COM7 -b 460800 read_flash 0 0x200000 flash_contents.bin and read 4MB of flash esptool.py -p COM10 -b 460800 read_flash 0 0x400000 flash_contents.bin

espefuse.py -p COM41 burn_efuse FLASH_CRYPT_CNT
espefuse.py v3.3.4-dev
Connecting...
Detecting chip type... Unsupported detection protocol, switching and trying again...
Detecting chip type... ESP32-S2

A fatal error occurred: Invalid the efuse name 'FLASH_CRYPT_CNT'. Available the efuse names: ['WR_DIS', 'RD_DIS', 'DIS_RTC_RAM_BOOT', 'DIS_ICACHE', 'DIS_DCACHE', 'DIS_DOWNLOAD_ICACHE', 'DIS_DOWNLOAD_DCACHE', DIS_FORCE_DOWNLOAD', 'DIS_USB', 'DIS_CAN', 'DIS_BOOT_REMAP', 'SOFT_DIS_JTAG', 'HARD_DIS_JTAG', DIS_DOWNLOAD_MANUAL_ENCRYPT', 'USB_EXCHG_PINS', 'EXT_PHY_ENABLE', 'USB_FORCE_NOPERSIST', 'BLOCK0_VERSION', VDD_SPI_FORCE', 'VDD_SPI_XPD', 'VDD_SPI_TIEH', 'WDT_DELAY_SEL', 'SPI_BOOT_CRYPT_CNT', 'SECURE_BOOT_KEY_REVOKE0', SECURE_BOOT_KEY_REVOKE1', 'SECURE_BOOT_KEY_REVOKE2', 'KEY_PURPOSE_0', 'KEY_PURPOSE_1', 'KEY_PURPOSE_2', KEY_PURPOSE_3', 'KEY_PURPOSE_4', 'KEY_PURPOSE_5', 'SECURE_BOOT_EN', 'SECURE_BOOT_AGGRESSIVE_REVOKE', FLASH_TPUW', 'DIS_DOWNLOAD_MODE', 'DIS_LEGACY_SPI_BOOT', 'UART_PRINT_CHANNEL', 'DIS_USB_DOWNLOAD_MODE', 'ENABLE_SECURITY_DOWNLOAD', 'UART_PRINT_CONTROL', 'PIN_POWER_SELECTION', 'FLASH_TYPE', 'FORCE_SEND_RESUME', SECURE_VERSION', 'MAC', 'SPI_PAD_CONFIG_CLK', 'SPI_PAD_CONFIG_Q', 'SPI_PAD_CONFIG_D', 'SPI_PAD_CONFIG_CS', SPI_PAD_CONFIG_HD', 'SPI_PAD_CONFIG_WP', 'SPI_PAD_CONFIG_DQS', 'SPI_PAD_CONFIG_D4', 'SPI_PAD_CONFIG_D5', SPI_PAD_CONFIG_D6', 'SPI_PAD_CONFIG_D7', 'WAFER_VERSION', 'FLASH_VERSION', 'BLOCK1_VERSION', 'PSRAM_VERSION', PKG_VERSION', 'OPTIONAL_UNIQUE_ID', 'BLOCK2_VERSION', 'CUSTOM_MAC', 'BLOCK_USR_DATA', 'BLOCK_KEY0', 'BLOCK_KEY1', BLOCK_KEY2', 'BLOCK_KEY3', 'BLOCK_KEY4', 'BLOCK_KEY5', 'BLOCK_SYS_DATA2']

i think, 'SPI_BOOT_CRYPT_CNT' need for esp32s2?
I would like to try disabling encryption altogether to return to the standard bootloader without encryption, is this possible?

@whoim2
Copy link

whoim2 commented Nov 9, 2023

I set SPI_BOOT_CRYPT_CNT (0b001 -> 0b011) and it worked! As I understand it, I have one attempt left, but I can already try to work via OTA (I have provided for it in the firmware). I just would like to return this particular board to Arduino, if possible)

I also compared the downloaded firmware and my own, and they are clearly different, that is, the downloaded one is encrypted. In mine, when I open the words from the F() macros with notepad, the downloaded file is complete garbage :)

UPD OTA work perfectly ;) Thanks!

Im add two bootloaders for ESP32 S2 (lolin s2 mini) for development with usb (tested) and release without usb/uart (not tested!) to this message
esp32s2_secure_bootloaders_for_arduino_default_partitions_lolin_s2_mini.zip

@sboicu
Copy link

sboicu commented Jan 21, 2024

3- adding suitable sdkconfig from Arduino folder to the project folder (from ..\components\arduino\tools\sdk\esp32 for ESP32)

where do you find the sdkconfig in Arduino for the project you want to build? @pedros89 maybe do you know?

@pedros89
Copy link

3- adding suitable sdkconfig from Arduino folder to the project folder (from ..\components\arduino\tools\sdk\esp32 for ESP32)

where do you find the sdkconfig in Arduino for the project you want to build? @pedros89 maybe do you know?

Are you looking for ?
C:\Users\YOUR_USER\AppData\Local\Arduino15
AppData is actually an hidden folder
This is the Arduino folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ESP-IDF related ESP-IDF related issues Resolution: Expired More info wasn't provided
Projects
None yet
Development

No branches or pull requests

10 participants