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.

TM4C123GH6PM: TM4c123 Firmware Upgrade through USB and Serial both

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL, EK-TM4C1294XL

Hello!

I am using TM4c123 for my application and in that, I need to do firmware upgrade through USB and UART both. User should be able to use any of these interfaces to upgrade the device. 

My plan is to copy the new firmware file from any of the interfaces to external flash and ask the bootloader to boot the application from the new firmware stored in the flash.

I will use TM4c123 as USB host and copy the firmware file from the device to flash. For serial also, I will use UART0 and copy the firmware file over serial to flash.

  1. Can I use same bootloader for both the interfaces as per my application?
  2. Do I need to change ROM bootloader or same can be used?
  3. Can you guide me with demo examples from SDK?

Thanks,

Naman

  • Hi,

      We have bootloader examples like boot_usb and boot_serial which you can find in folder <TivaWare_Installation>/examples/boards/ek-tm4c123gxl/. The way the bootloader is designed today, you can only use one interface at a time. If you need to be able to boot-load from two different interfaces then you will need to modify the bootloader on your own. Here we are talking about the flash-based bootloader.

      The TM4C123 also support ROM-based bootloader. The bootloader firmware is stored in the ROM and this is not modifiable. The ROM bootloader will be able bootload among USB, Ethernet, UART, I2C, Please refer to the Bootloader User's guide for detail. Below is the excerpt.

    I think the answer in this post will be helpful to you. https://e2e.ti.com/support/microcontrollers/other/f/908/p/915369/3383182#3383182

      

  • Thanks, Charles for the reply. 

    A bit delayed, but I successfully run the boot_usb demo. However, it requires a programmer like LM Flash and a computer connection over USB.

    My requirements are somewhat different than this. Let me explain you:

    • I want to upgrade firmware using USB stick. (Pendrive)
    • I will copy my new application to Pendrive and connect it to the device (Using Micro to USB OTG cable ofcourse)
    • I will inform the existing application that Upgrade firmware from the Pendrive
    • The application should validate CRC and accept the new firmware, copy it to some predefined memory location
    • After reboot, the bootloader should execute the new application
    • So, I will have two partitions in the Flash memory and one partition will store the currently running application, the other will store the newly copied application.

    Is this possible on TM4C123? Is there any example suggested for this purpose?

    Thanks,

    Naman

  • Hi Naman,

      In that case please refer to the usb_stick_update (the bootloader) and the usb_stick_demo (the application firmware) examples. They can be found in the <TivaWare_Installation>/examples/boards/ek-tm4c1294xl/. Please note the example is for the TM4C129 processor. However, you should be able to port to TM4C123 quickly. 

  • Hi Charles,

    • I tried with the usb_stick_update demo and ported to TM4C123, still, the USB Stick is not detected. Below is the code to configure USB:

    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
    SysCtlDelay(80);
    uDMAEnable();
    uDMAControlBaseSet(g_sDMAControlTable);
    
    
    
    //
    // Enable the USB controller.
    //
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    SysCtlUSBPLLEnable();
    
    // PF4 as USB0EPEN
    
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_GPIOPinConfigure(GPIO_PF4_USB0EPEN);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTF_BASE, GPIO_PIN_4);
    
    // PB0 and PB1 as USB0ID and USB0VBUS
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
    // PD4 and PD5 as D- and D+
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    
    USBStackModeSet(0, eUSBModeForceHost, 0);
    
    
    
    //
    // Register the host class driver
    //
    USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS);
    
    //
    // Open an instance of the mass storage class driver.
    //
    g_psMSCInstance = USBHMSCDriveOpen(0, MSCCallback);
    
    
    
    USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
    
    SysCtlVCOGet(SYSCTL_XTAL_16MHZ, &ui32PLLRate);
    
    USBHCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);
    USBHCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);
    
    USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE);

    • Below are the functions used for startup_css.c

    Used: 

    1. SysTickHandler
    2. USB0HostIntHandler
    • I have also shorted R25 and R29 resistors as described in few other posts in TI community.

    The problem I am facing is, the USB pendrive is not detected by the board. MSCCallback function is also not being called. What am I missing?

    Thanks,

    Naman

  • Hi Naman,

      Can you try the same examples that was part of the collateral in this app note. Go to section 6 that illustrates the usb_stick_update.

    https://www.ti.com/lit/an/spna243/spna243.pdf?ts=1596558027995&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FTM4C123GH6ZXR

  • Thanks Charles!

    That's what I was searching for..! I had to short H18 and H19 pins.

    Don't know why I didn't come across this document before..

    Thanks,

    Naman

  • Hi Naman,

      This app note was recently uploaded and perhaps that's why you didn't find it in the past. However, I also forgot about it. I should have pointed you this app note in the beginning instead of having you port the example from TM4C129 to TM4C123. But glad your problem is solved now.