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.

[参考译文] CC1312R:BIM_util.c jumpToPrgEntry()函数具有与优化相关的行为。

Guru**** 2484615 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1196268/cc1312r-bim_util-c-jumptoprgentry-function-has-optimization-dependent-behaviour

器件型号:CC1312R

  bim_onchip_CC1312R1_LAUNCHXL_nortos_cliclang 工程(simplelink_cc13xx_cc26xx_sdk_6_30_01_03、TI ARM clang 编译器 v2.1.3LTS)中使用的函数 jumpToPrgEntry ()具有与优化相关的行为-如果没有优化级别、它将按我们的要求工作、但不会进行优化。

如果没有优化、编译器会生成从堆栈获取 ResetISR 地址的代码、但 SP 值已更改、因此会跳转到错误的地址。  

/*******************************************************************************
 * @fn          jumpToPrgEntry
 *
 * @brief       This function jumps the execution to program entry to execute
 *              application
 *
 * @param       vectorTable - address of application vector table.
 *
 * @return      None.
 */
void jumpToPrgEntry(uint32_t *vectorTable)
{
    // Set SP to vectorTable[0]
#ifdef __ICCARM__
    __asm volatile (
        "LDR R5,[R0,#0x0] \n"
        "MOV SP, R5       \n"
    );
#else
    __asm volatile (" LDR SP, [R0, #0x0] ");
#endif

    // Jump to vectorTable[1]
    ( (void (*)(void)) (*(vectorTable + 1)) )();
}

我为我找到了一个解决方案,但对我来说,仍然很有趣的是,实施 jumpToPrgEntry()的最佳方法是什么,它不依赖于优化?

此致、

Dimitar  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Dimitar、

    非常感谢您的报告、我很高兴您找到了一个解决方案。 我看到同样的行为。 我将联系 Rnd 并提交一个 TT。 当他们有适合您的解决方案时、我将更新该主题。 现在、我将关闭它。  

    此致、

    SID