当前位置:网站首页>Process of manually encrypt the mass-producing firmware and programming ESP devices
Process of manually encrypt the mass-producing firmware and programming ESP devices
2022-07-04 20:04:00 【25March】
The requirements are as follows
Encrypting the mass-produced firmware, after encryption you can use the tool to erase the old firmware, and it support repeated flashing the firmware.
Required tools:
- esptool , you can refer to Introduction and use of esptool.py
- Flash download tool
Reference Documentation:
solution
Specify the Flash encryption key (
key.bin), i.e. each module uses the same Flash encryption key (key.bin). Firstly using the Flash encryption key (key.bin) to encrypt the separate binary plaintext firmware that compiled by project, then you can flash the encrypted ciphertext firmware directly using the Flash Download Tool. After the ciphertext firmware flashed, you need to use esptool to falsh the Flash encryption key (key.bin) to the Efuse, then turn on the Control Bit of Flash Encryption in Efuse to make sure the encrypted firmware boots properly. The steps are as follows:
1 Use the esptool tool to generate a Flash encryption key (key.bin) for production firmware, for example, the generated encryption key is key.bin:
espsecure.py generate_flash_encryption_key key.bin
2 Encrypt each firmware (bin file) to be flashed, using the hello-world as an example
- **Turned on the Flash encryption option in menuconfig, as follows: **
menuconfig -> Security features -> Enable flash encryption on boot
- **Since Flash encryption increases the size of the bootloader .bin firmware, the offset of the default partition table needs to be adjusted, which is 0x8000, can be adjusted to 0xa000. You can modify the settings for partition_table in menuconfig. As follows: **
menuconfig -> Partition Table -> Offset of partition table
- Then compile the project and check the firmware download address corresponding to the compiled firmware. You can find that the download address of hello-world.bin becomes 0x20000
Project build complete. To flash, run this command:
E:.espressif\python_env\idf4.3_py3.8_env\Scripts\python.exe …\components\esptool_py\esptool\esptool.py -p (PORT) -b 460800 --before default_reset --after no_reset --chip esp32c3 write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x0 build\bootloader\bootloader.bin 0xa000 build\partition_table\partition-table.bin 0x20000 build\hello-world.bin
or run ‘idf.py -p (PORT) flash’
3 Using the generated Flash encryption key (key.bin file) to encrypt each individual firmware (bin file) that compiled by project. As follows:
- ) to encrypt bootloader.bin, and the encrypted bootloader.bin becomes key_bootloader.bin**
espsecure.py encrypt_flash_data --keyfile key.bin --address 0x1000 -o key_bootloader.bin build/bootloader/bootloader.bin
- Using the generated Flash encryption key (
key.bin) to encrypt partition-table.bin, and the encrypted partition-table.bin becomes key_partition-table.bin
espsecure.py encrypt_flash_data --keyfile key.bin --address 0xa000 -o key_partition-table.bin build/partition_table/partition-table.bin
- Using the generated Flash encryption key (
key.bin) to encrypt hello_world.bin, and the encrypted hello_world.bin becomes key_hello-world.bin
espsecure.py encrypt_flash_data --keyfile key.bin --address 0x20000 -o key_hello-world.bin build/hello_world.bin
4 **According to the corresponding download address of the firmware compiled by project, program the encrypted firmware (encrypted bin file), use the esptool to download the encrypted firmware as follows: **
esptool.py -b 460800 --before default_reset --after no_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 key_bootloader.bin 0xa000 key_partition-table.bin 0x20000 key_hello-world.bin
note:
This step to download the encryption firmware can also be downloaded directly using the Flash Download Tool as follows:

5 Program the Flash encryption key (key.bin) to Efuse:
espefuse.py burn_key flash_encryption key.bin
6 Use the esptool tool to turn on the Control Bits for Flash Encryption in Efuse:
espefuse.py burn_efuse FLASH_CRYPT_CONFIG 0xF FLASH_CRYPT_CNT 1
Instructions
If the Flash encryption key (
key.bin) is not written in Efuse or not turn on the Control Bits for Flash encryption in Efuse, the encrypted “firmware” (bin file) does not boot properly.After Flash encryption is enabled, the Flash Download Tool cannot be used to reprogram the firmware and erase the firmware, but the esptool tool is supported to reprogram the firmware and erase the firmware.
**For encrypted modules encrypted by Flash to reprogram firmware, the reprogram firmware requires to turn on the configuration option of “
Flash Encryption” in menuconfig, and use the same encryption key (key.bin) as the old firmware to encrypt and flash, so that the reprogram firmware can boot properly. ****Burning encryption keys in Efuse is non-erasable, so new keys cannot be reprogrammed. **
This solution meets the requirements that it can also use the esptool tool to
reprogram the firmware, erase, read Flashoperation on the module after the module production firmware is encrypted, but the read firmware is encrypted firmware. If the new module does not flash the key (key.bin) corresponding to the encryption firmware, only reprogram the encrypted firmware to the new module, it can’t boot properly.
边栏推荐
- 黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
- [graduation season] green ant new fermented grains wine, red mud small stove. If it snows late, can you drink a cup?
- How to use async Awati asynchronous task processing instead of backgroundworker?
- Multi table operation - external connection query
- 如何使用Async-Awati异步任務處理代替BackgroundWorker?
- Thinking on demand development
- CANN算子:利用迭代器高效实现Tensor数据切割分块处理
- Socket programming demo II
- 多表操作-内连接查询
- The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
猜你喜欢
![[problem] Druid reports exception SQL injection violation, part always true condition not allow solution](/img/cc/160bc8ccdc378901510c1b61c3f5d3.png)
[problem] Druid reports exception SQL injection violation, part always true condition not allow solution

黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,

华为nova 10系列支持应用安全检测功能 筑牢手机安全防火墙

The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize

Swagger suddenly went crazy

勾股数规律(任意三个数能够满足勾股定理需要满足的条件)

Crystal optoelectronics: ar-hud products of Chang'an dark blue sl03 are supplied by the company

English grammar_ Noun - use

What are the consequences of closing the read / write channel?

C language - Introduction - Foundation - grammar - process control (VII)
随机推荐
西门子HMI下载时提示缺少面板映像解决方案
An example of multi module collaboration based on NCF
BCG 使用之CBCGPProgressDlg进度条使用
kotlin 继承
Kotlin inheritance
[QNX hypervisor 2.2 user manual]6.3.1 factory page and control page
上线首月,这家露营地游客好评率高达99.9%!他是怎么做到的?
kotlin 条件控制
Chrome开发工具:VMxxx文件是什么鬼
HDU 1372 & POJ 2243 Knight moves (breadth first search)
Actual combat simulation │ JWT login authentication
线上数据库迁移的几种方法
Multi table operation - external connection query
1003 emergency (25 points) (PAT class a)
1003 Emergency(25 分)(PAT甲级)
Key rendering paths for performance optimization
Pointnet / pointnet++ point cloud data set processing and training
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
node_ Exporter deployment
1006 Sign In and Sign Out(25 分)(PAT甲级)

