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.
工具与软件:
你(们)好
IAM 尝试 通过为自定义引导加载程序和自定义应用对闪存进行分区来通过以太网引导加载程序代码执行自定义固件升级
我所面临的问题是
固件升级后、非 RTOS 应用程序正常工作并正常引导
而 在固件升级中使用基于 RTOS 的应用程序,它会卡在下面提到的切换地址功能中
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);
//
//禁用所有处理器中断。 而不是禁用它们
//一次写入一个 NVIC 可以禁用所有功能
//外设中断。
//
HWREG (NVIC_DIS0)= 0xffffffff;
HWREG (NVIC_DIS1)= 0xffffffff;
HWREG (NVIC_DIS2)= 0xffffffff;
HWREG (NVIC_DIS3)= 0xffffffff;
HWREG (NVIC_VTABLE)= StartAddress;
//从应用程序的向量表加载堆栈指针。
_asm (" LDR R1、[r0]\n"
" mov sp、R1");
//从应用程序的矢量表加载初始 PC 并分支到
//应用程序的入口点。
_asm (" LDR r0、[R0、#4]\n"
" bx r0\n");
}
我将共享引导加载程序和应用程序.CMD 文件
Bootloader.cmd 文件
/****************************************************************************** * * 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;
应用程序.cmd 文件
/****************************************************************************** * * 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;
您能帮助我们检查.cmd 文件中的任何配置错误、或者对引导基于 RTOS 的代码所做的任何更改吗
调试特性
验证 MSP 和 PSP
您好!
您的 StartAddress 是什么? 在链接器文件中、APP_BASE 设置为0xC000。 在 TI-RTOS 项目中、您是否将 m3Hwi.resetVectorAddress 设置为0xC000?
在 TI-RTOS .cfg 文件中、添加:
/*为此应用设置一个非零复位矢量地址、因为是由放置在地址零的引导加载程序启动的。
链接器命令文件中的闪存区域设置为从该地址开始、以避免使用任何闪存
为引导加载程序保留。 */
m3Hwi.resetVectorAddress = 0xC000;
使用示例软件参考 Chester 在这篇文章中的答案。 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
否我们不使用 TI-RTOS、我们使用的是 FreeRTOS
我对 FreeRTOS 不是那么熟悉。 您的意思是、它被固定在 SwitchAddress? r0寄存器包含什么内容?
您能告诉我如何读取该 r0寄存器吗
只需单步执行并在寄存器窗口中读取它。
我之前说过在寄存器窗口中读取 r0寄存器。
在固件升级之前
更新后的固件更新
您能告诉我这里有什么问题吗
否、我无法仅通过查看寄存器来辨别问题。 您可以这么做吗?
您说应用程序从0xC000开始。 在您的 PC 中、它位于0x5FBE。 该地址是否有任何内容? 处理器为什么会跳转到这个地址? 您需要找出答案。 如果您的 TI-RTOS 应用程序确实已加载到0xC000、那么您可以单步执行并查看处理器是否跳转到您的应用程序的入口点。 请在0xC004查看您的地址。 这是应用的复位矢量。 那里的价值是什么? 您甚至可以强制 PC 达到该值、然后查看它是否运行应用程序。
更改地址后、也无法引导
您是否可以建议在配置中进行任何更改
您能否说明需要进行任何具体更改才能 使用跳转位置从闪存引导代码
就像任何配置更改或任何代码更改一样
这是正确的吗?
//从应用程序的向量表加载堆栈指针。
_asm (" LDR R1、[r0]\n"
" mov sp、R1");
//从应用程序的矢量表加载初始 PC 并分支到
//应用程序的入口点。
_asm (" LDR r0、[R0、#4]\n"
" bx r0\n");
在 bl_config.h 文件中、您是否更改为0xC000? stock 示例将其设置为0x4000。 如果要使用不同的 APP_START_ADDRESS、则需要相应地进行更改。 既然您说它适用于加载非 RTOS 固件、那么您为什么不 在它们之间进行比较?
//从应用程序的向量表加载堆栈指针。
_asm (" LDR R1、[r0]\n"
" mov sp、R1");
//从应用程序的矢量表加载初始 PC 并分支到
//应用程序的入口点。
_asm (" LDR r0、[R0、#4]\n"
" bx r0\n");
这对于加载非 RTOS 固件是否起作用? 请参阅下面的如何将引导加载程序示例跳转到应用程序。 它首先使用应用程序的起始地址对 NVIC_VTABLE 寄存器进行编程。 在本例中、需要将0xC000编程到 NVIC_VTABLE 寄存器中。 因此、如果此寄存器编程为0xC000、请检查 NVIC_VTABLE 寄存器。 应用程序0xC000处的第一个位置包含 SP。 如您所见、它会将 0xC000处的内容加载到 SP 寄存器中。 最后、它将跳转到应用程序。 请参阅 bl_startup_ccs.s 文件。
;; ;; 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