Fix crash caused by using higher MSI range as sysclk on STM32WL #2786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have an STM32WLE5 module with no HSE, the official C demo code uses MSI range11. It worked with embassy about 1 year ago. (ref: https://andelf.github.io/blog/2023/01/23/stm32wl-lora-with-rust-embassy/ )
Now after I porting the old code to the current embassy main branch, I got an error after BD is initiated:
The minimal reproduce code:
After a year. So many new changes were merged. I had to look into the rcc part. The crash point is randomly located between LS init and FLASH setting.
After some digging, I found this comment might be related:
embassy/embassy-stm32/src/rcc/bd.rs
Lines 118 to 126 in a4eebdc
Sadly, STM32WLE5's condition is worse, if I use MSIRange11(48MHz), it crashes no matter what the ls config is.
Then I realized it was caused by the fact that:
msi_enable(MSIRange::RANGE48M)
is called, the system clock is already 48MThis might also happen for other families. I just added a quick fix for the STM32WL family only.
Any other solutions? (simplify rcc init using prebuilt macros / init LS before sysclk / ...?)