This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB MSC Device using SPI Flash as storage media

Other Parts Discussed in Thread: MSP430USBDEVPACK

Within the MSP430 USB MSP430USBDEVPACK software "ecosystem", are there any code examples that support a SPI NOR flash as the storage media to implement a USB MSC device class design?

I have seen several implementations using SD/MMC type media, but not for a "raw" SPI NOR flash chip. Does this exist within the MSP430USBDEVPACK or other TI USB support software?

FYI: I could not find a USB capable MSP430 part number from the selection list, but an example would be MSP4306638 etc...

Robert G

  • Each SPI NOR flash has a unique command set. You probably would not find any generic example.
    By "raw", do you mean without a file system?
  • Hi Mike,

    Yes, a specific SPI flash chip would have specific commands ( although most these days share a common set ).

    Yes, "raw" meaning a flash chip that has no type of embedded "smarts" such as a typical SD card has. So all of the requirements for writing and reading to such a chip would have to be done in the driver in the context of using it as part of a USB device class MSC/MSD. FS, FAT, etc would all have to be included in the code running on the MSP430x.

    Also, Its not just the "raw" SPI flash command set that is needed, but all of the complexities of using it in the context of a mass storage device presented to the host as a cohesive file system.

    Microchip has attempted this in their PIC32 Harmony USB example list, but as of yet, the SPI flash MSD "driver" doesnt work and I am looking for alternatives.

    I don't have the skill set to write something like this so I am hoping there may be such an example project within the TI framework for the MSP430 USB software.

    Robert

  • Robert,

    TI SD examples use the "FATfs" open library which handles all the complexities of the FAT file system. To modify it, you would simply need to modify the disk_read() and disk_write() functions to access the SPI instead of the SD.
  • Mike,

    Thanks for the info. I think that is where the problem for me is. With an SD card, all you need is a read/write interface to the memory/media because the SD card has a small MCU handling the sector boundary issues, as well as the timing of the write and erase cycles, and a bunch of other things particular to NAND flash that are not part of this discussion.
    But the key point is the SD card internal MCU encapsulates all of the low level driver details so that simple write() and read() interfacing is all that is needed.
    That means I would have to fill in these details as part of the required driver to the SPI flash if there isnt already an example driver provided somewhere within the TI resources for some particular flash IC as an example, which would be very helpful if available.
    I can and have designed simple read(), write(), erasesector(), statuscheck() type drivers for "raw" SPI flash chips many times, so that part is not the problem. Its the logic involved with how to deal with the sector boundary complexities, since NOR flash requires a sector to be erased completely before writing new data. That means that issues such as fragmented files have to be kept track of somewhere in order to maintain the file data when writing new files etc etc.
    Now, if the FATfs handles all of that, where the actual read/write physical addresses of the flash are determined and passed to the disk_write() and disk_read() calls that would be a no-brainer, but I somehow doubt that is what is these calls provide.
    Please advise.

    Thanks
    Robert
  • You are making it more complex than what it is. You do not need to bend any spoons with your mind here :)
    This being said, FATFs has a few low level functions that you will need to create (nothing fancy). All other "logical" stuff is handled by the rest of the library.
    I would recommend that you get a nice cup of coffee and read both: FATFs and the MSP5529 example and trace the functions down to the low level ones. It will be a good exercise and will take away a lot of the unknowns for you. It will have a small learning curve, but nothing too much. Good luck.
  • OK, Neo, I'll take your word for it...

    That being said, is there a recommended eval hardware kit that you would recommend that has enough of the USB hardware onboard and SPI interface access I can use to implement a device MSC test?

    Also, when you said "read both: FATFs and the MSP5529 example", did you mean FATFs example code, or a document on FATFs?

    Thanks very much,

    Robert

  • MSP-EXP430F5529 has everything you will need. Its example code has a USB-flash implementation of the SD card. User's Guide is here: www.ti.com/.../slau330b.pdf

    So, reading the example code of the MSP-EXP430F5529 and the FATFs documentation from (elm-chan.org/.../00index_e.html), you should get it working on a SPI NOR.
  • Thanks, Mike.

    I'll take a look at all of the info. It does appear to have a solid path to SPI mode SD media. From what your stated, it should be a useful bridge to my goal of SPI Flash integration.

    Regards

    Robert

**Attention** This is a public forum