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.

TMDSCNCD28379D: USB firmware update with USB FLASH drive (Pen drive)

Part Number: TMDSCNCD28379D
Other Parts Discussed in Thread: C2000WARE, , TMDSCNCD28388D, TMS320F28379D

As part of the SDK, TI provides a USB flash programmer - C:\ti\c2000\C2000Ware_4_03_00_00\utilities\flash_programmers\usb_flash_programmer. 

This USB on the device is configured in device mode where the USB host is the computer the device is attached to.

We want to be able to perform a firmware update by plugging in a USB FLASH drive (Pen drive). To accomplish this I believe I need a custom bootloader and custom flash kernel.

For the custom bootloader I started with the usb_ex7_host_msc.c project found at - C:\ti\c2000\C2000Ware_4_03_00_00\driverlib\f2837xd\examples\cpu1\usb and incorporated some of the boot rom code found at - C:\ti\c2000\C2000Ware_4_03_00_00\libraries\boot_rom\f2837xd\revB\rom_sources.

With this I am able to run this application from FLASH. I have a USB FLASH drive (Pen drive) with a led_ex1_blinky.dat file on it. When I plug in the FLASH drive the custom bootloader running from FLASH reads the led_ex1_blinky.dat file and writes it to RAM. After completing the writing to RAM, it jumps to the new main() in RAM and starts executed properly (i.e. LED starts blinking). So, I think my custom bootloader is working.

For the custom flash kernel, I started with the following USB flash kernel - C:\ti\c2000\C2000Ware_4_03_00_00\device_support\f2837xd\examples\dual\F2837xD_usb_flash_kernels\cpu01. I modified this incorporating usb_ex7_host_msc.c functionality.  

With this I am able to run this application from RAM. I have a USB FLASH drive (Pen drive) with led_ex1_blinky.dat file on it. When I plug in the FLASH drive the custom flash kernel running from RAM reads the led_ex1_blinky.dat file and writes it to FLASH. After completing the writing to FLASH, it jumps to the new main() in FLASH and starts executed properly (i.e. LED starts blinking). So, I think my custom flash kernel is working.

The issue I am having is when I try to combine the two. I start with the custom FLASH bootloader running out of FLASH. I have two .dat files on the USB FLASH drive. The new custom flash kernel and the  led_ex1_blinky.dat. The process should mimic the USB flash programmer. 

1) Custom FLASH bootloader reads in custom flash kernel .dat file and writes it to RAM

2) After completing the writing of the custom flash kernel to RAM it should jump to the new main() in RAM and start executing

3) During the execution of the custom flash kernel it should read in the led_ex1_blinky.dat and start writing it to FLASH

4) Onces the custom flash kernel is done writing the led_ex1_blinky.dat image to FLASH it should jump to the new main() in FLASH and start executing

Well I am seeing steps 1) and 2). Once the freshly programmed into RAM flash kernel starts executing it is waiting for the USB to enumerate even though it is plugged in. I do not want to have to unplug the USB drive and plug it back in to program the led_ex1_blinky.dat. 

I do try to unplug the USB drive and plug it back in at which point it looks like it is detected but it is failing in device.c - 

void __error__(const char *filename, uint32_t line)

NOTE - it is pretty difficult to debug the custom flash kernel in RAM since it is all assembly at this point (i.e. no symbols). From this error function I can see the file where the assert takes place:

C:\ti\c2000\C2000Ware_4_03_00_00\libraries\communications\usb\f2837xd\source\host\usbhostenum.c. Specifically line 5013 -

//*****************************************************************************
//
//! This function completes a control transaction to a device.
//!
//! \param ui32Index is the controller index to use for this transfer.
//! \param psSetupPacket is the setup request to be sent.
//! \param psDevice is the device instance pointer for this request.
//! \param pui8Data is the data to send for OUT requests or the receive buffer
//! for IN requests.
//! \param ui32Size is the size of the buffer in \e pui8Data.
//! \param ui32MaxPacketSize is the maximum packet size for the device for this
//! request.
//!
//! This function handles the state changes necessary to send a control
//! transaction to a device.  This function should not be called from within
//! an interrupt callback as it is a blocking function.
//!
//! \return The number of bytes of data that were sent or received as a result
//! of this request.
//
//*****************************************************************************
uint32_t
USBHCDControlTransfer(uint32_t ui32Index, tUSBRequest *psSetupPacket,
                      tUSBHostDevice *psDevice, uint8_t *pui8Data,
                      uint32_t ui32Size, uint32_t ui32MaxPacketSize)
{
    uint32_t ui32Remaining;
    uint32_t ui32DataSize;

    //
    // Debug sanity check.
    //
    ASSERT(g_sUSBHEP0State.iState == eEP0StateIdle);

Again, since I do not have any symbols, just assembly it makes debugging pretty hard.

In the custom bootloader I have tried calling 

SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_USBA); 

in the custom bootloader just prior to jumping to the flash kernel main() to reset the USB where in the custom flash kernel it makes the following calls to initialize the device (including USB) NOTE this is mainly from the usb_ex7_host_msc.c:

uint32_t main(void)
{
//
// Step 1. Initialize System Control:
// Enable Peripheral Clocks
// This example function is found in the F2837xD_SysCtrl.c file.
//
    InitSysCtrl(); //PLL activates
//
// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
//
    InitGpio();

//
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
//
    DINT;

//
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2837xD_PieCtrl.c file.
//
    InitPieCtrl();

//
// Disable CPU interrupts and clear all CPU interrupt flags:
//
    IER = 0x0000;
    IFR = 0x0000;

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in F2837xD_DefaultIsr.c.
// This function is found in F2837xD_PieVect.c.
//
    InitPieVectTable();
    InitFlash();

//
// Gain pump semaphore
//

    SeizeFlashPump();

    Init_Flash_Sectors();

    Board_init();

    C2000Ware_libraries_init();

    EINT;
    ERTM;

    Interrupt_enableMaster();

    UsbHost_Initialize();

where UsbHost_Initialize() is (basically from main() in usb_ex7_host_msc.c)

void UsbHost_Initialize()
{
    g_UsbRxBuffer = &g_cTmpBuf[0];
    startAddress = g_UsbRxBuffer;

    // initially wait for device connection.
    g_eState = STATE_NO_DEVICE;
    g_eUIState = STATE_NO_DEVICE;

    // configure the required pins for USB operation.
    USBGPIOEnable();

    // register the interrupt handler for USB Interrupts.
    //Interrupt_register(INT_USBA, INT_myUSB0_ISR);

    // Initialize the USB stack mode and pass in a mode callback.
    //USBStackModeSet(0, eUSBModeForceHost, ModeCallback);

    // Register the host class drivers.
    USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS);

    // Open an instance of the mass storage class driver.
    g_psMSCInstance = USBHMSCDriveOpen(0, (tUSBHMSCCallback)MSCCallback);

    // initialize the power configuration. This sets the power enable signal
    // to be active high and does not enable the power fault.
    //USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);

    // initialize the USB controller for OTG operation with a 2ms polling
    // rate.
    //USBHCDInit(0,g_pHCDPool, HCD_MEMORY_SIZE);

    // initialize the file system.
    f_mount(0, &g_sFatFs);
}

I am kind of stuck at this point. If I run the custom bootloader from FLASH and load led_ex1_blinky.dat into RAM it works. If I run the custom flash kernel from RAM and load led_ex1_blinky.dat into FLASH it works. The issue is when the custom bootloader loads the custom flash kernel. At the point the custom flash kernel starts running the USB is not in a good state. It does not enumerate the USB (see USB FLASH drive attached) and if I unplug it and plug it back in it errors out.

The bottom line is that the USB is not in a good state (initialized/configured) when running the flash kernel after it has been programmed by the custom bootloader.

Any thoughts on the resetting / initialization / configuration of the USB from when I leave the custom bootloader to initializing the USB in the custom flash kernel?

Anything i can try or to look at?

Thanks for your help,

