Hi, I would like to use this new mcuxsdk as an external cmake library for my project.
But we would like to use our own armgcc toolchain declarations (gcc flags ...), instead of the one included in the sdk.
I have thought of different things:
We would like to avoid the "boards" layer of zephyr to be able to build for an mcu target directly, by including few internal cmakes files of this mcuxsdk.
We find this sdk more convenient than the one generated by the website SDK Builder (which doesn't have public repo to mirror it and cmake integration looks incomplete). But it's a bit tedious to work with, by its complexity.
Thanks you
Notes:
It was not an easy task, but I've made the sdk build a static library.
It doesn't use the integrated armgcc toolchain flag and the "board" layer of the sdk, targeting an MCU directly
Only tested on RT devices
Code snippet:
# Create SDK static library
add_library(${PROJECT_NAME})
# NXP Project name
set(MCUX_SDK_PROJECT_NAME ${PROJECT_NAME})
# Driver and components selectors
# $GENERATED_CORE_PATH : from CMakeUserPresets.json
include(${GENERATED_CORE_PATH}/cmake/config.cmake)
# Include logging CMake extension/functions files
include(${SdkRootDirPath}/cmake/extension/logging.cmake)
# Include NXP custom CMake extension/functions files
include(${SdkRootDirPath}/cmake/extension/function.cmake)
# NXP Low levels folder:
# $NXP_TYPE : from CMakeUserPresets.json (eg. "RT" or "IMX")
# $NXP_FAMILY : from CMakeUserPresets.json (eg. "RT10xx", "i.MX93" ...)
# $NXP_DEVICE : from CMakeUserPresets.json (eg. "MIMXRT1042", "MIMX9331" ...)
set(DEVICE_PATH "${PROJECT_NAME}/devices/${NXP_TYPE}/${NXP_FAMILY}/${NXP_DEVICE}")
# Set device variables
include(${DEVICE_PATH}/variable.cmake)
# Include CMSIS, system and startup files
include(${SdkRootDirPath}/devices/arm/device_header.cmake)
# CMSIS
mcux_add_cmakelists(${SdkRootDirPath}/arch/arm/CMSIS)
# XIP related
mcux_add_cmakelists(${DEVICE_PATH}/xip)
# device specific drivers
mcux_add_cmakelists(${DEVICE_PATH}/drivers)
# Load all drivers (generic)
mcux_load_all_cmakelists_in_directory(${SdkRootDirPath}/drivers)
# Load all components (generic)
mcux_add_cmakelists(${CMAKE_CURRENT_SOURCE_DIR}/../../components OPTIONAL)
I do use the SDK as an external CMake library.
Basically I have set-up my custom CMake library files which is not that difficult and then link the SDK as a library with the application.
You can see how this works for example with docker/github/github actions in one of my articles: https://mcuoneclipse.com/2023/10/02/ci-cd-for-embedded-with-vs-code-docker-and-github-actions/
The project is on GitHub too: https://github.com/ErichStyger/MCUXpresso_LPC55S16_CI_CD
I hope this helps,
Erich
Thanks, great resource and tutorial !
My idea was to download and use the new sdk system (west).
Its full downloaded size is almost 8Gb which is a bad idea to use as is for my CI/CD system (we don't use Docker yet), so I've made a lightweight version which only target the RT devices (the ones we use currently) it's about 1Gb now.
Next step, is to be able to build the SDK as an external static library targeting the RT MCU that our projects use.
It still looks complex to do because of the west system and its "board" layer that we would like like to bypass if possible.