TM4C1294NCPDT: Firmware upgrade RTOS Application Booting issue

Part Number: TM4C1294NCPDT

Tool/software:

Hi Team

Iam trying to do custom  firmware upgrade via ethernet bootloader code  by partitioning the FLASH for custom bootloader and custom Application

The problem iam facing is  

Non RTOS Application are working and booting properly after Firmware upgrade

Whereas  using RTOS based application in firmware upgrade , It get stuck in switch address function mentioned below

void SwitchAddress(uint32_t StartAddress)
{
UARTprintf("Start at %x\n",StartAddress);

IntDisable(INT_TIMER0A);
IntDisable(INT_TIMER1A);
IntDisable(INT_TIMER2A);
IntDisable(INT_EMAC0);
IntDisable(FAULT_SYSTICK);
IntDisable(FAULT_NMI);
IntDisable(FAULT_HARD);
//
// 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_VTABLE) = StartAddress;

// Load the stack pointer from the application's vector table.
__asm(" ldr r1, [r0]\n"
" mov sp, r1");

// Load the initial PC from the application's vector table and branch to
// the application's entry point.
__asm(" ldr r0, [r0, #4]\n"
" bx r0\n");
}

I will share my Bootloader and Application .CMD files 

Bootloader.cmd file

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/******************************************************************************
*
* Copyright (c) 2013-2017 Texas Instruments Incorporated. All rights reserved.
* Software License Agreement
*
* Texas Instruments (TI) is supplying this software for use solely and
* exclusively on TI's microcontroller products. The software is owned by
* TI and/or its suppliers, and is protected under applicable copyright
* laws. You may not combine this software with "viral" open-source
* software in order to form a larger program.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
* NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
* NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
* CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
* DAMAGES, FOR ANY REASON WHATSOEVER.
*
*
*****************************************************************************/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Application .cmd file

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/******************************************************************************
*
* Default Linker Command file for the Texas Instruments TM4C1294NCPDT
*
* This is derived from revision 15071 of the TivaWare Library.
*
*****************************************************************************/
--retain=g_pfnVectors
#define APP_BASE 0xC000//0x04000 //000B078
#define RAM_BASE 0x20000000 + 512
MEMORY
{
FLASH (RX) : origin = APP_BASE, length = 0x00016000//(1024K - 0xB078)
SRAM (RWX) : origin = 0x20000000, length = 256K//0x01000000
}
/* The following command line options are set as part of the CCS project. */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Can you please help us check any configuration mistakes in .cmd file or any changes to be made for booting RTOS based code 

from Non-RTOS bootloader 

  • how to verify this msp and psp

  • it got stuck here

  • Hi,

      What is your StartAddress? In your linker file you have the APP_BASE set to 0xC000. On your TI-RTOS project, did you set the m3Hwi.resetVectorAddress to 0xC000? 

    In your TI-RTOS .cfg file, add:

    /* Set a non-zero reset vector address for this application, since is started by a bootloader placed at address zero.
    The FLASH memory region in the linker command file is set to start at this address, to avoid using any flash
    reserved for the bootloader. */
    m3Hwi.resetVectorAddress = 0xC000;

    Refer to the answer by Chester in this post with example software. https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1024278/tm4c1294ncpdt-rtos-bios-not-working/3786291?tisearch=e2e-sitesearch&keymatch=vtable%20relocate#3786291

  • No we are not using Ti-RTOS , we are using Freertos 

  • I'm not that familiar with FreeRTOS. What do you mean that it gets stuck at SwitchAddress? What does the r0 register contain?

  • how to check r0 register

  • can you please tell me how to read this r0 register

  • you just single step and read it in the register window. 

  • I said to read the r0 register in the registers window.

  • Before firmware upgarde

    After firmware upgarde

    can you tell any issue here

  • No, I can't tell the issues by looking at just registers. Can you?

    You said your application starts at 0xC000. Looking at your PC, it is at 0x5FBE. Is there anything at this address? Why does the processor jump to this address? You need to find out. If your TI-RTOS application is indeed loaded to 0xC000 then you can single step and see if the processor jumps to the entry point for your application. Check your address at 0xC004. This is your Reset Vector for your application. What is the value there? You can even force the PC to that value and see if it runs the application. 

  • After changing the address also it is not booting 

    can you suggest any changes to be made in configurations 

  • can you tell any specific change need to be done to boot the code from flash  using jump location 
    like any configuration changes or any code changes 

  • this is correct ?

    // Load the stack pointer from the application's vector table.
    __asm(" ldr r1, [r0]\n"
    " mov sp, r1");

    // Load the initial PC from the application's vector table and branch to
    // the application's entry point.
    __asm(" ldr r0, [r0, #4]\n"
    " bx r0\n");

  • In the bl_config.h file, did you change to 0xC000? The stock example sets it to 0x4000. If you want to use a different APP_START_ADDRESS then you need to change accordingly. Since you said it works for loading a non-RTOS firmware, why don't you compare between them?

    // Load the stack pointer from the application's vector table.
    __asm(" ldr r1, [r0]\n"
    " mov sp, r1");

    // Load the initial PC from the application's vector table and branch to
    // the application's entry point.
    __asm(" ldr r0, [r0, #4]\n"
    " bx r0\n");

    Did this work for loading the non-RTOS firmware? See below how the bootloader example jumps to the application. It first programs the NVIC_VTABLE register with the application's start address. In your case, the 0xC000 needs to be programmed to NVIC_VTABLE register. So check the NVIC_VTABLE register if this programmed to 0xC000. The first location at 0xC000 of your application contains the SP.  As you can see, it will load the content at 0xC000 into the SP register. Finally, it jumps to the application. Refer to the bl_startup_ccs.s file. 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    ;;
    ;; Set the application's vector table start address. Typically this is the
    ;; application start address but in some cases an application may relocate
    ;; this so we can't assume that these two addresses are equal.
    ;;
    movw r0, #(VTABLE_START_ADDRESS & 0xffff)
    .if (VTABLE_START_ADDRESS > 0xffff)
    movt r0, #(VTABLE_START_ADDRESS >> 16)
    .endif
    movw r1, #(NVIC_VTABLE & 0xffff)
    movt r1, #(NVIC_VTABLE >> 16)
    str r0, [r1]
    ;;
    ;; Load the stack pointer from the application's vector table.
    ;;
    .if (APP_START_ADDRESS != VTABLE_START_ADDRESS)
    movw r0, #(APP_START_ADDRESS & 0xffff)
    .if (APP_START_ADDRESS > 0xffff)
    movt r0, #(APP_START_ADDRESS >> 16)
    .endif
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX