From b0779f0ee868d67d159983af60b4bf24b954a853 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 29 Jun 2017 12:44:24 +0700 Subject: [PATCH] fill stack region with pattern 0xADADADAD for detect stack usage --- cores/nRF5/gcc_startup_nrf52.S | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cores/nRF5/gcc_startup_nrf52.S b/cores/nRF5/gcc_startup_nrf52.S index a75d3ad1..74501e01 100755 --- a/cores/nRF5/gcc_startup_nrf52.S +++ b/cores/nRF5/gcc_startup_nrf52.S @@ -28,7 +28,7 @@ .syntax unified .arch armv7e-m -/* Adafruit nrf52 use RTOS, thus disable stack here */ +/* Adafruit define stack & heap inside linker script */ /* .section .stack .align 3 #ifdef __STACK_SIZE @@ -362,6 +362,16 @@ Reset_Handler: .L_loop1_done: +/* Adafruit fill stack region with pattern 0xADADADAD */ + ldr r0, =__StackLimit + ldr r1, =__StackSize + ldr r2, =0xADADADAD +.L_fill: + str r2, [r0] + adds r0, 4 + subs r1, 4 + bne .L_fill + /* This part of work usually is done in C library startup code. Otherwise, * define __STARTUP_CLEAR_BSS to enable it in this startup. This section * clears the RAM where BSS data is located.