I'm trying to build a msd with stm32f4 which will be connected to a pc with USB. I need to visualize it as "USB drive" formatted in FAT. Initially I was planning to use a nand flash but I can't use it "bare bone", I need a translation layer, can someone please link application notes/articles about it? now that i know what I need I will also search myself!

  • \$\begingroup\$ What do you mean you can't format in fat? With an SPI flash module you can format it any way you want... \$\endgroup\$ Oct 24 '16 at 7:20
  • \$\begingroup\$ For his structure a nand flash can't be used with fat disk (as far as I know reading around on this site and forum). So I can use a SPI eeprom maybe? \$\endgroup\$
    – user126977
    Oct 24 '16 at 7:27
  • \$\begingroup\$ SPI EEPROM is (probably) flash. Can you please add an explaination about the difficulties in using flash with FAT fs? \$\endgroup\$ Oct 24 '16 at 7:30
  • \$\begingroup\$ Seems that I missed a step: as @Duskwuff said I need a translation layer. The problem was with nand internal management. "A FAT file system is not usable on NAND because of lack of wear leveling and bad block handling" from lpcware.com/content/forum/fatfs-works-nand-flash \$\endgroup\$
    – user126977
    Oct 24 '16 at 7:39
  • \$\begingroup\$ Ok now I get it, it is a problem of wear. This is correct and you should handle it in your code, I was thinking you could not implement FAT32 on flash, not that you did not want to do it because of wear. \$\endgroup\$ Oct 24 '16 at 7:41

Initially I was planning to use a nand flash to read and write data, but I can't format it in FAT.

Sure you can -- if you use a flash translation layer. That's how SSDs and USB flash drives work, after all.

That being said, an SPI or QSPI flash device will probably be easier to get started with.

  • \$\begingroup\$ Thanks for this advice, it is what I was missing! have you got any application mote/article about it? \$\endgroup\$
    – user126977
    Oct 24 '16 at 7:40
  • \$\begingroup\$ Not offhand, but check ST's site. They probably have a couple sample applications along these lines. (I would not be surprised if they had at least one fully worked USBMSD example.) \$\endgroup\$
    – user39382
    Oct 24 '16 at 7:42
  • 1
    \$\begingroup\$ Not sure these samples take care of wear-leveling appropriately, though. They are mostly there to show how to use the MCU peripherals, not more. And this flash translation layer is really not trivial to design. I'm not aware of open-source code taking care of this. \$\endgroup\$
    – dim
    Oct 24 '16 at 8:11
  • \$\begingroup\$ I didn't have time yet to Google it, it seems that there is no open source code to do this task and I should design my own? \$\endgroup\$
    – user126977
    Oct 24 '16 at 10:47
  • \$\begingroup\$ Linux does has some work in this direction which might be worth researching: JFFS. \$\endgroup\$
    – pjc50
    Oct 24 '16 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.