From 89a05716df4964579d3cf67e7669c8a5fecdd008 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 14 Feb 2023 01:53:06 +0100 Subject: [PATCH] cortex-m-rt: initialize the frame pointer chain. AAPCS says the starting value should be 0: https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#6214the-frame-pointer > The end of the frame record chain is indicated by the address zero in the address for the previous frame --- cortex-m-rt/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index 6f721975..35ff168f 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -530,6 +530,11 @@ cfg_global_asm! { ldr r1, =__vector_table str r1, [r0]", + // Initialize the frame pointer chain. + // https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#6214the-frame-pointer + // > The end of the frame record chain is indicated by the address zero in the address for the previous frame + "mov r7, #0", + // Run user pre-init code which must be executed immediately after startup, before the // potentially time-consuming memory initialisation takes place. // Example use cases include disabling default watchdogs or enabling RAM.