Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions CI/update/stm32wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
system_path = ""

# CMSIS outside of the core. Can be updated by arg
CMSIS_path = core_path.parent / "ArduinoModule-CMSIS" / "CMSIS_5"
# CMSIS_VERSION = "CMSIS_5"
CMSIS_VERSION = "CMSIS_6"
CMSIS_path = core_path.parent / "ArduinoModule-CMSIS" / CMSIS_VERSION
CMSIS_DSPSrc_path = ""

# Out sources files
Expand Down Expand Up @@ -82,7 +84,7 @@ def checkConfig(arg_core, arg_cmsis):

if arg_core is not None:
core_path = Path(arg_core).resolve()
CMSIS_path = core_path.parent / "ArduinoModule-CMSIS" / "CMSIS_5"
CMSIS_path = core_path.parent / "ArduinoModule-CMSIS" / CMSIS_VERSION

if not core_path.is_dir():
print(f"Could not find {core_path}")
Expand All @@ -103,7 +105,11 @@ def checkConfig(arg_core, arg_cmsis):

if arg_cmsis is not None:
CMSIS_path = Path(arg_cmsis).resolve()
CMSIS_DSPSrc_path = CMSIS_path / "CMSIS" / "DSP" / "Source"

if CMSIS_VERSION == "CMSIS_6":
CMSIS_DSPSrc_path = CMSIS_path / ".." / "CMSIS-DSP" / "Source"
else:
CMSIS_DSPSrc_path = CMSIS_path / "CMSIS" / "DSP" / "Source"


def printCMSISStartup(log):
Expand Down Expand Up @@ -289,13 +295,16 @@ def wrap(arg_core, arg_cmsis, log):
print("CMSIS DSP generation skipped.")
else:
# Delete all subfolders
deleteFolder(CMSIS_DSP_outSrc_path / "*")
for path_object in CMSIS_DSP_outSrc_path.glob("*"):
if path_object.is_dir():
deleteFolder(path_object)
for path_object in CMSIS_DSPSrc_path.glob("**/*"):
if path_object.is_file() and path_object.name.endswith(".c"):
dn = path_object.parent.name
fn = path_object.name
if dn in fn:
fdn = CMSIS_DSP_outSrc_path / dn
createFolder(fdn)
with open(fdn / (f"{fn}"), "w", newline="\n") as out_file:
out_file.write(
dsp_file_template.render(dsp_dir=dn, dsp_name=fn)
Expand Down
52 changes: 46 additions & 6 deletions cmake/ensure_core_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ function(declare_deps CORE_VERSION)
# 2. find the versions of the dependencies for that core
set(XPACK_VERSION "0.0.0")
set(CMSIS_VERSION "0.0.0")
set(CMSIS_DSP_VERSION "0.0.0")
set(CMSIS_NN_VERSION "0.0.0")
# Note: we're ignoring the STM32Tools dep, because unlike Arduino IDE we don't need it (upload + misc scripts)
string(JSON LEN_DEPS LENGTH "${DEPS}")
math(EXPR LEN_DEPS "${LEN_DEPS}-1")
Expand All @@ -106,6 +108,10 @@ function(declare_deps CORE_VERSION)
string(JSON XPACK_VERSION GET "${DEPS}" ${I_DEP} "version")
elseif(${DEP_NAME} STREQUAL "CMSIS")
string(JSON CMSIS_VERSION GET "${DEPS}" ${I_DEP} "version")
elseif(${DEP_NAME} STREQUAL "CMSIS_DSP")
string(JSON CMSIS_DSP_VERSION GET "${DEPS}" ${I_DEP} "version")
elseif(${DEP_NAME} STREQUAL "CMSIS_NN")
string(JSON CMSIS_NN_VERSION GET "${DEPS}" ${I_DEP} "version")
endif()
endforeach()

Expand All @@ -114,6 +120,10 @@ function(declare_deps CORE_VERSION)
set(XPACK_SHA "")
set(CMSIS_URL "")
set(CMSIS_SHA "")
set(CMSIS_DSP_URL "")
set(CMSIS_DSP_SHA "")
set(CMSIS_NN_URL "")
set(CMSIS_NN_SHA "")
foreach(I_TOOL RANGE ${LEN_TOOLS})
string(JSON TOOL_NAME GET "${TOOLS}" ${I_TOOL} "name")
string(JSON TOOL_VERSION GET "${TOOLS}" ${I_TOOL} "version")
Expand All @@ -122,6 +132,10 @@ function(declare_deps CORE_VERSION)
get_target_url("${TOOL_SUPPORT}" XPACK_URL XPACK_SHA)
elseif(${TOOL_NAME} STREQUAL "CMSIS" AND ${TOOL_VERSION} VERSION_EQUAL ${CMSIS_VERSION})
get_target_url("${TOOL_SUPPORT}" CMSIS_URL CMSIS_SHA)
elseif(${TOOL_NAME} STREQUAL "CMSIS_DSP" AND ${TOOL_VERSION} VERSION_EQUAL ${CMSIS_DSP_VERSION})
get_target_url("${TOOL_SUPPORT}" CMSIS_DSP_URL CMSIS_DSP_SHA)
elseif(${TOOL_NAME} STREQUAL "CMSIS_NN" AND ${TOOL_VERSION} VERSION_EQUAL ${CMSIS_NN_VERSION})
get_target_url("${TOOL_SUPPORT}" CMSIS_NN_URL CMSIS_NN_SHA)
endif()
endforeach()

Expand All @@ -136,29 +150,55 @@ function(declare_deps CORE_VERSION)
)

