Skip to content

Commit 7c4054d

Browse files
committed
chore(cmake): support CMSIS_6, DSP and NN
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent b783738 commit 7c4054d

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

cmake/ensure_core_deps.cmake

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ function(declare_deps CORE_VERSION)
9797
# 2. find the versions of the dependencies for that core
9898
set(XPACK_VERSION "0.0.0")
9999
set(CMSIS_VERSION "0.0.0")
100+
set(CMSIS_DSP_VERSION "0.0.0")
101+
set(CMSIS_NN_VERSION "0.0.0")
100102
# Note: we're ignoring the STM32Tools dep, because unlike Arduino IDE we don't need it (upload + misc scripts)
101103
string(JSON LEN_DEPS LENGTH "${DEPS}")
102104
math(EXPR LEN_DEPS "${LEN_DEPS}-1")
@@ -106,6 +108,10 @@ function(declare_deps CORE_VERSION)
106108
string(JSON XPACK_VERSION GET "${DEPS}" ${I_DEP} "version")
107109
elseif(${DEP_NAME} STREQUAL "CMSIS")
108110
string(JSON CMSIS_VERSION GET "${DEPS}" ${I_DEP} "version")
111+
elseif(${DEP_NAME} STREQUAL "CMSIS_DSP")
112+
string(JSON CMSIS_DSP_VERSION GET "${DEPS}" ${I_DEP} "version")
113+
elseif(${DEP_NAME} STREQUAL "CMSIS_NN")
114+
string(JSON CMSIS_NN_VERSION GET "${DEPS}" ${I_DEP} "version")
109115
endif()
110116
endforeach()
111117

@@ -114,6 +120,10 @@ function(declare_deps CORE_VERSION)
114120
set(XPACK_SHA "")
115121
set(CMSIS_URL "")
116122
set(CMSIS_SHA "")
123+
set(CMSIS_DSP_URL "")
124+
set(CMSIS_DSP_SHA "")
125+
set(CMSIS_NN_URL "")
126+
set(CMSIS_NN_SHA "")
117127
foreach(I_TOOL RANGE ${LEN_TOOLS})
118128
string(JSON TOOL_NAME GET "${TOOLS}" ${I_TOOL} "name")
119129
string(JSON TOOL_VERSION GET "${TOOLS}" ${I_TOOL} "version")
@@ -122,6 +132,10 @@ function(declare_deps CORE_VERSION)
122132
get_target_url("${TOOL_SUPPORT}" XPACK_URL XPACK_SHA)
123133
elseif(${TOOL_NAME} STREQUAL "CMSIS" AND ${TOOL_VERSION} VERSION_EQUAL ${CMSIS_VERSION})
124134
get_target_url("${TOOL_SUPPORT}" CMSIS_URL CMSIS_SHA)
135+
elseif(${TOOL_NAME} STREQUAL "CMSIS_DSP" AND ${TOOL_VERSION} VERSION_EQUAL ${CMSIS_DSP_VERSION})
136+
get_target_url("${TOOL_SUPPORT}" CMSIS_DSP_URL CMSIS_DSP_SHA)
137+
elseif(${TOOL_NAME} STREQUAL "CMSIS_NN" AND ${TOOL_VERSION} VERSION_EQUAL ${CMSIS_NN_VERSION})
138+
get_target_url("${TOOL_SUPPORT}" CMSIS_NN_URL CMSIS_NN_SHA)
125139
endif()
126140
endforeach()
127141

@@ -136,29 +150,55 @@ function(declare_deps CORE_VERSION)
136150
)
137151

138152
FetchContent_Declare(
139-
CMSIS5
140-
SOURCE_DIR ${DL_DIR}/dist/CMSIS5
153+
CMSIS6
154+
SOURCE_DIR ${DL_DIR}/dist/CMSIS6
141155
PREFIX ${DL_DIR}
142156
URL "${CMSIS_URL}"
143157
URL_HASH SHA256=${CMSIS_SHA}
144158
UPDATE_DISCONNECTED
145159
)
160+
161+
FetchContent_Declare(
162+
CMSIS_DSP
163+
SOURCE_DIR ${DL_DIR}/dist/CMSIS_DSP
164+
PREFIX ${DL_DIR}
165+
URL "${CMSIS_DSP_URL}"
166+
URL_HASH SHA256=${CMSIS_DSP_SHA}
167+
UPDATE_DISCONNECTED
168+
)
169+
170+
FetchContent_Declare(
171+
CMSIS_NN
172+
SOURCE_DIR ${DL_DIR}/dist/CMSIS_NN
173+
PREFIX ${DL_DIR}
174+
URL "${CMSIS_NN_URL}"
175+
URL_HASH SHA256=${CMSIS_NN_SHA}
176+
UPDATE_DISCONNECTED
177+
)
146178
endfunction()
147179

