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

Build nRF Connect SDK Project via Command Line

Hi,

I'm working on an application for the nRF9160 using the nRF Connect SDK. I want to integrate this app into our build system and thus would like to be able to build the project via the command line. One thing I'm concerned about is what operations Segger EM Studio is doing behind the scenes when you click "Open nRF Connect SDK Project... ". Doing this links all of the Zephyr files as well as the GNU ARM Embedded Toolchain files.

So my question is, Is there a way to replicate this on our build server using the command line?

- Jack

Parents
  • Hi Jack,

    Just adding to what jbrzozoski is referring to:


    • When using the command line you need to define the environment variables for the GNU Arm Embedded toolchain:

    export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    export GNUARMEMB_TOOLCHAIN_PATH=/c/gnuarmemb

    • Set up build environment

    cd $NCS_BASE/zephyr
    source zephyr-env.sh

    cd $NCS_BASE/nrf/samples/nrf9160/mqtt_simple/
    mkdir build && cd build
    
    # Use cmake to configure a Ninja-based build system:
    cmake -GNinja -DBOARD=nrf9160_pca10090ns ..
    
    # Now run ninja on the generated build system:
    ninja
    ninja flash

    Also worth noticing that there is a difference when building Secure/Non-Secure Zephyr applications.


    Extra tip:

    To flash precompiled .hex files you can either use the nRF Connect Programmer application or do it via command line nrfjprog:

    nrfjprog --program <application>.hex -f nrf91 --sectorerase -r --verify
    

    Best Regards,
    Martin L.

  • Hi, I'm trying to build the coap_client application using the command line on Windows since I'm having problems using Segger.
    I already flashed the Secure Boot, now I'm trying using this commands

    cd C:\Nordic_SDK\ncs\zephyr

    zephyr-env.cmd

    set ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb

    set GNUARMEMB_TOOLCHAIN_PATH = “C:\Program Files (x86)\GNU Tools ARM Embedded\8 2018-q4-major”

    cd C:\Nordic_SDK\ncs\nrf\samples\nrf9160\coap_client

    mkdir build && cd build

    cmake .. -DBOARD=nrf9160_pca10090ns -GNinja

    ninja flash

    But then it reports the following message

    C:\Nordic_SDK\ncs\nrf\samples\nrf9160\coap_client\build>cmake .. -DBOARD=nrf9160_pca10090ns -GNinja
    Zephyr version: 1.14.0
    -- Found PythonInterp: C:/Python37/python.exe (found suitable version "3.7.2", minimum required is "3.4")
    -- Selected BOARD nrf9160_pca10090ns
    CMake Error at C:/Nordic_SDK/ncs/zephyr/cmake/extensions.cmake:1104 (message):
    Assertion failed: GNUARMEMB_TOOLCHAIN_PATH is not set
    Call Stack (most recent call first):
    C:/Nordic_SDK/ncs/zephyr/cmake/toolchain/gnuarmemb/generic.cmake:11 (assert)
    C:/Nordic_SDK/ncs/zephyr/cmake/generic_toolchain.cmake:55 (include)
    C:/Nordic_SDK/ncs/zephyr/cmake/app/boilerplate.cmake:395 (include)
    CMakeLists.txt:9 (include)

    It says that the Toolchain Path is not set but I set it with the Gnuarmemb Path I set in the Getting Started Assistant to verify if the Toolchain was correctly installed. Do I have to set a different path?

    Thanks in advance for any clarification you can give me.

    On a side note, will it be possible to build projects using Segger soon? Everytime I try to build a project it gives me an error unless I switch to the v3.0.0 release and then it works.

  • Hello Marco,

    1. I would recommend you to switch to the version 7-2018-q2-update, since the newest version (8-2018-q4-major) has a critical bug and should not be used.
    2. I think the issue can be the same as Hellesvik is experiencing in this thread.

    (There may also be an issue with spaces in the paths)

    Here is my path to the ARM Toolchain: 

    I set:

     export GNUARMEMB_TOOLCHAIN_PATH=/c/gnuarmemb

    and here is what's in this path: C:\gnuarmemb\arm-none-eabi\


    There is a Segger release that is coming very soon, I can update you when it's ready.

    Best Regards,

    Martin L.

Reply Children
Related