From a4883d8fa65c0987985d8e5546583b0f5d07513e Mon Sep 17 00:00:00 2001 From: wanggang26 Date: Sun, 4 Aug 2024 19:11:38 +0800 Subject: [PATCH] nucleo-h745zi: fix potential bl jump to app failed issue After changing sp, following functions calling will result in unpredictable behavior in case of jumping Signed-off-by: wanggang26 --- .../arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c index f09e0847c6..9e6eb92c39 100644 --- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c +++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c @@ -172,10 +172,12 @@ int board_boot_image(const char *path, uint32_t hdr_size) /* Set main and process stack pointers */ - __asm__ __volatile__("\tmsr msp, %0\n" : : "r" (vt.spr)); - setcontrol(0x00); - ARM_ISB(); - ((void (*)(void))vt.reset)(); + __asm__ __volatile__("\tmsr msp, %0\n" + "\tmsr control, %1\n" + "\tisb\n" + "\tmov pc, %2\n" + : + : "r" (vt.spr), "r" (0), "r" (vt.reset)); return 0; }