TinyCircuits-Thumby-Code-Editor icon indicating copy to clipboard operation
TinyCircuits-Thumby-Code-Editor copied to clipboard

Reduce filesystem overhead of UF2

Open ace-dent opened this issue 2 years ago • 1 comments

From https://github.com/TinyCircuits/TinyCircuits-Thumby-Code-Editor/pull/73#issuecomment-1402119063

Investigate how bundling an FS with picotool might be optimized, to reduce the overall size of the UF2 for flashing.


Current process noted here:

  1. Load a Thumby with everything that is needed for shipping (MicroPython, games, libs, etc.).
  2. Use picotool (https://github.com/raspberrypi/picotool) to clone a UF2 from the Thumby. I use Linux and this command: sudo ./picotool save -r 0x10000000 0x10200000 ThumbyFirmware.uf2.

This specifies an address range of 2,097,152 bytes / 2048 KiB / 2 MiB. Using picotool info -a will give the actual end address - so it may be possible to avoid copying empty 256 byte blocks?... but this may be required to keep the filesystem intact?


See also documentation on the format: https://github.com/microsoft/uf2

ace-dent avatar Aug 16 '23 19:08 ace-dent

Note the deliberate low efficiency of the UF2 format:

  • One UF2 block is fixed as 512 bytes (36 bytes overhead, up to 476 bytes of data).
  • Flash chips normally have a minimum page size of ~ 256 bytes (4 x 64 bytes).
  • It is expected that only one 256B flash page will fit per 512B block- with the remaining space padded (zero filled).
  • With this default setup, each block is ~57% data / ~43% blank.

It may be possible to configure the RP2040 / flash storage to use a different page size for improved packing.

ace-dent avatar Aug 21 '23 16:08 ace-dent