Skip to content

kconfig: configure NUM_IRQS from Devicetree information#104819

Merged
MaureenHelm merged 4 commits intozephyrproject-rtos:mainfrom
mathieuchopstm:topic/kconfig_num_irqs
Mar 20, 2026
Merged

kconfig: configure NUM_IRQS from Devicetree information#104819
MaureenHelm merged 4 commits intozephyrproject-rtos:mainfrom
mathieuchopstm:topic/kconfig_num_irqs

Conversation

@mathieuchopstm
Copy link
Contributor

Spiritual successor of #33774

Introduce a new Kconfig preprocessor helper dt_highest_controller_irq_number(path, cell) which, given the path to an interrupt controller and the name of the "IRQ number" cell among the controller's interrupt-cells, returns the maximal "IRQ number" found among all nodes linked to this controller. (the helper could be made more generic, e.g. dt_pha_cells_minmax_by_controller(path, prop, cell, min_or_max), where dt_highest_controller_irq_number(path, cell) = dt_pha_cells_minmax_by_controller(path, "interrupts", cell, max) if it sounds more useful)

Using this new helper, replace all hardcoded CONFIG_IRQ_NUM defaults in STM32 SoC files which heavily simplifies them and should provide a footprint reduction in many use cases. (this is limited to Cortex-M SoCs for now, but it could easily be expanded to (1) all STM32s SoCs and (2) Cortex-M-based SoCs)

Use new Kconfig preprocessor helper to compute CONFIG_NUM_IRQS during build
instead of hardcoding it based on product Reference Manual

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add release note section about the new Kconfig preprocessor function
`dt_highest_controller_irq_number`.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
As CONFIG_NUM_IRQS is now determined dynamically, it is possible that apps
which registered ISRs outside drivers will trigger a build failure if the
registered IRQn is higher than the biggest active device's IRQn.

Add a note in the migration guide which describes this problem and gives
the solution to tackle these build failures.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
@mathieuchopstm
Copy link
Contributor Author

Rebased + added support for new STM32C5 / STM32H5{E,F} / STM32WBA2 SoCs (no change necessary in STM32U3 as it already used a common config NUM_IRQS)

Diff here: https://github.com/zephyrproject-rtos/zephyr/compare/08254a95de00f6b5a6309ee9e4c71cd15f3b44a1..56bc08175dfe0f85dbd3e1c6c64fa42439661553

@mathieuchopstm mathieuchopstm removed the DNM This PR should not be merged (Do Not Merge) label Mar 20, 2026
@sonarqubecloud
Copy link

@MaureenHelm MaureenHelm merged commit 4772b98 into zephyrproject-rtos:main Mar 20, 2026
31 of 32 checks passed
@mathieuchopstm mathieuchopstm deleted the topic/kconfig_num_irqs branch March 23, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards/SoCs area: Build System area: Devicetree area: Kconfig platform: STM32 ST Micro STM32 Release Notes To be mentioned in the release notes RFC Request For Comments: want input from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants