esptool possible to autoselect "--encrypted" flag

rfleming
Posts: 62
Joined: Tue Oct 09, 2018 12:30 am

esptool possible to autoselect "--encrypted" flag

Postby rfleming » Thu May 27, 2021 4:33 am

I am trying to create a batch file that will always program my esp32 correctly regardless if the flash is currently encrypted. The only difference between these 2 firmwares is one requires the "-u" flag, while the other I use "--encrypted" with esptool.py

For example, my CLI for
Unencrypted:

Code: Select all

@%ESP_TOOL% --chip esp32 --port %COMPORT% --baud 460800 --before default_reset --after hard_reset write_flash -u --flash_mode dio --flash_freq 40m --flash_size 4MB [b]<...firmware paths/locations>[/b]
Encrypted:

Code: Select all

@%ESP_TOOL% --chip esp32 --port %COMPORT% --baud 460800 --before default_reset --after hard_reset write_flash --encrypt --flash_mode dio --flash_freq 40m --flash_size 4MB [b]<...firmware paths/locations>[/b]
The reason is I want to be able to use the same script for writing firmware to my device the first time and then consecutive times also.

The only way I know of atm is to do an esp efuse read, interpret the data myself, then run the appropriate cli option. Is there any shortcut to this process? Perhaps its already been implemented in esptool?

Cheers,
Ryan.

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

Re: esptool possible to autoselect "--encrypted" flag

Postby WiFive » Thu May 27, 2021 5:54 am

I don't think so but it's a good feature request

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: esptool possible to autoselect "--encrypted" flag

Postby ESP_Angus » Fri May 28, 2021 12:20 am

Hi Ryan,

I can see how this would be useful. The main downside is that it gets a little complex as there are 3 different possibilities:
  • Some files are always written plaintext regardless of flash encryption status (such as SPIFFS for example)
  • Sometimes you want to write a file encrypted if encryption is on, and decrypted if encryption is off (the case here)
  • Sometimes you want to write the file encrypted even though encryption is off, because you plan to turn it on via efuse in the next step.
However, esptool.py v3.1 already has an --encrypt-files option to split the first type of file from the third type. Maybe it could also add a --auto-encrypt-files option to split the second type from the third type (i.e. --auto-encrypt-files means "encrypt this file if encryption is on, write it plaintext otherwise" and --encrypt-files means "always encrypt this file").

Do you have a GitHub account? If so, encourage you to please make a feature request at https://github.com/espressif/esptool/issues/ - can link back to this thread for more context.

Who is online

Users browsing this forum: No registered users and 171 guests