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.

TM4C129X Evaluation Board and boot-demo-usb not working. Why?

Other Parts Discussed in Thread: TM4C1294KCPDT, LMFLASHPROGRAMMER

Hi,
I'm porting my LM3S9B96 application with its bootloader to my new TM4C1294KCPDT. Everything now seems to work (thanks to suggestions) except USB in bootloader. So to check if this is a software rather than an hardware problem, I tried to load a Tivaware demo, and it also failed. Not sure about the demo was working, I tested it on the evaluation board and... surprise! It's not working also on that board. So? What to do now?

Let's start from the beginning: the demo I'm trying is boot-demo-usb located in "SW-TM4C-2.1.1.71\examples\boards\dk-tm4c129x\boot_demo_usb". The demo should show up a composite device with a simulated mouse and a DFU interface (ok, perhaps I should have chosen a simpler demo, shouldn't I?).

Loading firmware with ICDI and starting application shows the "Waiting for host..." message on screen. Connecting the USB cable in the USB ON THE GO connector does not change anything. Device does not show up in Window's Device Manager.

After further investigation I found that no USB interrupt is fired from the USB peripheral. To do so I simply wrote down this interrupt routine:

void myUSB0DeviceIntHandler(void)
{
		// call real interrupt handler
		USB0DeviceIntHandler();
}

Then I imported myUSB0DeviceIntHandler in my startup file instead of the original interrupt handler, placed a breakpoint in myUSB0DeviceIntHandler and waited... But no interrupt came up when connecting or disconnecting wire or trying to enumerate devices.

My final goal is to verify if it is possible to make USB0 to work with only DP/DM wire couple, without VBUS, ID, ... and so on, as the final design only involves the two data lines.

  • Hello Stefano,

    Since you are using the DK-TM4C129x I would first suggest loading the existing bin file in the example project to see if the board is fine. Have you attempted that step?

    Regards
    Amit
  • Hi Amit,
    I tried to load the precompiled executable with LMFlashProgrammer, but results are the same:


    Board is powered with external supply. All jumpers should be in the correct position.

    Do you think the board can have some hardware problem? Is there any other test I can do?

    Thanks,
    Stefano

  • Hello Stefano

    Did you check the device manager has the correct drivers installed for the application?

    Regards
    Amit
  • Hi Amit,
    unfortunately device does not appear in device manager, neither with the infamous yellow question mark. I don't have a speaker with my PC, but I think I wouldn't hear the ding-dong when connecting it (just why my cursor on PC never changes into an hourglass as it is supposed to do when new hardware is being installed).
    Just to be sure I also plugged the board into another PC with a different O.S., but nothing happened; I suspect there is an hardware fault on the board. I'll try next Monday to load a different firmware for testing.

    In the meantime, I would like to have your kindly help for understanding the basic knowledge of my initial problem: as on my board only DP/DM data lines are coupled to the USB connector from the Tiva, will it work as an host or a device controlling its status only by firmware (as LM3S did on the previous board version)? Basically I would like to know if missing VBUS monitoring will lead to any problem in detecting the device from PC (when it's activated in DFU Bootloader mode).

    Please keep in mind that I'm using a customized bootloader, so I can eventually add any library call I need for turning the peripheral in device mode.

    In my final application, in turn, I would need to activate the host mode when I'll have to transfer data to a pen drive; VDD is brought to USB connector with a diode, to avoid the device is being powered when connected to PC for programming.

    Thanks and have a nice weekend,
    Stefano
  • Hello Stefano,

    My understanding is that to be able to work as a host or device in OTG mode Session Request signalling needs to be done which requires VBUS and ID pin monitoring. The only thing that can be done when DP and DM are connected is forced Host or forces Device mode.

    Also I did check the boot_demo_usb and the device manager shows a DFU class device. Hopefully I can send you the screen snapshots of every step for DK-TM4C129x with boot_demo_usb so that it can be used to check your setup.

    One quick check would be to erase the main MCU flash and connect the USB connector. if it does not show the ROM USB DFU, then it could be an issue with the USB section.

    Regards
    Amit
  • Hi Amit,
    I tried as you suggested to fully erase flash and... WOW USB DFU appeared. I was able to load boot-demo-usb with LMFlashProgrammer by DFU, so I can confirm that USB is correctly working. But now, what can be the problem with the demo code? It still does not show up in device manager. Do you have a board like mine to test?

    Thanks,
    Stefano
  • I also tried to do the same thing on my own custom device, and internal bootloader works even without VBUS and ID pin, i.e. only with DP/DM. I was able to firmware my bootloader with the internal bootloader! I only have to discover why USB is not working in my own bootloader...
  • Hello Stefano

    Things to check.

    1. Check if the crystal frequency used in your boot loader matches the one on the board
    2. Check the configuration of the USB being done by the custom boot loader when the same gets flashed using a debugger.

    Regards
    Amit
  • Hi Amit,
    finally I managed to make it work!

    I started from this article in the wiki, found searching on the support forum. So I had the suspect that device was not properly turning on in device mode. I modified the source code of boot-demo-usb adding the following line

        //
        // Set the USB stack mode to Device mode with VBUS monitoring.
        //
        USBStackModeSet(0, eUSBModeForceDevice, 0);
    

    just before USBDHIDMouseCompositeInit call, and suddenly boot-demo-usb started to work.

    Then I did the same test on usb_dev_serial demo. The plain code was not running on my demo board, no USB interrupt arrived. So I opened usb_dev_serial.c and changed the following line

        //
        // Set the USB stack mode to Device mode with VBUS monitoring.
        //
        USBStackModeSet(0, eUSBModeDevice, 0);
    

    into this one

        //
        // Set the USB stack mode to Device mode with VBUS monitoring.
        //
        USBStackModeSet(0, eUSBModeForceDevice, 0);

    and also usb_dev_serial demo started working.

    And so came my bootloader turn to work. As it's not using usblib, I couldn't call USBStackModeSet directly. I had to dig into usblib to find that the magic is done by writing the correct bit into USB's GPCS register (that is not documented in TM4C129KCPDT datasheet as it's marked as under NDA). Basically I modified the USBBLInit found in bl_usbfuncs.c in this way:

    void
    USBBLInit(void)
    {
        bool bForceDevice = true; //<<<<<<<<<<<<<< ADDED CODE
    	
        //
        // Configure the USB Pins based on the bl_config.h settings.
        //
    #if defined(USB_VBUS_CONFIG) || defined(USB_ID_CONFIG) || \
        defined(USB_DP_CONFIG) || defined(USB_DM_CONFIG)
        USBConfigurePins();
        bForceDevice = false; //<<<<<<<<<<<<<< ADDED CODE
    #endif
    
        //
        // Initialize a couple of fields in the device state structure.
        //
        g_sUSBDeviceState.ui32Configuration = DEFAULT_CONFIG_ID;
    
        //
        // Enable the USB controller.
        //
        HWREG(SYSCTL_RCGCUSB) = SYSCTL_RCGCUSB_R0;
    
        //
        // Wait for the peripheral ready
        //
        while((HWREG(SYSCTL_PRUSB) & SYSCTL_PRUSB_R0) != SYSCTL_PRUSB_R0)
        {
        }
    
    #if defined(TARGET_IS_TM4C129_RA0) ||                                         \
        defined(TARGET_IS_TM4C129_RA1) ||                                         \
        defined(TARGET_IS_TM4C129_RA2)
        //
        // Turn on USB Phy clock from PLL VCO
        //
        HWREG(USB0_BASE + USB_O_CC) = (USB_CC_CLKEN | (7 << USB_CC_CLKDIV_S));
    #else
        //
        // Turn on USB Phy clock.
        //
        HWREG(SYSCTL_RCC2) &= ~SYSCTL_RCC2_USBPWRDN;
    #endif
    
        //
        // Clear any pending interrupts.
        //
        HWREGH(USB0_BASE + USB_O_TXIS);
        HWREGB(USB0_BASE + USB_O_IS);
    		
        //
        // Check if USB must be forced in device mode as there is no hardware way to do so
        //
        if (bForceDevice)                                          //<<<<<<<<<<<<<< ADDED CODE
        {                                                          //<<<<<<<<<<<<<< ADDED CODE
            HWREGH(USB0_BASE + USB_O_GPCS) |= USB_GPCS_DEVMOD;     //<<<<<<<<<<<<<< ADDED CODE
        }                                                          //<<<<<<<<<<<<<< ADDED CODE
    
        //
        // Enable USB Interrupts.
        //
        HWREGH(USB0_BASE + USB_O_TXIE) = USB_TXIS_EP0;
        HWREGB(USB0_BASE + USB_O_IE) = (USB_IS_DISCON | USB_IS_RESET);
    
        //
        // Default to the state where remote wakeup is disabled.
        //
        g_sUSBDeviceState.ui8Status = 0;
        g_sUSBDeviceState.bRemoteWakeup = false;
    
        //
        // Determine the self- or bus-powered state based on bl_config.h setting.
        //
    #if USB_BUS_POWERED
        g_sUSBDeviceState.ui8Status &= ~USB_STATUS_SELF_PWR;
    #else
        g_sUSBDeviceState.ui8Status |= USB_STATUS_SELF_PWR;
    #endif
    
        //
        // Attach the device using the soft connect.
        //
        HWREGB(USB0_BASE + USB_O_POWER) |= USB_POWER_SOFTCONN;
    
        //
        // Enable the USB interrupt.
        //
        HWREG(NVIC_EN1) = 1 << (INT_USB0 - 48);
    }

    And that did the trick.

    My final thoughts:

    1. As nobody seems to have found the same problem on the evaluation board, I should have a faulty board or a faulty uC on board, on which VUSB is not correctly detected the way that device mode, if not forced, does never start to work
    2. I tried to pull out all of the J25 jumpers from evaluation board, and board is still detected with the modified demo code, so it' true that device mode is really forced
    3. ROM bootloader seems to use only DP/DM pins, as it works both on the evaluation board, without J25 jumpers inserted,  and on my board, which uses only DP/DM, so it has to force device mode for sure

    Thanks for your support and regards,
    Stefano

  • Hello Stefano,

    I believe I was closing on the same when I said. Glad to see you running full steam ahead.

    "2. Check the configuration of the USB being done by the custom boot loader when the same gets flashed using a debugger."

    Regards
    Amit