Hacker News new | ask | show | jobs
by makapuf 736 days ago
I often wonder how you do that : the usb mass storage let you use blocks, not files (if you want files use the MTP/PTP usb protocol), so how will the target "know" that I'm uploading a file to write to the flash wihtout writing and reading a full FAT on the device flash ?
2 comments

This blog article gives a rundown of all of the ways this has been implemented. https://makecode.com/blog/one-chip-to-flash-them-all
Nice! So what this means is that you put all info for flashing a part of flash in a 512 byte sector so you don't need filesystem info (place within file, even order) since it's all written as a bunch of self contained 512 bytes commands in the data itself. Clever!
The flash on the mbed was a real 2MB FAT disk that you could upload one or more random files to, not just mbed binaries. I assume they built a dual ported flash driver that arbitrates access between the loader and the USB storage driver. I should also mention it looked for .bin files and checked the mtimes to load the newest .bin file in the disk's root. So it was using a real FAT file system on both ends.