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 b84388bc5 mcu/nrf5340: Trust zone RAM clean update
b84388bc5 is described below

commit b84388bc54eb4376c7d01e1e6a7d3823b5e584ee
Author: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl>
AuthorDate: Fri Jun 10 12:29:31 2022 +0200

    mcu/nrf5340: Trust zone RAM clean update
    
    RAM_SIZE was always taken from bps.h.
    With trust zone in place it may be that the bootloader
    had limited RAM assigned in linker scripts.
    This may happen when MCU_BOOT_MEASURED_STARTUP is used.
    This change clears only RAM that bootloader used.
    If nothing special was done to linker scripts RAM size
    will be the same as it used to be.
    
    Signed-off-by: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl>
---
 hw/mcu/nordic/nrf5340/src/hal_system_start.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/mcu/nordic/nrf5340/src/hal_system_start.c 
b/hw/mcu/nordic/nrf5340/src/hal_system_start.c
index ecb3cf196..c744a5bc5 100644
--- a/hw/mcu/nordic/nrf5340/src/hal_system_start.c
+++ b/hw/mcu/nordic/nrf5340/src/hal_system_start.c
@@ -68,6 +68,8 @@ static const unsigned int net_gpios[] = { 
UNMANGLE_MYNEWT_VAL(MYNEWT_VAL(MCU_GPI
 static const unsigned int periph_gpios[] = { 
UNMANGLE_MYNEWT_VAL(MYNEWT_VAL(MCU_GPIO_PERIPH)) };
 #endif
 
+extern uint8_t __StackTop[];
+
 void
 hal_system_start(void *img_start)
 {
@@ -142,13 +144,12 @@ hal_system_start(void *img_start)
      * Normal loop here is inlined by GCC to call to memset hence asm version 
of
      * memset that does not use stack (that just get erased).
      */
-    asm volatile("    add     %1, %1, %0    \n"
-                 "    mov     r0, #0        \n"
+    asm volatile("    mov     r0, #0        \n"
                  "1:  stmia   %0!, {r0}     \n"
                  "    cmp     %0, %1        \n"
                  "    blt     1b            \n"
         :
-        : "r" (&_ram_start), "r" (RAM_SIZE)
+        : "r" (&_ram_start), "r" (&__StackTop)
         : "r0");
     /* Application startup code expects interrupts to be enabled */
     __enable_irq();

Reply via email to