-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: allow definition of HSI divider in board config #6287
Conversation
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.
See inline
Excuse me, how is that a breaking change? |
It will break non-intree builds - Breaking change says:This change requires a mitigation entry in the release notes. |
But what do you understand will break? This is a sincere question here. I dont understand the issue. |
If STM32_BOARD_USEHSI is declared in an out of tree build, the build will fail. Yes it has a message - that is great, but there have been very stern complaints about undocumented changes that break the build. This tag make sure the release notes have a mention. |
With the current code, if any board external or internal defines STM32_BOARD_USEHSI, the board will hang as soon as the code to configure the PLL is executed. It just does not work. Thats why I believe that no external project is actually defining USEHSI. Otherwise, the bug would have been found already. I think a build error is preferable to a runtime hang with no obvious explanation. |
@slorquet Please fix the CI failures |
It seems that some jobs were cancelled when you requested changes. will these restart automatically? |
That is not how it works.... The cancel is caused because of the real build failure https://github.com/apache/incubator-nuttx/runs/6472207049?check_suite_focus=true Fixed it, do a fixup (rebase -i master and either squash (s) it or do fixup (f) and force push - that will start CI again. |
Sorry! Did not see this. looking into it now. |
I think I have managed to execute the workflow you suggested. I changed my patch to only use this define when the clock actually uses HSI. I have verified that this compiles and execute both for HSE and HSI. |
nothing in the last commits have a relation to this pull request. Note: I've run out of spoons on this issue. |
c9c2070
to
7220de0
Compare
When the CI first failed, I was surprised to encounter an attempt to set the HSI divider in a board that did not use HSI. I investigated and found that code in the rcc_reset() function, which was surprising That is why I moved the code into stm32_clockconfig() where the HSI configuration is applied: The STM32 chips boot with a default clock that just works, so there is no need to set a HSI divider in the rcc_reset code. Since my board works like this (a breakage would hang) I am confident that my change is correct. Thats just my opinion and I agree that someone could add more info here if you dont have enough trust in my change. |
@slorquet I have pinged Jukka on Slack, I looking at this in detail now: I just has a quick look at the Clock tree and the code more carefully. Thing make less sense now :( The HSI is the default clock on reset: The original code
So this code is : RCC_CR_HSIDIV_MASK is dropping the default. So the comments say....But the RM0433 Rev 7 says:
So it is really slowing down the system by 4X at boot. I wonder if the HW he was debugging was an issue. Let's see what he says. My take is: It s it better to boot faster and make it work with 00: Division by 1, hsi(_ker)_ck = 64 MHz (default after reset), then set up the clock tree and the the final setting can be done with the divisor once the clock tree is configured. Which is the direction you have taken. I know you ran it as a test, but did you review and verify the code path's order of operations of modifying the clock tree without the drop and ensure there is not an issue with going out of spec on the PLL set up? Are you up for that? If not the safe thing to do is leave the original code with the /4 and your final change. |
I did not and I have no issue to restore the default setting in rcc_reset. Shall I proceed to restore this just now? |
Yes. Better safe then sorry. |
I think there is an error in the log message: "This commit adds the ability to choose the HSE divider, which must be indicated in board.h ." (Emphasis mine.) I think you meant HSI divider here. |
Sure, will update that. |
…dicated in board.h if used.
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.
Thank you @slorquet!
Summary
nucleo-h743zi is the only instanciation of stm32h7, and this board uses the HSE oscillator provided by the stlink interface.
If the integrated stlink debugger is disabled (this can happen in certain power configurations) then the CPU has no more clock reference. The HSI can be used instead, but definitions to do so easily are currently lacking.
When the HSI is used, the HSI divider is hardwired to 4, which results in a 16 MHz reference clock, and this requires a full recomputation of all PLL constants to match the complex clock tree speeds.
This commit adds the ability to choose the HSI divider, which must be indicated in board.h .
This is useful to match the HSI frequency to the existing HSE config, eg 8 MHz.
This allows to use the exact same PLL configuration and minimizes code changes.
Impact
None expected if projects based on STM32H7 continue to use HSE.
This is new code that only applies to users of STM32H7 that want to use the HSI oscillator. To my knowledge there is none but you never know.
Testing
In theory, all projects using STM32H7 should be retested. No regression is expected.