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.

PROBLEMS WITH BOOT LOADER - LM4F132



I'm using the LM4F132 and can't establish the communication between the bootloader (Uart 0) and the LM Flash Programmer. When the LM Flash Programmer tries to communicate with my target, I get the following error message: "Failed to establish communication with the board. To program using the serial port, the board must be programmed with the serial flash loader or a properly configured bootloader".

I'm using the following settings for the Flash Programmer:

      Program Address Offset: 0x1000

      COM5; Baud Rate 115200

      transfer size 76

      Auto Baud Support disabled

I'm following some hints posted in this forum and the code examples boot_demo1, boot_demo2 and boot_serial provided in dk-tm4c123g, trying to incorporate the use of the bootloader into the very beginning of my application (based on uC/OS-III). By now, I just want to use the ROM bootloader as follows:

MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
MAP_UARTConfigSetExpClk(UART0_BASE, get_cpu_clock_frequency(), 115200,
                            (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
                             UART_CONFIG_WLEN_8));
MAP_UARTEnable(UART0_BASE);

MAP_SysTickIntDisable();
MAP_SysTickDisable();

HWREG(NVIC_DIS0) = 0xffffffff;
HWREG(NVIC_DIS1) = 0xffffffff;

ROM_UpdateUART(); //or (*((void (*)(void))(*(uint32_t *)0x2c)))();

Besides that, I'm also using the LM4F232H5QD.icf file provided with IAR with no changes. As I could understand from this file, the flash/ROM initial address is set to 0x00000000. Am I right? 4251.LM4F232H5QD.zip

Could you guys help me out?

Thanks in advance,

Fernando

  • Hi Fernando,

    Lets debug it.

    First of all, have you verified that UART0 is working on your board? Try to print something to UART0 before jumping to the ROM bootloader and see if it appears on the terminal.

    Second. Try erase the entire flash with LM Flash programmer, and lets see if the LM Flash programmer works with the ROM bootloader without anything in the flash. Please note you will need to set the program address offset to 0x0, since we want the ROM bootloader to write the application at the beginning of the flash. And leave the options in the LM Flash programmer as default(such as not check the box for disable Auto Baud).

    If above are verified and working, start to debug your application, and step it through with a debugger, and see if the processor enters ROM_UpdateUART(), and it should never return. 

    Make sure that your flashed based bootloader binary is less than 0x1000, otherwise you will be corrupting the bootloader image with the target application.

    Let me know how it goes.

    Angela

  • Hi, Angela. Thanks for your help.

    I tested the UART0 on my board and it is ok.

    I erased the the entire flash using the IAR/I-JET because LM Flash Programmer did not work for that.

    Once the flash was erased, I was able to download a binary file to the flash now using the Flash Programmer set with default configuration and it worked just fine:

          Program Address Offset: 0x0 / COM5 / Baud Rate 115200 / transfer size 60 / Auto Baud Support enabled

    I programmed my board again as described in my first post but the LM Flash Programmer keeps indicating that my flash muts be programmed with a serial flash loader.

    I'm not implementing any sort of bootloader in my application. I would like to use the ROM bootlader to update my platform already programmed by . Do I need to implement one?

    I could debug the firmware until the call:

             ROM_UpdateUART(); //or (*((void (*)(void))(*(uint32_t *)0x2c)))();

    Let me know if you need any other information.

    Thanks again,

    Fernando

  • Your implementation looks fine to me. Can you verify  get_cpu_clock_frequency() return the same frequency that you have configured? 

    MAP_UARTConfigSetExpClk(UART0_BASE, get_cpu_clock_frequency(), 115200,
                                (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
                                 UART_CONFIG_WLEN_8));


    Also how did you setup the system clock frequency? Can you copy the paste that API call?

    I will try to duplicate the issue on my setup.

    Angela

  • get_cpu_clock_frequency() is returning 80.000.000, as expected.

    The API that sets the system clock is the following:

    // Set the clock to run with PLL at 80MHz.
    MAP_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                           SYSCTL_XTAL_10MHZ);

    Thanks,

    Fernando

  • Hi Fernando.

    That call was correct assuming your XTAl is 10MHz. I have tried it on LM4F232 Eval board, and programmed a small application in the beginning of the flash, this small application just setup the system clock, and configure the UART pins and 115200 baud rate, disable the interrupt, and jump to ROM_UpdateUART(). In Flash programmer, you will need to check "Disable Auto Baud Support", and configure the COM port, and Baud Rate as 115200, and I left the transfer size as default(60). In the program tab, make sure you set the  "Program Address Offset" to be 0, since we wanted the ROM boot loader to program a binary to the beginning of the flash.

    All works fine on the eval board. One thing to check is your LM Flash programmer version, the latest version is 1588, that is the one I tested with. If yours isn't most update, perhaps download the new one, and give it a try.

    Also try to power cycle the board, and re-start Flash Programmer, and see if it makes any difference.

    Another thing, instead of just disable the first two NVIC registers, disable all 5 of them, in case you do have a interrupt enabled one of the upper banks. The code will be like this.

    //
    // 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;

    If it still doesn't work after all above suggestions, try to test it on LM4F232 eval board if you have one, and see if you can get that to work.

    Good Luck!

    Angela