As I ponder this:

1) Is it possible Windows 10 (and possibly Linux these days) doesn't like
FAT12? I can't find a definitive answer, but believe it should be OK
2) Is it reasonable for me to expect mkfatfs to be able to create FAT16 on a
32Mbyte flash device with 512byte sectors (and 64k erase sector/4k
sub-sector erase)?

mkfatfs will only ever format this flash device as FAT12 whatever I try, so
I wanted to try FAT16 to eliminate 1) as a possibility

nsh> mkfatfs -F 16 /dev/mtdblock0
mkfatfs_tryfat16: WARNING:  Too few or too many clusters for FAT16: 4081 <
2046 < 2302
mkfatfs_clustersearch: WARNING:  Cannot format FAT16 at 32 sectors/cluster
mkfatfs_tryfat16: WARNING:  Too few or too many clusters for FAT16: 4081 <
1023 < 1278
mkfatfs_clustersearch: WARNING:  Cannot format FAT16 at 64 sectors/cluster
mkfatfs_tryfat16: WARNING:  Too few or too many clusters for FAT16: 4081 <
511 < 766
mkfatfs_clustersearch: WARNING:  Cannot format FAT16 at 128 sectors/cluster
mkfatfs_configfatfs: WARNING:  Failed to set cluster size

I believe that a 32Byte device should format as FAT16 with 4085 clusters,
and 16*512 byte sectors, but mkfatfs is only attempting calculations for
32/64/128 sectors/cluster.

If I make a change in "mkfatfs_clustersearchlimits" to allow 16
sectors/cluster to be tried for a device with 64k sectors, it will create
FAT16...

...but the file (a 1Mbyte .wav file) is still corrupted and it is very slow
to write a file (via USB) to the msd (gets to 99% quickly then takes minutes
for the last 1%). 

A 24k jpg file gets corrupted similarly too.

Windows still says there's a problem with the drive and wants to fix it, but
Explorer will show the files that have been copied to this msd.

The corruption is always after the first 16k boundary on the msd.

I don't think this is FAT12 vs FAT16.

Uboot tests show this memory is OK. I have ordered a 1Gbit device to try (in
case the device on this board is damaged, or NuttX just doesn't like 256Mbit
M25P devices for some reason!!).

But still hopeful of some suggestions!

>-----Original Message-----
>From: Tim <t...@jti.uk.com.INVALID>
>Sent: 12 January 2022 17:42
>To: dev@nuttx.apache.org
>Subject: FAT/MTD/USBMSD...still.
>
>Yep, me again!
>
>USB device is working. I can create a ram disk, format it as FAT, set it as
a LUN
>device and Windows and Linux see it as an MSD device. I can read and write
to it,
>reliably.
>
>I have an MT25QL256A device (32Mbyte) which is correctly connected to the
>SAMA5D17 via SPI0, has a block driver, and I can format it as FAT
>
>nsh> df
>  Block    Number
>    Size     Blocks       Used   Available Mounted on
>16384       2046          2        2044       /mnt/fs
>  1024       1004          2        1002       /mnt/ramfs
>         0             0           0              0       /proc
>
>When I run msconn it is pretty much always seen by Linux, but it's very
>unpredictable with Win10 (get the connection sound, device manager sees it
as a
>drive, but doesn't reliably do the Windows equivalent of mounting it.
>Mostly.
>
>If I copy a 1Mbyte file to it (Ubuntu 20.04) it seems to write the file -
it appears in
>"Files" in Ubuntu. But if I try and eject the MSD, it tells me one or more
>applications are keeping the device busy.
>
>Windows behaviour is much quirkier but similar. The file seems not to
write, or
>Windows wants to fix errors, or just sits there. Eventually, if detected
properly,
>the file appears not to write, but an msdis followed by msconn shows it is
>there....but it is corrupted if I compare to the original file written. The
size is right
>but it is not the same contents.
>
>Go back to Linux, and it no longer wants to see the MSD, unless I reformat
it via
>nsh.
>
>My belief is that the USB MSD, or FAT, or this flash device, is somehow not
>working right for me. Everything else has absolutely been me not setting up
>something right, or a stack issue, or not understanding dumb things, but I
have
>eventually got there (with help from you guys...thanks!). Right now,
though, this
>has me completely stumped again :(
>
>Anyone seen anything like this before and got any suggestions of things for
me to
>look at or try tomorrow?
>


Reply via email to