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.

RTOS/TM4C1294NCPDT: Boot loader getting erased

Part Number: TM4C1294NCPDT

Tool/software: TI-RTOS

Hello, I'm relatively new to ARM, TI-RTOS and boot loader. But, I have these things all working on another TM4C123 board I designed. I'm now trying to get the flash based bootloader working on the TM4C1294 but stumped. It seems to be downloading my code okay, but after the download completes my bootloader has been erased at the start of flash. I've been trying to sort through this all week but no luck yet. My application is TI-RTOS based and I've adjusted it's build to locate at 0x1000 and it loads and runs at this location from the debugger. But, as noted, it always erases the bootloader  when doing this regardless of the erase options set for the debugger. So, I'm attempting to load my app via the bootloader for now after flashing the bootloader code. My application's cmd file is as follows:

#define APP_BASE 0x00001000
#define APP_LENG 0x000FF000
#define RAM_BASE 0x20000000
#define RAM_LENG 0x00040000
MEMORY
{
    FLASH (RX) : origin = APP_BASE, length = APP_LENG
    SRAM (RWX) : origin = RAM_BASE, length = RAM_LENG
}
/* Section allocation in memory */
SECTIONS
{
    .text   :   > FLASH
#ifdef __TI_COMPILER_VERSION
#if __TI_COMPILER_VERSION >= 15009000
    .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
#endif
#endif
    .const  :   > FLASH
    .cinit  :   > FLASH
    .pinit  :   > FLASH
    .init_array : > FLASH
    .data   :   > SRAM
    .bss    :   > SRAM
    .sysmem :   > SRAM
    .stack  :   > SRAM
}
I've built the bootloader code with some hooks to blink LED's on my board as it's flashing the code. My CMD file for the bootloader build is as follows:

/* System memory map */
MEMORY
{
    FLASH (RX) : origin = 0x00000000, length = 0x00001000
    SRAM (RWX) : origin = 0x20000000, length = 0x00040000
}
/* Section allocation in memory */
SECTIONS
{
    GROUP
    {
        .intvecs
        .text
        .const
        .data
    } load = FLASH, run = 0x20000000, LOAD_START(init_load), RUN_START(init_run), SIZE(init_size)
    GROUP
    {
        .bss
        .stack
    } run = SRAM, RUN_START(bss_run), RUN_END(bss_end), SIZE(bss_size), RUN_END(__STACK_TOP)
}

I've not had much luck in the debugger stepping through the boot loader code as it relocates itself. At one point I tried to set breakpoints in bl_main, but not sure if this is possible and seems erratic?  After the download completes, it appears my code is present at the 0x1000 address, but the area from 0 to 0x1000 is all 0xFFFF filled and bootloader is gone. Yes, I have the offset set to 0x1000 in lmflash when flashing my application. My TI-RTOS build includes the following as required. 

/* Relocate reset vectors and code to start at 0x1000 after bootloader */
Program.sectMap[".resetVecs"].loadAddress = 0x00001000;
The boot loader fits in just under the 4k space. Any ideas or suggestions to get this figured out would be greatly appreciated. Thanks in advance for any help offered.
Regards,
Bob Starr
  • Hi Robert,
    I think the problem is with your APP_BASE. Please change it to 0x4000 instead of 0x1000. Please refer to the datasheet that each flash sector is 16kB. When you define the APP_BASE to 0x1000, the app will occupy the same sector as the bootloader which is starting at 0x0. In order to program the application firmware the sector to which the firmware will be programmed will need to be erased first and this is the reason the first sector where the bootloader resides is erased.
  • Hi Charles, many thanks for the sector size oversight. Trying to debug in panic mode to get boards shipping. I've adjusted all the offsets to 0x4000 and my app runs from debugger still, but the boot loader is no longer working after adjusting it for 0x4000. Looking at the startup code in the debugger now. The debugger seems to work single stepping the assembly code. But, if I put a breakpoint after copy of the bootloader to SRAM, it never seems to get there. Trying to figure out what's going on with the copy now. I'm not up to speed on ARM assembly code. Something is major wrong and seems to trash execution, still digging...

  • It's working now, many thanks for pointing my oversite out. Thank god it was fixed before cb1 got on my case... lol
  • Hi Bob,
    Do you mind to share with the community what did you change to make it work?
  • I had copied the boot loader code from my TM4C123 based project and overlooked the larger 16k flash page size. The comment in your boot loader config template header bl_config.h.tmpl (shown below) says 1k is the flash page for all Tiva MCU's. I assume I originally pulled the template from here.  I changed this from 0x400 to 0x4000 and it solved my problem. Might want to update the comments in the boot_loader source config header template. This threw me off as I assumed 1K page size was used for all Tiva's.

    Thanks,

    Bob

    //*****************************************************************************
    //
    // The size of a single, erasable page in the flash.  This must be a power
    // of 2.  The default value of 1KB represents the page size for the internal
    // flash on all Tiva MCUs and this value should only be overridden if
    // configuring a boot loader to access external flash devices with a page size
    // different from this.
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    #define FLASH_PAGE_SIZE         0x00004000
  • Hi Bob,
    Thanks. I thought you had already changed all references to 0x4000 and still not working and this is why I ask if there is something else that you change to make it work finally. If it is only the FLASH_PAGE_SIZE to 0x4000 then you are right, this needs to change too. Thank you!
  • I had changed everything but this value and boot loader wasn't working. My app was running at the new 16k offset in the debugger (as expected) and was no longer overwriting the flash, but the bootloader stopped working as I didn't change the page size to 0x4000 also (comment threw me off). The boot loader would still run at 1k, but would get wiped out afterward due to wrong page size. Anyway, just update the comment in your bl_config template, it might save others a lot of frustration. Thanks again for your help.