Brent

  • Brent,

    Do you need to enumerate the USB again if it already detected during the custom FLASH bootloader execution.?

    Is the custom Flash bootloader waiting for USB to be enumerated/detected again?

    Best Regards

    Siddharth

  • Hi Siddharth,

    Thanks for responding. I guess I am wondering how to do this?

    Again, for the custom bootloader, I started with the usb_ex7_host_msc.c and incorporated some of the USB boot rom code - C:\ti\c2000\C2000Ware_4_03_00_00\libraries\boot_rom\f2837xd\revB\rom_sources

    #include "board.h"
    #include "c2000ware_libraries.h"
    #include "usb_host.h"
    #include "c1_bootrom.h"
    
    //******************************************************************************
    //
    // This is the main loop that runs the application.
    //
    //******************************************************************************
    uint32_t main(void)
    {
        // initialize device clock and peripherals
        Device_init();
    
        // initialize GPIO and configure GPIO pins for USB.
        Device_initGPIO();
    
        // initialize PIE and clear PIE registers. Disables CPU interrupts.
        Interrupt_initModule();
    
        // initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        Interrupt_initVectorTable();
    
        Board_init();
    
        C2000Ware_libraries_init();
    
        // enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        EINT;
        ERTM;
    
        // enable interrupts
        Interrupt_enableMaster();
    
        UsbHost_Initialize();
    
        while(UsbHost_CheckForFlashDrive() == false)
        {
            SysCtl_delay(SysCtl_getClock(20000000U)/30);
        }
    
        numBytes = Cmd_Read_Firmware_Data(false);
    	
        uint32_t EntryAddr = USB_Boot(USB_BOOT);
        
    	UsbHost_CloseFile();
    
        return entryAddr;
    }
    
    
    

     

    Here is my modified USB_Boot(). You can see at the end it does the following (part of original code):

    //Disconnect from the bus, disable USB interrupts, and
    //reset the USB module. But first, wait for any ongoing
    //transfers to complete.

    So, I am not sure how it can stay enumerated? I did try commenting this part of the code out, but it did not make a difference.

    Uint32 USB_Boot(Uint16 bootMode)
    {
        uint32_t disconnectDelay;
        entryAddr = FLASH_ENTRY_POINT;
    
    
        //Assign the USB data reader function to the global
        //function pointer for loading data.
        GetWordData = &USB_GetWordData;
    
        //The first data word should be a valid key. If it's not,
        //bypass the bootloader.
        if (USB_GetWordData() != 0x08AA)
            return FLASH_ENTRY_POINT;
    
        //Use the shared utility functions to load the data.
        ReadReservedFn();
        entryAddr = GetLongData();
        CopyData();
    	
        //Disconnect from the bus, disable USB interrupts, and
        //reset the USB module. But first, wait for any ongoing
        //transfers to complete.
        for (disconnectDelay = 0; disconnectDelay < 10000; disconnectDelay++) {;}
        USBREG8(USB_O_POWER) &= ~USB_POWER_SOFTCONN;
        EALLOW;
        PieCtrlRegs.PIEIER9.bit.INTx15 = 0;
        IER &= ~M_INT9;
        DevCfgRegs.SOFTPRES11.bit.USB_A = 1;
        DevCfgRegs.SOFTPRES11.bit.USB_A = 0;
        EDIS;
    
        //Bypass and disable the main and aux PLLs
        EALLOW;
        ClkCfgRegs.SYSPLLCTL1.bit.PLLCLKEN = 0;
        ClkCfgRegs.SYSPLLMULT.bit.IMULT = 0;
        ClkCfgRegs.SYSPLLCTL1.bit.PLLEN = 0;
        ClkCfgRegs.AUXPLLCTL1.bit.PLLCLKEN = 0;
        ClkCfgRegs.AUXPLLMULT.bit.IMULT = 0;
        ClkCfgRegs.AUXPLLCTL1.bit.PLLEN = 0;
        EDIS;
    
        return entryAddr;
    }

    Below is my custom flash kernel code. The callback void MSCCallback(() sets the enumeration state and stores it in g_eState. This callback is set in UsbHost_Initialize() (this function also sets g_eState to default state).

    g_psMSCInstance = USBHMSCDriveOpen(0, (tUSBHMSCCallback)MSCCallback);

    //*****************************************************************************
    //
    // USB Configurations
    //
    //*****************************************************************************
    //
    // Define to pass to SysCtl_setAuxClock(). Will configure the clock as follows:
    // AUXPLLCLK =
    //       20MHz (XTAL_OSC) * 12 (IMULT) / (4 (SYSDIV) )
    //
    #define DEVICE_AUXSETCLOCK_CFG_USB   (SYSCTL_OSCSRC_XTAL | SYSCTL_PLL_ENABLE |\
                                          SYSCTL_IMULT(12) | SYSCTL_SYSDIV(4))
    #define myUSB0_BASE USB0_BASE
    
    // Interrupt Settings for INT_myUSB0
    #define INT_myUSB0 INT_USBA
    #define INT_myUSB0_INTERRUPT_ACK_GROUP INTERRUPT_ACK_GROUP9
    extern __interrupt void INT_myUSB0_ISR(void);
    
    #define DEVICE_OSCSRC_FREQ          20000000U
    #define DEVICE_SYSCLK_FREQ          ((DEVICE_OSCSRC_FREQ * 20 * 1) / 2)
    #define DEVICE_GPIO_PIN_LED1        31U  // GPIO number for LD2
    #define DEVICE_DELAY_US(x) SysCtl_delay(((((long double)(x)) / (1000000.0L /  \
                                  (long double)DEVICE_SYSCLK_FREQ)) - 9.0L) / 5.0L)
    
    uint8_t g_pui8HCDPool[myUSB0_LIB_HCD_MEMORY_SIZE];
    
    
    // definitions
    bool flashDriveConnected = false;
    bool readFileContents = false;
    bool firstTime = false;
    
    volatile tState g_eState;
    volatile tState g_eUIState;
    extern char * g_UsbRxBuffer;
    char * startAddress;
    
    int numBytes;
    FRESULT fresult;
    
    int Cmd_Read_Firmware_Data(bool);
    
    //******************************************************************************
    //
    // The current USB operating mode - Host, Device or unknown.
    //
    //******************************************************************************
    tUSBMode g_eCurrentUSBMode;
    
    
    //******************************************************************************
    //
    // This buffer holds the full path to the current working directory.  Initially
    // it is root ("/").
    //
    //******************************************************************************
    static char g_cCwdBuf[PATH_BUF_SIZE] = "/";
    
    
    //******************************************************************************
    //
    // A temporary data buffer used when manipulating file paths, or reading data
    // from the memory card.
    //
    //******************************************************************************
    static char g_cTmpBuf[CMD_BUF_SIZE];
    
    
    //******************************************************************************
    //
    // The memory pool to provide to the Host controller driver.
    //
    //******************************************************************************
    //uint8_t g_pHCDPool[HCD_MEMORY_SIZE];
    
    
    //******************************************************************************
    //
    // The instance data for the MSC driver.
    //
    //******************************************************************************
    tUSBHMSCInstance *g_psMSCInstance = 0;
    
    
    //******************************************************************************
    //
    // Declare the USB Events driver interface.
    //
    //******************************************************************************
    DECLARE_EVENT_DRIVER(g_sUSBEventDriver, 0, 0, USBHCDEvents);
    
    
    //******************************************************************************
    //
    // The global that holds all of the host drivers in use in the application.
    // In this case, only the MSC class is loaded.
    //
    //******************************************************************************
    static tUSBHostClassDriver const * const g_ppHostClassDrivers[] =
    {
        &g_sUSBHostMSCClassDriver,
        &g_sUSBEventDriver
    };
    
    
    //******************************************************************************
    //
    // A table that holds a mapping between the numerical FRESULT code and
    // it's name as a string.  This is used for looking up error codes for
    // printing to the console.
    //
    //******************************************************************************
    tFresultString g_sFresultStrings[] =
    {
        FRESULT_ENTRY(FR_OK),
        FRESULT_ENTRY(FR_NOT_READY),
        FRESULT_ENTRY(FR_NO_FILE),
        FRESULT_ENTRY(FR_NO_PATH),
        FRESULT_ENTRY(FR_INVALID_NAME),
        FRESULT_ENTRY(FR_INVALID_DRIVE),
        FRESULT_ENTRY(FR_DENIED),
        FRESULT_ENTRY(FR_EXIST),
        FRESULT_ENTRY(FR_RW_ERROR),
        FRESULT_ENTRY(FR_WRITE_PROTECTED),
        FRESULT_ENTRY(FR_NOT_ENABLED),
        FRESULT_ENTRY(FR_NO_FILESYSTEM),
        FRESULT_ENTRY(FR_INVALID_OBJECT),
        FRESULT_ENTRY(FR_MKFS_ABORTED)
    };
    
    
    //******************************************************************************
    //
    // USB Mode callback
    //
    // \param ulIndex is the zero-based index of the USB controller making the
    //        callback.
    // \param eMode indicates the new operating mode.
    //
    // This function is called by the USB library whenever an OTG mode change
    // occurs and, if a connection has been made, informs us of whether we are to
    // operate as a host or device.
    //
    // \return None.
    //
    //******************************************************************************
    void ModeCallback(uint32_t ui32Index, tUSBMode eMode)
    {
        //
        // Save the new mode.
        //
    
        g_eCurrentUSBMode = eMode;
    }
    
    
    int Cmd_Read_Firmware_Data(bool opened)
    {
        unsigned short usBytesRead;
    
        if (!opened)
        {
            //
            // Do not attempt to do anything if there is not a drive attached.
            //
            if(g_eState != STATE_DEVICE_READY)
            {
              return(FR_NOT_READY);
            }
    
            strcpy(g_cTmpBuf, "/firmware.dat");
    
            //
            // Open the file for reading.
            //
            fresult = f_open(&g_sFileObject, g_cTmpBuf, FA_READ);
    
            //
            // If there was some problem opening the file, then return an error.
            //
            if(fresult != FR_OK)
            {
              return(fresult);
            }
        }
    
        //
        // Read a block of data from the file.  Read as much as can fit in the
        // temporary buffer
        //
        fresult = f_read(&g_sFileObject, g_cTmpBuf, sizeof(g_cTmpBuf),
                         &usBytesRead);
    
        //
        // If there was an error reading, then print a newline and return the
        // error to the user.
        //
        if(fresult != FR_OK)
        {
            return(fresult);
        }
    	
        //
        // Return number of bytes read
        //
        return(usBytesRead);
    }
    
    
    //******************************************************************************
    //
    // This is the callback from the MSC driver.
    //
    // \param ui32Instance is the driver instance which is needed when communicating
    // with the driver.
    // \param ui32Event is one of the events defined by the driver.
    // \param pvData is a pointer to data passed into the initial call to register
    // the callback.
    //
    // This function handles callback events from the MSC driver.  The only events
    // currently handled are the MSC_EVENT_OPEN and MSC_EVENT_CLOSE.  This allows
    // the main routine to know when an MSC device has been detected and
    // enumerated and when an MSC device has been removed from the system.
    //
    // \return Returns \e true on success or \e false on failure.
    //
    //******************************************************************************
    void MSCCallback(tUSBHMSCInstance *psMSCInstance, uint32_t ui32Event,
                void *pvEventData)
    {
        //
        // Determine the event.
        //
        switch(ui32Event)
        {
            //
            // Called when the device driver has successfully enumerated an MSC
            // device.
            //
            case MSC_EVENT_OPEN:
            {
                //
                // Proceed to the enumeration state.
                //
                g_eState = STATE_DEVICE_ENUM;
                break;
            }
    
            //
            // Called when the device driver has been unloaded due to error or
            // the device is no longer present.
            //
            case MSC_EVENT_CLOSE:
            {
                //
                // Go back to the "no device" state and wait for a new connection.
                //
                g_eState = STATE_NO_DEVICE;
    
                break;
            }
    
            default:
            {
                break;
            }
        }
    }
    
    
    //******************************************************************************
    //
    // This is the generic callback from host stack.
    //
    // \param pvData is actually a pointer to a tEventInfo structure.
    //
    // This function will be called to inform the application when a USB event has
    // occurred that is outside those related to the mass storage device.  At this
    // point this is used to detect unsupported devices being inserted and removed.
    // It is also used to inform the application when a power fault has occurred.
    // This function is required when the g_USBGenericEventDriver is included in
    // the host controller driver array that is passed in to the
    // USBHCDRegisterDrivers() function.
    //
    // \return None.
    //
    //******************************************************************************
    void USBHCDEvents(void *pvData)
    {
        tEventInfo *pEventInfo;
    
        //
        // Cast this pointer to its actual type.
        //
        pEventInfo = (tEventInfo *)pvData;
    
        switch(pEventInfo->ui32Event)
        {
            //
            // New keyboard detected.
            //
            case USB_EVENT_UNKNOWN_CONNECTED:
            {
                //
                // An unknown device was detected.
                //
                g_eState = STATE_UNKNOWN_DEVICE;
    
                break;
            }
    
            //
            // Keyboard has been unplugged.
            //
            case USB_EVENT_DISCONNECTED:
            {
                //
                // Unknown device has been removed.
                //
                g_eState = STATE_NO_DEVICE;
    
                break;
            }
    
            case USB_EVENT_POWER_FAULT:
            {
                //
                // No power means no device is present.
                //
                g_eState = STATE_POWER_FAULT;
    
                break;
            }
    
            default:
            {
                break;
            }
        }
    }
    
    
    //******************************************************************************
    //
    // This function reads text from a file. The USB host main function is called
    // throughout this process to keep USB alive and well.
    //
    //******************************************************************************
    void TryToMountUsbDrive(void)
    {
       tState eStateCopy;
    
       // See if a mass storage device has been enumerated.
       if(g_eState == STATE_DEVICE_ENUM)
       {
           // Take it easy on the Mass storage device if it is slow to
           // start up after connecting.
           if(USBHMSCDriveReady(g_psMSCInstance) != 0)
           {
               // Wait about 100ms before attempting to check if the
               // device is ready again.
               SysCtl_delay(SysCtl_getClock(DEVICE_OSCSRC_FREQ)/30);
    
               //break;
           }
    
           // Reset the working directory to the root.
           g_cCwdBuf[0] = '/';
           g_cCwdBuf[1] = '\0';
    
           // Attempt to open the directory.  Some drives take longer to
           // start up than others, and this may fail (even though the USB
           // device has enumerated) if it is still initializing.
           f_mount(0, &g_sFatFs);
           if(f_opendir(&g_sDirObject, g_cCwdBuf) == FR_OK)
           {
               //
               // The drive is fully ready, so move to that state.
               //
               g_eState = STATE_DEVICE_READY;
           }
       }
    
       // See if the state has changed.  We make a copy of g_eUIState to
       // prevent a compiler warning about undefined order of volatile
       // accesses.
       eStateCopy = g_eUIState;
       if(g_eState != eStateCopy)
       {
           //
           // Determine the new state.
           //
           switch(g_eState)
           {
               //
               // A previously connected device has been disconnected.
               //
               case STATE_NO_DEVICE:
               {
                   flashDriveConnected = false;
                   readFileContents = false;
                   firstTime = false;
                   GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
                   break;
               }
    
               // A mass storage device is being enumerated.
               case STATE_DEVICE_ENUM:
               {
                   break;
               }
    
               // A mass storage device has been enumerated and initialized.
               case STATE_DEVICE_READY:
               {
                   if (firstTime == false)
                   {
                       firstTime = true;
                       flashDriveConnected = true;
                       GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
                       // Save the current state.
                       g_eUIState = g_eState;
                       return;
                   }
    
                   break;
               }
    
               // An unknown device has been connected.
               case STATE_UNKNOWN_DEVICE:
               {
                   break;
               }
    
               // A power fault has occurred.
    
               case STATE_POWER_FAULT:
               {
                   break;
               }
           }
    
           // Save the current state.
           g_eUIState = g_eState;
       }
    
       // Run the main routine of the Host controller driver.
       USBHCDMain();
    }
    
    
    void UsbHost_Initialize()
    {
        g_UsbRxBuffer = &g_cTmpBuf[0];
        startAddress = g_UsbRxBuffer;
    
        // initially wait for device connection.
        g_eState = STATE_NO_DEVICE;
        g_eUIState = STATE_NO_DEVICE;
    
        // configure the required pins for USB operation.
        USBGPIOEnable();
    
        // register the interrupt handler for USB Interrupts.
        //Interrupt_register(INT_USBA, INT_myUSB0_ISR);
    
        // Initialize the USB stack mode and pass in a mode callback.
        //USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
    
        // Register the host class drivers.
        USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS);
    
        // Open an instance of the mass storage class driver.
        g_psMSCInstance = USBHMSCDriveOpen(0, (tUSBHMSCCallback)MSCCallback);
    
        // initialize the power configuration. This sets the power enable signal
        // to be active high and does not enable the power fault.
        //USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
    
        // initialize the USB controller for OTG operation with a 2ms polling
        // rate.
        //USBHCDInit(0,g_pHCDPool, HCD_MEMORY_SIZE);
    
        // initialize the file system.
        f_mount(0, &g_sFatFs);
    }
    
    void UsbHost_CloseFile()
    {
        f_close(&g_sFileObject);
    }
    
    
    bool UsbHost_CheckForFlashDrive()
    {
        TryToMountUsbDrive();
    
        if (flashDriveConnected == true && readFileContents == false)
        {
           readFileContents = true;
           return true;
        }
    
        return false;
    }
    
    
    //******************************************************************************
    //
    //! Host interrupt service routine wrapper to make ISR compatible with
    //! C2000 PIE controller.
    //
    //******************************************************************************
    __interrupt void
    INT_myUSB0_ISR(void)
    {
        USB0HostIntHandler();
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    }
    
    
    //*****************************************************************************
    //
    // PINMUX Configurations
    //
    //*****************************************************************************
    void PinMux_init()
    {
        //
        // PinMux for modules assigned to CPU1
        //
    
        // USB pinmux
        GPIO_setAnalogMode(42, GPIO_ANALOG_ENABLED);
        GPIO_setAnalogMode(43, GPIO_ANALOG_ENABLED);
    
    }
    
    //*****************************************************************************
    //
    // INTERRUPT Configurations
    //
    //*****************************************************************************
    void INTERRUPT_init(){
    
        // Interrupt Settings for INT_myUSB0
        Interrupt_register(INT_myUSB0, &INT_myUSB0_ISR);
        Interrupt_enable(INT_myUSB0);
    }
    //*****************************************************************************
    //
    // USB Configurations
    //
    //*****************************************************************************
    void USB_init(){
        //
        // Set the clocking to run from the PLL at 60MHz
        //
        SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
    }
    
    void USBLib_init(){
        //
        // Initialize the USB stack mode and pass in a mode callback.
        //
        USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
        //
        // Initialize the power configuration.
        //
        USBHCDPowerConfigInit(0,USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
        //
        // Initialize the USB controller for OTG operation with a 2ms polling
        // rate.
        //
        USBHCDInit(0,g_pui8HCDPool, myUSB0_LIB_HCD_MEMORY_SIZE);
    }
    
    void C2000Ware_libraries_init()
    {
        USBLib_init();
    }
    
    
    //*****************************************************************************
    //
    // Board Configurations
    // Initializes the rest of the modules.
    // Call this function in your application if you wish to do all module
    // initialization.
    // If you wish to not use some of the initializations, instead of the
    // Board_init use the individual Module_inits
    //
    //*****************************************************************************
    void Board_init()
    {
        EALLOW;
    
        PinMux_init();
        USB_init();
        INTERRUPT_init();
    
        EDIS;
    }
    
    extern Device_initGPIO();
    
    //
    // Main
    //
    uint32_t main(void)
    {
    //
    // Step 1. Initialize System Control:
    // Enable Peripheral Clocks
    // This example function is found in the F2837xD_SysCtrl.c file.
    //
        InitSysCtrl(); //PLL activates
    	
    //
    // Step 2. Initialize GPIO:
    // This example function is found in the F2837xD_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    //
        InitGpio();
    
    //
    // Step 3. Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
    //
        DINT;
    
    //
    // Initialize the PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    // This function is found in the F2837xD_PieCtrl.c file.
    //
        InitPieCtrl();
    
    //
    // Disable CPU interrupts and clear all CPU interrupt flags:
    //
        IER = 0x0000;
        IFR = 0x0000;
    
    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in F2837xD_DefaultIsr.c.
    // This function is found in F2837xD_PieVect.c.
    //
        InitPieVectTable();
        InitFlash();
    
    //
    // Gain pump semaphore
    //
        SeizeFlashPump();
    
        Init_Flash_Sectors();
    
        Board_init();
    
        C2000Ware_libraries_init();
    
    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //
        EINT;
        ERTM;
    
        Interrupt_enableMaster();
    	
    	UsbHost_Initialize();
    
        while(UsbHost_CheckForFlashDrive() == false)
        {
            SysCtl_delay(SysCtl_getClock(20000000U)/30);
        }
    
    //
    // Loads CPU01 application into FLASH
    //
        numBytes = Cmd_Read_Firmware_Data(false);
        uint32_t EntryAddr = USB_Boot(USB_BOOT);
        UsbHost_CloseFile();
    
    //
    // Leave control over flash pump
    //
        ReleaseFlashPump();
    
        return EntryAddr;
    }
    
    //
    // Init_Flash_Sectors - Initialize flash API and active flash bank sectors
    //
    void Init_Flash_Sectors(void)
    {
        EALLOW;
        Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
        Fapi_StatusType oReturnCheck;
    
        oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 150);
    
        if(oReturnCheck != Fapi_Status_Success)
        {
            Example_Error(oReturnCheck);
        }
    
        oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    
        if(oReturnCheck != Fapi_Status_Success)
        {
            Example_Error(oReturnCheck);
        }
    
        Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA;
        EDIS;
    }
    
    //
    // assignSharedRAMstoCPU2 - Assign shared RAM to CPU2 control
    //
    
    //
    // Example_Error - For this example, if an error is found just stop here
    //
    #ifdef __TI_COMPILER_VERSION__
        #if __TI_COMPILER_VERSION__ >= 15009000
            #pragma CODE_SECTION(Example_Error,".TI.ramfunc");
        #else
            #pragma CODE_SECTION(Example_Error,"ramfuncs");
        #endif
    #endif
    void Example_Error(Fapi_StatusType status)
    {
        //
        // Error code will be in the status parameter
        //
        __asm("    ESTOP0");
    }

    When the custom bootloader jumps to the custom flash kernel code and starts executing, the USB is not initialized correctly otherwise it would enumerate and start reading in the LED blink .dat file.

    Looking at my custom flash kernel code do you see something that I am NOT doing or doing incorrectly in the initialization after jumping to the flash kernel from the custom bootloader?

    Again, if I use the customer bootloader running out of FLASH and have it program the LED blink program in RAM and jump to it this works. Meaning the custom bootloader programs RAM with the LED blink .dat file and jumps to it where the LED blink program executes properly and starts blinking the LED.

    But after the custom bootloader programs the custom flash kernel to RAM and starts executing - the USB is not in a good state. With the USB flash drive still plugged in after the custom bootloader programs the custom flash kernel and jumps to it the flash kernel code is sitting in the while loop:

        while(UsbHost_CheckForFlashDrive() == false)
        {
            SysCtl_delay(SysCtl_getClock(20000000U)/30);
        }
    

    If I unplug and plug back in the USB flash drive this is when I get the enumeration error. So, I am not sure how to properly initialize the USB in the flash kernel code?

    I would like to not have to unplug the USB flash drive after programming the custom flash kernel into RAM. Not sure how to do this?

    I have been looking at this for a while now. Any help or suggestions would be greatly appreciated.

    Thanks,

    Brent

  • Just to provide a little more information. I ran my custom bootloader from FLASH and instead of downloading, programming, and executing my custom flash kernel. I downloaded, programmed, and executed the usb_ex7_host_msc application to see if that would work (Blink LED program works).

    Turns out I get the same error.

    The custom usb host bootloader is able to read the usb_ex7_host_msc.dat file and write it to RAM where the usb_ex7_host_msc application begins executing. The usb_ex7_host_msc prints out the following to a terminal window as expected:

    At which point it calls ReadLine()

    while(1)
    {
    //
    // Get a line of text from the user.
    //
       ReadLine(); <== NEVER RETURNS FROM

    In ReadLine(), g_eState never changes to STATE_DEVICE_ENUM. This would occur in the callback function MSCCallback() but never does.

    If I unplug the plugged in USB flash drive and plug it back in, I get the enumeration error first described above.

    Bottom line is the usb_ex7_host_msc application (and my custom flash kernel) are NOT initializing the USB properly.

    I started looking at how the USB flash kernel initializes the USB. Note it does it for USB Device mode NOT Host mode like I would need.

    Looking at the code for the USB flash kernel in the SDK - C:\ti\c2000\C2000Ware_4_03_00_00\device_support\f2837xd\examples\dual\F2837xD_usb_flash_kernels\cpu01

    In F2837xD_usb_flash_kernels_cpu01.c -  USB_Boot() is called.

     

    uint32_t EntryAddr = USB_Boot(USB_BOOT);

    In USB_Boot() it calls USB_Init() which does the following to configure the USB for DEVICE mode:

    //
    // USB_Init -  Jump starts some vital set-up for USB protocol.
    //
    void USB_Init()
    {
        //
        //enable USB controller clock
        //initialize three layers of interrupt enables
        //peripheral interrupt, PIE interrupt, EINT/DINT
        //
        EALLOW;
        //ClkCfgRegs.CLKSRCCTL1.bit.OSCCLKSRCSEL = 0x0;    //Use INTOSC2 (~10 MHz)
                                                           //as the main PLL
                                                           //clock source
        ClkCfgRegs.SYSPLLMULT.all = 12;                    //Set IMULT to 12,
                                                           //clear FMULT
        ClkCfgRegs.SYSPLLCTL1.bit.PLLEN = 1;               //Enable the main PLL
        ClkCfgRegs.SYSCLKDIVSEL.bit.PLLSYSCLKDIV = 0;      //Set PLLSYSCLKDIV to 1
        while (ClkCfgRegs.SYSPLLSTS.bit.LOCKS != 1) {;}    //Wait for the PLL to
                                                           //lock
        ClkCfgRegs.SYSPLLCTL1.bit.PLLCLKEN = 1;            //Turn off the main
                                                           //PLL bypass
    
        //ClkCfgRegs.CLKSRCCTL2.bit.AUXOSCCLKSRCSEL = 0x1; //Use XTAL (20 MHz) as
                                                           //the aux PLL clock
                                                           //source
        ClkCfgRegs.AUXPLLMULT.all = 6;                     //Set IMULT to 6, clear
                                                           //FMULT - 120MHz
        ClkCfgRegs.AUXPLLCTL1.bit.PLLEN = 1;               //Enable the aux PLL
        ClkCfgRegs.AUXCLKDIVSEL.bit.AUXPLLDIV = 2/2;       //Set AUXPLLDIV to 2
        while (ClkCfgRegs.AUXPLLSTS.bit.LOCKS != 1) {;}    //Wait for the PLL
                                                           //to lock
        ClkCfgRegs.AUXPLLCTL1.bit.PLLCLKEN = 1;            //Turn off aux PLL
                                                           //bypass
        DevCfgRegs.DC12.bit.USB_A = 1;     //feature enabled: device only
        CpuSysRegs.PCLKCR11.bit.USB_A = 1; //module clock turned on
    
        //
        //Connect the PHY to the GPIO pins by setting the GPBAMSEL
        //bits for GPIOs 42 and 43. VBUS and ID are now de-spec'd
        //due to the lack of a 5V fail-safe ESD structure, so
        //GPIOs 46 and 47 are not muxed out.
        //
        GpioCtrlRegs.GPBAMSEL.bit.GPIO42 = 1;
        GpioCtrlRegs.GPBAMSEL.bit.GPIO43 = 1;
    
        IER = 0x0000;
        IFR = 0x0000;
        //c1brom_enable_pie_in_boot(0);
        PieVectTable.USBA_INT = &UsbIntHandler;
        PieCtrlRegs.PIECTRL.bit.ENPIE = 1;  //enable the PIE block
        PieCtrlRegs.PIEIER9.bit.INTx15 = 1; //enable USBA interrupt(CPU1 only)
        EDIS;
        IER |= M_INT9;
        EINT;
    
        //
        //Reset the USB driver's global variables
        //
        ResetUsbDriver();
    
        //
        //Force USB device mode by setting DEVMODOTG and DEVMOD
        //
        USBREG32(USB_O_GPCS) = 0x3;
    
        //
        //Clear active interrupts
        //
        USBREG16(USB_O_TXIS);
        USBREG16(USB_O_RXIS);
        USBREG8(USB_O_IS);
    
        //
        //Set up endpoint 1 for bulk transfers with a 64-byte FIFO
        //
        USBREG8(USB_O_EPIDX) = 1;
        USBREG8(USB_O_RXFIFOSZ) = 0x03;
        USBREG16(USB_O_RXFIFOADD) = 0x100;
        USBREG8(USB_O_RXCSRH1) = 0x40;
    
        //
        //Enable USB interrupts for EP0 transmit/receive, EP1 receive,
        //disconnection, and reset
        //
        USBREG16(USB_O_TXIE) = 0x0001;
        USBREG16(USB_O_RXIE) = 0x0002;
        USBREG8(USB_O_IE) = (USB_IE_DISCON | USB_IE_RESET);
    
        //
        //Attach the USB PHY to the bus
        //
        USBREG8(USB_O_POWER) |= USB_POWER_SOFTCONN;
    }

    The usb_ex7_host_msc application does the following to initialize the USB for HOST mode:

    void USB_init(){
        //
        // Set the clocking to run from the PLL at 60MHz
        //
        SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
    }
    
    
    //*****************************************************************************
    //
    // PINMUX Configurations
    //
    //*****************************************************************************
    void PinMux_init()
    {
    	//
    	// PinMux for modules assigned to CPU1
    	//
    	
    	// USB pinmux
    	GPIO_setAnalogMode(42, GPIO_ANALOG_ENABLED);
    	GPIO_setAnalogMode(43, GPIO_ANALOG_ENABLED);
    
    }
    
    
    void Board_init()
    {
    	EALLOW;
    
    	PinMux_init();
    	USB_init();
    	INTERRUPT_init();
    
    	EDIS;
    }
    
    
    uint8_t g_pui8HCDPool[myUSB0_LIB_HCD_MEMORY_SIZE];
    void USBLib_init(){
        //
        // Initialize the USB stack mode and pass in a mode callback.
        //
        USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
        //
        // Initialize the power configuration.
        //
        USBHCDPowerConfigInit(0,USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
        //
        // Initialize the USB controller for OTG operation with a 2ms polling
        // rate.
        //
        USBHCDInit(0,g_pui8HCDPool, myUSB0_LIB_HCD_MEMORY_SIZE);
    }
    
    
    void C2000Ware_libraries_init()
    {
        USBLib_init();
    }
    
    
    //******************************************************************************
    //
    //! Enables USB related GPIOs to perform their USB function.
    //
    //******************************************************************************
    void USBGPIOEnable(void)
    {
        //
        // Set the USB DM and DP.
        //
        GPIO_setMasterCore(42, GPIO_CORE_CPU1);
        GPIO_setAnalogMode(42, GPIO_ANALOG_ENABLED);
        GPIO_setMasterCore(43, GPIO_CORE_CPU1);
        GPIO_setAnalogMode(43, GPIO_ANALOG_ENABLED);
    
        //
        // Set the direction for VBUS.
        //
        GPIO_setMasterCore(46, GPIO_CORE_CPU1);
        GPIO_setDirectionMode(46, GPIO_DIR_MODE_IN);
    
        //
        // Set the direction for ID.
        //
        GPIO_setMasterCore(47, GPIO_CORE_CPU1);
        GPIO_setDirectionMode(47, GPIO_DIR_MODE_IN);
    
        GPIO_setMasterCore(120, GPIO_CORE_CPU1);
        GPIO_setDirectionMode(120, GPIO_DIR_MODE_IN);
    
        GPIO_setMasterCore(121, GPIO_CORE_CPU1);
    	GPIO_setDirectionMode(121, GPIO_DIR_MODE_OUT);
    	GPIO_writePin(121, 1);
    }
    
    
    int main(void)
    {
        int iStatus;
    
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Initialize GPIO and configure GPIO pins for USB.
        //
        Device_initGPIO();
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
    
        //
        // Set the clocking to run from the PLL at 60MHz
        //
        //SysCtl_setAuxClock(DEVICE_AUXSETCLOCK_CFG_USB);
        Board_init();
    
        C2000Ware_libraries_init();
        //
        // Initially wait for device connection.
        //
        g_eState = STATE_NO_DEVICE;
        g_eUIState = STATE_NO_DEVICE;
    
        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;
    
        //
        // Configure the required pins for USB operation.
        //
        USBGPIOEnable();
    
        //
        // Register the interrupt handler for USB Interrupts.
        //
        //Interrupt_register(INT_USBA, INT_myUSB0_ISR);
    
        //
        // Configure SCIA for debug output.
        //
        ConfigureSCI();
    
        SCIprintf("\n\nUSB Mass Storage Host program\n");
        SCIprintf("Type \'help\' for help.\n\n");
    
        //
        // Enable Interrupts
        //
        Interrupt_enableMaster();
    
        //
        // Initialize the USB stack mode and pass in a mode callback.
        //
        //USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
    
        //
        // Register the host class drivers.
        //
        USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS);
    
        //
        // Open an instance of the mass storage class driver.
        //
        g_psMSCInstance = USBHMSCDriveOpen(0, (tUSBHMSCCallback)MSCCallback);
    
    
        //
        // Initialize the power configuration. This sets the power enable signal
        // to be active high and does not enable the power fault.
        //
        //USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
    
        //
        // Initialize the USB controller for OTG operation with a 2ms polling
        // rate.
        //
        //USBHCDInit(0,g_pHCDPool, HCD_MEMORY_SIZE);
    
        //
        // Initialize the file system.
        //
        f_mount(0, &g_sFatFs);
    

    As is, the USB flash drive stays plugged in as the custom bootloader turns execution over to the usb_ex7_host_msc application running in RAM and it is never enumerated. If I unplug the USB flash drive and plug it back in to enumerate, I get the error described before.

    Can anyone provide some insight on what I need to do differently in the initialization/configuration of the USB for HOST mode? 

    Thanks,

    Brent

  • Brent, 

    Will consult the boot rom expert to see if they have any suggestions on it. 

    Will get back to you in a couple of days.

    Best Regards

    Siddharth

  • Hi Siddharth,

    I was just following up on this - on how the USB initialization would need to change for the usb_ex7_host_msc application?

    Here are the steps:

    1. Custom bootloader is running out of FLASH
    2. Plug in USB Flash drive (Pen drive)
    3. Custom booloader reads in the usb_ex7_host_msc application from USB Flash drive (Pen drive)
    4. Custom bootloader writes the usb_ex7_host_msc application to RAM
    5. Customer bootloader jumps to usb_ex7_host_msc application in RAM
    6. usb_ex7_host_msc application starts executing
    7. USB is not being intialized properly in the usb_ex7_host_msc application
    8. If USB Flash drive (Pen drive) which is still plugged does not enumerate (NOTE in the main() ofthe usb_ex7_host_msc application it sets g_eState = STATE_NO_DEVICE; g_eUIState = STATE_NO_DEVICE;). If I unplug and plug back in the USB Flash drive the enumeration fails as described above.

    Thanks for your help,

    Brent

  • Brent, 

    I tired running the "usb_ex7_host_msc" application from RAM and it is able to detect the flash drive connected to it. 

    It works in both cases - when the flash drive is already connected and when the flash drive is connected after the code starts executing. 

    I also tried pluging and unplugging the flash drive and it was able to detect the changes. 

    Can you try running only the usb_ex7_host_msc application from RAM?

    Best Regards

    Siddharth

  • Hi Siddharth,

    Thank you for the response.

    I probably have not explained my issue properly. I can launch the usb_ex7_host_msc application in CC and run it both from RAM and FLASH. That is NOT my issue. My issue is a different use case.

    Specifically, we would like to perform USB flash programming with a USB FLASH drive (Pen drive). This is using USB HOST mode.

    The current FLASH programmer uses USB DEVICE mode. It works as follows:

    1. Processor runs USB bootloader in ROM (USB DEVICE mode).
    2. User attaches USB to computer and it enumerates.
    3. User from a command line runs the usb_flash_programmer.exe with parameters for the flash kernel and the application that will be programmed to flash.
    4. The USB bootloader reads in the flash kernel and writes it to RAM.
    5. After the USB bootloader is done writing it to RAM it jumps to the flash kernel in RAM and it starts executing.
    6. The flash kernel using the USB in DEVICE mode reads in the application and writes the application to FLASH.
    7. After writing the application to FLASH it jumps to FLASH and starts executing the program.

    To start the process of doing this with a USB FLASH drive in USB HOST mode, I created a custom bootloader. For the custom bootloader I started with the usb_ex7_host_msc project found at - C:\ti\c2000\C2000Ware_4_03_00_00\driverlib\f2837xd\examples\cpu1\usb and incorporated some of the boot rom code found at - C:\ti\c2000\C2000Ware_4_03_00_00\libraries\boot_rom\f2837xd\revB\rom_sources.

    This custom bootloader runs out of FLASH and will read in a .dat file from a plugged in USB FLASH drive (Pen drive). The custom bootloader will write the .dat file to RAM. Once it is done writing the .dat file to RAM it will jump to RAM and start executing the .at program.

    I have tested this where the .dat file is the LED blink program. The custom bootloader successfully reads in the LED Blink .dat program, writes it to RAM, jumps to RAM, and started executing the LED blink program in RAM.

    The next step would be to create a custom flash kernel based on the usb_ex7_host_msc project which would read in the LED blink .dat file from the USB FLASH drive (Pen drive) and write the .dat file to FLASH. Once that is complete the custom flash kernel would jump to FLASH and start executing the LED blink application.

    As an initial step I use my custom bootloader using USB in HOST mode and try to read in the usb_ex7_host_msc .dat file from a USB FLASH drive (Pen drive). The custom bootloader reads in the usb_ex7_host_msc .dat file and writes the .dat file to RAM. After it is done it jumps to RAM and starts executing. NOTE: The USB FLASH drive (Pen drive) is still plugged in. The usb_ex7_host_msc now in RAM starts executing.

    The already plugged in USB FLASH drive (Pen drive) never re-enumerates. If I unplug the USB FLASH drive (Pen drive) and plug it back in, I get the enumeration error I described above.

    The issue is the CURRENT way that the usb_ex7_host_msc project initializes the USB is not working in this use case. I need to modify since it is not working the current way the usb_ex7_host_msc project initializes the USB for HOST mode.

    Does that make sense?

    Any thoughts on what I would need to change in the usb_ex7_host_msc project?

    Thanks for your help,

    Brent

  • Brent,

    I understood the use case. If the usb_ex7_host_msc works from RAM, it should also work when it is copied over by the custom bootloader. Can you ensure that the .dat file for usb_ex7_host_msc is loaded correctly?  Maybe you can load this file using the memory browser of CCS and see if it works. 

    Also, you can check the USBDEVCTL register to check the mode of USB?

    Best Regards

    Siddharth 

  • Hi Siddharth,

    The custom bootloader is just using the C:\ti\c2000\C2000Ware_4_03_00_00\libraries\boot_rom\f2837xd\revB\rom_sources USB_Boot(). I have been able to use the custom bootloader to successfully program RAM with other applications such as the LED Blink program with no issues. 

    In CC I did a memory dump of the ,text section when CC loads the usb_ex7_host_msc application into RAM and also a memory text dump of the .text section when my custom bootloader loads the usb_ex7_host_msc application into RAM.

    They are identical. This tells me that the custom bootloader using the C:\ti\c2000\C2000Ware_4_03_00_00\libraries\boot_rom\f2837xd\revB\rom_sources USB_Boot() is programming the RAM correctly. I also repeated this with the LED Blink program.

    The application usb_ex7_host_msc application .text section starts at 0000c000 and had a length of 00005f7c. Here is the memory map:

    ******************************************************************************
                 TMS320C2000 Linker PC v22.6.0                     
    ******************************************************************************
    >> Linked Wed Jul 19 10:25:37 2023
    
    OUTPUT FILE NAME:   <usb_ex7_host_msc.out>
    ENTRY POINT SYMBOL: "code_start"  address: 00000000
    
    
    MEMORY CONFIGURATION
    
             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
    PAGE 0:
      BEGIN                 00000000   00000002  00000002  00000000  RWIX
      RAMM0                 00000123   000002dd  00000090  0000024d  RWIX
      RAMLS0                00008000   00000800  00000000  00000800  RWIX
      RAMLS1                00008800   00000800  00000000  00000800  RWIX
      RAMLS2                00009000   00000800  00000000  00000800  RWIX
      RAMLS3                00009800   00000800  00000000  00000800  RWIX
      RAMLS4                0000a000   00000800  00000000  00000800  RWIX
      RAMD0                 0000b000   00000800  00000000  00000800  RWIX
      RAMGS0to7_combined    0000c000   00008000  00007644  000009bc  RWIX
      RESET                 003fffc0   00000002  00000000  00000002  RWIX
    
    PAGE 1:
      BOOT_RSVD             00000002   00000121  00000000  00000121  RWIX
      RAMM1                 00000400   000003f8  000003f8  00000000  RWIX
      RAMLS5                0000a800   00000800  00000000  00000800  RWIX
      RAMD1                 0000b800   00000800  00000000  00000800  RWIX
      RAMGS15_RSVD          0001bff8   00000008  00000000  00000008  RWIX
    
    
    SECTION ALLOCATION MAP
    
     output                                  attributes/
    section   page    origin      length       input sections
    --------  ----  ----------  ----------   ----------------
    codestart 
    *          0    00000000    00000002     
                      00000000    00000002     F2837xD_CodeStartBranch.obj (codestart)
    
    .cinit     0    00000128    0000008c     
                      00000128    00000078     (.cinit..data.load) [load image, compression = lzss]
                      000001a0    00000006     (__TI_handler_table)
                      000001a6    00000004     (.cinit..bss.load) [load image, compression = zero_init]
                      000001aa    00000002     --HOLE-- [fill = 0]
                      000001ac    00000008     (__TI_cinit_table)
    
    .text      0    0000c000    00005f7c     
      

    I have attached the two memory dumps.

    usb_ex7_host_msc_orig.dat

    usb_ex7_host_msc_mine.dat

    You asked me to look at register USBDEVCTL. I am unable to read this register along with other USB registers in CC. I am getting the following error when I try to export the USB registers to a file. Is there another way to get this information?

    C28xx_CPU1: Unable to save register UsbaRegs_USB_EPIDX_TEST: Memory map prevented reading 0x04000E@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBDEVCTL: Memory map prevented reading 0x040060@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXFIFOSZ_RXFIFSZ: Memory map prevented reading 0x040062@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_CONTIM_VPLEN: Memory map prevented reading 0x04007A@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBFSEOF: Memory map prevented reading 0x04007C@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBLSEOF: Memory map prevented reading 0x04007E@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBTXFUNCADDR0: Memory map prevented reading 0x040080@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXHUBADDR0_TXHUBPORT0: Memory map prevented reading 0x040082@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBTXFUNCADDR1: Memory map prevented reading 0x040088@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXHUBADDR1_TXHUBPORT1: Memory map prevented reading 0x04008A@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBRXFUNCADDR1: Memory map prevented reading 0x04008C@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXHUBADDR1_RXHUBPORT1: Memory map prevented reading 0x04008E@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBTXFUNCADDR2: Memory map prevented reading 0x040090@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXHUBADDR2_TXHUBPORT2: Memory map prevented reading 0x040092@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBRXFUNCADDR2: Memory map prevented reading 0x040094@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXHUBADDR2_RXHUBPORT2: Memory map prevented reading 0x040096@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBTXFUNCADDR3: Memory map prevented reading 0x040098@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXHUBADDR3_TXHUBPORT3: Memory map prevented reading 0x04009A@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBRXFUNCADDR3: Memory map prevented reading 0x04009C@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXHUBADDR3_RXHUBPORT3: Memory map prevented reading 0x04009E@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_CSRL0_CSRH0: Memory map prevented reading 0x040102@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USBCOUNT0: Memory map prevented reading 0x040106@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TYPE0_NAKLMT: Memory map prevented reading 0x040108@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXCSRL1_TXCSRH1: Memory map prevented reading 0x040112@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXCSRL1_RXCSRH1: Memory map prevented reading 0x040116@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXTYPE1_TXINTERVAL1: Memory map prevented reading 0x04011A@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXTYPE1_RXINTERVAL1: Memory map prevented reading 0x04011C@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXCSRL2_TXCSRH2: Memory map prevented reading 0x040122@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXCSRL2_RXCSRH2: Memory map prevented reading 0x040126@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXTYPE2_TXINTERVAL2: Memory map prevented reading 0x04012A@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXTYPE2_RXINTERVAL2: Memory map prevented reading 0x04012C@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXCSRL3_TXCSRH3: Memory map prevented reading 0x040132@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXCSRL3_RXCSRH3: Memory map prevented reading 0x040136@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_TXTYPE3_TXINTERVAL3: Memory map prevented reading 0x04013A@Program
    C28xx_CPU1: Unable to save register UsbaRegs_USB_RXTYPE3_RXINTERVAL3: Memory map prevented reading 0x04013C@Program

    Here is what I am seeing in CC:

    I exported the USB registers after the USB has been initialized. Once in the case CC downloads the usb_ex7_host_msc application into RAM. I set a breakpoint which you can see in the above picture right before it calls fmount(). The other USB register export is done after the custom bootloader programs the usb_ex7_host_msc application into RAM, jumps there and starts executing. I pause the execution and do the export.

    usb_ex7_host_msc.txt
    521177 40
    R UsbaRegs_USB_FADDR_POWER 0x0000000F 0x6000
    R UsbaRegs_USBTXIS 0x0000000F 0x6000
    R UsbaRegs_USBRXIS 0x0000000F 0x0000
    R UsbaRegs_USBTXIE 0x0000000F 0x0000
    R UsbaRegs_USBRXIE 0x0000000F 0xFFFE
    R UsbaRegs_USB_IS_IE 0x0000000F 0xFFFE
    R UsbaRegs_USBFRAME 0x0000000F 0x0000
    R UsbaRegs_USBFIFO0 0x0000000B 0x4B004000
    R UsbaRegs_USBFIFO1 0x0000000B 0x00010000
    R UsbaRegs_USBFIFO2 0x0000000B 0x00010000
    R UsbaRegs_USBFIFO3 0x0000000B 0x00010000
    R UsbaRegs_USBTXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBRXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBTXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT1 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT2 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT3 0x0000000F 0x1FF8
    R UsbaRegs_USBRQPKTCOUNT1 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT2 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT3 0x0000000F 0x0000
    R UsbaRegs_USBRXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBTXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBEPC 0x0000000B 0x00000005
    R UsbaRegs_USBEPCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBEPCIM 0x0000000B 0x00000001
    R UsbaRegs_USBEPCISC 0x0000000B 0x00000000
    R UsbaRegs_USBDRRIS 0x0000000B 0x00000001
    R UsbaRegs_USBDRIM 0x0000000B 0x00000000
    R UsbaRegs_USBDRISC 0x0000000B 0x00000000
    R UsbaRegs_USBGPCS 0x0000000B 0x00000012
    R UsbaRegs_USBVDC 0x0000000B 0x00000001
    R UsbaRegs_USBVDCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBVDCIM 0x0000000B 0x00000000
    R UsbaRegs_USBVDCISC 0x0000000B 0x00000000
    R UsbaRegs_USBIDVRIS 0x0000000B 0x00000001
    R UsbaRegs_USBIDVIM 0x0000000B 0x00000001
    R UsbaRegs_USBIDVISC 0x0000000B 0x00000001
    R UsbaRegs_USBDMASEL 0x0000000B 0x00332211
    

    usb_ex7_host_msc_written_into_ram_custom_bootloader.txt
    521177 40
    R UsbaRegs_USB_FADDR_POWER 0x0000000F 0x6000
    R UsbaRegs_USBTXIS 0x0000000F 0x6000
    R UsbaRegs_USBRXIS 0x0000000F 0x0000
    R UsbaRegs_USBTXIE 0x0000000F 0x0000
    R UsbaRegs_USBRXIE 0x0000000F 0xFFFE
    R UsbaRegs_USB_IS_IE 0x0000000F 0xFFFE
    R UsbaRegs_USBFRAME 0x0000000F 0x02A9
    R UsbaRegs_USBFIFO0 0x0000000B 0x01000680
    R UsbaRegs_USBFIFO1 0x0000000B 0x00120000
    R UsbaRegs_USBFIFO2 0x0000000B 0x00120000
    R UsbaRegs_USBFIFO3 0x0000000B 0x00120000
    R UsbaRegs_USBTXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBRXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBTXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT1 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT2 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT3 0x0000000F 0x1FF8
    R UsbaRegs_USBRQPKTCOUNT1 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT2 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT3 0x0000000F 0x0000
    R UsbaRegs_USBRXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBTXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBEPC 0x0000000B 0x00000005
    R UsbaRegs_USBEPCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBEPCIM 0x0000000B 0x00000001
    R UsbaRegs_USBEPCISC 0x0000000B 0x00000000
    R UsbaRegs_USBDRRIS 0x0000000B 0x80000001
    R UsbaRegs_USBDRIM 0x0000000B 0x00000000
    R UsbaRegs_USBDRISC 0x0000000B 0x00000000
    R UsbaRegs_USBGPCS 0x0000000B 0x00000012
    R UsbaRegs_USBVDC 0x0000000B 0x00000001
    R UsbaRegs_USBVDCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBVDCIM 0x0000000B 0x00000000
    R UsbaRegs_USBVDCISC 0x0000000B 0x00000000
    R UsbaRegs_USBIDVRIS 0x0000000B 0x00000000
    R UsbaRegs_USBIDVIM 0x0000000B 0x00000001
    R UsbaRegs_USBIDVISC 0x0000000B 0x00000000
    R UsbaRegs_USBDMASEL 0x0000000B 0x00332211
    

    There is a difference from downloading and running the usb_ex7_host_msc application in CC compared to using the custom bootloader. The custom bootloader has already initialized/configured the USB for HOST mode and is using the USB HOST mode to program RAM with the usb_ex7_host_msc application prior to jumping to the usb_ex7_host_msc application and running. 

    In the two cases the start conditions are just different and to me it seems like the usb_ex7_host_msc application in this case is not initializing/configuration the USB HOST properly.

    You also mentioned loading the .dat file using the memory browser of CC. I see how to do an export but not import the .dat file. Can you point me to documentation to do this?

    Hope this provides some insight.

    Thanks for your help,

    Brent

  • Brent, 

    The USB Boot configures it in Device mode and the usb_ex7_host_msc runs in Host mode.  Looks like the usb_ex7_host_msc is unable to handle this use case  where switching from Device mode to host mode is involved.  There is another example (usb_ex8_dual_detect) where it swithces from device to host mode.  Can you try adding the following code in usb_ex7_host_msc to reset the USB before performing any other USB functions

    //
    // Disconnect from the bus, disable USB interrupts, and
    // reset the USB module. But first, wait for any ongoing
    // transfers to complete.
    //
    HWREGB(USB0_BASE + USB_O_POWER) &= ~USB_POWER_SOFTCONN;

    //
    // Disable USB interrupts
    //
    Interrupt_disable((uint32_t)INT_USBA);

    //
    // Reset USB
    //
    SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_USBA);

    //
    // Attach the USB PHY to the bus
    //
    HWREGB(USB0_BASE + USB_O_POWER) |= USB_POWER_SOFTCONN;

    Best Regards

    Siddharth

  • Hi Siddharth,

    Thank you for the response.

    For my custom bootloader, I started with the usb_ex7_host_msc application and added the USB_Boot() code.

    I commented out the USB initialization() call in USB_Boot() which you can see below.

    I did this since the custom bootloader (usb_ex7_host_msc application) is already configured for USB HOST mode when it calls USB_Boot(). I want to keep it in USB HOST mode as USB_Boot() is reading in the usb_ex7_host_msc application and writing to RAM using USB HOST mode. I do NOT want it initialized for USB DEVICE mode. 

    So, I do not think that is the issue.

    Uint32 USB_Boot(Uint16 bootMode)
    {
        uint32_t disconnectDelay;
        entryAddr = FLASH_ENTRY_POINT;
    
        //If the USB module is not enabled, bypass the bootloader
        //BAW if (DevCfgRegs.DC12.bit.USB_A == 0)
        //BAW    return FLASH_ENTRY_POINT;
    
        //Assign the USB data reader function to the global
        //function pointer for loading data.
        GetWordData = &USB_GetWordData;
    
        //Set up the USB to receive data
        // USB_Boot_Init();
        // UsbHost_Initialize();
    
        //BAW
        /*
        EntryAddr = TI_OTP_C1BROM_ESCAPE_POINT_13;
        if((EntryAddr != 0xFFFFFFFF) &&
                (EntryAddr != 0x00000000))
        {
            //if OTP is programmed, then call OTP function
            ((void (*)(void))EntryAddr)();
        }
        */
    
        //The first data word should be a valid key. If it's not,
        //bypass the bootloader.
        if (USB_GetWordData() != 0x08AA)
            return FLASH_ENTRY_POINT;
    
        //Use the shared utility functions to load the data.
        ReadReservedFn();
        entryAddr = GetLongData();
        CopyData();
    
        // BAW
        /*
        EntryAddr = TI_OTP_C1BROM_ESCAPE_POINT_13;
        if((EntryAddr != 0xFFFFFFFF) &&
                (EntryAddr != 0x00000000))
        {
            // if OTP is programmed, then call OTP function
            ((void (*)(void))EntryAddr)();
        }
        */
    
    #if 0
        //Disconnect from the bus, disable USB interrupts, and
        //reset the USB module. But first, wait for any ongoing
        //transfers to complete.
        for (disconnectDelay = 0; disconnectDelay < 10000; disconnectDelay++) {;}
        USBREG8(USB_O_POWER) &= ~USB_POWER_SOFTCONN;
        EALLOW;
        PieCtrlRegs.PIEIER9.bit.INTx15 = 0;
        IER &= ~M_INT9;
        DevCfgRegs.SOFTPRES11.bit.USB_A = 1;
        DevCfgRegs.SOFTPRES11.bit.USB_A = 0;
        EDIS;
    
        //Bypass and disable the main and aux PLLs
        EALLOW;
        ClkCfgRegs.SYSPLLCTL1.bit.PLLCLKEN = 0;
        ClkCfgRegs.SYSPLLMULT.bit.IMULT = 0;
        ClkCfgRegs.SYSPLLCTL1.bit.PLLEN = 0;
        ClkCfgRegs.AUXPLLCTL1.bit.PLLCLKEN = 0;
        ClkCfgRegs.AUXPLLMULT.bit.IMULT = 0;
        ClkCfgRegs.AUXPLLCTL1.bit.PLLEN = 0;
        EDIS;
    #endif
        // BAW
        /*
        EntryAddr = TI_OTP_C1BROM_ESCAPE_POINT_13;
        if((EntryAddr != 0xFFFFFFFF) &&
                (EntryAddr != 0x00000000))
        {
            // if OTP is programmed, then call OTP function
            ((void (*)(void))EntryAddr)();
        }
        */
    
    
        return entryAddr;
    }

    I can try adding the code you mentioned above after the custom bootloader (usb_ex7_host_msc application) finishes writing the usb_ex7_host_msc application to RAM PRIOR to jumping to the usb_ex7_host_msc application.

    Is that what you are suggesting I try?

    Thanks,

    Brent

  • Brent, 

    Are you initializating it to Host mode in your custom bootloader or is it done in the usb_ex7_host_msc application itself?

    You can try adding the above code at the start of the usb_ex7_host_msc application , the code is making sure that the usb is reset and all interrupts are disabled before you start running the usb_ex7_host_msc  application.

    Best Regards

    Siddharth

  • Hi Siddharth,

    Yes, I am initializing the USB for HOST mode in the custom bootloader. Again, the custom bootloader is just the usb_ex7_host_msc application where I added the USB Boot code. So, the custom bootloader is initializing the USB exactly the same way as the usb_ex7_host_msc application.

    Once the custom bootloader is done writing the usb_ex7_host_msc application to RAM (which the custom bootloader read over the USB Host (USB Flash drive)) it jumps to the RAM location and starts executing the usb_ex7_host_msc application. The usb_ex7_host_msc application is running its USB HOST initialization code but the USB is not working at this point.

    I will try adding the code you provided after the custom bootloaders is done writing the usb_ex7_host_msc application to RAM and BEFORE it jumps to the usb_ex7_host_msc application where it will go through its USB HOST initialization.

    Brent

  • Hi Siddharth,

    Yes, I am initializing the USB for HOST mode in the custom bootloader. Again, the custom bootloader is just the usb_ex7_host_msc application where I added the USB Boot code. So, the custom bootloader is initializing the USB exactly the same way as the usb_ex7_host_msc application.

    Once the custom bootloader is done writing the usb_ex7_host_msc application to RAM (which the custom bootloader read over the USB Host (USB Flash drive)) it jumps to the RAM location and starts executing the usb_ex7_host_msc application. The usb_ex7_host_msc application is running its USB HOST initialization code but the USB is not working at this point.

    I will try adding the code you provided after the custom bootloaders is done writing the usb_ex7_host_msc application to RAM and BEFORE it jumps to the usb_ex7_host_msc application where it will go through its USB HOST initialization.

    I notice in the code you have above USB0_BASE. Do you mean 

    #define USB0_BASE_ADDR  0x00040000  //Soprano found in USB_Regs.h?

    Brent

  • Hi Siddharth,

    Unfortunately, I tried the code you provided above but get the same result.

    I keep the USB Flash drive (Pen drive) plugged in the entire time.

    1. In CC run customer bootloader from FLASH.
    2. The custom bootloader - USB Host mode - reads in the usb_ex7_host_msc application from the USB Flash drive (Pen drive) and programs it to RAM.
    3. After jumping to RAM and starting to run the usb_ex7_host_msc application where it initializes the USB for HOST mode and calls ReadLine() where it never returns from.

     while(1)
        {
            //
            // Get a line of text from the user.
            //
            ReadLine();

     

          4. g_eState in ReadLine() never changes from STATE_NO_DEVICE (value 0) to STATE_DEVICE_ENUM

          5. I unplug the USB Flash drive (Pen drive) and plug it back in and CC halts at the following location:

    From the map file 0xd8F0:

    0000d4e7 00000418 device.obj (.text)
    0000d8ff 00000376 usblib_eabi.lib : usbhostenum.obj (.text:USBHostIntHandlerInternal)

    I have also attached 5 captures of the USB registers. Some of the registers are not able to be read. Is there a way to get the contents of these registers?

    custom_bootloader_before_reset.txt - This is the USB registers in the custom bootloader application PRIOR to calling the code you provided. It has programmed RAM with the usb_ex7_host_msc application.

    custom_bootloader_after_reset.txt - This is the USB registers in the custom bootloader application AFTER the code you provided and BEFORE jumping to the usb_ex7_host_msc application.

    usb_ex7_host_msc_fmount.txt - This is the USB registers in the usb_ex7_host_msc application at f_mount(). 

    usb_ex7_host_msc_after_fmount.txt - This is the USB registers in the usb_ex7_host_msc app pausing it when it is running after f_mount(). At this point it is stuck in ReadLine() with no enumeration.

    usb_ex7_host_msc_unplug_plugin.txt - This is the USB registers in the usb_ex7_host_msc app after I unplug the USB Flash drive and plug it back in.

    custom_bootloader_before_reset.txt
    521177 40
    R UsbaRegs_USB_FADDR_POWER 0x0000000F 0x6000
    R UsbaRegs_USBTXIS 0x0000000F 0x6000
    R UsbaRegs_USBRXIS 0x0000000F 0x0000
    R UsbaRegs_USBTXIE 0x0000000F 0x0000
    R UsbaRegs_USBRXIE 0x0000000F 0xFFFE
    R UsbaRegs_USB_IS_IE 0x0000000F 0xFFFE
    R UsbaRegs_USBFRAME 0x0000000F 0x00DD
    R UsbaRegs_USBFIFO0 0x0000000B 0x4B004000
    R UsbaRegs_USBFIFO1 0x0000000B 0x54231990
    R UsbaRegs_USBFIFO2 0x0000000B 0x00010000
    R UsbaRegs_USBFIFO3 0x0000000B 0x00010000
    R UsbaRegs_USBTXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBRXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBTXMAXP1 0x0000000F 0x0040
    R UsbaRegs_USBRXMAXP1 0x0000000F 0x0040
    R UsbaRegs_USBRXCOUNT1 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT2 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT3 0x0000000F 0x1FF8
    R UsbaRegs_USBRQPKTCOUNT1 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT2 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT3 0x0000000F 0x0000
    R UsbaRegs_USBRXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBTXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBEPC 0x0000000B 0x00000005
    R UsbaRegs_USBEPCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBEPCIM 0x0000000B 0x00000001
    R UsbaRegs_USBEPCISC 0x0000000B 0x00000000
    R UsbaRegs_USBDRRIS 0x0000000B 0x80000001
    R UsbaRegs_USBDRIM 0x0000000B 0x00000000
    R UsbaRegs_USBDRISC 0x0000000B 0x00000000
    R UsbaRegs_USBGPCS 0x0000000B 0x00000012
    R UsbaRegs_USBVDC 0x0000000B 0x00000001
    R UsbaRegs_USBVDCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBVDCIM 0x0000000B 0x00000000
    R UsbaRegs_USBVDCISC 0x0000000B 0x00000000
    R UsbaRegs_USBIDVRIS 0x0000000B 0x00000000
    R UsbaRegs_USBIDVIM 0x0000000B 0x00000001
    R UsbaRegs_USBIDVISC 0x0000000B 0x00000000
    R UsbaRegs_USBDMASEL 0x0000000B 0x00332211
    

    custom_bootloader_after_reset.txt
    521177 40
    R UsbaRegs_USB_FADDR_POWER 0x0000000F 0x6000
    R UsbaRegs_USBTXIS 0x0000000F 0x6000
    R UsbaRegs_USBRXIS 0x0000000F 0x0000
    R UsbaRegs_USBTXIE 0x0000000F 0x0000
    R UsbaRegs_USBRXIE 0x0000000F 0xFFFE
    R UsbaRegs_USB_IS_IE 0x0000000F 0xFFFE
    R UsbaRegs_USBFRAME 0x0000000F 0x0000
    R UsbaRegs_USBFIFO0 0x0000000B 0x4B004000
    R UsbaRegs_USBFIFO1 0x0000000B 0x00010000
    R UsbaRegs_USBFIFO2 0x0000000B 0x00010000
    R UsbaRegs_USBFIFO3 0x0000000B 0x00010000
    R UsbaRegs_USBTXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBRXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBTXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT1 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT2 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT3 0x0000000F 0x1FF8
    R UsbaRegs_USBRQPKTCOUNT1 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT2 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT3 0x0000000F 0x0000
    R UsbaRegs_USBRXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBTXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBEPC 0x0000000B 0x00000000
    R UsbaRegs_USBEPCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBEPCIM 0x0000000B 0x00000000
    R UsbaRegs_USBEPCISC 0x0000000B 0x00000000
    R UsbaRegs_USBDRRIS 0x0000000B 0x80000000
    R UsbaRegs_USBDRIM 0x0000000B 0x00000000
    R UsbaRegs_USBDRISC 0x0000000B 0x00000000
    R UsbaRegs_USBGPCS 0x0000000B 0x00000001
    R UsbaRegs_USBVDC 0x0000000B 0x00000000
    R UsbaRegs_USBVDCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBVDCIM 0x0000000B 0x00000000
    R UsbaRegs_USBVDCISC 0x0000000B 0x00000000
    R UsbaRegs_USBIDVRIS 0x0000000B 0x00000000
    R UsbaRegs_USBIDVIM 0x0000000B 0x00000000
    R UsbaRegs_USBIDVISC 0x0000000B 0x00000000
    R UsbaRegs_USBDMASEL 0x0000000B 0x00332211
    

    usb_ex7_host_msc_fmount.txt
    521177 40
    R UsbaRegs_USB_FADDR_POWER 0x0000000F 0x6000
    R UsbaRegs_USBTXIS 0x0000000F 0x6000
    R UsbaRegs_USBRXIS 0x0000000F 0x0000
    R UsbaRegs_USBTXIE 0x0000000F 0x0000
    R UsbaRegs_USBRXIE 0x0000000F 0xFFFE
    R UsbaRegs_USB_IS_IE 0x0000000F 0xFFFE
    R UsbaRegs_USBFRAME 0x0000000F 0x0000
    R UsbaRegs_USBFIFO0 0x0000000B 0x4B004000
    R UsbaRegs_USBFIFO1 0x0000000B 0x4B004000
    R UsbaRegs_USBFIFO2 0x0000000B 0x4B004000
    R UsbaRegs_USBFIFO3 0x0000000B 0x4B004000
    R UsbaRegs_USBTXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBRXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBTXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT1 0x0000000F 0x1FFC
    R UsbaRegs_USBTXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT2 0x0000000F 0x1FFC
    R UsbaRegs_USBTXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT3 0x0000000F 0x1FFC
    R UsbaRegs_USBRQPKTCOUNT1 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT2 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT3 0x0000000F 0x0000
    R UsbaRegs_USBRXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBTXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBEPC 0x0000000B 0x00000005
    R UsbaRegs_USBEPCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBEPCIM 0x0000000B 0x00000001
    R UsbaRegs_USBEPCISC 0x0000000B 0x00000000
    R UsbaRegs_USBDRRIS 0x0000000B 0x80000000
    R UsbaRegs_USBDRIM 0x0000000B 0x00000000
    R UsbaRegs_USBDRISC 0x0000000B 0x00000000
    R UsbaRegs_USBGPCS 0x0000000B 0x00000012
    R UsbaRegs_USBVDC 0x0000000B 0x00000001
    R UsbaRegs_USBVDCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBVDCIM 0x0000000B 0x00000000
    R UsbaRegs_USBVDCISC 0x0000000B 0x00000000
    R UsbaRegs_USBIDVRIS 0x0000000B 0x00000001
    R UsbaRegs_USBIDVIM 0x0000000B 0x00000001
    R UsbaRegs_USBIDVISC 0x0000000B 0x00000001
    R UsbaRegs_USBDMASEL 0x0000000B 0x00332211
    

    usb_ex7_host_msc_after_fmount.txt
    521177 40
    R UsbaRegs_USB_FADDR_POWER 0x0000000F 0x6000
    R UsbaRegs_USBTXIS 0x0000000F 0x6000
    R UsbaRegs_USBRXIS 0x0000000F 0x0000
    R UsbaRegs_USBTXIE 0x0000000F 0x0000
    R UsbaRegs_USBRXIE 0x0000000F 0xFFFE
    R UsbaRegs_USB_IS_IE 0x0000000F 0xFFFE
    R UsbaRegs_USBFRAME 0x0000000F 0x03EC
    R UsbaRegs_USBFIFO0 0x0000000B 0x01000680
    R UsbaRegs_USBFIFO1 0x0000000B 0x00120000
    R UsbaRegs_USBFIFO2 0x0000000B 0x00120000
    R UsbaRegs_USBFIFO3 0x0000000B 0x00120000
    R UsbaRegs_USBTXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBRXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBTXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP1 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT1 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT2 0x0000000F 0x1FF8
    R UsbaRegs_USBTXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT3 0x0000000F 0x1FF8
    R UsbaRegs_USBRQPKTCOUNT1 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT2 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT3 0x0000000F 0x0000
    R UsbaRegs_USBRXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBTXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBEPC 0x0000000B 0x00000005
    R UsbaRegs_USBEPCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBEPCIM 0x0000000B 0x00000001
    R UsbaRegs_USBEPCISC 0x0000000B 0x00000000
    R UsbaRegs_USBDRRIS 0x0000000B 0x40000001
    R UsbaRegs_USBDRIM 0x0000000B 0x00000000
    R UsbaRegs_USBDRISC 0x0000000B 0x00000000
    R UsbaRegs_USBGPCS 0x0000000B 0x00000012
    R UsbaRegs_USBVDC 0x0000000B 0x00000001
    R UsbaRegs_USBVDCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBVDCIM 0x0000000B 0x00000000
    R UsbaRegs_USBVDCISC 0x0000000B 0x00000000
    R UsbaRegs_USBIDVRIS 0x0000000B 0x00000000
    R UsbaRegs_USBIDVIM 0x0000000B 0x00000001
    R UsbaRegs_USBIDVISC 0x0000000B 0x00000000
    R UsbaRegs_USBDMASEL 0x0000000B 0x00332211
    

    usb_ex7_host_msc_unplug_plugin.txt
    521177 40
    R UsbaRegs_USB_FADDR_POWER 0x0000000F 0x6000
    R UsbaRegs_USBTXIS 0x0000000F 0x6000
    R UsbaRegs_USBRXIS 0x0000000F 0x0000
    R UsbaRegs_USBTXIE 0x0000000F 0x0000
    R UsbaRegs_USBRXIE 0x0000000F 0xFFFE
    R UsbaRegs_USB_IS_IE 0x0000000F 0xFFFE
    R UsbaRegs_USBFRAME 0x0000000F 0x046D
    R UsbaRegs_USBFIFO0 0x0000000B 0x4B004000
    R UsbaRegs_USBFIFO1 0x0000000B 0x53425355
    R UsbaRegs_USBFIFO2 0x0000000B 0x00040932
    R UsbaRegs_USBFIFO3 0x0000000B 0x00040932
    R UsbaRegs_USBTXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBRXFIFOADD 0x0000000F 0x0000
    R UsbaRegs_USBTXMAXP1 0x0000000F 0x0040
    R UsbaRegs_USBRXMAXP1 0x0000000F 0x0040
    R UsbaRegs_USBRXCOUNT1 0x0000000F 0x1FFC
    R UsbaRegs_USBTXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP2 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT2 0x0000000F 0x1FF4
    R UsbaRegs_USBTXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXMAXP3 0x0000000F 0x0000
    R UsbaRegs_USBRXCOUNT3 0x0000000F 0x1FF4
    R UsbaRegs_USBRQPKTCOUNT1 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT2 0x0000000F 0x0000
    R UsbaRegs_USBRQPKTCOUNT3 0x0000000F 0x0000
    R UsbaRegs_USBRXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBTXDPKTBUFDIS 0x0000000F 0x0000
    R UsbaRegs_USBEPC 0x0000000B 0x00000005
    R UsbaRegs_USBEPCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBEPCIM 0x0000000B 0x00000001
    R UsbaRegs_USBEPCISC 0x0000000B 0x00000000
    R UsbaRegs_USBDRRIS 0x0000000B 0x80000001
    R UsbaRegs_USBDRIM 0x0000000B 0x00000000
    R UsbaRegs_USBDRISC 0x0000000B 0x00000000
    R UsbaRegs_USBGPCS 0x0000000B 0x00000012
    R UsbaRegs_USBVDC 0x0000000B 0x00000001
    R UsbaRegs_USBVDCRIS 0x0000000B 0x00000000
    R UsbaRegs_USBVDCIM 0x0000000B 0x00000000
    R UsbaRegs_USBVDCISC 0x0000000B 0x00000000
    R UsbaRegs_USBIDVRIS 0x0000000B 0x00000000
    R UsbaRegs_USBIDVIM 0x0000000B 0x00000001
    R UsbaRegs_USBIDVISC 0x0000000B 0x00000000
    R UsbaRegs_USBDMASEL 0x0000000B 0x00332211
    

  • Just to provide a little more information.

    Since CC register view was not displaying some of the USB registers, I went to the base address in the memory window (0x40000).  Before you mentioned wanted to know the value of USBDEVCTL (offset 0x60). 

    I ran the usb_ex7_host_msc application in CC in RAM. I set a break point at f_mount(). The value of this register is 0x5D.

    I then ran the custom bootloader which loads the usb_ex7_host_msc application into RAM. I set a break point at f_mount(). The value of USBDEVCTL is also 0x5D.

    Are there other registers you want values of?

    Thanks for your help,

    Brent

  • Brent,

    USBDEVCTL's value of 0x5D indicates that it is in host mode.  To move from the STATE_NO_DEVICE to STATE_DEVICE_ENUM, it has to detect the device connected . This happens when there is a change in the USB signals which triggers an interrupt.  

    If I ran the usb_ex7_host_msc from RAM and connect/disconnect the mass storage device, it detects it without any issue.  I am not sure why it is not detectng the device in this case.  Will take a look at the register dumps that you shared to see if I find something.

    Best Regards

    Siddharth

  • Thanks Siddharth,

    If there are registers you want the values for that do not appear in the register dump but in the memory view let me know.

    Brent

  • Brent, 

    Sure, will take a look and get back to you with any suggestions to resolve this issue.

    Best Regards

    Siddharth

  • Hi Siddharth,

    I wanted to give you all the USB registers, so I did a memory dump.

    Running in CC with the original usb_ex7_host_msc application out of the SDK I set a break point at f_mount() while running out of RAM. I did a memory dump at this breakpoint starting at 0x40000 through 0x40454.

    I did the same thing in the case where the custom bootloader loaded the usb_ex7_host_msc application .dat file from a USB Flash drive (Pen drive) into RAM, jumped to RAM and hit a breakpoint at f_mount().

    The attached spreadsheet shows you the contents of the USB registers and where they differ, I highlighted the rows in yellow.

    I have a column which shows use the offset off the base USB register location. For example, in the spreadsheet in the offset column, 0x60 corresponds to the USBDEVCTL register.

    Hope this helps.

    Brent

    4212.USB_Registers.xlsx

  • Brent,

    I ran the usb_ex7_host_msc application from RAM with a Flash drive connected to it. It was able to detect it and worked fine.  Then I reset the PC to run from the main function again , this time it detected it as a unknown device.  However, if I do a CPU reset and then rerun the program, it works fine.  I still need to debug further what the CPU reset actually does and if it can be simulated in software. Will keep you posted.

    Best Regards

    Siddharth

  • Thank you for looking into this.

  • Brent , 

    I am yet to figure out how to simulate a CPU reset , was unable to spend time on this today. 

    Will let you know if I figure out something.

    Best Regards

    Siddharth

  • Hi Siddharth,

    Just following up on this. Any progress?

    Thanks,

    Brent

  • Hi Siddharth,

    Any thoughts or progress on what would need to be done to the usb_ex7_host_msc application code to allow your test case to work?

    I can perform the same test with the LED blink application and others. Specifically:

    1. Run Blink LED application from CC
    2. Pause application
    3. Reset PC to main of Blink LED application
    4. Select Resume

    This works. This tells me there is something in the usb_ex7_host_msc application initialization code that is not quite correct.

    Thanks for your help,

    Brent

  • Brent,

    Rerunning the usb_ex7_host_msc example from the code start or the code entry point works for me. Here are the steps that I tried

    1. Load usb_ex7_host_msc to RAM 

    2. Run it , it detects the mass storage device

    3. pause

    4. Set the PC to the code_start or the entry point

    5. Run the code again

    6. It is able to detect the already connected usb mass storage. 

    If you set the PC to main instead of the code_start , it doesn't work.

    Please try and let me know if this works.

    Best Regards

    Siddharth 

  • Hi Siddharth,

    It does not quite work. I follow your steps.

    1. Load usb_ex7_host_msc to RAM 

    2. Run it, it detects the mass storage device. I also run the ls command.

    3. Pause - you can see when I pause it that the application is running in RAM

    4. Set the PC to the code_start or the entry point. 

    5. Run the code again

    You can see it does NOT show - "Mass storage device connected." and as a result I can no longer type in commands.

    If I then try unplugging the USB Flash drive and plugging it in it errors out in device.

    //*****************************************************************************
    //
    // Error handling function to be called when an ASSERT is violated
    //
    //*****************************************************************************
    void __error__(const char *filename, uint32_t line)
    {
        //
        // An ASSERT condition was evaluated as false. You can use the filename and
        // line parameters to determine what went wrong.
        //
        ESTOP0;
    }

     

    This is from the .map file from the usb_ex7_host_msc example. I believe from what you stated I should be entering 0x0000 for the PC after I pause the application and before I start it again?

    codestart 
    *          0    00000000    00000002     
                      00000000    00000002     F2837xD_CodeStartBranch.obj (codestart)

    This is the usb_ex7_host_msc example from the SDK running of RAM.

    Any thoughts on why it is not working?

    Thanks for your help,

    Brent

  • Brent, 

    It works for me , these are the steps that I did.   It's exactly the same steps that you have done, so am not sure what could be going wrong.

    Yes, the entry point is correct , PC should have 0x000 after pausing .

    1. Load usb_ex7_host_msc to RAM 

    2. Run it, it detects the mass storage device. I also run the ls command.

    3. Pause 

    4.  Set the PC to the code_start or the entry point

    5. Run the code again

    Best Regards

    Siddharth

  • Hi Siddharth,

    That is really perplexing. Below I am detailing my steps to see where we are differing. I do notice you have print outs to the console where I do not?? How have you modified the application.

    1) In CC I import the MSC project from C:\ti\c2000\C2000Ware_5_00_00_00\driverlib\f2837xd\examples\cpu1\usb

    2) Select CPU1

    3) Try building the application to run out of RAM. NOTE: It will not build right after importing the project from the TI SDK. The linker command file does not allocate enough memory for the application.

    Do you see this also??

     

    4) Modify the linker command file so the application will build. How did you modify the linker command file to get it to build successfully??

     

    5) Download application into the RAM

    6) Run the application. You can see that it is connected/mounted to the USB device. I can perform a "ls" command. Everything works great.

    7) I pause the application.

     

    8) I set the PC to 0x0000.

    9) I select resume. As shown below the USB is never connected/mounted to. I can no longer type anything in the terminal window. I pause the application to show the call stack and current PC.

    I am using a F2837x controlCard with a docking station.

    Are your steps different from mine at all? I am using C2000Ware 5.00 and CC Version: 12.3.0.00005.

    Thank you for your help,

    Brent

  • Brent, 

    I was using the TMDSCNCD28388D control card earlier but I have also verified the same example on TMDSCNCD28379D control card.  

    I have imported the same example from C:\ti\c2000\C2000Ware_5_00_00_00\driverlib\f2837xd\examples\cpu1\usb and see the compilation error and I have fixed it by updating the linker command file 

      .data            : >> RAMGS5 | RAMGS6to11_combined,    PAGE = 1

    Howvever if I pause , reset the PC to 0x0 and then run it again, it works fine. 

    One thing to note it that there is a dual selector-switch on the TMS320F28379D Control Card labeled 'A:SW1' and it contains two switches.  Out of the box, Switch '1' is in the 'ON' position and Switch '2' is in the 'OFF' position .  Switch '2' needs to be in the 'ON' position in order to connect the MCU's pin(SCI-RX) to the FTDI chip.    However I don't think this might be the cause since the "ls" command works for you during the first time. 

    Best Regards

    Siddharth

  • Hi Siddharth,

    With you stating that you were using the same steps, application, and hardware, the only difference I could see was the actual USB Flash drive. I found another one and your test case now works. 

    My USB firmware update with the USB Flash drive with the custom USB bootloader and customer USB flash kernel now works.

    I do see the same issue that the SDK USB flash programmers has with larger binary files since my custom USB flash kernel is based on the one in the SDK.: 

    TMDSCNCD28379D: USB Flash Programmer does not work with larger files - C2000 microcontrollers forum - C2000Tm︎ microcontrollers - TI E2E support forums

    Brent