VSCode: replicating build configurations (preset bugs + command line)

OS: Windows

NCS Version: v2.0.2 Installed using toolchain manager

IDE: VSCode 1.70.2 + nordic-semiconductor.nrf-connect-extension-pack 2022.5.1

I have applications created as "freestanding" e.g.

and these work well. I have found the bit about using CMakePresets to share configuration details (https://nrfconnect.github.io/vscode-nrf-connect/connect/ui.html#build-specific-actions) which seems like it should be perfect.

First Issue: Creating a build configuration from the defined CMakePresets ignores the "binaryDir" field (build directory is always default). It is saved from the UI "Save Configuration", just not loaded

1a) The UI doesn't allow the build directory to be nested inside a folder (e.g. " ${sourceDir}/build/${presetName}") which really helps keep things tidy when multiple configurations are needed IMO

Second Issue: Replicating the build in command line for automated / CI builds

This is the output I get running the following commands in "C:\git\central" (west build command is the output of "Copy Build Command" in VSCode)

> C:\git\ncs\v2.0.2\zephyr\zephyr-env.cmd
> west build --build-dir c:\git\central\build_nRF52820 c:\git\central --pristine --board nrf52833dk_nrf52820 -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DCONF_FILE:STRING="c:/git/central/prj-nRF52820.conf"

2a) Is there a Github Actions template/example for building NCS firmware images?

  • I can confirm after following through "toolchain/environment.json" that I can recreate the environment and build an image from a fresh shell. 

    # Zephyr install root
    $Env:ZEPHYR_BASE = "<ncs install directory>/v2.0.2/zephyr"
    
    # Toolchain setup
    $toolchain = "<ncs install directory>/toolchains/v2.0.2"
    
    ## overwrite ZEPHYR_SDK_INSTALL_DIR
    $Env:ZEPHYR_SDK_INSTALL_DIR = "$toolchain/opt/zephyr-sdk"
    
    ## overwrite PYTHONPATH with values from environment.json
    $pythonPathValues = @(
    	"$toolchain/opt/bin",
    	"$toolchain/opt/bin/Lib",
    	"$toolchain/opt/bin/Lib/site-packages"
    )
    $pythonPath = $pythonPathValues -join ";"
    $Env:PYTHONPATH = $pythonPath
    
    ## Prepend PATH with values from environment.json
    $pathValues = @(
    	"$toolchain/.",
    	"$toolchain/mingw64/bin",
    	"$toolchain/bin",
    	"$toolchain/opt/bin",
    	"$toolchain/opt/bin/Scripts",
    	"$toolchain/nanopb/generator-bin",
    	"$toolchain/opt/zephyr-sdk/arm-zephyr-eabi/bin"
    )
    $prepPath = $pathValues -join ";"
    $Env:PATH = $prepPath + ';' + $Env:PATH

    For anyone finding this at a later date ^^ is the script for NCS v2.0.2 (in powershell, adapt as required. What's happening should be fairly obvious)

  • Is this the best place to be reporting bugs/issues with NCS? Even with the shell environment established, there's still a few things I'd rather like to see improved in the experience

    First Issue: Creating a build configuration from the defined CMakePresets ignores the "binaryDir" field (build directory is always default). It is saved from the UI "Save Configuration", just not loaded

    1a) The UI doesn't allow the build directory to be nested inside a folder (e.g. " ${sourceDir}/build/${presetName}") which really helps keep things tidy when multiple configurations are needed IMO

    ^^ are both a real annoyance particularly when bringing new people into a project.

    Documentation around setting up the shell environment seems to be completely missing (I still can't find anything even now I know what to be searching for)

  • Sorry for the late reply. I was out of office for the last couple of weeks. This is indeed a good place to report bugs/issues. I have forwarded your input to our nRF Connect SDK team. If I receive a direct reply, I will update this ticket as well.

    Best regards,

    Edvin

Related