From f726cb5123eda12feb8746e3acb34a1f7d7b0340 Mon Sep 17 00:00:00 2001 From: Sudan Landge Date: Tue, 29 Apr 2025 15:05:15 +0100 Subject: [PATCH] modules: CMSIS_6: Switch to CMSIS_6 for Cortex-M What is the change? Switch to module CMSIS_6 for Cortex-M while continuing to use cmsis module (version 5.9.0) for Cortex-A/R. Why do we need this change? The current cmsis module consists of: - Cortex-M support from upstream cmsis 5.9.0 - Cortex-A/R support which was not upstreamed to CMSIS Upstream cmsis 5.9 was deprecated so we should be using CMSIS_6 however, it seems due to lack of Cortex-A/R support in upstream and other reasons, this was pushed back. While upstreaming Cortex-A/R support to CMSIS_6 could take its time, this shouldn't stop Cortex-M to start using CMSIS_6. Also, if we do not use CMSIS_6 for Cortex-M then using the newer GCC 14.2 toolchain will return below compiler error: ``` zephyrproject/modules/hal/cmsis/CMSIS/Core/Include/core_cm85.h:4406:10: fatal error: pac_armv81.h: No such file or directory 4406 | #include "pac_armv81.h" ``` Using CMSIS_6 for Cortex-M will fix this. Signed-off-by: Sudan Landge --- modules/cmsis/CMakeLists.txt | 2 +- modules/cmsis/Kconfig | 16 ----------- modules/cmsis/cmsis_core.h | 4 +-- modules/cmsis_6/CMakeLists.txt | 9 ++++++ modules/cmsis_6/Kconfig | 28 +++++++++++++++++++ modules/cmsis_6/cmsis_core.h | 14 ++++++++++ modules/{cmsis => cmsis_6}/cmsis_core_m.h | 8 +++--- .../cmsis_core_m_defaults.h | 8 +++--- 8 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 modules/cmsis_6/CMakeLists.txt create mode 100644 modules/cmsis_6/Kconfig create mode 100644 modules/cmsis_6/cmsis_core.h rename modules/{cmsis => cmsis_6}/cmsis_core_m.h (90%) rename modules/{cmsis => cmsis_6}/cmsis_core_m_defaults.h (93%) diff --git a/modules/cmsis/CMakeLists.txt b/modules/cmsis/CMakeLists.txt index 59a8307a8fb..d23bcaea979 100644 --- a/modules/cmsis/CMakeLists.txt +++ b/modules/cmsis/CMakeLists.txt @@ -3,6 +3,6 @@ add_subdirectory(${ZEPHYR_CURRENT_MODULE_DIR} cmsis) -if(CONFIG_CPU_CORTEX_M OR CONFIG_CPU_AARCH32_CORTEX_A OR CONFIG_CPU_AARCH32_CORTEX_R) +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 aba63d35e1a..9cc5ee79630 100644 --- a/modules/cmsis/Kconfig +++ b/modules/cmsis/Kconfig @@ -8,7 +8,6 @@ config HAS_CMSIS_CORE bool select HAS_CMSIS_CORE_A if CPU_AARCH32_CORTEX_A select HAS_CMSIS_CORE_R if CPU_AARCH32_CORTEX_R - select HAS_CMSIS_CORE_M if CPU_CORTEX_M if HAS_CMSIS_CORE @@ -18,19 +17,4 @@ config HAS_CMSIS_CORE_A config HAS_CMSIS_CORE_R bool -config HAS_CMSIS_CORE_M - bool - -config CMSIS_M_CHECK_DEVICE_DEFINES - bool "Check device defines" - default n - depends on HAS_CMSIS_CORE_M - help - This options enables the validation of CMSIS configuration flags. - -config CMSIS_CORE_HAS_SYSTEM_CORE_CLOCK - bool - help - Enable this option if CMSIS SystemCoreClock symbols is available. - endif diff --git a/modules/cmsis/cmsis_core.h b/modules/cmsis/cmsis_core.h index 4f57c682138..b85533b56ae 100644 --- a/modules/cmsis/cmsis_core.h +++ b/modules/cmsis/cmsis_core.h @@ -6,9 +6,7 @@ #ifndef ZEPHYR_MODULES_CMSIS_CMSIS_H_ #define ZEPHYR_MODULES_CMSIS_CMSIS_H_ -#if defined(CONFIG_CPU_CORTEX_M) -#include "cmsis_core_m.h" -#elif defined(CONFIG_CPU_AARCH32_CORTEX_A) || defined(CONFIG_CPU_AARCH32_CORTEX_R) +#if defined(CONFIG_CPU_AARCH32_CORTEX_A) || defined(CONFIG_CPU_AARCH32_CORTEX_R) #include "cmsis_core_a_r.h" #endif diff --git a/modules/cmsis_6/CMakeLists.txt b/modules/cmsis_6/CMakeLists.txt new file mode 100644 index 00000000000..1f501f45342 --- /dev/null +++ b/modules/cmsis_6/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# Copyright 2025 Arm Limited and/or its affiliates +# SPDX-License-Identifier: Apache-2.0 + +add_subdirectory(${ZEPHYR_CURRENT_MODULE_DIR} cmsis_6) + +if(CONFIG_CPU_CORTEX_M) + zephyr_include_directories(.) +endif() diff --git a/modules/cmsis_6/Kconfig b/modules/cmsis_6/Kconfig new file mode 100644 index 00000000000..6da2792698e --- /dev/null +++ b/modules/cmsis_6/Kconfig @@ -0,0 +1,28 @@ +# Copyright (c) 2016 Intel Corporation +# Copyright 2025 Arm Limited and/or its affiliates +# SPDX-License-Identifier: Apache-2.0 + +config ZEPHYR_CMSIS_6_MODULE + bool + +config HAS_CMSIS_CORE + bool + select HAS_CMSIS_CORE_M if CPU_CORTEX_M + +if HAS_CMSIS_CORE + +config HAS_CMSIS_CORE_M + bool + +config CMSIS_M_CHECK_DEVICE_DEFINES + bool "Check device defines" + depends on HAS_CMSIS_CORE_M + help + This options enables the validation of CMSIS configuration flags. + +config CMSIS_CORE_HAS_SYSTEM_CORE_CLOCK + bool + help + Enable this option if CMSIS SystemCoreClock symbols is available. + +endif diff --git a/modules/cmsis_6/cmsis_core.h b/modules/cmsis_6/cmsis_core.h new file mode 100644 index 00000000000..3d85be7a396 --- /dev/null +++ b/modules/cmsis_6/cmsis_core.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright 2025 Arm Limited and/or its affiliates + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_H_ +#define ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_H_ + +#if defined(CONFIG_CPU_CORTEX_M) +#include "cmsis_core_m.h" +#endif + +#endif /* ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_H_ */ diff --git a/modules/cmsis/cmsis_core_m.h b/modules/cmsis_6/cmsis_core_m.h similarity index 90% rename from modules/cmsis/cmsis_core_m.h rename to modules/cmsis_6/cmsis_core_m.h index c8552f0ee77..4137e853376 100644 --- a/modules/cmsis/cmsis_core_m.h +++ b/modules/cmsis_6/cmsis_core_m.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2017 Nordic Semiconductor ASA - * Copyright (c) 2023 Arm Limited + * Copyright 2023,2025 Arm Limited and/or its affiliates * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,8 +12,8 @@ * This header contains the interface to the ARM CMSIS Core headers. */ -#ifndef ZEPHYR_MODULES_CMSIS_CMSIS_M_H_ -#define ZEPHYR_MODULES_CMSIS_CMSIS_M_H_ +#ifndef ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_M_H_ +#define ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_M_H_ #if defined(CONFIG_CMSIS_M_CHECK_DEVICE_DEFINES) && CONFIG_CMSIS_M_CHECK_DEVICE_DEFINES == 1U #define __CHECK_DEVICE_DEFINES 1U @@ -68,4 +68,4 @@ #error "__SAUREGION_PRESENT and CONFIG_CPU_HAS_ARM_SAU are not set to the same value" #endif -#endif /* ZEPHYR_MODULES_CMSIS_CMSIS_M_H_ */ +#endif /* ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_M_H_ */ diff --git a/modules/cmsis/cmsis_core_m_defaults.h b/modules/cmsis_6/cmsis_core_m_defaults.h similarity index 93% rename from modules/cmsis/cmsis_core_m_defaults.h rename to modules/cmsis_6/cmsis_core_m_defaults.h index f2c0656d220..bb084440ef7 100644 --- a/modules/cmsis/cmsis_core_m_defaults.h +++ b/modules/cmsis_6/cmsis_core_m_defaults.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2017 Nordic Semiconductor ASA - * Copyright (c) 2023 Arm Limited + * Copyright 2023,2025 Arm Limited and/or its affiliates * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,8 +13,8 @@ * ARM CMSIS Core headers. */ -#ifndef ZEPHYR_MODULES_CMSIS_CMSIS_M_DEFAULTS_H_ -#define ZEPHYR_MODULES_CMSIS_CMSIS_M_DEFAULTS_H_ +#ifndef ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_M_DEFAULTS_H_ +#define ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_M_DEFAULTS_H_ #include @@ -143,4 +143,4 @@ typedef enum { #error "Unknown Cortex-M device" #endif -#endif /* ZEPHYR_MODULES_CMSIS_CMSIS_M_DEFAULTS_H_ */ +#endif /* ZEPHYR_MODULES_CMSIS_6_CMSIS_CORE_M_DEFAULTS_H_ */