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.

TM4C DFU boot loader wont proc

Other Parts Discussed in Thread: TM4C1233H6PM

Greetings!

I am currently trying to get the bootloader USB DFU on our project board to proc when the flash is erased/empty.

I tested this functionality out on a LaunchPad Tiva C series and it worked. The flash was empty, BOOTCFG was set at default to satisfy condition 3;

3. If the EN bit is set or the status doesn't match the specified polarity, the data at address
0x0000.0004 is read, and if the data at this address is 0xFFFF.FFFF, the ROM is mapped to
address 0x0000.0000 and execution continues out of the ROM Boot Loader.

;There is an external clock set at 16MHz, USB header is properly attached and plugged in to a PC.

The eval board comes right up as a DFU device and I can flash it. On our project board nothing comes up on the PC. 

Things I have done:

  • I checked the boot loader code between the eval board and project board and there are differences, but what those differences do I haven't figured out yet. 
  • When the boot loader runs on the eval board it sets the USB registers. When the boot loader on our project board runs the USB registers are not set from other then their default value.
  • I can get the USB DFU to proc on our project board by uploading a small app that purposefully procs the USB DFU Boot loader. See code below.
#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c1233h6pm.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
#include "driverlib/rom_map.h"  //added by MS

//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Blinky (blinky)</h1>
//!
//! A simple app that procs the USB DFU
//
//*****************************************************************************

//*****************************************************************************
//
// Proc USB DFU
//
//*****************************************************************************
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
    //

    MAP_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL  | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ | SYSCTL_INT_OSC_DIS);

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

    #define SYSTICKS_PER_SECOND 100
    uint32_t ui32SysClock = MAP_SysCtlClockGet();
    MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    MAP_SysTickIntEnable();
    MAP_SysTickEnable();

    // Disable all interrupts
    MAP_IntMasterDisable();
    MAP_SysTickIntDisable();
    MAP_SysTickDisable();
    HWREG(NVIC_DIS0) = 0xffffffff;
    HWREG(NVIC_DIS1) = 0xffffffff;

    // 1. Enable USB PLL
    // 2. Enable USB controller
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);

    MAP_SysCtlUSBPLLEnable();

    // 3. Enable USB D+ D- pins

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

Any input and or advice on how to get our USB DFU to proc would be greatly appreciated.

-Matt

Edit: spelling

  • Hi Matt,

         So, you are loading the same firmware at your Tiva Launchpad and Project board? But, at the Project board it did not work. Seems, like the problem might be caused by hardware design.

         Did you use the Tiva Launchpad as reference for your project board design?

    - kel

  • According to our hardware engineer it was based on the Launchpad. The external clock is connected and running at 16MHz.

    It is not a problem of loading firmware on the board. I can load firmware on the board and run it as mentioned in one of the above bullets. It is a problem of the boot loader not starting up USB DFU on the custom project board when the flash is erased.

    I can tell the boot loader on the custom board is running by watching and stepping through the boot loader code. The boot loader is just not kicking off the USB DFU.

    Upon further investigation I discovered that the custom board boot loader is not setting the system control register RCC value properly.

    Custom Board RCC register:

    SYSCTL_RCC	0x078E3D51	Run-Mode Clock Configuration [Memory Mapped]	
    	SYSCTL_RCC_ACG	        0	Auto Clock Gating	
    	SYSCTL_RCC_SYSDIV	1111	System Clock Divisor	
    	SYSCTL_RCC_USESYSDIV	0	Enable System Clock Divider	
    	SYSCTL_RCC_PWRDN	1	PLL Power Down	
    	SYSCTL_RCC_BYPASS	1	PLL Bypass	
    	SYSCTL_RCC_XTAL	        10101	Crystal Value	
    	SYSCTL_RCC_OSCSRC	01	Oscillator Source	
    	SYSCTL_RCC_MOSCDIS	1	Main Oscillator Disable	

    Launchpad RCC register:

    SYSCTL_RCC	0x03CE0540	Run-Mode Clock Configuration [Memory Mapped]	
    	SYSCTL_RCC_ACG	        0	Auto Clock Gating	
    	SYSCTL_RCC_SYSDIV	0111	System Clock Divisor	
    	SYSCTL_RCC_USESYSDIV	1	Enable System Clock Divider	
    	SYSCTL_RCC_USEPWMDIV	0	Enable PWM Clock Divisor	
    	SYSCTL_RCC_PWMDIV	111	PWM Unit Clock Divisor	
    	SYSCTL_RCC_PWRDN	0	PLL Power Down	
    	SYSCTL_RCC_BYPASS	0	PLL Bypass	
    	SYSCTL_RCC_XTAL	        10101	Crystal Value	
    	SYSCTL_RCC_OSCSRC	00 - 	Oscillator Source	
    	SYSCTL_RCC_MOSCDIS	0	Main Oscillator Disable	

    The boot loader is not switching to the external oscillator (by setting SYSCTL_RCC_OSCRC to 00) and is staying on the internal oscillator. From what my hardware engineer told me the internal clock on the TM4C we are using (TM4C1233H6PM) is not accurate enough for USB and therefore USB won't "turn on" so to speak.

    -Matt

  • We found the solution to our problem. It had to do with the order of the interfaces which were connected. The I2C bus was being seen by the boot loader as connected and so it would stop and use I2C to perform and update. Since we were not using I2C for firmware update the desired interface (USB DFU) would never be initialized.

    The fix was removing the pull up resistors on our I2C bus. During power up the boot loader did not "see" the I2C as a valid update interface and skipped it. The boot loader continued through the interfaces and finally initialized the USB DFU interface.

    The hardware engineer is going to permanently fix the problem in the next board revision.

    -Matt