This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zephyr nrf sdk automated build server with docker image

Hello,

I am trying to setup a windows docker image to use on a build server for zephyr nrfsdk projects, but i am haveing difficulty getting things configured correctly.

For setting up the sdk, I am using this powershell script (which seems to be working correctly):

[string]$ncs_path = "C:/ncs"

function Install-Nrf-Sdk {
    param (
        [string]$version
    )

    [string]$sdk_path = "$ncs_path/$version"
    [string]$venv_path = "$sdk_path/python-env"
    
    python -m pip install virtualenv
    python -m venv "$venv_path"
    . "$venv_path/Scripts/activate.ps1"
    python -m pip install west
    west init -m https://github.com/nrfconnect/sdk-nrf --mr $version "$sdk_path"
    $Env:ZEPHYR_BASE = "$sdk_path"
    west update
    pip3 install -r "$sdk_path/zephyr/scripts/requirements.txt"
    pip3 install -r "$sdk_path/nrf/scripts/requirements.txt"
    pip3 install -r "$sdk_path/bootloader/mcuboot/scripts/requirements.txt"
    deactivate
}

Install-Nrf-Sdk "v1.6.1"

 For the project build step, the projects use custom boards and have `set(BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/)` in the `CMakeList.txt` and the working directory is set to the project directory. Then this powershell script is run:

[string]$ncs_path = "C:/ncs"
[string]$version = "$(SDK_VERSION)"
[string]$sdk_path = "$ncs_path/$version"
[string]$venv_path = "$sdk_path/python-env"

. "$venv_path/Scripts/activate.ps1"

$Env:ZEPHYR_BASE="$sdk_path\zephyr"
. "$Env:ZEPHYR_BASE\zephyr-env.cmd"
west zephyr-export
$Env:ZEPHYR_TOOLCHAIN_VARIANT="gnuarmemb"
$Env:GNUARMEMB_TOOLCHAIN_PATH="C:/Tools/arm-eabi"

cmake . -G "Ninja" -DCMAKE_BUILD_TYPE=RELEASE -DBOARD="$(BOARD_TYPE)" -DCONF_FILE="Release.conf" -B ./build
ninja -C ./build

But the build is failing 

Zephyr (C:/ncs/v1.6.1/zephyr/share/zephyr-package/cmake)
has been added to the user package registry in:
HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\Zephyr

ZephyrUnittest (C:/ncs/v1.6.1/zephyr/share/zephyrunittest-package/cmake)
has been added to the user package registry in:
HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\ZephyrUnittest

Including boilerplate (Zephyr base (cached)): C:/ncs/v1.6.1/zephyr/cmake/app/boilerplate.cmake
-- Application: C:/azp/agent/_work/1/s/Embedded.Firmware.TagBeacon.RTOS
-- Zephyr version: 2.6.0-rc1 (C:/ncs/v1.6.1/zephyr), build: v2.6.0-rc1-ncs1
-- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
-- Board: core_plt003
-- Cache files will be written to: C:/ncs/v1.6.1/zephyr/.cache
CMake Error at C:/ncs/v1.6.1/zephyr/cmake/generic_toolchain.cmake:36 (include):
  include could not find load file:

    C:\Tools\arm-eabi/cmake/toolchain/gnuarmemb/generic.cmake
Call Stack (most recent call first):
  C:/ncs/v1.6.1/zephyr/cmake/app/boilerplate.cmake:553 (include)
  C:/ncs/v1.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  C:/ncs/v1.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  CMakeLists.txt:10 (find_package)


-- Found BOARD.dts: C:/azp/agent/_work/1/s/Embedded.Firmware.TagBeacon.RTOS/boards/arm/core_plt003/core_plt003.dts
CMake Error at C:/ncs/v1.6.1/zephyr/cmake/dts.cmake:157 (message):
  command failed with return code: The system cannot find the file specified
Call Stack (most recent call first):
  C:/ncs/v1.6.1/zephyr/cmake/app/boilerplate.cmake:554 (include)
  C:/ncs/v1.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  C:/ncs/v1.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  CMakeLists.txt:10 (find_package)

Is there any documentation on how to correctly setup a build server?

  • Hello,

     

     

    Is there any documentation on how to correctly setup a build server?

    There is some information from the upstream project itself:

    https://github.com/zephyrproject-rtos/docker-image

    And we have a blog post on the matter:

    https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/build-ncs-application-firmware-images-using-docker

     

     For the project build step, the projects use custom boards and have `set(BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/)` in the `CMakeList.txt` and the working directory is set to the project directory. Then this powershell script is run:
    But the build is failing 

    Does this mean that a generic sample is built successfully when configured for any "standard" board?

     

    Given your shell output, especially these lines:

    CMake Error at C:/ncs/v1.6.1/zephyr/cmake/generic_toolchain.cmake:36 (include):
      include could not find load file:
    
        C:\Tools\arm-eabi/cmake/toolchain/gnuarmemb/generic.cmake

     

    This indicates that the env "TOOLCHAIN_ROOT" is not set correctly (it should be: "c:/ncs/v1.6.1/zephyr/" in your case) . I am able to reproduce a similar error when running this command:

    mkdir build && cd build && TOOLCHAIN_ROOT=/wrong/path cmake .. -DBOARD=nrf9160dk_nrf9160ns -GNinja

     

    Which then produces this output (some line numbers does not match with yours, so might be a red herring):

    Including boilerplate (Zephyr base): /opt/ncs/zephyr/cmake/app/boilerplate.cmake
    -- Application: /opt/ncs/nrf/applications/asset_tracker
    -- Zephyr version: 2.6.0-rc1 (/opt/ncs/zephyr), build: v2.6.0-rc1-ncs1
    -- Found Python3: /usr/bin/python3.9 (found suitable exact version "3.9.5") found components: Interpreter 
    -- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
    -- Board: nrf9160dk_nrf9160ns, Revision: 0.7.0
    -- Cache files will be written to: /home/hkn/.cache/zephyr
    -- Found dtc: /usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
    CMake Error at /opt/ncs/zephyr/cmake/generic_toolchain.cmake:36 (include):
      include could not find load file:
    
        /wrong/path/cmake/toolchain/gnuarmemb/generic.cmake
    Call Stack (most recent call first):
      /opt/ncs/zephyr/cmake/app/boilerplate.cmake:553 (include)
      /opt/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      /opt/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
      CMakeLists.txt:13 (find_package)
    
    
    -- Found BOARD.dts: /opt/ncs/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160ns.dts
    -- Found devicetree overlay: /opt/ncs/nrf/applications/asset_tracker/nrf9160dk_nrf9160ns.overlay
    CMake Error at /opt/ncs/zephyr/cmake/dts.cmake:157 (message):
      command failed with return code: No such file or directory
    Call Stack (most recent call first):
      /opt/ncs/zephyr/cmake/app/boilerplate.cmake:554 (include)
      /opt/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      /opt/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
      CMakeLists.txt:13 (find_package)
    
    
    -- Configuring incomplete, errors occurred!

     

    The TOOLCHAIN_ROOT is set as default to $ZEPHYR_BASE if not defined. Could you check if you have this defined in your env?

     

    Kind regards,

    Håkon

  • Adding `$Env:TOOLCHAIN_ROOT="$Env:ZEPHYR_BASE"` has fixed the issue. Builds are now successful!

    Cheers

Related