Speeding up/automating programming of devices

craige
Posts: 2
Joined: Tue Aug 13, 2024 8:27 am

Speeding up/automating programming of devices

Postby craige » Tue Aug 13, 2024 8:52 am

Hello,

We are currently in the process of scaling up the manufacturing of our product containing an ESP32-C6 module. The first step after assembly is to program the devices, which consists of the following steps executed in a .bat file;

Code: Select all

# Erase device 
esptool.py -p COM15 -b 921600 --before default_reset --after no_reset --chip esp32c6 erase_flash --force

# Burn key to block0
espefuse.py --port COM15 burn_key BLOCK_KEY0 device_flash_encrypt.bin XTS_AES_128_KEY

# Flash encrypted bootloader necessary binaries 
esptool.py --chip esp32c6 -p COM15 -b 921600 --before=default_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 8MB 0x0 ./build/bootloader/bootloader.bin 0x100000 ./build/application.bin 0xe000 ./build/partition_table/partition-table.bin 0xfd000 ./build/ota_data_initial.bin

# Wait for ~30 seconds for the binaries to encrypt on the device
TIMEOUT /T 30 /NOBREAK

# Store standard NVS encryption key
esptool.py -p COM15 --before=default_reset --after no_reset write_flash  --encrypt 0xFC000 std_nvs_key.bin

# Await NVS file ID
set /p "nvsnum=Enter nvs file number: "

# Flash the pre-generated, encrypted, unique device keys/ID binary 
esptool.py -p COM15 write_flash 0xF000 ./100-b1/bin/nvs_enc_-%nvsnum%.bin

# Rename the file with the device batch# so it can't be used again
set /p "bNum=Enter device batch number: "
ren .\100-b1\bin\nvs_enc_-%nvsnum%.bin nvs_enc_-%nvsnum%.bin-USED_%bNum%
We have been managing okay at small volumes ourselves, but I think this is going to get a lot more challenging when moving this process to an external manufacturing partner; It's a fairly slow and cumbersome process due to the number of steps, waiting for the flash to encrypt, and having to select a unique ID binary.

I was wondering if anyone had any advice or experience in streamlining or automating this process for a manufacturer to handle - as I mentioned we currently just runs these steps out of a windows .bat file, which can be a bit temperamental (no checks for errors) and slow.

aliarifat794
Posts: 200
Joined: Sun Jun 23, 2024 6:18 pm

Re: Speeding up/automating programming of devices

Postby aliarifat794 » Sat Aug 17, 2024 2:50 pm

Instead of a fixed TIMEOUT, consider using a loop that checks when the flash encryption is complete, reducing unnecessary waiting time.

username
Posts: 538
Joined: Thu May 03, 2018 1:18 pm

Re: Speeding up/automating programming of devices

Postby username » Sat Aug 17, 2024 5:21 pm

I upload my code at 1152000.

craige
Posts: 2
Joined: Tue Aug 13, 2024 8:27 am

Re: Speeding up/automating programming of devices

Postby craige » Mon Aug 19, 2024 2:07 pm

@aliarifat794
Instead of a fixed TIMEOUT, consider using a loop that checks when the flash encryption is complete, reducing unnecessary waiting time.
The TIMEOUT is only about 2s longer than it actually takes the memory to encrypt. How would you check if it's complete?
Also, is there a way to pre-encrypt the binaries so I can avoid this wait completely?

@username
I upload my code at 1152000.
How do you alter the speed to that?

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 103 guests