-
Notifications
You must be signed in to change notification settings - Fork 0
Tinkering with Data Storage
Some scenarios I've thought of for utilizing the SPI flash access capabilities provided by Ichi.
What could be simpler than making a backup? But it is an extremely important step!
Important
Always back up your data! For every single one!
As described in Under the Hood, the recovery operation requires multiple steps to complete. The specific commands will be the same as those in the subsequent section, Extraction and Recovery of Calibration Data, so I will defer them until then.
Tip
This section applies only to stock firmware or third-party firmware using the same data layout as stock firmware.
The stock firmware stores calibration data at address 0x10000 in the SPI flash, with a length of 400 bytes. It is recommended to back up 512 bytes.
The following command examples are executed on Linux using the UF2 tool uf2conv.py.
Convert the SPI flash data file DATA.UF2 to binary format:
$ python utils/uf2conv.py -c -o spi_flash.bin /media/user1/ICHI/DATA.UF2
--- UF2 File Header Info ---
All block flag values consistent, 0x0000
----------------------------
Converted to bin, output size: 2097152, start address: 0x0
Wrote 2097152 bytes to spi_flash.bin
Extract calibration data. Note: Calibration data address 0x10000 equals 64 KB.
$ dd if=spi_flash.bin skip=64k bs=1 count=512 of=calib.bin
512+0 records in
512+0 records out
512 bytes copied, 0.00171606 s, 298 kB/s
Convert calibration data (calib.bin) to UF2 format:
$ python utils/uf2conv.py -c -b 0x10000 -o calib.uf2 calib.bin
Converted to uf2, output size: 1024, start address: 0x10000
Wrote 1024 bytes to calib.uf2
When calibration data needs to be restored, simply copy the calib.uf2 file to the ICHI drive.
LittleFS is a filesystem for microcontrollers that has some great features such as dynamic wear-leveling, power-loss resilience and bounded RAM and ROM usage. However, one drawback is the lack of operating system support.
Nevertheless, as a compromise, accessing LittleFS within a browser is technically feasible and also quite user-friendly.
Using the following recipe, one can implement an in-browser WYSIWYG LittleFS File Explorer, and Ichi fits perfectly into this scenario:
-
WebUSB: The emergence of UF2 is closely tied to WebUSB. For instance, the Micro:bit Editor has supported WebUSB-based flashing from the very beginning
-
UF2 is an extremely simple file format, and encoding/decoding UF2 blocks poses no difficulty
-
UF2 (and hence Ichi) permits writing of non-contiguous data
-
A JavaScript LittleFS library, such as