Stack initialization workaround.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9668 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2016-06-26 18:30:32 +00:00
parent e8f9eaea0d
commit 12c3d9e416
2 changed files with 21 additions and 0 deletions

View File

@ -45,6 +45,15 @@
/* Module pre-compile time settings. */ /* Module pre-compile time settings. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Enforces initialization of MSP.
* @note This is required if the boot process is not reliable for whatever
* reason (bad ROMs, bad bootloaders, bad debuggers=.
*/
#if !defined(CRT0_VTOR_INIT) || defined(__DOXYGEN__)
#define CRT0_FORCE_MSP_INIT TRUE
#endif
/** /**
* @brief VTOR special register initialization. * @brief VTOR special register initialization.
* @details VTOR is initialized to point to the vectors table. * @details VTOR is initialized to point to the vectors table.
@ -142,6 +151,12 @@ Reset_Handler:
/* Interrupts are globally masked initially.*/ /* Interrupts are globally masked initially.*/
cpsid i cpsid i
#if CRT0_FORCE_MSP_INIT == TRUE
/* MSP stack pointers initialization.*/
ldr r0, =__main_stack_end__
msr MSP, r0
#endif
/* PSP stack pointers initialization.*/ /* PSP stack pointers initialization.*/
ldr r0, =__process_stack_end__ ldr r0, =__process_stack_end__
msr PSP, r0 msr PSP, r0

View File

@ -180,6 +180,12 @@ Reset_Handler:
/* Interrupts are globally masked initially.*/ /* Interrupts are globally masked initially.*/
cpsid i cpsid i
#if CRT0_FORCE_MSP_INIT == TRUE
/* MSP stack pointers initialization.*/
ldr r0, =__main_stack_end__
msr MSP, r0
#endif
/* PSP stack pointers initialization.*/ /* PSP stack pointers initialization.*/
ldr r0, =__process_stack_end__ ldr r0, =__process_stack_end__
msr PSP, r0 msr PSP, r0