Cannot Replicate Build in Docker Environment

I'm working on automating some of our builds for the nRF5340 in our CI, and 

Currently, we can build these locally (on MacOS) with the NCS Connect VSCode toolchain, version 1.4.99-dev1 (historical reasons).

I'm able to demonstrate builds from command line locally with `west build -p -b nrf5340dk_nrf5340_cpuapp`, and so I'm fairly sure it *should* be possible to replicate it.

When I try to do the same with 

```

ncs -

   nrf

   nrfxlib

   zephyr

   apprepo

```


However, after a few days of on-and-off experimenting with this, it seems like there are some differences in the way that command line 

In the Docker image, I've tried both setting up a manual image based on these instructions and Ubuntu 20.04, as well as the `fw-nrfconnect-nrf-docker` image (github.com/.../fw-nrfconnect-nrf-docker). In both cases, I see the same result when I attempt to build:

Unsuccessful build in Docker using nrf-sdk:

```

root@c97d33dc36a3:/apprepo# west -v build -p always -b nrf5340dk_nrf5340_cpuapp
ZEPHYR_BASE=/zephyr (origin: env)
-- west build: making build dir /apprepo/build pristine
cmake version 3.20.5 is OK; minimum version is 3.13.1
Running CMake: /usr/local/bin/cmake -DBINARY_DIR=/apprepo/build -DSOURCE_DIR=/apprepo -P /zephyr/cmake/pristine.cmake
-- west build: generating a build system
cmake version 3.20.5 is OK; minimum version is 3.13.1
Running CMake: /usr/local/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/apprepo/build -S/apprepo -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp
Including boilerplate (Zephyr base): /zephyr/cmake/app/boilerplate.cmake
-- Application: /apprepo
-- Zephyr version: 2.7.0 (/zephyr), build: v2.7.0-ncs1
-- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter
-- Found west (found suitable version "0.12.0", minimum required is "0.7.1")
CMake Error at /zephyr/cmake/zephyr_module.cmake:61 (message):
ERROR: "kconfig" key in /apprepo/drivers/zephyr/module.yml has value
"Kconfig" which does not point to a valid Kconfig file.
```
However, this same application, on the host machine, builds fine when I simply navigate into `apprepo` and run `west -v build -p -b nrf5340dk_nrf5340_cpuapp:
Successful build on Host
```
➜ ~/Projects/drydock/parentdir/i2c-lsm6dsl-driver git:(dev-add-nrf-connect-sdk-docker-build-image) ✗ west -v build -p -b nrf5340dk_nrf5340_cpuapp
ZEPHYR_BASE=/Users/joshua.milburn/Projects/drydock/parentdir/zephyr (origin: configfile)
-- west build: generating a build system
cmake version 3.22.1 is OK; minimum version is 3.13.1
Running CMake: /usr/local/bin/cmake -DWEST_PYTHON=/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 -B/Users/joshua.milburn/Projects/drydock/parentdir/i2c-lsm6dsl-driver/build -S/Users/joshua.milburn/Projects/drydock/parentdir/i2c-lsm6dsl-driver -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp
Including boilerplate (Zephyr base): /Users/joshua.milburn/Projects/drydock/parentdir/zephyr/cmake/app/boilerplate.cmake
CMake Deprecation Warning at /Users/joshua.milburn/Projects/drydock/parentdir/zephyr/cmake/app/boilerplate.cmake:37 (cmake_policy):
The OLD behavior for policy CMP0079 will be removed from a future version
of CMake.

The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
/Users/joshua.milburn/Projects/drydock/parentdir/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
/Users/joshua.milburn/Projects/drydock/parentdir/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
CMakeLists.txt:38 (find_package)


