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.

USB DFU bootloader not working TM4C1233D5PM

Other Parts Discussed in Thread: TM4C123GH6PM, EK-TM4C123GXL, TM4C1233D5PM, TM4C123GE6PM

Am unable to get this device to enumerate as a USB DFU using either dfuprog -e or LM Flash Programmer. We're using this part on our own board which is based off the LaunchPad design (TM4C123GH6PM) and confident the part is working. We can enumerate it as a CDC virtual COM port with no problem so pretty sure the hardware is working.

However, we've tried taking sample code both from this forum and from sample code in TivaWare2.0 usb_dev_bulk.c and boot_demo_usb.c to no avail.

Wonder if someone can take a look at the code and offer any suggestions? We've been struggling with this for quite a while and would be grateful for any input.

Many many thanks.

int
main(void)
{

// Enable lazy stacking for interrupt handlers. This allows floating-point

// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPULazyStackingEnable();

//
// Set the clocking to run from the PLL at 50MHz
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);

//
// Configure the required pins for USB operation.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_4);

#define SYSTICKS_PER_SECOND 100
uint32_t ui32SysClock = ROM_SysCtlClockGet();
ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
ROM_SysTickIntEnable();
ROM_SysTickEnable();

//USBDCDTerm(0);  // Doesn't make any difference

// Disable all interrupts
ROM_IntMasterDisable();
ROM_SysTickIntDisable();
ROM_SysTickDisable();
HWREG(NVIC_DIS0) = 0xffffffff;
HWREG(NVIC_DIS1) = 0xffffffff;

// 1. Enable USB PLL
// 2. Enable USB controller
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);ROM_SysCtlUSBPLLEnable();

ROM_SysCtlUSBPLLEnable();

// 3. Enable USB D+ D- pins

