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.

TM4C1294NCZAD: USB Mass Storage Device with different sector size

Part Number: TM4C1294NCZAD

Hello

We are working on Tiva MCU TM4C1294NCZAD, using Tivaware 2.1.4.178, trying implementing MSC class on USB with an external NAND Flash. We started from usb_dev_msc example, which uses mx66l51235f EEPROM. 

Currently our PC sees it an external device when connected (but doesn't recognizes it as formatted even if a file system in installed on board), but after a while it disappears.

Sectore size of our Nand Flash (whose driver is working for write and read operations)  is 2048 Byte, while is 4096 Byte in the EEPROM used in the original example. Is it possibile to use the USB library with this sector size? How should we adapt USB library or usb_dev_msc file to work with this size? 

Thank you

  • Hello Mirco,

    I don't see a need for you to do anything like adapting the USB library to handle that.

    The example you are referring to uses the TivaWare provided mx66l51235f.c/.h files which defines the MX66L51235F_BLOCK_SIZE as 0x1000 or 4096 bytes, and then uses SPIFlashRead/SPIFlashWrite API's to communicate with the EEPROM. This file is located at [Install Path]\TivaWare_C_Series-2.1.4.178\examples\boards\dk-tm4c129x\drivers if you need review it.

    So what you need is to make your own driver file for your NAND Flash to handle the same operations, and then ensure the API's are added to the descriptor for the USB device which for the usb_dev_msc example is located in usb_msc_structs.c and is labeled g_sMSCDevice.

    The easiest way to do this is to take and modify these existing API's from usbdspiflash.c to work with your NAND Flash. This is based on the tMSCDMedia structure defined in usbdmsc.h. The existing API's are:

    USBDMSCStorageOpen,
    USBDMSCStorageClose,
    USBDMSCStorageRead,
    USBDMSCStorageWrite,
    USBDMSCStorageNumBlocks,
    USBDMSCStorageBlockSize

    As part of making the equivalents for the above API's, you can ensure that the sector size is being treated as 2048 bytes rather than 4096 bytes as it is within those API's which determined how the USB library handled the sector size for the EEPROM.
  • Hi Ralph
    I made a few steps forward. Now my PC sees my NAND flash as an external device of 256MB size, but no files inside it... So I looked in USB properties-> events, where the last one is "Device not migrated". How can I make migration work? I don't know that information are exchanged
  • Hello Mirco,

    I hadn't heard of that error before but from reading up on it some, it sounds like the device driver is not working properly. To me this means one of two things.

    1) (Unlikely) The drivers on your PC are the older TivaWare ones, and you should update to the latest from: software-dl.ti.com/.../SW-TM4C-2.1.4.178.PATCH-1.0.zip - that potentially could resolve the issue if it's purely due to TivaWare drivers, but then I would expect it to have not worked to begin with.

    2) The way you updated the descriptor caused an error in device enumeration and that is the source of the error, so you would need to compare the working enumeration from our TivaWare example vs your own and see what could be missing.