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