Skip to content

Commit

Permalink
arch/arm/src/imxrt/imxrt_start.c: Clear CONTROL register at start to …
Browse files Browse the repository at this point in the history
…make sure we use MSP as the stack pointer

When entering the function from an external bootloader, the CPU could be using PSP. But the following
code expects MSP to be in use.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Feb 13, 2024
1 parent 2a9b792 commit a3b7b2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arch/arm/src/imxrt/imxrt_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,16 @@ void __start(void)
const register uint32_t *src;
register uint32_t *dest;

/* Make sure that interrupts are disabled and set SP */
/* Make sure that interrupts are disabled and set MSP */

__asm__ __volatile__ ("\tcpsid i\n");
__asm__ __volatile__ ("MSR MSP, %0\n" : : "r" (IDLE_STACK) :);

/* Make sure that we use MSP from now on */

__asm__ __volatile__ ("MSR CONTROL, %0\n" : : "r" (0) :);
__asm__ __volatile__ ("ISB SY\n");

/* Make sure VECTAB is set to NuttX vector table
* and not the one from the boot ROM and have consistency
* with debugger that automatically set the VECTAB
Expand Down

0 comments on commit a3b7b2d

Please sign in to comment.