cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble having Windows 10 recognize a STM32L4 board configured as a FAT16 disk over USB MSD.

erussell
Associate II

I am working on a bootloader for the STM32L4 and using the STM32L4R9I-EVAL board. Using STM32CubeMX version 5 I've generated code for a device USB MSD and have included FatFs as the file system. I've used the FatFs routine, f_mkfs() to format the drive as FAT16 which creates the partition sector, the FAT Boot sector, and the first sector of the FAT Table. When I connect USB to MacOS the disk is recognized and is available for copying a file. However, connecting to Window 10 fails. With a USB analyzer I can see that at times only the partition is read, other times the Fat Boot sector is read, and sometimes even first sector of the the FAT Table. But Windows determines that the disk cannot be read. I have thought that there may be a timing issue or a formatting issue but am not sure how to diagnose what is wrong with the connection to Windows. Does anyone have any suggestions?

Just to answer why I'm not using the DFU class - we have an existing product (using a different processor) where firmware updates use the MSD class. It is easy for users to just drag and drop a file without the need for a separate app which is necessary for DFU. Also DFU uses the control endpoint so for large files the download time is greater.

4 REPLIES 4
Pavel A.
Evangelist III

While you wait for more clever replies, try to connect the device to WIn10 thru a usb 2.0 hub. Sometimes this helps with electrical and timing issues.

-- pa

erussell
Associate II

Thank you for your quick response! Actually I am connecting through a USB 2.0 hub.

Microsoft usually pitches a fit over two things, either the data is broken/inconsistent, or the reported capacity is wrong. The MBR and BPB need to flow properly into each other. Then it will pull FAT table and directory sectors.

Emulating a FAT partition requires a pretty solid understanding of block storage devices and file systems/structures.

On some of the boards with SDRAM I've built an MSC SDRAM-DISK implementation. MKFS is probably overkill, if you haven't built a formatter before, it's probably the quick/easy route.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
erussell
Associate II

Based on what you said I reviewed the data in the MBR and the BPB generated by f_mkfs() and can't find any problem. The problem appears to be in the reading of the FAT tables. In my configuration there are 17 sectors in the FAT Table and the USB analyzer shows that some (not a consistent number each time) are read but not all 17. On the Mac I am finding that I am able to connect successfully most of the time but not all of the time - with the same problem of not getting through all 17 sectors. Sometimes I can inject a breakpoint in the disk read function and can still connect successfully with the Mac. This seems like a timing problem or other communication problem. I am new to the STM32 processor and its USB Device library so have no experience but assume it should be well tested. If you have any other suggestions I would be very appreciative.