Frequently Asked Questions
CMake
How to get detailed cmake configuration log about from which cmake files the include/source/configuration is added.
You can use
--log-level=debug
to get detailed steps of cmake adding source/include/configuration. A cmd example is likewest build -b evkbmimxrt1170 examples/demo_apps/hello_world -Dcore_id=cm4 --log-level=debug
The logs look like
How to replace the default linker file with the customized one?
Generally, when you type
--config=<CMAKE_BUILD_TYPE>
in the command line, the cmake settings insidemcuxsdk/arch/arm/target
folder will take effect. The link file for the corresponding config is then used. If running with “–log-level=debug” in the command line, you can find the log, such as:-- DEBUG: Add -T C:/git_repo/migrate_sdk_repo/mcuxsdk/devices/Kinetis/MK64F12/gcc/MK64FN1M0xxx12_flash.ld to LD flags, load from CMakefile: C:/git_repo/migrate_sdk_repo/mcuxsdk/arch/arm/target/flash.cmake
To replace the default linker file with the customized one, you need to remove the default linker file and add the customized one by
mcux_remove_<toolchain>_linker_script
andmcux_add_<toolchain>_linker_script
in reconfig.cmake. For example:# mcuxsdk/examples/frdmk64f/demo_apps/hello_world/reconfig.cmake mcux_remove_armgcc_linker_script( TARGETS debug release BASE_PATH ${SdkRootDirPath} LINKER devices/${soc_portfolio}/${soc_series}/${device}/gcc/${CONFIG_MCUX_TOOLCHAIN_LINKER_DEVICE_PREFIX}_flash.ld ) mcux_add_armgcc_linker_script( TARGETS debug release BASE_PATH ${SdkRootDirPath} LINKER examples/frdmk64f/demo_apps/hello_world/hello_world_flash.ld )
If running with “–log-level=debug”, you can find the log:
-- DEBUG: Add linker flag -T C:/git_repo/migrate_sdk_repo/mcuxsdk/devices/Kinetis/MK64F12/gcc/MK64FN1M0xxx12_flash.ld into TO_BE_REMOVED_FLAGS list, load from CMakefile: 1171 -- DEBUG: Remove linker flag -T C:/git_repo/migrate_sdk_repo/mcuxsdk/devices/Kinetis/MK64F12/gcc/MK64FN1M0xxx12_flash.ld, load from CMakefile: 1182 -- DEBUG: Add -T C:/git_repo/migrate_sdk_repo/mcuxsdk/examples/frdmk64f/demo_apps/hello_world/hello_world_flash.ld to LD flags, load from CMakefile: C:/git_repo/migrate_sdk_repo/mcuxsdk/examples/frdmk64f/demo_apps/hello_world/reconfig.cmake
Kconfig
How the kconfig symbols(configurations) are handled and integrated into build?
All kconfig symbols will firstly been generated into .config with kconfig process lib. We do some updates on the kconfig process lib to meet our needs
Symbols starting with
MCUX_
will be got by cmake and determine which components/drivers/project_segments to be included in.Macro symbols will be generated into config header files
3.1 In the kconfig menu, if the header is specified, like menu “freertos-kernel(FreeRTOSConfig.h)”, the all symbols under this menu will be generated into FreeRTOSConfig.h
3.2 If there is no specified headers in the menu, then all systems be generated into mcux_config.h.
3.3 all generated config headers are generated and placed under the project root path, like boards/frdmk64f/demo_apps/hello_world. These headers are expected to be included
in the sources/headers in advance.
3.4 By default, kconfig will put CONFIG_ prefix in the macros, if you need it, then add “No prefix in generated macro” in the help, like
if MCUX_COMPONENT_middleware.freertos-kernel config configUSE_PREEMPTION bool "configUSE_PREEMPTION" default y help No prefix in generated macro config configUSE_TICKLESS_IDLE bool "configUSE_TICKLESS_IDLE" default 0 help No prefix in generated macro
For board device variant selection, kconfig files will provide default. We also expect in boards/
<board>
/prj.conf, developers can explicitly specify it, like
GUI Project
Why do I get an “wrong argument type nil (expected Regexp)” error when running
-t guiproject
?That’s because you have run west command for armgcc toolchain, so that the script will get build information from cache, but there is no GUI project for armgcc. In this case, you need to add “-p always” to run a pristine build.
We have updated the script, if you get the latest commit, you will get more explicit error message:
Currently supported toolchain: ["iar", "mdk"], but script get armgcc, please check --toolchain in west command, or try run with -p always to prevent setting by cache.
Why the IDE can not identify the MCU when I open the project?
For Keil MDK, if you get build error like:
For IAR, if the error like
Fatal Error[Pe035]: #error directive: "Unknown target."
And no device setting:Please check the variable
MCUX_TOOLCHAIN_IAR_CPU_IDENTIFIER
andMCUX_TOOLCHAIN_MDK_CPU_IDENTIFIER
inmcuxsdk/devices/${soc_series}/${device}/Kconfig.chip
, make sure it’s a valid device identifier.
BUILD
Why does GUI project build pass but fail on the command line?
To create GUI project, the script parses
build.ninja
and set them in project template file. There may be some presets in the template file that make your project compile successfully, but they will not be used by CMake. So you need to compare the build options in the GUI project with those inbuild.ninja
and add missing assembler/compiler/linker flags in CMake.For IAR project, you can check build options by setting log level to
All
.For MDK project, you can check build options in
C/C++(AC6)
/Asm
/Linker
option tab.Why does IAR GUI project run pass but fail on the command line?
There are two possible causes for this. The first one is caused by wrong compiler/linker flags, please refer to previous question
Why does GUI project build pass but fail on the command line?
.If the flags are identical, please check the version of CMake and Ninja. The IAR IDE GUI project will use
.o
extension for object name, developer may relocate these object in linker file. For example:initialize by copy { readwrite, /* Place in RAM flash and performance dependent functions */ readonly object fsl_flexspi_nor_flash.o, readonly object nor_flash_ops.o, readonly object fsl_flexspi.o, readonly object fsl_clock.o, readonly object ABImemclr4.o, section .textrw, section CodeQuickAccess, section DataQuickAccess };
However, meta build system use CMake and Ninja, in some of low version CMake and Ninja, the generated object has
.c.o
extesion name. This misalignment will cause the link configuration not to take effect. So please make sure the minimum version for CMake is3.30.0
, and1.12.1
for Ninja.