Chapter 4. Software framework
4.7.26 After enabling Secure Boot or ash encryption, what should I pay attention to
during OTA (Over-The-Air) updates?
• After enabling Secure Boot, you must sign the new rmware to be used for OTA updates. Otherwise, the new
rmware cannot be applied to the device.
• After enabling ash encryption, when generating a new rmware, please ensure that the ash encryption option
is enabled.
4.8 Storage
4.8.1 FAT Filesystem
How to improve the damage to FatFs le system caused by accidental power loss?
Since FatFs is designed to not support write transactions, the accidental power loss may cause error to
partitions, which cannot be restored by simply modifying FatFs. For now, it is recommended to resolve
this problem in application level by creating two identical FatFs partitions to do backups, or you can also
choose a more secure le system instead, such as LittleFS and SafeFAT (charged).
How to make and ash the image of a FatFs le system?
Here we will use a third-party tool, since there is no such tool provided in ESP-IDF now. The entire
process shows as below:
• Step 1: use the mkfatfs tool to create image in a specied folder. Here we create a 1048576-byte
image named fat_img.bin in the le_image folder.
./mkfatfs -c file_image -s 1048576 ./fat_img.bin
• Step 2: ash the image to address 0x110000:
esptool.py -p /dev/ttyUSB1 -b 460800 --before default_reset --after hard_
,→reset write_flash --flash_mode dio --flash_size detect --flash_freq 80m␣
,→0x110000 ~/Desktop/fat_img.bin;
• Step 3: mount the image in program:
static void initialize_filesystem() {
static wl_handle_t
wl_handle = WL_INVALID_HANDLE;
const esp_vfs_fat_mount_config_t
mount_config = { .max_files = 10, };
ESP_LOGI(TAG, "Mounting FATfilesystem");
esp_err_t err = esp_vfs_fat_spiflash_mount("/spiflash", "storage", &
,→mount_config, &wl_handle);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to mount FATFS (%s)", esp_err_to_name(err));
return;
}
}
Espressif Systems 109
Submit Document Feedback
Release master