-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use FAT16 instead of FAT12, for greater compatibility with Android and other OS's #2751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Whether FAT12, FAT16, or FAT32 is used depends on the size of the filesystem. A FAT12 filesystem is defined to be < 4087 clusters, a FAT16 filesystem is 4087 to 65526 clusters, and FAT32 is a range above that. The typical 2MB filesystem we supply can therefore only be FAT12, by definition. One issue has been that FAT12 is not well supported, as you see. On Windows, there's a bug (which is supposedly being fixed) that delays writing to a FAT12 filesystem for tens of seconds. See #111. I've thought about presenting a FAT16 filesystem that would appear to be larger than the actual capacity, but with a large number of bad blocks. The File Allocation Table has a mechanism for marking bad blocks. I did some experiments on this, but haven't made it a high priority. It's not so simple. |
Thanks for your explanation. I missed the first one. |
@olivier-boesch, https://github.com/izuchukwu/USBBridge#what states
so are you certain that this would provide compatibility with Android? |
I haven't looked at this in detail for several years, but my impression was that FAT16 would work. I have some very small SD cards and could try this with an Android tablet. But there is no work being done on this at the moment. |
This may be because the FAT16 CIRCUITPY presented by the larger flash chip still only has one FAT (File Allocation Table). Most FAT16 filesystems have two. |
A FAT16 USB flash drive is working with a Pixel 2 with Android 10. |
Well, Android is very picky. It would stand to reason it expects it.
It's an optional feature for fat16, and an unsupported feature of fat12 as far as googling gets me. Just changing this, neither board is read by android. |
As @dhalbert noted earlier, whether an OS mounts a FAT volume as FAT12, FAT16, or FAT32 is determined by its total number of clusters. An OS will calculate the total number of clusters from information present in the VBR. The thresholds vary slightly depending on the OS, but are always close to: The smallest volume that can present as FAT16 is 2MB where the cluster size is 512 bytes. For devices formatted with larger cluster sizes, the minimum size of the volume doubles as the cluster size doubles. For the commonly used cluster size of 2048 bytes, the minimum volume size is 8MB. Microsoft sets a minimum size for FAT16 at 8MB. Because MacOS Sonoma exhibits problems with auto-mounted FAT filesystems smaller than or equal to 8MB (see #8449), a good choice for minimum volume size is 8MB + physical volume size. It's possible to increase the volume size in the VBR to any value we like, and then fence off the non-existent clusters by marking them
|
@bill88t notes
Android may be looking at the fake MBR that CircuitPython presents as the first sector of the flash device, seeing that it's FAT12, and giving up before attempting to mount the filesystem. See |
The solution to this problem is to make Accomplishing this requires a persistent indication of the presence of ballooning and its geometry so that the flash read and write routines can take the correct actions. The FAT filesystem stores its VBR (Volume Boot Record) as its first sector. The VBR describes the geometry of the underlying device as well as descriptive parameters for the filesystem itself. For historical reasons, a large potion of the VBR is reserved for a bootstrap loader and is unused. FAT ballooning utilizes a few of these unused bytes to store a signature along with the actual size of the device before ballooning. When the filesystem is created, an additional parameter indicates to
Finally, Additional modifications are made so that The fake MBR presented by |
There should only be such a write if the OS were ignoring the bad cluster bits, such as the |
OS reformatting with If OS reformatting is an issue, it's possible to intercept a host OS write to the VBR and then force the |
See https://support.microsoft.com/en-us/topic/default-cluster-size-for-ntfs-fat-and-exfat-9772e6f1-e31a-00d7-e18f-73169155af95 for Microsoft's take on valid FAT filesystem geometry. |
Also see https://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc for quite a complete writeup from Microsoft. |
Ran some experiments and found that Android does support FAT12, it just doesn't like partition type x01 (FAT12). By changing the partition type to x0e (FAT16 LBA), Android successfully mounts a FAT12 filesystem. Tested by modifying the fake MBR returned by CircuitPython. |
Linux does not care for the partition type/filesystem mismatch, so simply changing the partition type is not a viable fix. We do now know the reason for Android refusing to mount the CP filesystem, but will need ballooning or something similar for a fully compatible fix. |
It would be to make the circuitpython filesystem recognizable by android systems. By doing so, it becomes possible to easily edit code with editors on mobile devices.
Wouldn't it be nice?
As far I know, the usb filesystem used by circuitpython is fat12. Is it was in fat16, it could be recognized by android devices.
The text was updated successfully, but these errors were encountered: