This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 7de204e746a889b86b3fe8f33a8019fa6400fafe
Author: Jacob Dahl <[email protected]>
AuthorDate: Thu Nov 19 13:58:50 2026 -0700

    arch/arm/stm32h7: Add an optional hook before clock setup.
    
    __start now calls a weak stm32_preclock_hook() right before
    stm32_clockconfig(), once .data and .bss are in place. A bootloader
    that hands over to the ROM's DFU bootloader has to do it while the
    chip is still as reset left it, and by the time the bootloader's main
    runs, clocks, caches, the MPU and USB are set up. PX4's bootloader
    uses the hook for reboot -i.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: Jacob Dahl <[email protected]>
---
 arch/arm/src/stm32h7/stm32_start.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm/src/stm32h7/stm32_start.c 
b/arch/arm/src/stm32h7/stm32_start.c
index fa55412dc06..efd46f1fa90 100644
--- a/arch/arm/src/stm32h7/stm32_start.c
+++ b/arch/arm/src/stm32h7/stm32_start.c
@@ -117,6 +117,12 @@ const uintptr_t g_idle_topstack = HEAP_BASE;
 void __start(void) noinstrument_function;
 #endif
 
+/* Called from __start before any clock setup, with .data and .bss in place.
+ * A bootloader can hand over to the ROM bootloader here.
+ */
+
+void stm32_preclock_hook(void) weak_function;
+
 #ifdef CONFIG_ARCH_CHIP_STM32H7_CORTEXM7
 /****************************************************************************
  * Name: stm32_tcmenable
@@ -244,6 +250,15 @@ void __start(void)
   arm_stack_check_init();
 #endif
 
+  /* Let the board act while the chip is still as reset left it, before
+   * any clock setup.
+   */
+
+  if (stm32_preclock_hook)
+    {
+      stm32_preclock_hook();
+    }
+
   /* Configure the UART so that we can get debug output as soon as possible */
 
   stm32_clockconfig();

Reply via email to