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
/****************************************************************************** * * 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. * * *****************************************************************************/ --retain=g_pfnVectors /* The following command line options are set as part of the CCS project. */ /* If you are building using the command line, or for some reason want to */ /* define them here, you can uncomment and modify these lines as needed. */ /* If you are using CCS for building, it is probably better to make any such */ /* modifications in your CCS project and leave this file alone. */ /* */ /* --heap_size=0 */ /* --stack_size=256 */ /* --library=rtsv7M3_T_le_eabi.lib */ /* The starting address of the application. Normally the interrupt vectors */ /* must be located at the beginning of the application. */ #define APP_BASE 0x00000000 #define RAM_BASE 0x20000000 #define APP_LENGTH 0x01000000 //0x010000000 #define EXSRAM_BASE 0x60000000 /* System memory map */ MEMORY { /* Application stored in and executes from internal flash */ FLASH (RX) : origin = APP_BASE, length = 0x0000B000 /* Application uses internal RAM for data */ SRAM (RWX) : origin = RAM_BASE, length = 0x00040000 SDRAM (RWX) : origin = EXSRAM_BASE, length = 0x01000000 } /* Section allocation in memory */ SECTIONS { .intvecs: > APP_BASE .text : > FLASH .const : > FLASH .cinit : > FLASH .pinit : > FLASH .init_array : > FLASH .vtable : > RAM_BASE .data : > SRAM .bss : > SRAM .sysmem : > SRAM .stack : > SRAM /* .sdram : > EXSRAM_BASE*/ #ifdef __TI_COMPILER_VERSION__ #if __TI_COMPILER_VERSION__ >= 15009000 .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT) #endif #endif } __STACK_TOP = __stack + 512;
Application .cmd file
/****************************************************************************** * * 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. */ /* If you are building using the command line, or for some reason want to */ /* define them here, you can uncomment and modify these lines as needed. */ /* If you are using CCS for building, it is probably better to make any such */ /* modifications in your CCS project and leave this file alone. */ /* */ /* --heap_size=0 */ /* --stack_size=256 */ /* --library=rtsv7M4_T_le_eabi.lib */ /* Section allocation in memory */ SECTIONS { .intvecs: > APP_BASE .text : > FLASH .const : > FLASH .cinit : > FLASH .pinit : > FLASH .init_array : > FLASH // .isr_vector : > FLASH .vtable : > RAM_BASE .data : > SRAM .bss : > SRAM .sysmem : > SRAM .stack : > SRAM #ifdef __TI_COMPILER_VERSION__ #if __TI_COMPILER_VERSION__ >= 15009000 .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT) #endif #endif } //_estack = 0x20040000; __STACK_TOP = __stack + 512;
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
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
I'm not that familiar with FreeRTOS. What do you mean that it gets stuck at SwitchAddress? What does the r0 register contain?
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
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.
;; ;; 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 .endif ldr sp, [r0] ;; ;; Load the initial PC from the application's vector table and branch to ;; the application's entry point. ;; ldr r0, [r0, #4] bx r0 .endasmfunc