-- Application: /Users/joshua.milburn/Projects/drydock/parentdir/i2c-lsm6dsl-driver
-- Using NCS Toolchain 1.4.0 for building. (/opt/nordic/ncs/v1.8.0/toolchain/cmake)
-- Zephyr version: 2.4.99 (/Users/joshua.milburn/Projects/drydock/parentdir/zephyr)
-- Found Python3: /opt/nordic/ncs/v1.8.0/toolchain/bin/python3 (found suitable exact version "3.9.6") found components: Interpreter
-- Found west (found suitable version "0.12.0", minimum required is "0.7.1")
...
... (build log truncated, but this results in binaries being built that I can flash to the device)
```
 
I've tried `source zephyr/zephyr-env.sh`, ensuring that the toolchain paths are set per the standard install guidance, and so forth - no success.
Is there an option that the 'NCS toolchain' is applying locally to provide more information at build time that is missing from the Docker build? A flag to suppress errors? I'm currently not sure where to go next on this.
  • edit: did not realize markdown code blocks don't work. Here is an edited version:

    ncs -

       nrf

       nrfxlib

       zephyr

       apprepo


    However, after a few days of on-and-off experimenting with this, it seems like there are some differences in the way that command line operates in the `nrf-sdk` installed in the Docker environment, vs the way the SDK installs and operates when installed as part of the VSCode extension.

    In the Docker image, I've tried both setting up a manual image based on these instructions and Ubuntu 20.04, as well as the `fw-nrfconnect-nrf-docker` image (github.com/.../fw-nrfconnect-nrf-docker). In both cases, I see the same result when I attempt to build:

    Unsuccessful build in Docker using nrf-sdk:

    root@c97d33dc36a3:/apprepo# west -v build -p always -b nrf5340dk_nrf5340_cpuapp


    ZEPHYR_BASE=/zephyr (origin: env)

    -- west build: making build dir /apprepo/build pristine

    cmake version 3.20.5 is OK; minimum version is 3.13.1

    Running CMake: /usr/local/bin/cmake -DBINARY_DIR=/apprepo/build -DSOURCE_DIR=/apprepo -P /zephyr/cmake/pristine.cmake

    -- west build: generating a build system

    cmake version 3.20.5 is OK; minimum version is 3.13.1

    Running CMake: /usr/local/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/apprepo/build -S/apprepo -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp

    Including boilerplate (Zephyr base): /zephyr/cmake/app/boilerplate.cmake

    -- Application: /apprepo

    -- Zephyr version: 2.7.0 (/zephyr), build: v2.7.0-ncs1

    -- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter

    -- Found west (found suitable version "0.12.0", minimum required is "0.7.1")

    CMake Error at /zephyr/cmake/zephyr_module.cmake:61 (message):

    ERROR: "kconfig" key in /apprepo/drivers/zephyr/module.yml has value

    "Kconfig" which does not point to a valid Kconfig file.
     
     
    However, this same application, on the host machine, builds fine when I simply navigate into `apprepo` and run `west -v build -p -b nrf5340dk_nrf5340_cpuapp:
    Successful build on Host
    ➜ ~/Projects/drydock/parentdir/i2c-lsm6dsl-driver git:(dev-add-nrf-connect-sdk-docker-build-image) ✗ west -v build -p -b nrf5340dk_nrf5340_cpuapp
    ZEPHYR_BASE=/Users/joshua.milburn/Projects/drydock/parentdir/zephyr (origin: configfile)
    -- west build: generating a build system
    cmake version 3.22.1 is OK; minimum version is 3.13.1
    Running CMake: /usr/local/bin/cmake -DWEST_PYTHON=/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 -B/Users/joshua.milburn/Projects/drydock/parentdir/i2c-lsm6dsl-driver/build -S/Users/joshua.milburn/Projects/drydock/parentdir/i2c-lsm6dsl-driver -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp
    Including boilerplate (Zephyr base): /Users/joshua.milburn/Projects/drydock/parentdir/zephyr/cmake/app/boilerplate.cmake
    CMake Deprecation Warning at /Users/joshua.milburn/Projects/drydock/parentdir/zephyr/cmake/app/boilerplate.cmake:37 (cmake_policy):
    The OLD behavior for policy CMP0079 will be removed from a future version
    of CMake.

    The cmake-policies(7) manual explains that the OLD behaviors of all
    policies are deprecated and that a policy should be set to OLD only under
    specific short-term circumstances. Projects should be ported to the NEW
    behavior and not rely on setting a policy to OLD.
    Call Stack (most recent call first):
    /Users/joshua.milburn/Projects/drydock/parentdir/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
    /Users/joshua.milburn/Projects/drydock/parentdir/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
    CMakeLists.txt:38 (find_package)


    -- Application: /Users/joshua.milburn/Projects/drydock/parentdir/i2c-lsm6dsl-driver
    -- Using NCS Toolchain 1.4.0 for building. (/opt/nordic/ncs/v1.8.0/toolchain/cmake)
    -- Zephyr version: 2.4.99 (/Users/joshua.milburn/Projects/drydock/parentdir/zephyr)
    -- Found Python3: /opt/nordic/ncs/v1.8.0/toolchain/bin/python3 (found suitable exact version "3.9.6") found components: Interpreter
    -- Found west (found suitable version "0.12.0", minimum required is "0.7.1")


    ...

    ... (build log truncated, but this results in binaries being built that I can flash to the device)
     
  • Hi

    Could you try to set up nrf-connect-sdk using the Matter nRF Connect Lighting Example Application Docker Setup tutorial?
    It would be interresting to see if this works for you, and the difference between that and your docker attempt.

    If that docker setup explanation solves your whole problem, that would be a bonus.
    If not, let me know, and I will look closer at your issue.

    Regards,
    Sigurd Hellesvik



  • thanks for the suggestion!

    Before I was able to try that out, I saw one item that looked interesting in the sample projects. Many have source "Kconfig.zephyr" at the top of the Kconfig file. I did not have that in my project.


    I added it, and the build started working in Docker. Keep in mind, there were no other changes to the project -- and it built fine in VSCode without adding `source "Kconfig.zephyr"` to the Kconfig file in my project.

    Do you have a list or reference for what the NCS/VSCode build steps introduce that might not be included by default when using `west build -p -b ...` in a fresh nrf-sdk install?

    Its odd, because the build *works fine* when built from NCS/VSCode, but failed until I added `source Kconfig.zephyr` to the top of a `Kconfig` file at the root of my application. 

    Are there other differences that app developers should be aware of when trying to move a project build to CI? This is not discussed in the documentation currently, unless I am missing it. Thanks!

  • Are there other differences that app developers should be aware of when trying to move a project build to CI?

    As you say, we do not have any documentation on this at this moment.

    If you or anyone else struggle with using the nRF Connect SDK as for CI, feel free to open a new DevZone ticket, and we will assist with your issues.

    Regards,
    Sigurd Hellesvik

Related