Skip to content

modules: cmsis, cmsis_6: only add the intended cmsis module #93715

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fabiobaltieri
Copy link
Member

@fabiobaltieri fabiobaltieri commented Jul 25, 2025

The current code base is meant to use cmsis for Cortex A and R and cmsis_6 for Cortex M, but the build system is configured to include the path for both when Cortex M is selected. This leaves us exposed to PR using the old headers, that would not get caught in CI but would fail the build on a project using Cortex M that only has the cmsis_6 module.

Change the cmsis module setting to only include the module files in the intended case.

Deps

@fabiobaltieri
Copy link
Member Author

fabiobaltieri commented Jul 25, 2025

This should fail until #93707 is merged -- it does

@fabiobaltieri fabiobaltieri requested a review from ithinuel July 25, 2025 10:12
@fabiobaltieri
Copy link
Member Author

@wearyzen can we delete https://github.com/zephyrproject-rtos/cmsis/tree/master/CMSIS/Core entirely or there's a reason to keep it? Would still do this change as well but I'm happy to open a PR to drop that code if we don't need it anymore.

@fabiobaltieri fabiobaltieri changed the title modules: cmsis: only add cmsis path for Cortex A and R modules: cmsis, cmsis_6: only add the intended cmsis module Jul 25, 2025
wearyzen
wearyzen previously approved these changes Jul 25, 2025
@wearyzen wearyzen dismissed their stale review July 25, 2025 10:56

I am not sure if this will be enough,
cmsis-dsp uses the old cmsis here :

set(cmsis_glue_path ${ZEPHYR_CMSIS_MODULE_DIR})

cmsis-nn here:
set(cmsis_glue_path ${ZEPHYR_CMSIS_MODULE_DIR})

So even if the ci doesn't catch this, this could result in another bug report

@wearyzen
Copy link
Contributor

@wearyzen can we delete https://github.com/zephyrproject-rtos/cmsis/tree/master/CMSIS/Core entirely or there's a reason to keep it? Would still do this change as well but I'm happy to open a PR to drop that code if we don't need it anymore.

There are modules still using it so I don't think we should delete it.

@fabiobaltieri
Copy link
Member Author

ok but it looks like both cmsis-dsp and cmsis-nn have that include line behind a CONFIG entry, so CI should still catch it for tests that do not enable those modules (i.e. most of them, I did run this change before merging the revert and it did indeed fail)

@fabiobaltieri
Copy link
Member Author

fabiobaltieri commented Jul 25, 2025

Also, looks like it's not that unused after all, even putting those modules aside :-)

@wearyzen
Copy link
Contributor

wearyzen commented Jul 25, 2025

Also, looks like it's not that unused after all, even putting those modules aside :-)

Maybe we introduce a new config USE_CMSIS_5_MODULE which cmsis-nn and cmsis-dsp (or the other current reported modules) enables and is enabled by default for Cortex-A and R, and then the include goes under this config?

@wearyzen
Copy link
Contributor

Also, looks like it's not that unused after all, even putting those modules aside :-)

Maybe we introduce a new config USE_CMSIS_5_MODULE which cmsis-nn and cmsis-dsp (or the other current reported modules) enables and is enabled by default for Cortex-A and R, and then the include goes under this config?

Yeah I think this would be good to keep track of who is using the old cmsis as well.

@wearyzen
Copy link
Contributor

wearyzen commented Jul 25, 2025

This seems to fix things locally for me and covers all the current CI failures

git diff
diff --git a/modules/Kconfig.microchip b/modules/Kconfig.microchip
index 7497d99ead0..947d92e9cf1 100644
--- a/modules/Kconfig.microchip
+++ b/modules/Kconfig.microchip
@@ -10,3 +10,6 @@ config HAS_MPFS_HAL

 config HAS_MEC5_HAL
        bool "Microchip MEC5 HAL drivers support"
+
+config HAS_CMSIS_5_CORE_M
+       default y
diff --git a/modules/cmsis/CMakeLists.txt b/modules/cmsis/CMakeLists.txt
index 4044ae891b3..b1c2bc270fd 100644
--- a/modules/cmsis/CMakeLists.txt
+++ b/modules/cmsis/CMakeLists.txt
@@ -1,7 +1,10 @@
 # Copyright (c) 2023 Nordic Semiconductor ASA
 # SPDX-License-Identifier: Apache-2.0

