USB Mass Storage - Windows asks to format the disk

Folks,

I am working on porting Mass Storage library on STM32F107. I have a Spansion S25FL064K connected to SPI interface

of STM32F107. As the current Mass Storage library does not support SPI Flash interface, I have ported the SPI flash interface and changed the MAL layer(mass_mal.c) in the mass storage library to interface with flash connected to SPI interface. I have declared Max_LUn value to 0. Do I need to make any further changes?

With this, The device is detected by windows properly. But, as soon as device is detected as Removable disk, I am

posed with a message from windows - “You need to format the disk in F:\ before you can use it” . I did not expect

this to happen. I thought my device will be detected as an 8MB removable hard disk. Any one faced with such issue

earlier or any pointer to what could be going wrong?

However, I tried to format the device but i am blessed with an error saying windows can not format the device. I have read mass storage demo documentation as well. As per the documentation, the drive need not have any file system mounted on it as Windows reads the data block by block.

Do I need to make any further changes to the Mass Storage library apart from these for this to work as I expected?

Any help would be greatly appreciated.

Thanks,

Sai

If windows does not find a valid filesystem on the disk, it will prompt you to format the device. If you intend to use the device only as a raw block device, you can unmount the drive by opening an administrator command prompt and executing:

mountvol /d

For example:

mountvol f: /d

If Windows failed to format the device, you probably have a bug in your implementation. Search for a program called ‘Disk Investigator’, which will let you look at the raw data on the disk. Another useful tool is ‘dd for windows’, which will let you blast data onto raw block devices. If I were you, I would use dd to write some test data to the device, then put a bunch of print statements in your code and make sure that what you are receiving is what you’re sending, then verify that it’s actually getting written to your flash device.