This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 67e5206d9 boot/startup: Add optional stack fill in startup
67e5206d9 is described below
commit 67e5206d9c292c62a9fe5b72c57aa717809b98f7
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Mar 26 12:29:14 2025 +0100
boot/startup: Add optional stack fill in startup
Code was already present in default startup code for NRF5340.
Now is available for all devices with common startup.
It allows to verify real main stack requirements (interrupt
stack) and stack used in bootloader.
Signed-off-by: Jerzy Kasenberg <[email protected]>
---
boot/startup/src/arch/cortex_m0/cortex_m0_startup.s | 11 +++++++++++
boot/startup/src/arch/cortex_m3/cortex_m3_startup.s | 11 +++++++++++
boot/startup/src/arch/cortex_m33/cortex_m33_startup.s | 11 +++++++++++
boot/startup/src/arch/cortex_m4/cortex_m4_startup.s | 11 +++++++++++
boot/startup/src/arch/cortex_m7/cortex_m7_startup.s | 11 +++++++++++
boot/startup/syscfg.yml | 5 +++++
6 files changed, 60 insertions(+)
diff --git a/boot/startup/src/arch/cortex_m0/cortex_m0_startup.s
b/boot/startup/src/arch/cortex_m0/cortex_m0_startup.s
index eab559146..fd590791a 100644
--- a/boot/startup/src/arch/cortex_m0/cortex_m0_startup.s
+++ b/boot/startup/src/arch/cortex_m0/cortex_m0_startup.s
@@ -17,6 +17,8 @@
* under the License.
*/
+#include "syscfg/syscfg.h"
+
.syntax unified
.arch armv6-m
@@ -64,6 +66,15 @@ Reset_Handler:
.L_zero_table_done:
+#if MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r0, =MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r2, =__StackLimit
+ mov r1, sp
+0: stm r2!, {r0}
+ cmp r2, r1
+ blt 0b
+#endif
+
ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
diff --git a/boot/startup/src/arch/cortex_m3/cortex_m3_startup.s
b/boot/startup/src/arch/cortex_m3/cortex_m3_startup.s
index 03f77f779..4e6b20eea 100644
--- a/boot/startup/src/arch/cortex_m3/cortex_m3_startup.s
+++ b/boot/startup/src/arch/cortex_m3/cortex_m3_startup.s
@@ -17,6 +17,8 @@
* under the License.
*/
+#include "syscfg/syscfg.h"
+
.syntax unified
.arch armv7-m
@@ -67,6 +69,15 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:
+#if MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r0, =MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r2, =__StackLimit
+ mov r1, sp
+0: stm r2!, {r0}
+ cmp r2, r1
+ blt 0b
+#endif
+
ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
diff --git a/boot/startup/src/arch/cortex_m33/cortex_m33_startup.s
b/boot/startup/src/arch/cortex_m33/cortex_m33_startup.s
index 471927f42..27f995c91 100644
--- a/boot/startup/src/arch/cortex_m33/cortex_m33_startup.s
+++ b/boot/startup/src/arch/cortex_m33/cortex_m33_startup.s
@@ -17,6 +17,8 @@
* under the License.
*/
+#include "syscfg/syscfg.h"
+
.syntax unified
.arch armv7-m
@@ -70,6 +72,15 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:
+#if MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r0, =MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r2, =__StackLimit
+ mov r1, sp
+0: stm r2!, {r0}
+ cmp r2, r1
+ blt 0b
+#endif
+
ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
diff --git a/boot/startup/src/arch/cortex_m4/cortex_m4_startup.s
b/boot/startup/src/arch/cortex_m4/cortex_m4_startup.s
index 03f77f779..4e6b20eea 100644
--- a/boot/startup/src/arch/cortex_m4/cortex_m4_startup.s
+++ b/boot/startup/src/arch/cortex_m4/cortex_m4_startup.s
@@ -17,6 +17,8 @@
* under the License.
*/
+#include "syscfg/syscfg.h"
+
.syntax unified
.arch armv7-m
@@ -67,6 +69,15 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:
+#if MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r0, =MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r2, =__StackLimit
+ mov r1, sp
+0: stm r2!, {r0}
+ cmp r2, r1
+ blt 0b
+#endif
+
ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
diff --git a/boot/startup/src/arch/cortex_m7/cortex_m7_startup.s
b/boot/startup/src/arch/cortex_m7/cortex_m7_startup.s
index 03f77f779..4e6b20eea 100644
--- a/boot/startup/src/arch/cortex_m7/cortex_m7_startup.s
+++ b/boot/startup/src/arch/cortex_m7/cortex_m7_startup.s
@@ -17,6 +17,8 @@
* under the License.
*/
+#include "syscfg/syscfg.h"
+
.syntax unified
.arch armv7-m
@@ -67,6 +69,15 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:
+#if MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r0, =MYNEWT_VAL_MAIN_STACK_FILL
+ ldr r2, =__StackLimit
+ mov r1, sp
+0: stm r2!, {r0}
+ cmp r2, r1
+ blt 0b
+#endif
+
ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
diff --git a/boot/startup/syscfg.yml b/boot/startup/syscfg.yml
index 7aa08dce9..20d0a6601 100644
--- a/boot/startup/syscfg.yml
+++ b/boot/startup/syscfg.yml
@@ -34,6 +34,11 @@ syscfg.defs:
For bootloader it's main stack, for application this stack is used
by interrupts
and exceptions.
value: 768
+ MAIN_STACK_FILL:
+ description: >
+ Fill main stack (interrupt stack) with pattern on startup.
+ If not 0, value will be used as a pattern.
+ value: 0
INCLUDE_IMAGE_HEADER:
description: Add image header to generated executable.
value: 1