Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boot/startup: Add optional stack fill in startup #3398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions boot/startup/src/arch/cortex_m0/cortex_m0_startup.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

#include "syscfg/syscfg.h"

.syntax unified
.arch armv6-m

Expand Down Expand Up @@ -64,6 +66,14 @@ Reset_Handler:

.L_zero_table_done:

#if MYNEWT_VAL_MAIN_STACK_FILL
ldr r2, =0xdeadbeef
ldr r0, =__StackLimit
0: stm r0!, {r2}
cmp r0, sp
blt 0b
#endif

ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
Expand Down
10 changes: 10 additions & 0 deletions boot/startup/src/arch/cortex_m3/cortex_m3_startup.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

#include "syscfg/syscfg.h"

.syntax unified
.arch armv7-m

Expand Down Expand Up @@ -67,6 +69,14 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:

#if MYNEWT_VAL_MAIN_STACK_FILL
ldr r2, =0xdeadbeef
ldr r0, =__StackLimit
0: stm r0!, {r2}
cmp r0, sp
blt 0b
#endif

ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
Expand Down
10 changes: 10 additions & 0 deletions boot/startup/src/arch/cortex_m33/cortex_m33_startup.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

#include "syscfg/syscfg.h"

.syntax unified
.arch armv7-m

Expand Down Expand Up @@ -70,6 +72,14 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:

#if MYNEWT_VAL_MAIN_STACK_FILL
ldr r2, =0xdeadbeef
ldr r0, =__StackLimit
0: stm r0!, {r2}
cmp r0, sp
blt 0b
#endif

ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
Expand Down
10 changes: 10 additions & 0 deletions boot/startup/src/arch/cortex_m4/cortex_m4_startup.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

#include "syscfg/syscfg.h"

.syntax unified
.arch armv7-m

Expand Down Expand Up @@ -67,6 +69,14 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:

#if MYNEWT_VAL_MAIN_STACK_FILL
ldr r2, =0xdeadbeef
ldr r0, =__StackLimit
0: stm r0!, {r2}
cmp r0, sp
blt 0b
#endif

ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
Expand Down
10 changes: 10 additions & 0 deletions boot/startup/src/arch/cortex_m7/cortex_m7_startup.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

#include "syscfg/syscfg.h"

.syntax unified
.arch armv7-m

Expand Down Expand Up @@ -67,6 +69,14 @@ Reset_Handler:
b .L_for_each_zero_region
.L_zero_table_done:

#if MYNEWT_VAL_MAIN_STACK_FILL
ldr r2, =0xdeadbeef
ldr r0, =__StackLimit
0: stm r0!, {r2}
cmp r0, sp
blt 0b
#endif

ldr r0, =__HeapBase
ldr r1, =__HeapLimit
bl _sbrkInit
Expand Down
4 changes: 4 additions & 0 deletions boot/startup/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ 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.
value: 0
INCLUDE_IMAGE_HEADER:
description: Add image header to generated executable.
value: 1
Expand Down