Reduce Flash time
Problem: The html folder (especially the images) are part of the code and blow up the binary which increases flash times.
Approach: Put the html files in a separate partition.
Steps:
-
Add a partition table:
# Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x6000, phy_init, data, phy, 0xf000, 0x1000, factory, app, factory, 0x10000, 1M, storage, data, spiffs, , 0x2F0000,
-
create a file format containing the files (e.g. a serialized FnvIndexMap)
-
flash this data to the storage partition: e.g.,
espflash write-bin 0x110000 mybin.bin
-
Read the flash partition in the code:
let mut bytes = [0u8; 32]; let mut flash = FlashStorage::new(); let flash_addr = 0x110000; error!("Flash size = {}", flash.capacity()); flash.read(flash_addr, &mut bytes).unwrap(); error!("Read from {:x}: {:02x?}", flash_addr, &bytes[..32]); error!("content: {}", core::str::from_utf8(&bytes).unwrap());
-
Deserialize the files and use in the code
Blockers:
- There is no sensible way to automatically flash the storage partition only when it has not changed. (https://github.com/esp-rs/espflash/issues/630)