-
Notifications
You must be signed in to change notification settings - Fork 7.6k
stm32h7: synchronize cores properly during boot #90668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stm32h7: synchronize cores properly during boot #90668
Conversation
Reorder the HSEM semaphore ID definitions to be sorted by ascending value. The dummy defines are also changed to be sorted in the same order. The definitions for STM32MP1 are already in an order that follows this order so they don't need to be changed. Signed-off-by: Mathieu Choplain <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For commit "soc: st: stm32: hsem: update description for fifth HSEM":
could you also mention in the commit message that you remove definition of macro CFG_HW_ENTRY_STOP_MODE_MASK_SEMID
that is not used.
bc8bbb5
to
28440f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits, otherwise looks good!
The fifth HSEM (#define is equal to 4 due to zero-indexing) is used on STM32H7 to synchronize the two cores. Update the comment above the SEMID define to reflect this alternate usage. Also remove the associated define CFG_HW_ENTRY_STOP_MODE_MASK_SEMID, which is unused. Signed-off-by: Mathieu Choplain <[email protected]>
On dual-core STM32H7, the Cortex-M4 core is supposed to wait until the Cortex-M7 initializes the system before starting to execute. CM7 should signal this by locking a specific HSEM, which CM4 should poll until locked. However, the logic on the Cortex-M4 side was reading the "RLR" register of HSEM, which *locks the semaphore on read* - in turn, this makes the CM4 start directly since it sees that the semaphore is locked (by itself). Use proper LL API to read HSEM status - which will read the "R" register instead - to make sure CM4 doesn't begin execution earlier than it should. Suggested-by: hglassdyb Signed-off-by: Mathieu Choplain <[email protected]>
28440f0
to
0362bab
Compare
|
On dual-core STM32H7, the Cortex-M4 core is supposed to wait until the Cortex-M7 initializes the system before starting to execute. CM7 should signal this by locking a specific HSEM, which CM4 should poll until locked. However, the logic on the Cortex-M4 side was reading the
HSEM_RLR
register to obtain semaphore status, which locks the semaphore on read - in turn, this makes the CM4 start directly since it sees that the semaphore is locked (by itself).Replace raw register read with call to proper LL API, which will read the
HSEM_R
register instead ofHSEM_RLR
, to make sure CM4 doesn't begin execution earlier than it should, and update the comments insoc_m4.c
andsoc_m7.c
related to this boot process.Fixes #86494 - confirmed working on STM32H747I-DISCO by flashing
samples/basic/blinky
on Cortex-M4 andsamples/hello_world
on Cortex-M7. With patch, the LED can be seen blinking only ifCONFIG_STM32H7_DUAL_CORE=y
(andCONFIG_STM32H7_BOOT_M4_AT_INIT=y
if theBCM4
option byte is disabled) - without patch, the LED can be seen blinking in all scenarios if theBCM4
option byte is enabled.First commit tidies
stm32_hsem.h
- mostly cosmetic changes, but I also removed the seemingly unusedCFG_HW_ENTRY_STOP_MODE_MASK_SEMID
define. This commit can be dropped if preferred.