From b6140f15f3f761db057a90e3d5966f97338776e6 Mon Sep 17 00:00:00 2001 From: DipSwitch Date: Thu, 7 Apr 2016 00:27:26 +0200 Subject: [PATCH] cpu/cortex-m: Enable STKALIGN to make the Cortex-M keep the stack 8 byte aligned on 4 byte aligned stack pointers --- cpu/cortexm_common/cortexm_init.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpu/cortexm_common/cortexm_init.c b/cpu/cortexm_common/cortexm_init.c index 6e098b65cb..1875da98fd 100644 --- a/cpu/cortexm_common/cortexm_init.c +++ b/cpu/cortexm_common/cortexm_init.c @@ -52,4 +52,12 @@ void cortexm_init(void) /* enable wake up on events for __WFE CPU sleep */ SCB->SCR |= SCB_SCR_SEVONPEND_Msk; + + /* for Cortex-M3 r1p0 and up the STKALIGN option was added, but not automatically + * enabled until revision r2p0. For 64bit function arguments to work properly this + * needs to be enabled. + */ +#ifdef SCB_CCR_STKALIGN_Msk + SCB->CCR |= SCB_CCR_STKALIGN_Msk; +#endif }