diff --git a/arch/arm/core/cortex_m/reset.S b/arch/arm/core/cortex_m/reset.S index dedb5f0982f..564d0a2c1a9 100644 --- a/arch/arm/core/cortex_m/reset.S +++ b/arch/arm/core/cortex_m/reset.S @@ -33,6 +33,7 @@ _ASM_FILE_PROLOGUE GTEXT(__reset) +GTEXT(memset) GDATA(_interrupt_stack) /** @@ -78,6 +79,13 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start) msr BASEPRI, r0 #endif +#ifdef CONFIG_INIT_STACKS + ldr r0, =_interrupt_stack + mov r1, #0xaa + ldr r2, =CONFIG_ISR_STACK_SIZE + bl memset +#endif + /* * Set PSP and use it to boot without using MSP, so that it * gets set to _interrupt_stack during nanoInit(). diff --git a/arch/arm/core/cortex_m/vector_table.S b/arch/arm/core/cortex_m/vector_table.S index 240b3a07c76..c9f725ba743 100644 --- a/arch/arm/core/cortex_m/vector_table.S +++ b/arch/arm/core/cortex_m/vector_table.S @@ -36,6 +36,8 @@ _ASM_FILE_PROLOGUE +GDATA(_main_stack) + SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) /* in XIP kernels. the entry point is also the start of the vector table */ @@ -43,7 +45,13 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,__start) #endif - .word 0 /* no need for a stack, the kernel sets one up before running C */ + /* + * setting the _very_ early boot on the main stack allows to use memset + * on the interrupt stack when CONFIG_INIT_STACKS is enabled before + * switching to the interrupt stack for the rest of the early boot + */ + .word _main_stack + CONFIG_MAIN_STACK_SIZE + .word __reset .word __nmi