FetchContent_Declare(
CMSIS5
SOURCE_DIR ${DL_DIR}/dist/CMSIS5
CMSIS6
SOURCE_DIR ${DL_DIR}/dist/CMSIS6
PREFIX ${DL_DIR}
URL "${CMSIS_URL}"
URL_HASH SHA256=${CMSIS_SHA}
UPDATE_DISCONNECTED
)

FetchContent_Declare(
CMSIS_DSP
SOURCE_DIR ${DL_DIR}/dist/CMSIS_DSP
PREFIX ${DL_DIR}
URL "${CMSIS_DSP_URL}"
URL_HASH SHA256=${CMSIS_DSP_SHA}
UPDATE_DISCONNECTED
)

FetchContent_Declare(
CMSIS_NN
SOURCE_DIR ${DL_DIR}/dist/CMSIS_NN
PREFIX ${DL_DIR}
URL "${CMSIS_NN_URL}"
URL_HASH SHA256=${CMSIS_NN_SHA}
UPDATE_DISCONNECTED
)
endfunction()

# defines a CMSIS5_PATH in the caller's scope
# defines a CMSIS6_PATH in the caller's scope
function(ensure_core_deps)
if(NOT EXISTS ${DL_DIR}/dist/CMSIS5 OR NOT EXISTS ${DL_DIR}/dist/xpack)
if(NOT EXISTS ${DL_DIR}/dist/CMSIS6 OR NOT EXISTS ${DL_DIR}/dist/xpack)
get_core_version(COREVER)
declare_deps(${COREVER})
message(STATUS "Downloading the CMSIS...")
FetchContent_MakeAvailable(CMSIS5)
FetchContent_MakeAvailable(CMSIS6)
message(STATUS "Downloading the CMSIS... Done.")
message(STATUS "Downloading the CMSIS_DSP...")
FetchContent_MakeAvailable(CMSIS_DSP)
message(STATUS "Downloading the CMSIS_DSP... Done.")
message(STATUS "Downloading the CMSIS_NN...")
FetchContent_MakeAvailable(CMSIS_NN)
message(STATUS "Downloading the CMSIS_NN... Done.")
message(STATUS "Downloading the compiler toolchain...")
FetchContent_MakeAvailable(xpack)
message(STATUS "Downloading the compiler toolchain... Done.")
endif()

set(CMSIS5_PATH ${DL_DIR}/dist/CMSIS5 PARENT_SCOPE)
set(CMSIS6_PATH ${DL_DIR}/dist/CMSIS6 PARENT_SCOPE)
set(CMSIS_DSP_PATH ${DL_DIR}/dist/CMSIS_DSP PARENT_SCOPE)
set(CMSIS_NN_PATH ${DL_DIR}/dist/CMSIS_NN PARENT_SCOPE)

find_program(CMAKE_ASM_COMPILER arm-none-eabi-gcc PATHS ${DL_DIR}/dist/xpack/bin REQUIRED)
find_program(CMAKE_C_COMPILER arm-none-eabi-gcc PATHS ${DL_DIR}/dist/xpack/bin REQUIRED)
Expand Down
10 changes: 5 additions & 5 deletions cmake/set_base_arduino_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target_link_options(base_config INTERFACE
LINKER:--script=${BUILD_SYSTEM_PATH}/ldscript.ld
)
target_link_directories(base_config INTERFACE
"${CMSIS5_PATH}/CMSIS/DSP/Lib/GCC"
"${CMSIS6_PATH}/CMSIS/DSP/Lib/GCC"
)

