请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC2674R10 主题中讨论的其他器件:CC1354P10
工具与软件:
尊敬的 TI 团队:
示例:mcuboot_LP_EM_CC1354P10_1_nortos_ticlang
SDK:simplelink_cc13xx_cc26xx_sdk_7_41_00_17
使用使用使用-O0和 exclude_trace 未定义编译的引导加载程序示例会导致异常。
调查后,我们发现 mcuboot_app.c 中的 start_app()是不安全的。
编译器可能会生成行为不符合预期的代码。
下面是一个修复建议:
__attribute__((noreturn, naked)) static void start_app(const uint32_t * volatile vector_table)
{
/* The following code resets the SP to the value specified in the
* provided vector table, and then the Reset Handler is invoked.
*
* Per ARM Cortex specification:
*
* ARM Cortex VTOR
*
*
* Offset Vector
*
* 0x00000000 ++++++++++++++++++++++++++
* | Initial SP value |
* 0x00000004 ++++++++++++++++++++++++++
* | Reset |
* 0x00000008 ++++++++++++++++++++++++++
* | NMI |
* ++++++++++++++++++++++++++
* | . |
* | . |
* | . |
*
* */
/* Reset the SP with the value stored at vector_table[0] */
__asm volatile ("ldr r1, [r0]");
__asm volatile ("msr msp, r1");
/* Jump to the Reset Handler address at vector_table[1] */
__asm volatile ("ldr r0, [r0, #4]");
__asm volatile ("bx r0"); // jump, not call (blx)
}
此致、
托比亚斯