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.

RTOS/PROCESSOR-SDK-AM335X: USB access to SD card

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: AM3352

Tool/software: TI-RTOS

Hi Experts,

We are developing a  product (using AM3352) need to implement a key feature which act as USB MSC dev to let PC access MMCSD stored video files.

 

So far we can test “usb_dev_msc_evmAM335x_arm_project” sample project successfully(on skAm335xEVM, pdk_am335x_1_0_6 ).

But this sample project is to access internal RAM as virtual disk.

 

We try to modify this sample project to enable USB MSC dev mode and change RAM disk access to MMCSD.

After several months tries and TI E2E search, we still stuck at "CortxA8: Unhandled ADP_Stopped exception 0x20023" error.

 

Could you kindly help to provide us a sample project which can let AM335x MMCSD as USB MSC dev to PC (like thumbdrive)?

Thanks.

Rex Liao

  • The RTOS team have been notified. They will respond here.
  • Hi,

    The current USB device mode only uses internal RAM as the storage which host PC can access. AM335x also has MMCSD driver which allows the AM335x to access MMCSD card.

    Why you need to use the PC to access the MMCSD via USB interface?

    Regards, Eric
  • Hi Eric,

    This feature is our product key specification.

    We know SDK already include two separated samples like you mentioned.

    But can't merge those two samples successfully.

    Please kindly  provide a sample project  which can let AM335x MMCSD as USB MSC dev to PC (like thumbdrive)??

    BR,

    Rex Liao

    lding said:
    Hi,

    The current USB device mode only uses internal RAM as the storage which host PC can access. AM335x also has MMCSD driver which allows the AM335x to access MMCSD card.

    Why you need to use the PC to access the MMCSD via USB interface?

    Regards, Eric

  • Hi,

    We don't have those two projects merged. There is an example how to merge several RTOS examples at www.ti.com/.../sprac93.pdf you look the approach we did.

    Regards, Eric
  • Hi,

     

    We read "sprac93" document before.

    Actually, we already merge those two examples into one application and can run successfully.

     

    But key is how to change USB dev access path from RAMdisk access to MMCSD.

     

    We modified "usbdmscglue.c" and use diskio fucntion (disk_initialize,disk_read.disk_write) to access MMCSD.

     

    After several months tries and TI E2E search, we still stuck at "CortxA8: Unhandled ADP_Stopped exception 0x20023" error.

     

     

    Without this feature, the project will fail. And we already raise this stitutaion to TI local contact window.

    Please advise how to solve this.

     

    BR,

  • Eten,

    "CortxA8: Unhandled ADP_Stopped exception 0x20023"

    It would be helpful if you could provide details on where this error happens in your project? Could you please debug and provide more details on what code causes this?
    Do you have a way for this to be reproduced on the AM335x GPEVM?

    "Actually, we already merge those two examples into one application and can run successfully."
    What does this statement mean?

    Lali
  • Hi Lali,

    List current status as below,

    PDK version:pdk_am335x_1_0_6 HW board: StarterKit skAM3358

    1. Merge "usb_dev_msc_evmAM335x_arm_project" + "MMCSD_FatfsConsole_evmAM335x_DMA_armExampleProject" into one project.
    Can run it successfully. PC USB access with RAM disk; UART access MMCSD contents.
    Two sepearted BIOS tasks.

    2. delete MMCSD BIOS task, only leave USB BIOS task.
    reference e2e.ti.com/.../575591 to modify usbdmscglue.c

    In USBDMSCStorageOpen() add disk_initialize(0);
    In USBDMSCStorageRead() modify to disk_read(0, pucData, ulSector, ulNumBlocks);
    In USBDMSCStorageWrite() modify to disk_write(0, pucData, ulSector, ulNumBlocks);
    In USBDMSCStorageNumBlocks() modify to disk_ioctl(0, GET_SECTOR_COUNT, &ulSectorCount);
    and modify related MMCSD driver to return right SD card blocks for disk_ioctl.

    When project runs, "CortxA8: Unhandled ADP_Stopped exception 0x20023" occurs at CCS.


    In dev_msc_main.c, USB BIOS task, there has one comment "All USB dev events are handled in interrupt context".
    We think RAMdisk access could achieve at ISR domain, but MMCSD read/write shall can't do it the same way.

    Please kindly advise how to solve this.

    BR,
    Rex Liao
  • Hi Rex

    Thanks for the detail info on your implementation. 

    Could you also try changing the ISR functions and main functions according to this thread here so that the main ISR work is done in BIOS task context instead of from the ISR. Hope this helps


    -Thanh

  • Hi Thanh,

    We had read the E2E post, and modify like the POST mentioned.

    But it didn't work.

    This is why we arise this issue here.

    Due to USB driver is complex to us,

    suggest TI can  provide us a sample project which can let AM335x MMCSD as USB MSC dev to PC (like thumbdrive) for our development reference?

    Thanks.

    Rex Liao

  • We are working on an example.  We have gotten the USB talks to the MMCSD card without exception. We will provide an example shortly.

    Thanks for your patience.

    -Thanh

  • Hi Thanh,

    Thanks for the update & will wait for the example

    Please kindly also help to test it with SD card capacity size > 32GB.

    Thanks a lot.

    BR,

    Rex Liao

    Thanh H Tran said:

    We are working on an example.  We have gotten the USB talks to the MMCSD card without exception. We will provide an example shortly.

    Thanks for your patience.

    -Thanh

  • Hi Rex,

    We were able to bring up an example of USB device MSC to MMCSD on AM335x GP EVM. We have tested this on the 32GB and 64GB Sandisk micro SD cards. Both cards were formatted as FAT32. This is an engineer drop. We have not gone through full testing cycle yet. It’s not an official release yet. Please see release note for known issues.

    The example requires modifications to the USB and MMCSD modules which could be retrieved from the below git repositories

    git.ti.com/.../usb (commit # be63349f2ad60ce5c9c18dcfe927929e3de13592)

    git.ti.com/.../sd-mmc (commit # 0b130debe6e0b2f2c73df21ecb0f3ee142f0a0a3)

    Here are the steps required to re-create the example which we used to verify this.

    - Install the latest PDK release

    - Replace the below directories with the latest git repository contents

    Replace <pdk_install_dir >/packages/ti/drv/usb with the source from git.ti.com/.../usb
    Replace <pdk_install_dir >/packages/ti/drv/mmcsd with the source from git.ti.com/.../sd-mmc
    Set up the build environment by running pdksetenv.sh/.bat
    <pdk_install_dir>/packages > source ./pdksetenv.sh
    Build the libraries for the above components
    <pdk_install_dir>/packages/ti/drv/usb> make
    <pdk_install_dir>/packages/ti/drv/usb> make xdc_meta



    <pdk_install_dir >/packages/ti/drv/mmcsd> make
    <pdk_install_dir >/packages/ti/drv/mmcsd> make xdc_meta



    - Create/Run the example project ‘USB_DevMsc_mmcsd_evmAM335x_armExampleProject’

    <pdk_install_dir >/packages> ./pdkProjectCreate.sh AM335x evmAM335x little usb example arm
    Import the project ‘USB_DevMsc_mmcsd_evmAM335x_armExampleProject’ under <pdk_install_dir >/packages/My Projects/ in CCS.
    Build & run the project on the A8 core with the SD card inserted

    - Connect & mount the Linux/Windows machine to the USB port of the GP EVM . The contents of the SD card can read via the mount.



    Please let us know if you have question or problem.
  • Hi Thanh,

    Thanks for your support !!

    We have tested the sample code.
    We found some questions/problems and need your help !

    1. The accessing speed that to copy file from SD is only 2MBytes/sec, How to imporive the accessing rate ? ( SD : SanDisk Extreme PRO microSDHC UHS-I 32GB V30 U3, its speed that tested with a old card reader is 20MB/sec )
    2. The action which Windows machine removes the USB storage is not work.
    3. It cannot work when to remove the SD card & to insert it again.
    4. When will the formal release ?

    Thank you ~

    Regards,
    Eten
  • Hi Eten

    For #1, we will be looking at where the bottle neck is with the speed and let you know later. But could you tell me what file size you use to measure the read speed? If the file is contiguous or not?

    #2, we will look to see what's wrong with it.

    For #3, we don't plan to address it.  The example we provide is just a simple example and is not meant to be a robust application that works in all different scenarios.  Customer is free to modify the example to handle their requirements.  The example has hook to detect when the card is removed or plugged in. These hooks can be used to take proper action to handle the card removal.

    Thanks

    -Thanh

  • As for the speed performance we could do this:

    Currently the USB-MMCSD example does simple way of reading from MMCSD: MMCSD reads 512 bytes for every 512 bytes request from USB. This is pretty costly since reading 512 bytes from MMCSD is taking as much time as reading a block of 2KB from MMCSD.

    To improve the read performance, we could do this: every time we read from MMCSD, we read a bigger block, 4K for example. We cache this 4K block. Chances are the next read request of 512 bytes will be in this same block. when we see that we could return the data immediately without going to the MMCSD driver again. You can implement this strategy in the usbd_mmcsd_glue.c read function. Please try this method.

    We will look at the unmount / safely remove command next.


    Best regards

    -Thanh