TI Device Drivers
We manually set the stack pointer in GCC startup files, and rely on the compiler start routines to set the stack pointer for ARM and LLVM. TIRTOS6 and TIRTOS7 also have their own copies of the startup code that overwrite c_int00 and set the stack pointer.
This leaves IAR as the odd one out, which can cause the stack pointer to be incorrect when loading IAR binaries with CCS. See the linked issue for more details.
To rectify this, we will need to modify all the startup_xxx_iar.c files for nortos and freertos:
- Replace __iar_program_start with a new ResetISR function in the vector table
- ResetISR must set MSP to STACK_TOP, which is already externed in that file
- We can do this with intrinsics or with inline assembly
- ResetISR then calls __iar_program_start and normality resumes