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.

Compiler/STARTERWARE-SITARA: Runtime Read/ Write from BBB to USB/SD card using Ti-RTOS

Part Number: STARTERWARE-SITARA

Tool/software: TI C/C++ Compiler

Hi, I am a new user in the Ti-RTOS world and thank you in advance for helping.

My goal is to R/W to USB/ SD Card using TI's StarterWare Code in ARM Cortex A-8 microprocessor (Sitara). Sitara (uP)  is part of a Texas Instrument Board called BagleBone Black (BBB).

To develop the software program, I started with the starter ware software package (pdk-RTOS). Code Composer Studio (Eclipse-based IDE) is used to build, compile, link, and load the program to onboard uP using JTAG interface. My program is written in C and arm-assembly. The code is compiled using the default compiler by TI.

As of now, I do not know how to write the value of a variable to a USB/ SD card (whichever one is easier) during runtime. Also, I do not know how to connect these interfaces properly and what changes are needed in my code to accomplish that.

Can. already provided projects like "USB_DevMsc_emmc_bbbAM335x_armExampleProject" be used as a starting point. 

Please help me out. I have tried on my own and nowhere so far.

Kind Regards,
Mahmud Reaz

  • Hi Mahmud,

    Mahmud Reaz said:
    My goal is to R/W to USB/ SD Card

    I'm not clear on what you want to do. It appears you want to use the BBB as a USB Mass Storage Class device connected to a Host PC.

    Mahmud Reaz said:
    already provided projects like "USB_DevMsc_emmc_bbbAM335x_armExampleProject" be used as a starting point

    This is a good starting point for USB Device MSC. This project uses the BBB on-board eMMC. You might want to review other AM335x examples which use SD, like USB_DevMsc_evmAM335x_armExampleProject.txt.

    Mahmud Reaz said:
    As of now, I do not know how to write the value of a variable to a USB/ SD card (whichever one is easier) during runtime. Also, I do not know how to connect these interfaces properly and what changes are needed in my code to accomplish that.

    I suggest you review the following:

    I confirmed the BBB USB Dev MSC example works properly. I suggest reviewing the example code and run-time behavior.

    Full source code is provided for the USB & MMCSD LLDs, so I suggest you review this code as required.

    Regards,
    Frank

  • Dear Frank,

    Thanks a lot for your guidance. I highly appreciate your help.

    My response to your comments below:

    "I'm not clear on what you want to do. It appears you want to use the BBB as a USB Mass Storage Class device connected to a Host PC."
     
    Let's say, instead of writing a value to DDR memory as indicated in the code below, I want to write the value of a register to the external drive (USB/ SD Card). 

    @*****************************************************************************
    @ This API writes to DDR memory
    @*****************************************************************************
    mem_pattern:
    movs r3, r0 @offset memory
    movs r0, #0x80000000 @ max address of memory
    ldr r0, [r0] @
    mov r1, #1 @
    mov r2, #2 @
    push {r1} @

    loop:

    @ "Move Not" should fill register with 1s
    mvn r1, #0 @
    push {r1} @
    subs r3, #1 @
    bne loop @

    ret:
    BX lr @ return to c_function

    .end

    Thanks for the suggestion of the documents to be reviewed. I will go through them asap.

    I look forward to your reply.
     
    Mahmud

  • Hi Mahmud,

    Mahmud Reaz said:
    Let's say, instead of writing a value to DDR memory as indicated in the code below, I want to write the value of a register to the external drive (USB/ SD Card). 

    Ok, so you want the AM437x to act as a USB MSC Host?

    Please look at the following docs: https://software-dl.ti.com/processor-sdk-rtos/esd/docs/06_03_00_106/AM437X/rtos/index_device_drv.html#driver-overview

    Do the diagrams in the sections "USB device Mass Storage Class" or "USB host Mass Storage Class" represent what you want to accomplish?

    Regards,
    Frank

  • Hi Frank,

    Thanks for helping me. I am sorry as it appears that I am unable to ask the right question to you and I appreciate your patience with me.

    I am not familiar with AM437x evm. I am using Baglebone Black in my project and XDS 110 Debug probe.

    Diagrams in the "USB Mass Storage Class" or  "USB host Storage Class" look different than the system I have in my mind. 

    My desired chain of events is given below:

    1. USB thumb drive will be physically connected to the BBB board.
    2. The main program will run from CCS to BBB (A8 Core) using XDS 110 (JTAG connector). Only XDS 110 will be physically connected to my Laptop via USB A port, where CCS is running.
    3. I want to open a file inside the USB thumb drive.
    4. I will periodically write values from the main function to a file in the USB thumb drive.
    5. Then, close and save the file in the USB thumb drive so that I can read it from my Laptop.

    I look forward to your opinion on this. 

    Also, I went through the example codes in MMCSD_bbbAM335x_DMA_armTestproject project. Although there are functions associated with initialization, read and write command I do not see a function that opens and close a file. 
    I look forward to your guidance. Thanks for your time.

  • Hi Mahmud,

    Mahmud Reaz said:
    My desired chain of events is given below:

    What you've described matches with diagram in "USB host Mass Storage Class", with the AM437x EVM replaced with the BBB. Please correct me if I'm mistaken.

    "the USB instance will act as a USB host communicating with a USB device that supports Mass Storage Class function (USB thumb drive or a small USB hard drive)."

    Mahmud Reaz said:
    Then, close and save the file in the USB thumb drive so that I can read it from my Laptop.

    In this case you'd disconnect the USB thumb drive from the EVM, and reconnect it to the PC?

    Regards,
    Frank

  • Hi Frank, Thanks for your reply.

    (1)  Yes, it matches with USB host Mass Storage Class with AM437xEVM replaced by BBB.

    (2)  Yes, in the end, I would disconnect the thumb drive from BBB and reconnect it to PC.

    Do you have any example code I can append to my existing code to accomplish the task?

    I look forward to your help.

    Sincerely,

    Mahmud Reaz

  • Hi Mahmud,

    Please see the following documentation:

    I don't see a USB Host MSC example/test for BBB. However, there is an example for AM335x GP EVM you could use to get started. If you execute pdkProjectCreate, you should see that this USB Host MSC example is created: USB_HostMsc_evmAM335x_armExampleProject.

    Regards,
    Frank