adafruit / tinyuf2

UF2 bootloader based on TinyUSB for embedded devices such as ESP32S2, STM32F4 and iMX RT10xx
MIT License
326 stars 178 forks source link

Improve FAT generation, bugs, favicon support #187

Closed henrygab closed 2 years ago

henrygab commented 2 years ago

.github/workflows/...

ports/test_ghostfat/boards/...

src/ghostfat.c

Click to expand FAT generation notes

Previously, code presumed that (other than firmware file) the existing files would have FAT entirely in first sector. This should now be fixed. Generation of FAT uses much simpler method now, relying on the following properties: 1. All files are laid out contiguously, in order listed in table 2. No unused sectors between files 3. Last "file" is actually firmware (generated UF2) New method of FAT generation is two steps: 1. Fill default value of CLUSTER+1 (or zero if past end of UF2) ... essentially make entire used FAT area a single, long, continuous FAT chain 2. Fill in the exceptions: a. clusters 0 & 1 need special values b. for each file, make end-of-FAT chain That's it! Simpler, and avoids the edge cases....