// 4. Activate USB DFU
ROM_SysCtlDelay(ui32SysClock / 3);
ROM_IntMasterEnable(); // Re-enable interrupts at NVIC level
ROM_UpdateUSB(0);
// 5. Should never get here since update is in progress

}

  • There was a posting with a similar problem in this forum under the title:

    TI-RTOS USB DFU mode problem

    Tried the code in that posting, but still no luck. Like them, I'm using an RTOS, but FreeRTOS, however, the code never reaches the point of starting it up and the NVIC entries are cleared in the code from that posting.

    Still searching for an answer.

  • I also tried: 

    FlashErase(0x00000000);

    suggested also by Kalefa Mohammed but device still not entering DFU mode.

    Am I missing something fundamental here?

  • I tried running the above code on the LaunchPad ED-TM4C123GXL board by inserting it at the top of the blinky demo program. Downloaded the code through the ICDI Debug port on that board and then switched the USB cable to the Device slot and changed the slide switch to Device.

    Still cannot see the DFU device using 'dfuprog -e'. However, can see the ICDI device (U2 on the board) acting as a DFU class when the USB cable is plugged into the Debug USB port. So I know everything is working on the Windows PC side.

    Would still greatly appreciate any help with this problem.

    Many thanks for reading this far!

  • Hi Gareth,

    I used Project0 and pasted in your code, added a pair of #includes and everything worked ok.

    7271.DFU_app.c
    //*****************************************************************************
    //
    // project0.c - Example to demonstrate minimal TivaWare setup
    //
    // Copyright (c) 2012-2013 Texas Instruments Incorporated. All rights reserved.
    // Software License Agreement
    //
    // Texas Instruments (TI) is supplying this software for use solely and
    // exclusively on TI's microcontroller products. The software is owned by
    // TI and/or its suppliers, and is protected under applicable copyright
    // laws. You may not combine this software with "viral" open-source
    // software in order to form a larger program.
    //
    // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
    // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
    // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
    // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
    // DAMAGES, FOR ANY REASON WHATSOEVER.
    //
    // This is part of revision 2.0.1.11577 of the EK-TM4C123GXL Firmware Package.
    //
    //*****************************************************************************
    
    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "inc/hw_nvic.h" 	//added by MS
    #include "driverlib/rom.h"  //added by MS
    
    //*****************************************************************************
    //
    // Define pin to LED color mapping.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    //! \addtogroup example_list
    //! <h1>Project Zero (project0)</h1>
    //!
    //! This example demonstrates the use of TivaWare to setup the clocks and
    //! toggle GPIO pins to make the LED's blink. This is a good place to start
    //! understanding your launchpad and the tools that can be used to program it.
    //! See http://www.ti.com/tm4c123g-launchpad/project0 for more information and
    //! tutorial videos.
    //
    //*****************************************************************************
    
    #define RED_LED GPIO_PIN_1
    #define BLUE_LED GPIO_PIN_2
    #define GREEN_LED GPIO_PIN_3
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    
    //*****************************************************************************
    //
    // Main 'C' Language entry point. Toggle an LED using TivaWare.
    // See http://www.ti.com/tm4c123g-launchpad/project0 for more information and
    // tutorial videos.
    //
    //*****************************************************************************
    int
    main(void)
    {
    // Enable lazy stacking for interrupt handlers. This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();
    
    //
    // Set the clocking to run from the PLL at 50MHz
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);
    
    //
    // Configure the required pins for USB operation.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_4);
    
    #define SYSTICKS_PER_SECOND 100
    uint32_t ui32SysClock = ROM_SysCtlClockGet();
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();
    
    //USBDCDTerm(0); // Doesn't make any difference
    
    // Disable all interrupts
    ROM_IntMasterDisable();
    ROM_SysTickIntDisable();
    ROM_SysTickDisable();
    HWREG(NVIC_DIS0) = 0xffffffff;
    HWREG(NVIC_DIS1) = 0xffffffff;
    
    // 1. Enable USB PLL
    // 2. Enable USB controller
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
    
    //ROM_SysCtlUSBPLLEnable();
    
    ROM_SysCtlUSBPLLEnable();
    
    // 3. Enable USB D+ D- pins
    
    // 4. Activate USB DFU
    ROM_SysCtlDelay(ui32SysClock / 3);
    ROM_IntMasterEnable(); // Re-enable interrupts at NVIC level
    ROM_UpdateUSB(0);
    // 5. Should never get here since update is in progress
    } 
    

    Did you copy in the startup source file for your IDE into your project (startup_ccs.c, startup_ewarm.c, etc)?

  • Hi Michael,

    Thank you so much for taking a look at my problem. Unfortunately I'm still unable to get the USB DFU class to show up using either 'dfuprog -e' or in the 'LM flash programmer'.

    I'm using IAR 6.4 and C:\ti\TivaWare_C_Series-2.0.1.11577\examples\boards\ek-tm4c123gxl\project0

    Setting the processor type in IAR to LM4F230H5QR when using the Tiva C Series LaunchPad (processor hardware is TM4C123G) and when using our own board LM4F120C4QR (processor is TM4C1233D5PM).

    When using the LaunchPad hardware I flash with the USB cable plugged in to the Debug USB port near the slide switch (set to Debug). But then, I assume, have to switch the USB cable to the Device port on the side of the card which connects to the processor U1 chip which was just flashed. No DFU class shows up with either 'dfuprog -e' or 'LM Flash programmer'. Note that if the USB cable is switched back to the Debug port (connected to the programming U2 chip, a DFU class device does show up with 'dfuprog -e' but this is not the chip that was just flashed).

    My apologies if I'm missing something obvious here. Have tried to give you as many details as possible. Could you let me know how you're getting the DFU to show up on the LaunchPad hardware?

    Thanks again for your help here.

    Gareth

  • I'm using IAR 6.4 and C:\ti\TivaWare_C_Series-2.0.1.11577\examples\boards\ek-tm4c123gxl\project0

    Setting the processor type in IAR to LM4F230H5QR when using the Tiva C Series LaunchPad (processor hardware is TM4C123G) and when using our own board LM4F120C4QR (processor is TM4C1233D5PM).

    But then, I assume, have to switch the USB cable to the Device port on the side of the card which connects to the processor U1 chip which was just flashed. No DFU class shows up with either 'dfuprog -e' or 'LM Flash programmer'..

    When you use the the DEVICE USB connection along the left edge, do you change the power switch at the top to DEVICE?  

  • Hi Michael,

    Yes, I switch the USB cable to the left edge connector (labeled DEVICE) and move the power switch to DEVICE and the green PWR LED lights up. 

    Just tried it again and still no DFU shows up in 'dfuprog -e'. Are you using a different procedure? I know I can program the device because the other sample programs work (e.g. blinky). Am still puzzled that this fails on both the TI board and my own board (which works fine in every other respect).

    Many thanks again!

    Gareth

  • Gareth,

    Are you using the source file that I posted?  If you're using a different source file, respond and attach it please.

    Also, check device manager for any unknown entries.  Everything may be running ok but if the drivers are corrupt or the device isn't enumerating, dfuprog and lmflash won't know what is connected.

  • Thanks Michael. Great suggestion. Under 'Device Manager' I see 'Other devices' -> 'Stellaris Device Firmware Update' and if I unplug the device it gets removed from the list. 

    Still nothing from 'dfuprog -e'. Have I not installed a driver? Remember that if I plug into the Debug USB port, it does enumerate the In-Circuit Debug Interface.

    Gareth

  • Hi Gareth,

    Interesting... what OS are you running?  In both XP and 7, it properly enumerates as "Stellaris/Tiva Device Firmware Upgrade > Stellaris/Tiva Device Firmware Upgrade".  Right-click the entry, check Properties, and check the details tab.  What are the USB VID and PID?  

    Also, you may want to try right-clicking and uninstalling this entry, disconnect then reconnect and point it to the windows_Drivers folder in Tivaware.  Also, once you install the drivers, you get a warning that they will not work until you reset you system.

  • Hi Michael,

    That was it! From the Device Manager under Windows 7 I installed the drivers from C:\ti\TivaWare_C_Series-2.0.1.11577\windows_drivers and it now enumerates property under both dfuprog and the LM Flash Programmer. I'm feeling very stupid for missing this but am glad you were able to find the problem. Thanks so much!

    We all really appreciate your help and are glad just to be off and running again.

    Gareth

  • Hey so I've got a similar problem as Gareth.  I've copied the code you guys are using and I don't get anything in device manager...no warnings or signs that a device (even one that isn't working or doesn't have drivers) exists.  I'm trying to go into the boot loader upon receiving a command over USB.  The command gets to the TM4C123GE6PM and I can hear the device disconnect in windows and I see it disappear under the hid devices since it's a hid device, but I see no DFU device (or any device for that matter) appear.  Here is the code I execute upon receiving the command.

            		// Launch boot loader
            		case 0x07:
        				//
        				// Terminate the USB device and detach from the bus.
        				//
        				USBDCDTerm(0);
    
        				//
        				// Disable all interrupts.
        				//
        				ROM_IntMasterDisable();
    
        				//
        				// Disable SysTick and its interrupt.
        				//
        				//ROM_SysTickIntDisable();	// Not using SysTick()
        				//ROM_SysTickDisable();
    
        				//
        				// Disable all processor interrupts.  Instead of disabling them one at a
        				// time, a direct write to NVIC is done to disable all peripheral
        				// interrupts.
        				//
        				HWREG(NVIC_DIS0) = 0xffffffff;
        				HWREG(NVIC_DIS1) = 0xffffffff;
    
        				//
        				// Enable and reset the USB peripheral.
        				//
        				ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
        				ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
        				ROM_SysCtlUSBPLLEnable();
    
        				//
        				// Wait for about a second.
        				//
        				ROM_SysCtlDelay(SysCtlClockGet());
    
        				//
        				// Re-enable interrupts at the NVIC level.
        				//
        				ROM_IntMasterEnable();
    
        				//
        				// Call the USB boot loader.
        				//
        				ROM_UpdateUSB(0);
    
            			break;

    I would try to reload the drivers, but I don't have that option because I get nothing in the device manager.  I also commented out SysTick because I don't use it at all.  The project works fine communicating back and forth to my computer, it just seems like I'm missing something small to kick off the DFU. 

    One thing to note is that I just plugged this code in without editing my tm4c123ge6pm.cmd file.  I was under the impression that I could at least launch the boot loader and see the DFU class without having to modify that.  Is that correct?  Should I be able to see it enumerate as DFU from just running the above code?

    Thanks,

    Rob

  • So I finally got this boot loader to launch and work correctly for my part.  I figured I'd post up the solution in case someone else had similar problems.

    			//
    			// Terminate the USB device and detach from the bus.
    			//
    			USBDCDTerm(0);
    
    			//
    			// Disable all interrupts.
    			//
    			ROM_IntMasterDisable();
    
    			//
    			// Disable SysTick and its interrupt.
    			//
    			ROM_SysTickIntDisable();	// Not using SysTick()
    			ROM_SysTickDisable();
    
    			//
    			// Disable all processor interrupts.  Instead of disabling them one at a
    			// time, a direct write to NVIC is done to disable all peripheral
    			// interrupts.
    			//
    			HWREG(NVIC_DIS0) = 0xffffffff;
    			HWREG(NVIC_DIS1) = 0xffffffff;
    		    HWREG(NVIC_DIS2) = 0xffffffff;
    		    HWREG(NVIC_DIS3) = 0xffffffff;
    		    HWREG(NVIC_DIS4) = 0xffffffff;
    
    			//
    			// Enable and reset the USB peripheral.
    			//
    			ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    			ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
    			ROM_SysCtlUSBPLLEnable();
    
    			//
    			// Wait for about a second.
    			//
    			ROM_SysCtlDelay(Sys_Clock / 3);
    
    
    			//
    			// Re-enable interrupts at the NVIC level.
    			//
    			ROM_IntMasterEnable();
    
    			//
    			// Call the USB boot loader.
    			//
    			ROM_UpdateUSB(0);

  • I was very interested to see the additional disable calls to the interrupt controller and should have done that in the original posting. Many thanks for the update and glad to hear you're up and running.