Skip to content

Improve Zephyr Build #448

@ReinhardKeil

Description

@ReinhardKeil

Type: Feature Request

1. Speedup Build process

The current implementation of Zephyr build requires a re-run of the build configuration as the west-defs are always added (see https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#west-defs).

However, when the Database (CmakeCache.txt) is already generated, and no changes to the *.csolution.yml file are made, it is sufficient to just call west build using the -d option, for example:

west build -d out/blinky/B-L475-IOT01A/Debug

When KConfig settings are changed, the build system still recognizes this.

A user could then easily copy this command and extend it with other t target options as shown next.

2. Making -t targets easier to access

west offers numerous -t target options, for example

west build -d out/blinky/B-L475-IOT01A/Debug -t rom_report

However, currently this would require to setup the compiler environment variables manually. Instead the environment variables below may be set by the VS Code extension when a solution contains west applications:

  • ZEPHYR_TOOLCHAIN_VARIANT
  • <TOOLCHAIN>_TOOLCHAIN_PATH

3. Execute Configuration Step in terminal window

The west build generating a build system step contains useful information that should be exposed to the user. When the output is routed to the terminal window it becomes also more obvious that there is a configuration step for the project.

The build steps for Zephry should be therefore as shown below:

  • Configuration (executed when settings are changed).
C:\w\CMSIS-Zephyr>west build -b frdm_mcxn947/mcxn947/cpu0 -d C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug -p auto C:/w/CMSIS-Zephyr/zephyr/samples/basic/threads --cmake-only -- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCONFIG_BUILD_OUTPUT_HEX=y -DCONFIG_DEBUG=y -DCONFIG_DEBUG_THREAD_INFO=y -DCONFIG_THREAD_STACK_INFO=y -DCONFIG_DEBUG_OPTIMIZATIONS=y"      
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: C:/w/CMSIS-Zephyr/zephyr/samples/basic/threads
-- CMake version: 3.31.5
-- Cache files will be written to: C:/Users/reikei01/zephyrproject/zephyr/.cache
-- Zephyr version: 4.3.99 (C:/Users/reikei01/zephyrproject/zephyr)
-- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
-- Board: frdm_mcxn947, qualifiers: mcxn947/cpu0
-- Found toolchain: gnuarmemb (c:/Users/reikei01/.vcpkg/artifacts/2139c4c6/compilers.arm.arm.none.eabi.gcc/14.3.1/)
-- Found BOARD.dts: C:/Users/reikei01/zephyrproject/zephyr/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.dts
unit address and first address in 'reg' (0x40113000) don't match for /soc/peripheral@50000000/opamp@113000
-- Generated zephyr.dts: C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug/zephyr/zephyr.dts
-- Generated pickled edt: C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug/zephyr/edt.pickle
-- Generated devicetree_generated.h: C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug/zephyr/include/generated/zephyr/devicetree_generated.h
Parsing C:/Users/reikei01/zephyrproject/zephyr/Kconfig
Loaded configuration 'C:/Users/reikei01/zephyrproject/zephyr/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0_defconfig'
Merged configuration 'C:/w/CMSIS-Zephyr/zephyr/samples/basic/threads/prj.conf'
Merged configuration 'C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to 'C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug/zephyr/.config'
Kconfig header saved to 'C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug/zephyr/include/generated/zephyr/autoconf.h'
-- Looking for device MCXN947 in C:/Users/reikei01/zephyrproject/modules/hal/nxp/mcux/mcux-sdk-ng/devices/
-- Found device folder: C:/Users/reikei01/zephyrproject/modules/hal/nxp/mcux/mcux-sdk-ng/devices/MCX/MCXN/MCXN947
-- Found gen_kobject_list: C:/Users/reikei01/zephyrproject/zephyr/scripts/build/gen_kobject_list.py
CMake Warning at C:/Users/reikei01/zephyrproject/zephyr/CMakeLists.txt:2359 (message):
  __ASSERT() statements are globally ENABLED


-- Configuring done (18.3s)
-- Generating done (3.0s)
-- Build files have been written to: C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug
  • Build (executed when settings are changed).
C:\w\CMSIS-Zephyr>west build -d C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug                                                                                                                                                                                                                                                              
[1/145] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.3.99 (C:/Users/reikei01/zephyrproject/zephyr), build: v4.3.0-2356-gcb93f97bd632
[145/145] Linking C executable zephyr\zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       65148 B         2 MB      3.11%
             RAM:       11072 B       320 KB      3.38%
           SRAMX:           0 B        96 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%
Generating files from C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug/zephyr/zephyr.elf for board: frdm_mcxn947

4. Refresh and Rebuild

These steps should always execute the configuration step and the build step.

5. Add command cmsis-csolution.getInfoPath

Path to the output directory of the current active clangd information.

This command is useful in tasks.json files that retrieve information from Zephyr projects. As CSolution is multi-project, a user would need to "Activate clangd information" on a project before such commands could be executed.

In practice this command would return the out directory, i.e. C:/w/CMSIS-Zephyr/out/threads/FRDM-MCXN947/Debug

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions