diff --git a/soc/st/stm32/stm32h7x/soc_m4.c b/soc/st/stm32/stm32h7x/soc_m4.c index 96762f89b81..7ee985a2a3a 100644 --- a/soc/st/stm32/stm32h7x/soc_m4.c +++ b/soc/st/stm32/stm32h7x/soc_m4.c @@ -37,19 +37,19 @@ void soc_early_init_hook(void) /* Enable hardware semaphore clock */ LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_HSEM); - /* In case CM4 has not been forced boot by CM7, - * CM4 needs to wait until CM7 has setup clock configuration + /** + * Cortex-M7 is responsible for initializing the system. + * + * CM7 will start CM4 ("forced boot") at the end of system + * initialization if the core is not already running - in + * this scenario, we don't have to wait because the system + * is initialized. Otherwise, wait for CM7 to initialize the + * system before proceeding with the boot process. CM7 will + * acquire a specific HSEM to indicate that CM4 can proceed. */ if (!LL_RCC_IsCM4BootForced()) { - /* - * Domain D2 is waiting for Cortex-M7 to perform - * system initialization - * (system clock config, external memory configuration.. ). - * End of system initialization is reached when CM7 takes HSEM. - */ - while ((HSEM->RLR[CFG_HW_ENTRY_STOP_MODE_SEMID] & HSEM_R_LOCK) - != HSEM_R_LOCK) { - ; + while (!LL_HSEM_IsSemaphoreLocked(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID)) { + /* Wait for CM7 to lock the HSEM after system initialization */ } } } diff --git a/soc/st/stm32/stm32h7x/soc_m7.c b/soc/st/stm32/stm32h7x/soc_m7.c index 46c9c954e95..6d68475cdc9 100644 --- a/soc/st/stm32/stm32h7x/soc_m7.c +++ b/soc/st/stm32/stm32h7x/soc_m7.c @@ -31,9 +31,13 @@ static int stm32h7_m4_wakeup(void) LL_APB4_GRP1_EnableClock(LL_APB4_GRP1_PERIPH_SYSCFG); if (READ_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4)) { - /* Cortex-M4 is waiting for end of system initialization made by - * Cortex-M7. This initialization is now finished, - * then Cortex-M7 takes HSEM so that CM4 can continue running. + /** + * Cortex-M4 has been started by hardware. + * Its `soc_early_init_hook()` will stall boot until + * a specific HSEM becomes locked, which indicates + * that Cortex-M7 has finished initializing the system. + * As system initialization is now complete, lock the + * HSEM to release CM4 and allow it to continue booting. */ LL_HSEM_1StepLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID); } else if (IS_ENABLED(CONFIG_STM32H7_BOOT_M4_AT_INIT)) {