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.

Can I modify the Boot Loader to perform USB DFU in USB HS?

HI,

I designed a board with TMC1294NCZAD and USB3320 external USB 2.0 PHY. The board works well. Currently, I use MCU's JTAG port to do download/update program.

I tried to do USB DFU on TM4C129x  Dev board and run Tiva boot loader (boot_usb) with a demo app (boot_demo_usb). it works fine. Unfortunately, the boot loader (boot_usb) uses the MCU's build-in USB port, I am unable to use it on my board directly. I am wondering if I can get help on modifying the boot loader, so I can perform USB DFU with external USB HS PHY?

Best Regards,

Simon

  • Hello Simon,

    The ROM Boot Loader cannot be changed. However you can use the Flash based boot loader to do so. Though the existing code base only shows how to use a Internal PHY, modifications may be done on the initialization to get the USB HS to work as a DFU class device. I do not have a working code base but would be glad to co-develop along side.

    Regards
    Amit
  • Hi Amit,

    Thanks for your reply.

    Regards,

    Simon
  • Amit,

    I have another question related to this. As I mentioned before, my board is majorly used as a USB 2.0 device, and receives command from connected PC to control on board peripherals, like ADC, DAC and programmable power supplies, etc. In addtion, the TM4C1294's UART0 is connected to PC thru CP2108 (UART USB bridge). The UART0 pins are assigned and configured.

    I modified the example  "boot_demo_uart", which comes with TivaWare_C_Series-2.1.1.71, removed touch screen portion of code (because my board does not have touch screen), and loaded the code to my board,  I am able to update MCU's FW on my board thru UART0 using LM Flash Programmer. It works very well.

    I tried to added the code of calling boot loader function to my existing code, as shown below. But it doe not work. Once I called the boot loader, and run LM Flash, I got a error message said "Failed to establish communication with board". I must be missing something. I am wondering what is the correct way to move control to the Boot Loader to do FW update. Would you please help me to find out? Thank you in advance!

    Best Regards,

    Simon

     //*****************************************************************************

    /// This is the main application entry function.

    //*****************************************************************************

    int  main(void)

    {

        uint_fast32_t ui32TxCount;

        uint_fast32_t ui32RxCount;

        char pcBuffer[16];

        uint32_t ui32SysClock,ui32PLLRate;

        uint32_t ui32Setting;

        //

        // Run from the PLL at 120 MHz.

        //

        ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |

                                               SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |

                                               SYSCTL_CFG_VCO_480), 120000000);

        //

        // Configure the device pins.

        //

        PinoutSet();

         //

        // Enable USB ULPI with high speed support.

        //

         USBULPIPinoutSet();

        ui32Setting = USBLIB_FEATURE_ULPI_HS;

        USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting);

        //

        // Setting the PLL frequency to zero tells the USB library to use the

        // external USB clock.

        //

        ui32PLLRate = 0;                //the 60MHz clock from External PHY is used by default in ULPI mode         SG

         //

        // Not configured initially.

        //

        g_bUSBConfigured = false;

         // Enable the system tick.

        //

        ROM_SysTickPeriodSet(ui32SysClock / SYSTICKS_PER_SECOND);

        ROM_SysTickIntEnable();

        ROM_SysTickEnable();

         //

        // Initialize the transmit and receive buffers.

        //

        USBBufferInit(&g_sTxBuffer);

        USBBufferInit(&g_sRxBuffer);

         //

        // Initialize the USB stack for device mode.

        //

        USBStackModeSet(0, eUSBModeDevice, 0);

         // Tell the USB library the CPU clock and the PLL frequency.  This is a

        // new requirement for TM4C129 devices.

        //

        USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock);

        USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

        //

        // Pass our device information to the USB library and place the device

        // on the bus.

        //

        USBDBulkInit(0, &g_sBulkDevice);

          //

        // Clear our local byte counters.

        //

        ui32RxCount = 0;

        ui32TxCount = 0;

          // Determine the number of system clock cycles in 1mS

        //

        ui32ClockMS = CYCLES_FROM_TIME_US(ui32SysClock, 1000);

         // Divide by 3 to get the number of SysCtlDelay loops in 1mS.

        //

        ui32ClockMS /= 3;

        // SysCtlDelay loops in 1uS.

           ui32ClockUS = ui32ClockMS/1000; 

            ui32Loop =10*ui32ClockUS;

            HwInit();                  // init all devices on board

            //

        // g_bUpdateSignalled = false, Normal Main application loop

        //

        while(!g_bUpdateSignalled)  

        {

        }

           //g_bUpdateSignalled = true, FW update enabled

           // Disable all processor interrupts.  Instead of disabling them one at a

          // time, a direct write to NVIC is done to disable all peripheral

         // interrupts.

         // Enable the UART that will be used for the firmware update.

            ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

                     //

                    // Configure the UART for 115200, 8-N-1.

                    //

               ROM_UARTConfigSetExpClk(UART0_BASE, ui32SysClock, 115200,

                                                                                     (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |

                                                                                      UART_CONFIG_WLEN_8));

                    //

                    // Enable the UART operation.

                    //

               ROM_UARTEnable(UART0_BASE);

              

        HWREG(NVIC_DIS0) = 0xffffffff;

        HWREG(NVIC_DIS1) = 0xffffffff;

        HWREG(NVIC_DIS2) = 0xffffffff;

        HWREG(NVIC_DIS3) = 0xffffffff;

        HWREG(NVIC_DIS4) = 0xffffffff;

         //

        // Call the ROM UART boot loader.

        //

        ROM_UpdateUART();

            

                while(1)             //should never come here

                {

                }

        

    }

  • Hello Simon,

    The procedure shown is correct. Now does the variable g_bUpdateSignalled become true and when it goes to the ROM Boot Loader does the PC show a location 0x01xx_xxxx? Do note that the debugger must not be connected when the final application does the boot call. For debug purpose to know if the PC is jumping to ROM you may connect the debugger. Once it goes to the ROM disconnect the debugger, reset the board and attempt.

    Regards
    Amit