hal/stm32n6: add configuration options for CPU/NPU clock#430
hal/stm32n6: add configuration options for CPU/NPU clock#430jmaksymowicz wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for configuring the CPU clock frequency and power supply on the STM32N6 platform, adding the _stm32_rccSetCPUClock and _stm32_pwrGetCPUVolt functions along with pre-baked PLL configurations. The review feedback highlights a critical issue where PWR registers are accessed before the PWR peripheral clock is enabled, which would lead to a Bus Fault or Hard Fault. Additionally, a compile-time preprocessor check is suggested to prevent invalid clock and voltage configurations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Unit Test Results10 860 tests +275 10 190 ✅ +276 53m 6s ⏱️ -11s Results for commit 203fb1d. ± Comparison against base commit a139fa2. This pull request removes 3 and adds 278 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
1d266a9 to
bf33119
Compare
Add voltage scaling configuration. YT: RTOS-1370
bf33119 to
203fb1d
Compare
Description
IMPORTANT: with this change PLL3 is reserved for clocking internal buses, peripherals and timers. If any external project reconfigures or otherwise depends on PLL3, please modify it to use PLL4 which is shall be reserved for auxiliary use.
The change to PLL allocation allows CPU and NPU clocks to be decoupled from the rest of the system, so that e.g. timers don't need to be reconfigured along with the CPU. The only exception is the SysTick - but it's not used in the kernel, so it's not a big problem.
To allow increasing the frequency, voltage scaling needs to be set to high using
PWR_CORE_CONFIGdefinition - it needs to be put intoboard_config.h. The constant also sets up the use of the chip's built-in SMPS (step-down power converter) which is unused on Nucleo boards, but must be enabled for pilot boards.Once voltage scaling has been set appropriately, the frequency can be chosen by setting
RCC_DEFAULT_CPU_CLOCKconstant. Currently the only valid choices are 600 MHz (maximum when VOS low) and 800 MHz (maximum when VOS high). These settings also configure the NPU and AXISRAM3/4/5/6 clocks:If there is business need clocking can be expanded to:
Motivation and Context
Increase CPU and NPU performance when requested.
YT: PP-512
Types of changes
How Has This Been Tested?
Checklist:
Special treatment