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() function has optimization dependent behaviour.

Part Number: CC1312R

The function jumpToPrgEntry() used in bim_onchip_CC1312R1_LAUNCHXL_nortos_ticlang project (simplelink_cc13xx_cc26xx_sdk_6_30_01_03, Ti arm clang compiler v2.1.3LTS) has optimization dependent behavious - it will work as we want in case of optimization level Z, but will not if no optimization.

In case of no optimization compiler generate code that obtain ResetISR address from the stack, but the SP value has been changed, so it jumps to incorrect address. 

/*******************************************************************************
 * @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)) )();
}

I found a solution for me, but for me is still interesting what is the best way to implement jumpToPrgEntry(), in a way that it is not optimization dependant?

Regards,

Dimitar 

  • Hi Dimitar,

    Thanks a lot for reporting this and I am glad you found yourself a solution. I see the same behavior. I will contact the RnD and file a ticket. I will update the thread when they have a solution for you. For now, I will close it. 

    Regards,

    Sid