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.

Tiva TM$C123 USB DFU bootlaoder flashing on USB serial device based board

Hi,

I am going thru lots of posts where USB DFU used, but I am not able to find the answer whether I can use USB DFU bootlaoder along with USB serial communication.

If yes, please suggest how?

I am having Ek-LM4F232 USB evaluation kit & DK-TM4c123 USB eval kit as well.

using Tivaware 1.0 & tivaware 2.0.

thanks 

  • Hello Sayed

    Yes, it is possible to have one interface endpoint as DFU and another as USB Serial COM. A similar example exists in DK-TM4C129X as boot_usb.

    Regards
    Amit
  • Thanks Amit!!

    Do you have any example code where USB configured as DFU at one interface endpoint and USB serial COM at another interface endpoint?

    I tried boot_usb, but due to library mismatch I found errors.

    Will you please help me to find which tivaware & CCS versions suitable for my code compiled for s/w tivaware 1.0 and h/w EK-lm4f232 board?

  • Hello Sayed,

    I did mention the same earlier. And yes it may not compile on TM4C123 or LM4F232 as the code is for TM4C129 device. The TivaWare version to use is 2.1.1.71 and CCSv6.x onwards. Also it would take some effort on your part to bring over the code from TM4C129x to LM4F232.

    Regards
    Amit
  • Hi Amit,

    Thanks a lot for the information!

    I will try to use the code with the mentioned CCS & tivaware.

    If in case,  somebody is using DFU with USB serail COM then kindly help me with small portion of code.

    I am implemented in line with USB_dev_serial (used boot_demo1 help) in which if I put Jump_to_bootloader before "while"
    loop then it will not connect to USB, and if I try to put inside while loop then USB_DFU will not be seen on LM_flash programmer.

    kindly suggest, how it can be implemented!!

  • Hello Sayed,

    I cannot share any customer code on the forum or otherwise. However I can assist in porting over the TM4C129 example to TM4C123.

    Regards
    Amit
  • Hi Amit,

    Hi  Amit,

    Thanks for your kind support!!

    Now, I am using Tivaware 2.1.0 & CCS 6.0.9 on DK-TM4C123 board. During compilation & execution following issues occured:

    1. When I tried to put boot_usb compiled in this platform, my DK-TM4C123 board not showing as DFU device. But when I am using the boot_usb compiled with tivaware 1.0 meant for EK-LM4F board, DK-TM4c123 board is shown as DFU in LM-flashprogrammer.

    2. So, I used boot_usb from tivaware 1.0 and the boot_demo1 from tivaware 2.1.... now the code is working fine, I want to confirm whether Is it fine to use the code like this?

    3. I am also trying to merge boot_demo_USB from TM4C129 example code with USB_dev_serial, I commented ROM_sysctldelay(ui32 sysclock/3)  & ROM_USBclockenable(usb0_base, 8, usb_clock_internal). code compiled!! but LM_flashprogrammer not detecting it as DFU.

    Please suggest!!

    modified USB_dev_serial.c main, added code start from  "  // USB boot 19/11/15 start "

     
    //*****************************************************************************
    //
    // This is the main application entry function.
    //
    //*****************************************************************************
    int
    main(void)
    {
        uint32_t ui32TxCount;
        uint32_t ui32RxCount;
        tRectangle sRect;
        char pcBuffer[16];
        uint32_t ui32Fullness;
     
        //
        // 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_GPIOB);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
        ROM_GPIOPinConfigure(GPIO_PG4_USB0EPEN);
        ROM_GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
        ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
        ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
     
        //
        // Erratum workaround for silicon revision A1.  VBUS must have pull-down.
        //
        if(CLASS_IS_TM4C123 && REVISION_IS_A1)
        {
            HWREG(GPIO_PORTB_BASE + GPIO_O_PDR) |= GPIO_PIN_1;
        }
     
        //
        // Not configured initially.
        //
        g_bUSBConfigured = false;
     
        //
        // Initialize the display driver.
        //
        CFAL96x64x16Init();
     
        //
        // Initialize the graphics context.
        //
        GrContextInit(&g_sContext, &g_sCFAL96x64x16);
     
        //
        // Fill the top 15 rows of the screen with blue to create the banner.
        //
        sRect.i16XMin = 0;
        sRect.i16YMin = 0;
        sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
        sRect.i16YMax = 9;
        GrContextForegroundSet(&g_sContext, ClrDarkBlue);
        GrRectFill(&g_sContext, &sRect);
     
        //
        // Put a white box around the banner.
        //
        GrContextForegroundSet(&g_sContext, ClrWhite);
        GrRectDraw(&g_sContext, &sRect);
     
        //
        // Put the application name in the middle of the banner.
        //
        GrContextFontSet(&g_sContext, g_psFontFixed6x8);
        GrStringDrawCentered(&g_sContext, "usb-dev-serial", -1,
                             GrContextDpyWidthGet(&g_sContext) / 2, 4, 0);
     
        //
        // Show the various static text elements on the color STN display.
        //
        GrStringDraw(&g_sContext, "Tx #",-1, 0, 12, false);
        GrStringDraw(&g_sContext, "Tx buf", -1, 0, 22, false);
        GrStringDraw(&g_sContext, "Rx #", -1, 0, 32, false);
        GrStringDraw(&g_sContext, "Rx buf", -1, 0, 42, false);
        DrawBufferMeter(&g_sContext, 40, 22);
        DrawBufferMeter(&g_sContext, 40, 42);
     
        //
        // Enable the UART that we will be redirecting.
        //
        ROM_SysCtlPeripheralEnable(USB_UART_PERIPH);
     
        //
        // Enable and configure the UART RX and TX pins
        //
        ROM_SysCtlPeripheralEnable(TX_GPIO_PERIPH);
        ROM_SysCtlPeripheralEnable(RX_GPIO_PERIPH);
        ROM_GPIOPinTypeUART(TX_GPIO_BASE, TX_GPIO_PIN);
        ROM_GPIOPinTypeUART(RX_GPIO_BASE, RX_GPIO_PIN);
     
        //
        // TODO: Add code to configure handshake GPIOs if required.
        //
     
        //
        // Set the default UART configuration.
        //
        ROM_UARTConfigSetExpClk(USB_UART_BASE, ROM_SysCtlClockGet(),
                                DEFAULT_BIT_RATE, DEFAULT_UART_CONFIG);
        ROM_UARTFIFOLevelSet(USB_UART_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);
     
        //
        // Configure and enable UART interrupts.
        //
        ROM_UARTIntClear(USB_UART_BASE, ROM_UARTIntStatus(USB_UART_BASE, false));
        ROM_UARTIntEnable(USB_UART_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE |
                          UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX));
     
        //
        // Enable the system tick.
        //
        ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
        ROM_SysTickIntEnable();
        ROM_SysTickEnable();
     
        //
        // Tell the user what we are up to.
        //
        DisplayStatus(&g_sContext, " Configuring... ");
     
        //
        // Initialize the transmit and receive buffers.
        //
        USBBufferInit(&g_sTxBuffer);
        USBBufferInit(&g_sRxBuffer);
     
        //
        // Set the USB stack mode to Device mode with VBUS monitoring.
        //
        USBStackModeSet(0, eUSBModeDevice, 0);
     
        //
        // Pass our device information to the USB library and place the device
        // on the bus.
        //
        USBDCDCInit(0, &g_sCDCDevice);
     
        //
        // Wait for initial configuration to complete.
        //
        DisplayStatus(&g_sContext, "Waiting for host");
     
        //
        // Clear our local byte counters.
        //
        ui32RxCount = 0;
        ui32TxCount = 0;
     
        //
        // Enable interrupts now that the application is ready to start.
        //
        ROM_IntEnable(USB_UART_INT);
     
        
        // USB boot 19/11/15 start
     
        //
        // Terminate the USB device and detach from the bus.
        //
        USBDCDTerm(0);
     
        //
        // Disable all interrupts.
        //
        ROM_IntMasterDisable();
     
        //
        // Disable SysTick and its interrupt.
        //
        ROM_SysTickIntDisable();
        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);
    //commented for compilation   

    //ROM_USBClockEnable(USB0_BASE, 8, USB_CLOCK_INTERNAL);
     
        //
        // Wait for about a second.
     
      
     
        //commented for compilation
        //ROM_SysCtlDelay(ui32SysClock / 3);
     
        //
        // Re-enable interrupts at the NVIC level.
        //
        ROM_IntMasterEnable();
     
        //
        // Call the USB boot loader.
        //
        ROM_UpdateUSB(0);
     
        //USB boot 19/11/15 end
     
     
     
        //
        // Main application loop.
        //
     
     
        while(1)
        {
     
            //
            // Have we been asked to update the status display?
            //
            if(g_ui32Flags & COMMAND_STATUS_UPDATE)
            {
                //
                // Clear the command flag
                //
                ROM_IntMasterDisable();
                g_ui32Flags &= ~COMMAND_STATUS_UPDATE;
                ROM_IntMasterEnable();
     
                DisplayStatus(&g_sContext, g_pcStatus);
            }
     
            //
            // Has there been any transmit traffic since we last checked?
            //
            if(ui32TxCount != g_ui32UARTTxCount)
            {
                //
                // Take a snapshot of the latest transmit count.
                //
                ui32TxCount = g_ui32UARTTxCount;
     
                //
                // Update the display of bytes transmitted by the UART.
                //
                usnprintf(pcBuffer, 16, "%d ", ui32TxCount);
                GrStringDraw(&g_sContext, pcBuffer, -1, 40, 12, true);
     
                //
                // Update the RX buffer fullness. Remember that the buffers are
                // named relative to the USB whereas the status display is from
                // the UART's perspective. The USB's receive buffer is the UART's
                // transmit buffer.
                //
                ui32Fullness = ((USBBufferDataAvailable(&g_sRxBuffer) * 100) /
                              UART_BUFFER_SIZE);
     
                UpdateBufferMeter(&g_sContext, ui32Fullness, 40, 22);
            }
     
            //
            // Has there been any receive traffic since we last checked?
            //
            if(ui32RxCount != g_ui32UARTRxCount)
            {
                //
                // Take a snapshot of the latest receive count.
                //
                ui32RxCount = g_ui32UARTRxCount;
     
                //
                // Update the display of bytes received by the UART.
                //
                usnprintf(pcBuffer, 16, "%d ", ui32RxCount);
                GrStringDraw(&g_sContext, pcBuffer, -1, 40, 32, true);
     
                //
                // Update the TX buffer fullness. Remember that the buffers are
                // named relative to the USB whereas the status display is from
                // the UART's perspective. The USB's transmit buffer is the UART's
                // receive buffer.
                //
                ui32Fullness = ((USBBufferDataAvailable(&g_sTxBuffer) * 100) /
                              UART_BUFFER_SIZE);
     
                UpdateBufferMeter(&g_sContext, ui32Fullness, 40, 42);
            }
        }
    }

  • Hello Sayed

    1. I tried the example of boot_usb from the TivaWare 2.1.1.71 (I do not have a copy of 2.1.0 but it should not make much difference) for DK-TM4C123 and it works

    2. boot_usb demo from TM4C129 require change for Pin, Configuration when porting to TM4C123

    Regards
    Amit
  • Hi Amit,

    Thats great!!
    But I am not getting the success!!
    I copied the boot_demo_usb to examples/tm4c123xl folder from tm4c129 folder, then I import it to my workspace.
    Commented previous USB pin configuration in pinoutset.c & copied USB configuration code lines from USB_dev_serial.c .
    After compilation, I found error:
    #20 identifier GPIO_PG4_USBEPEN is undefined

    but GPIO_PG4_USBEPEN is defined in pin_map.h.

    If you succeeded in using boot_demo_usb with DK-TM4C123, kindly share the code or folder.

    regards
    Sayed Tausif
  • Hello Sayed

    DK-TM4C123 has it's own boot_usb example. You will need to make changes to the TM4C129 example as given in the following document

    www.ti.com/.../spma065.pdf

    Regards
    Amit
  • Hi Amit,
    I want to summarize again what had happened till now!
    Even, I am able to use boot_usb with boot_demo1 & boot_demo2 for tm4c123 board, and able to flash through DFU for these two examples. But when I am using boot_usb with modified usb_dev_serial then I am not able to find the required results.
    i.e. USB dfu & USB serial connect not working simultaneously!!

    As, you told boot_demo_usb is exclusively available for tm4c129. In which, according to you USB serial communication as well as USB DFU working simultaneously. So, I switched to the boot_demo_usb & tried to make it ready for tm4c123. While doing this exercise I found errors in compile time.
    I already shared the code.

    Kindly suggest/provide the solution.
  • Hello Sayed,

    The examples are a representative set of code. No vendor (including this one) cannot provide for an exhaustive example set.

    The TM4C123 differs in a lot of ways from the TM4C129: Pin out is different, Function calls are different. So if you make the changes for the same first and get compile clean, I can better assist you.

    Regards
    Amit