Comprehensive Issue Summary -- Light Background Reading
As you know, I’ve written up a comprehensive overview of how storage works. It also includes a link to the FAT32 file system specification.
I am an expert from my work in the Windows low-level storage stack for ~10 years, from my detailed knowledge of the FAT and exFAT specifications, and from my work improving ghostfat (UF2 bootloader’s read-only FAT generator), …
For anyone not familiar with why the solutions here might result in corruption, please familiarize yourself with those resources. If there are unclear scenarios, please ask in that forum thread, to allow this thread to be focused on Ian’s work.
Hi Ian,
I agree MTP is not a short-term option.
Informed Decision
I want to ensure that you make an informed decision. I will support your decision fully.
The above proposal would significantly improve the situation of when multiple initiators might write to the NAND. At the same time, it does still have scenarios where multi-initiators could cause corruption. Off the cuff, if the host caches any modification to the media, and the firmware writes to the media (while the serial port is closed), there will be a mismatch between the host cache and NAND FS. I agree that this is an edge case.
As the user base grows, even a 99% solution will still have the occasional user impact. User education here can be helpful to mitigate. For example, document that one should not have long-running logging running when disconnecting the serial port?
While users would likely only hit corruption once, this does raise a risk of reputational damage. This is mitigated by the user base tending to be more technically savvy and the marketing of the device as a hacker tool. Thus, it’s not a technical question, but one of your risk aversion.
Dynamically Changing USB Descriptors
TinyUSB supports multiple device configurations by dynamically changing USB descriptors.
Why is this interesting? It would entirely avoid the problems associated with reporting the proper Sense/ASC/ASCQ errors. The MSC would either be exposed to the host, or simply not … No emulated missing media, no fake media that is the cause of corruption.
Architecturally, this would appear to simplify changing between possible solutions: current solution, the above proposed solution, the modal switching option, or any other solution later implemented.
Adafruit found a way to dynamically add interfaces, and Hathach says this works, by then forcing re-enumeration. So, this is definitely something that TinyUSB itself supports.