148-
# defines a CMSIS5_PATH in the caller's scope
180+
# defines a CMSIS6_PATH in the caller's scope
149181
function(ensure_core_deps)
150-
if(NOT EXISTS ${DL_DIR}/dist/CMSIS5 OR NOT EXISTS ${DL_DIR}/dist/xpack)
182+
if(NOT EXISTS ${DL_DIR}/dist/CMSIS6 OR NOT EXISTS ${DL_DIR}/dist/xpack)
151183
get_core_version(COREVER)
152184
declare_deps(${COREVER})
153185
message(STATUS "Downloading the CMSIS...")
154-
FetchContent_MakeAvailable(CMSIS5)
186+
FetchContent_MakeAvailable(CMSIS6)
155187
message(STATUS "Downloading the CMSIS... Done.")
188+
message(STATUS "Downloading the CMSIS_DSP...")
189+
FetchContent_MakeAvailable(CMSIS_DSP)
190+
message(STATUS "Downloading the CMSIS_DSP... Done.")
191+
message(STATUS "Downloading the CMSIS_NN...")
192+
FetchContent_MakeAvailable(CMSIS_NN)
193+
message(STATUS "Downloading the CMSIS_NN... Done.")
156194
message(STATUS "Downloading the compiler toolchain...")
157195
FetchContent_MakeAvailable(xpack)
158196
message(STATUS "Downloading the compiler toolchain... Done.")
159197
endif()
160198

161-
set(CMSIS5_PATH ${DL_DIR}/dist/CMSIS5 PARENT_SCOPE)
199+
set(CMSIS6_PATH ${DL_DIR}/dist/CMSIS6 PARENT_SCOPE)
200+
set(CMSIS_DSP_PATH ${DL_DIR}/dist/CMSIS_DSP PARENT_SCOPE)
201+
set(CMSIS_NN_PATH ${DL_DIR}/dist/CMSIS_NN PARENT_SCOPE)
162202

163203
find_program(CMAKE_ASM_COMPILER arm-none-eabi-gcc PATHS ${DL_DIR}/dist/xpack/bin REQUIRED)
164204
find_program(CMAKE_C_COMPILER arm-none-eabi-gcc PATHS ${DL_DIR}/dist/xpack/bin REQUIRED)

cmake/set_base_arduino_config.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ target_link_options(base_config INTERFACE
4848
LINKER:--script=${BUILD_SYSTEM_PATH}/ldscript.ld
4949
)
5050
target_link_directories(base_config INTERFACE
51-
"${CMSIS5_PATH}/CMSIS/DSP/Lib/GCC"
51+
"${CMSIS6_PATH}/CMSIS/DSP/Lib/GCC"
5252
)
5353

5454
target_include_directories(base_config INTERFACE
@@ -61,10 +61,10 @@ target_include_directories(base_config INTERFACE
6161
"${BUILD_LIB_PATH}/VirtIO/inc"
6262
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc"
6363
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src"
64-
"${CMSIS5_PATH}/CMSIS/DSP/Include"
65-
"${CMSIS5_PATH}/CMSIS/DSP/PrivateInclude"
66-
"${CMSIS5_PATH}/CMSIS/Core/Include/"
67-
"${CMSIS5_PATH}/CMSIS"
64+
"${CMSIS_DSP_PATH}/Include"
65+
"${CMSIS_DSP_PATH}/PrivateInclude"
66+
"${CMSIS6_PATH}/CMSIS/Core/Include/"
67+
"${CMSIS6_PATH}/CMSIS"
6868
"${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP"
6969
"${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/open-amp/lib/include"
7070
"${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/libmetal/lib/include"

0 commit comments

Comments
 (0)