|
| 1 | +From 1ee9cf9c956ea6a266fc79dfa62071131f162510 Mon Sep 17 00:00:00 2001 |
| 2 | +From: RJ Ascani <rja@meta.com> |
| 3 | +Date: Wed, 13 May 2026 15:48:07 -0700 |
| 4 | +Subject: [PATCH] Fix ARMCM0plus directory case and compile-define mismatch |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +The Cortex DFP names the Cortex-M0+ device directory and headers |
| 10 | +`ARMCM0plus` (lowercase suffix), while the device source files |
| 11 | +(`startup_ARMCM0plus.c`, `system_ARMCM0plus.c`) gate their |
| 12 | +implementations on the `ARMCM0P` preprocessor macro — three different |
| 13 | +spellings. `cmsis.cmake` previously did |
| 14 | +`string(TOUPPER \"ARMCM\${CPU_NUMBER}\" ARM_CPU)`, producing |
| 15 | +`ARMCM0PLUS`: the include path lookup fails and the source files hit |
| 16 | +their `#error device not specified!` guard. |
| 17 | + |
| 18 | +Override `ARM_CPU` to `ARMCM0plus` and introduce a separate |
| 19 | +`CMSIS_DEVICE_CPU_DEFINE` set to `ARMCM0P` for the cmsis_startup and |
| 20 | +cmsis_system compile-definitions; all other cores still drive both |
| 21 | +paths from the uppercased default. |
| 22 | +--- |
| 23 | + cmsis.cmake | 20 ++++++++++++++++++-- |
| 24 | + 1 file changed, 18 insertions(+), 2 deletions(-) |
| 25 | + |
| 26 | +diff --git a/cmsis.cmake b/cmsis.cmake |
| 27 | +index 7f2b93f..c49f205 100644 |
| 28 | +--- a/cmsis.cmake |
| 29 | ++++ b/cmsis.cmake |
| 30 | +@@ -23,6 +23,15 @@ endif() |
| 31 | + |
| 32 | + string(TOUPPER "ARMCM${CPU_NUMBER}" ARM_CPU) |
| 33 | + |
| 34 | ++# Cortex-M0+ is special: the Cortex DFP names the device directory and headers |
| 35 | ++# `ARMCM0plus` (lowercase suffix), while the device sources gate their |
| 36 | ++# implementations on the `ARMCM0P` preprocessor macro. Override both so the |
| 37 | ++# directory lookup and `#include` resolution succeed; the compile-definition |
| 38 | ++# override is applied instead of `CMSIS_DEVICE_CPU_FEATURE` further down. |
| 39 | ++if(CPU_NUMBER STREQUAL "0plus") |
| 40 | ++ set(ARM_CPU "ARMCM0plus") |
| 41 | ++endif() |
| 42 | ++ |
| 43 | + # Set CPU specific features |
| 44 | + if(CMAKE_SYSTEM_PROCESSOR MATCHES "cortex-m33(\\+|$)") |
| 45 | + set(ARM_FEATURES "_DSP_FP") |
| 46 | +@@ -50,6 +59,13 @@ else() |
| 47 | + cmake_path(SET CMSIS_DEVICE_CPU_FEATURE "${ARM_CPU}") |
| 48 | + endif() |
| 49 | + |
| 50 | ++# Macro the device sources gate on. Matches CMSIS_DEVICE_CPU_FEATURE for most |
| 51 | ++# cores; Cortex-M0+ keys off `ARMCM0P`, not `ARMCM0plus`. |
| 52 | ++set(CMSIS_DEVICE_CPU_DEFINE "${CMSIS_DEVICE_CPU_FEATURE}") |
| 53 | ++if(CPU_NUMBER STREQUAL "0plus") |
| 54 | ++ set(CMSIS_DEVICE_CPU_DEFINE "ARMCM0P") |
| 55 | ++endif() |
| 56 | ++ |
| 57 | + target_include_directories(cmsis_device INTERFACE ${CMSIS_DEVICE_PATH}/${ARM_CPU}/Include) |
| 58 | + |
| 59 | + target_compile_options(cmsis_device INTERFACE |
| 60 | +@@ -66,12 +82,12 @@ target_sources(cmsis_startup INTERFACE |
| 61 | + set_source_files_properties(${CMSIS_DEVICE_PATH}/${ARM_CPU}/Source/startup_${ARM_CPU}.c |
| 62 | + PROPERTIES COMPILE_FLAGS -Wno-redundant-decls) |
| 63 | + |
| 64 | +-target_compile_definitions(cmsis_startup INTERFACE ${CMSIS_DEVICE_CPU_FEATURE}) |
| 65 | ++target_compile_definitions(cmsis_startup INTERFACE ${CMSIS_DEVICE_CPU_DEFINE}) |
| 66 | + target_link_libraries(cmsis_startup INTERFACE cmsis_device) |
| 67 | + |
| 68 | + # CMSIS system |
| 69 | + add_library(cmsis_system INTERFACE) |
| 70 | + target_sources(cmsis_system INTERFACE |
| 71 | + ${CMSIS_DEVICE_PATH}/${ARM_CPU}/Source/system_${ARM_CPU}.c) |
| 72 | +-target_compile_definitions(cmsis_system INTERFACE ${CMSIS_DEVICE_CPU_FEATURE}) |
| 73 | ++target_compile_definitions(cmsis_system INTERFACE ${CMSIS_DEVICE_CPU_DEFINE}) |
| 74 | + target_link_libraries(cmsis_system INTERFACE cmsis_startup) |
| 75 | +-- |
| 76 | +2.53.0 |
| 77 | + |
0 commit comments