target_include_directories(base_config INTERFACE
Expand All @@ -61,10 +61,10 @@ target_include_directories(base_config INTERFACE
"${BUILD_LIB_PATH}/VirtIO/inc"
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc"
"${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src"
"${CMSIS5_PATH}/CMSIS/DSP/Include"
"${CMSIS5_PATH}/CMSIS/DSP/PrivateInclude"
"${CMSIS5_PATH}/CMSIS/Core/Include/"
"${CMSIS5_PATH}/CMSIS"
"${CMSIS_DSP_PATH}/Include"
"${CMSIS_DSP_PATH}/PrivateInclude"
"${CMSIS6_PATH}/CMSIS/Core/Include/"
"${CMSIS6_PATH}/CMSIS"
"${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP"
"${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/open-amp/lib/include"
"${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/libmetal/lib/include"
Expand Down
1 change: 1 addition & 0 deletions libraries/CMSIS_DSP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ add_library(CMSIS_DSP_bin OBJECT EXCLUDE_FROM_ALL
src/SVMFunctions/SVMFunctionsF16.c
src/TransformFunctions/TransformFunctions.c
src/TransformFunctions/TransformFunctionsF16.c
src/WindowFunctions/WindowFunctions.c
)
target_link_libraries(CMSIS_DSP_bin PUBLIC CMSIS_DSP_usage)

Expand Down
1 change: 1 addition & 0 deletions libraries/CMSIS_DSP/src/WindowFunctions/WindowFunctions.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../Source/WindowFunctions/WindowFunctions.c"
9 changes: 9 additions & 0 deletions libraries/SrcWrapper/src/stm32/dwt.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,20 @@ void dwt_access(bool ena)
* Define DWT LSR mask which is (currentuly) not defined by the CMSIS.
* Same as ITM LSR one.
*/

#if !defined DWT_LSR_Present_Msk
#if defined(ITM_LSR_PRESENT_Msk)
#define DWT_LSR_Present_Msk ITM_LSR_PRESENT_Msk
#else
#define DWT_LSR_Present_Msk ITM_LSR_Present_Msk
#endif
#endif
#if !defined DWT_LSR_Access_Msk
#if defined(ITM_LSR_ACCESS_Msk)
#define DWT_LSR_Access_Msk ITM_LSR_ACCESS_Msk
#else
#define DWT_LSR_Access_Msk ITM_LSR_Access_Msk
#endif
#endif
uint32_t lsr = DWT->LSR;

Expand Down
6 changes: 4 additions & 2 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ tools_bin_path.linux={runtime.tools.STM32Tools.path}/linux

core_stm32_dir={build.core.path}/stm32
hal_dir={build.system.path}/Drivers/{build.series}_HAL_Driver
cmsis_dir={runtime.tools.CMSIS-5.9.0.path}/CMSIS
cmsis_dir={runtime.tools.CMSIS-6.2.0.path}/CMSIS
cmsis_dsp={runtime.tools.CMSIS_DSP-1.16.2.path}
cmsis_nn={runtime.tools.CMSIS_NN-7.0.0.path}
cmsis_dev_dir={build.system.path}/Drivers/CMSIS/Device/ST/{build.series}
usbd_core_dir={build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core
builtin_library_dir={build.core.path}/../../libraries
Expand All @@ -37,7 +39,7 @@ USBDevice_include_dir={builtin_library_dir}/USBDevice/inc
# STM compile variables
# ----------------------
compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{SrcWrapper_include_dir}" "-I{SrcWrapper_include_dir}/LL" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{USBDevice_include_dir}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" "-I{VirtIO_include_dir}" {build.virtio_extra_include}
compiler.arm.cmsis.c.flags="-I{cmsis_dir}/Core/Include/" "-I{cmsis_dev_dir}/Include/" "-I{cmsis_dev_dir}/Source/Templates/gcc/" "-I{cmsis_dir}/DSP/Include" "-I{cmsis_dir}/DSP/PrivateInclude"
compiler.arm.cmsis.c.flags="-I{cmsis_dir}/Core/Include/" "-I{cmsis_dev_dir}/Include/" "-I{cmsis_dev_dir}/Source/Templates/gcc/" "-I{cmsis_dsp}/Include" "-I{cmsis_dsp}/PrivateInclude"

compiler.warning_flags=-w
compiler.warning_flags.none=-w
Expand Down