@deadlyboy
Yes, there's a problem with Windows there. Users might inadvertently format it, destroying some of the data.
I have only used it on Linux, which doesn't display a "Do you want to format this?" dialog right away at least. I don't know of any direct way to prevent Windows from showing this.
I can think of a hack though: As long as you preserve a valid (yet empty) FatFS instance, you should be able to overwrite the free blocks with your custom data. I don't know too much about the structure of FAT, but probably you only have to start at a certain offset (and - maybe - avoid overwriting certain block numbers).
I recommend you overwrite a fresh SD card with random-ish, but predictable values, create a FAT on partition 1 and check which blocks have been changed. These are the blocks you should NOT overwrite.
Steps:
You can modify my Tool SDCheck (
https://github.com/ulikoehler/SDCheck) which I use to check for bad blocks in order to check for blocks differences afterwards (modifying it will have medium complexity. Note that the core SDCheck concept is to generate two 100% equivalent streams of pseudorandom numbers by using the same seed.).
Then, create a MSDOS partition table and format partition1 with FAT.
Use the modified SDCheck to print a list of blocks with differences. Repeat with a different seed.
This is certainly not an advice I'd give to an industrial user without testing it beforehand (and probably not even then - maybe different FAT implementations overwrite some of my data blocks). When using this method, make sure the user never ever places a file on the mounted filesystem.
You could also try using a raw partition, but Windows will probably try to format it anyway. Maybe a linux swap partition will note make Windows show the format dialog !?!
Alternatively, you could use the write protection switch when inserting the card into the PC, if your application allows that.
Alternatively, you could avoid inserting the SD card completely by using the STM32 USB in device mode and emulate a mass storage device. This will be incredibly complex but allow for a certain amount of flexibility.
Best regards