为了防止通过esptool.py read_flash命令将固件以明文的方式提取出来,所以启动flash加密非常有必要。
1。在项目根目录打开配置菜单idf.py menuconfig,选择Security features菜单,然后再选择
Enable flash encryption on boot即可。
2。编译项目idf.py build,此时bootloader大小会增加,需要改动分区表的偏移。
3。编译完成后第一次下载idf.py flash monitor,之后片内bootolader会使用默认aes随机密钥
加密整个flash,再次下载idf.py encrypted-flash monitor。
4。加密flash会对nvs存取数据有影响,nvs键值对无法识别,
CONFIG_NVS_ENCRYPTION is enabled, but no partition with subtype nvs_keys found in the partition table。
根本原因是 NVS 与 ESP32-S3 flash 加密系统不直接兼容,可以取消nvs使能加密即可。
idf.py menuconfig-->Component config-->NVS-->[]Enable NVS encryption
5。关闭flash加密只有一次机会 espefuse.py burn_efuse SPI_BOOT_CRYPT_CNT。