-if(CONFIG_CPU_AARCH32_CORTEX_A OR CONFIG_CPU_AARCH32_CORTEX_R)
+if(CONFIG_HAS_CMSIS_5_CORE_M OR CONFIG_HAS_CMSIS_CORE_A OR CONFIG_HAS_CMSIS_CORE_R)
   add_subdirectory(${ZEPHYR_CURRENT_MODULE_DIR} cmsis)
+endif()
+
+if(CONFIG_CPU_AARCH32_CORTEX_A OR CONFIG_CPU_AARCH32_CORTEX_R)
   zephyr_include_directories(.)
 endif()
diff --git a/modules/cmsis/Kconfig b/modules/cmsis/Kconfig
index 9cc5ee79630..617dfae4952 100644
--- a/modules/cmsis/Kconfig
+++ b/modules/cmsis/Kconfig
@@ -4,6 +4,9 @@
 config ZEPHYR_CMSIS_MODULE
        bool

+config HAS_CMSIS_5_CORE_M
+       bool
+
 config HAS_CMSIS_CORE
        bool
        select HAS_CMSIS_CORE_A if CPU_AARCH32_CORTEX_A

@fabiobaltieri
Copy link
Member Author

This seems to fix things locally for me and covers all the current CI failures

mmh that would enable HAS_CMSIS_5_CORE_M for everything, that set should go somewhere else, but listen I think I'd rather have the failing platform fixed and hold this rather than introducing another temporary workaround

@fabiobaltieri fabiobaltieri marked this pull request as draft July 25, 2025 14:57
@fabiobaltieri
Copy link
Member Author

Blocked on #93725

Copy link

github-actions bot commented Jul 25, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_ambiq zephyrproject-rtos/hal_ambiq@84ccbfc zephyrproject-rtos/hal_ambiq#56 zephyrproject-rtos/hal_ambiq#56/files
hal_microchip zephyrproject-rtos/hal_microchip@32a79d4 zephyrproject-rtos/hal_microchip#35 zephyrproject-rtos/hal_microchip#35/files
hal_silabs zephyrproject-rtos/hal_silabs@190a144 zephyrproject-rtos/hal_silabs#122 zephyrproject-rtos/hal_silabs#122/files

DNM label due to: 3 projects with PR revision

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@fabiobaltieri fabiobaltieri marked this pull request as ready for review July 25, 2025 17:12
@wearyzen
Copy link
Contributor

wearyzen commented Jul 25, 2025

wow that was quick 😃 Looks like you covered everything that Zephyr's ci covers!
Adding a small comment otherwise LGTM, thanks again for adding this change!

Always use the cmsis_6 version for DWT_LSR_Present_Msk and
DWT_LSR_Access_Msk, the old ones are not going to be available anymore
when Cortex-M is selected..

Signed-off-by: Fabio Baltieri <[email protected]>
… fixes

Update various hals to pickup the cmsis_6 related fixes.

Signed-off-by: Fabio Baltieri <[email protected]>
The current code base is meant to use cmsis for Cortex A and R and
cmsis_6 for Cortex M, but the build system is configured to include the
path for both when Cortex M is selected. This leaves us exposed to PR
using the old headers, that would not get caught in CI but would fail
the build on a project using Cortex M that only has the cmsis_6 module.

Change the cmsis module setting to only include the module files in the
intended case.

Signed-off-by: Fabio Baltieri <[email protected]>
@fabiobaltieri
Copy link
Member Author

fabiobaltieri commented Jul 25, 2025

wow that was quick 😃 Looks like you covered everything that Zephyr's ci covers!

Yeah well, that's what this specific run covers, there must be more in the hals but I really don't have an effective way of chasing that down so I'm afraid this is the best we can do.

Copy link

@AlessandroLuo
Copy link
Contributor

FYI zephyrproject-rtos/hal_ambiq#56 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture area: CMSIS-Core DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-hal_ambiq manifest-hal_microchip manifest-hal_silabs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants