This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unable to build blinky project outside SDK folder

Hello,

I am unable to build basic blinky project outside the NRF Connect sdk.

Board - Thingy 91 - nRF9160

SDK version - 1.7.0

builiding through command line tools - CMake and Ninja (windows)

I have provided build variables in the Cmakelists.txt as below.

# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

set(ZEPHYR_TOOLCHAIN_VARIANT gnuarmemb)
set(GNUARMEMB_TOOLCHAIN_PATH C:/coresensing/toolchain/gnuarmemb)
set(ZEPHYR_BASE C:/coresensing/toolchain/ncs/zephyr)
set(BOARD_ROOT C:/coresensing/toolchain/ncs/nrf)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(blinky)

target_sources(app PRIVATE src/main.c)

My application directory is as follows,

- Workspace

   - Blinky

      - src

         - main.c

      -CMakelists.txt

      -prj.conf

This is the Cmake error I am getting

PS C:\Users\Suhas\eclipse-workspace\blinky> cmake -B build -GNinja -DBOARD=thingy91_nRF9160_ns
Including boilerplate (Zephyr base (cached)): C:/coresensing/toolchain/ncs/zephyr/cmake/app/boilerplate.cmake
CMake Deprecation Warning at C:/coresensing/toolchain/ncs/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):
  C:/coresensing/toolchain/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  C:/coresensing/toolchain/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  CMakeLists.txt:25 (find_package)


-- Application: C:/Users/Suhas/eclipse-workspace/blinky
-- Zephyr version: 2.6.99 (C:/coresensing/toolchain/ncs/zephyr), build: v2.6.99-ncs1
-- Found Python3: C:/coresensing/toolchain/python/python.exe (found suitable exact version "3.9.7") found components: Interpreter
-- Found west (found suitable version "0.11.1", minimum required is "0.7.1")
-- Board: thingy91_nRF9160_ns
-- Cache files will be written to: C:/coresensing/toolchain/ncs/zephyr/.cache
-- Found toolchain: gnuarmemb (C:/coresensing/toolchain/gnuarmemb)
-- Found BOARD.dts: C:/coresensing/toolchain/ncs/nrf/boards/arm/thingy91_nrf9160/thingy91_nRF9160_ns.dts
-- Generated zephyr.dts: C:/Users/Suhas/eclipse-workspace/blinky/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: C:/Users/Suhas/eclipse-workspace/blinky/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: C:/Users/Suhas/eclipse-workspace/blinky/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: C:/Users/Suhas/eclipse-workspace/blinky/build/zephyr/dts.cmake
Parsing C:/coresensing/toolchain/ncs/zephyr/Kconfig
Loaded configuration 'C:/coresensing/toolchain/ncs/nrf/boards/arm/thingy91_nrf9160/thingy91_nRF9160_ns_defconfig'
Merged configuration 'C:/Users/Suhas/eclipse-workspace/blinky/prj.conf'
Configuration saved to 'C:/Users/Suhas/eclipse-workspace/blinky/build/zephyr/.config'
Kconfig header saved to 'C:/Users/Suhas/eclipse-workspace/blinky/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 10.3.1
-- The CXX compiler identification is GNU 10.3.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/coresensing/toolchain/gnuarmemb/bin/arm-none-eabi-gcc.exe
Changed board to secure thingy91_nRF9160 (NOT NS)

=== child image spm -  begin ===
Including boilerplate (Zephyr workspace): C:/coresensing/toolchain/ncs/zephyr/cmake/app/boilerplate.cmake
CMake Deprecation Warning at C:/coresensing/toolchain/ncs/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):
  C:/coresensing/toolchain/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  C:/coresensing/toolchain/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:91 (include_boilerplate)
  CMakeLists.txt:8 (find_package)


-- Application: C:/coresensing/toolchain/ncs/nrf/samples/spm
-- Zephyr version: 2.6.99 (C:/coresensing/toolchain/ncs/zephyr), build: v2.6.99-ncs1
-- Found Python3: C:/coresensing/toolchain/python/python.exe (found suitable exact version "3.9.7") found components: Interpreter
-- Found west (found suitable version "0.11.1", minimum required is "0.7.1")
-- Board: thingy91_nRF9160
-- Cache files will be written to: C:/coresensing/toolchain/ncs/zephyr/.cache
-- Found toolchain: gnuarmemb (C:/coresensing/toolchain/gnuarmemb)
-- Found BOARD.dts: C:/coresensing/toolchain/ncs/nrf/boards/arm/thingy91_nrf9160/thingy91_nRF9160.dts
-- Found devicetree overlay: C:/coresensing/toolchain/ncs/nrf/samples/spm/boards/thingy91_nRF9160.overlay
-- Generated zephyr.dts: C:/Users/Suhas/eclipse-workspace/blinky/build/spm/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: C:/Users/Suhas/eclipse-workspace/blinky/build/spm/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: C:/Users/Suhas/eclipse-workspace/blinky/build/spm/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: C:/Users/Suhas/eclipse-workspace/blinky/build/spm/zephyr/dts.cmake
Parsing C:/coresensing/toolchain/ncs/zephyr/Kconfig
Loaded configuration 'C:/coresensing/toolchain/ncs/nrf/boards/arm/thingy91_nrf9160/thingy91_nRF9160_defconfig'
Merged configuration 'C:/coresensing/toolchain/ncs/nrf/samples/spm/prj.conf'
Merged configuration 'C:/coresensing/toolchain/ncs/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Merged configuration 'C:/Users/Suhas/eclipse-workspace/blinky/build/spm/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to 'C:/Users/Suhas/eclipse-workspace/blinky/build/spm/zephyr/.config'
Kconfig header saved to 'C:/Users/Suhas/eclipse-workspace/blinky/build/spm/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 10.3.1
-- The CXX compiler identification is GNU 10.3.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/coresensing/toolchain/gnuarmemb/bin/arm-none-eabi-gcc.exe
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\coresensing\toolchain\python\lib\site-packages\west\manifest.py", line 1103, in from_file
    topdir = util.west_topdir()
  File "C:\coresensing\toolchain\python\lib\site-packages\west\util.py", line 82, in west_topdir
    raise WestNotFound('Could not find a West workspace '
west.util.WestNotFound: Could not find a West workspace in this or any parent directory
CMake Error at C:/coresensing/toolchain/ncs/nrfxlib/common.cmake:58 (message):
  Failed to find mbedtls, cannot build security libraries
Call Stack (most recent call first):
  C:/coresensing/toolchain/ncs/nrfxlib/nrf_security/CMakeLists.txt:173 (get_mbedtls_dir)


-- Configuring incomplete, errors occurred!
See also "C:/Users/Suhas/eclipse-workspace/blinky/build/spm/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Suhas/eclipse-workspace/blinky/build/spm/CMakeFiles/CMakeError.log".
CMake Error at C:/coresensing/toolchain/ncs/nrf/cmake/multi_image.cmake:301 (message):
  CMake generation for spm failed, aborting.  Command: 1
Call Stack (most recent call first):
  C:/coresensing/toolchain/ncs/nrf/cmake/multi_image.cmake:68 (add_child_image_from_source)
  C:/coresensing/toolchain/ncs/nrf/samples/CMakeLists.txt:58 (add_child_image)


-- Configuring incomplete, errors occurred!
See also "C:/Users/Suhas/eclipse-workspace/blinky/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Suhas/eclipse-workspace/blinky/build/CMakeFiles/CMakeError.log".
PS C:\Users\Suhas\eclipse-workspace\blinky>

Please let me know what I can do to fix this error.

Thank you.

 - Suhas

  • Hello Suhas,

    have you installed the nRF Connect SDK according to this guideline and performed all steps?

    Is there a reason why you are using this build command?

    cmake -B build -GNinja -DBOARD=thingy91_nRF9160_ns

    Normally, we recommend to use this one instead:

    west build -b thingy91_nrf9160ns

    Regards,

    Markus

  • Yes I have installed nRF Connect SDK according to the guideline. This can be confirmed because, the application compiles correctly inside the SDK.

    I need a freestanding application.

    the west command will not build anything,

    PS C:\Users\Suhas\eclipse-workspace\blinky> west build -b thingy91_nrf9160ns
    usage: west [-h] [-z ZEPHYR_BASE] [-v] [-V] <command> ...
    west: error: argument <command>: invalid choice: 'build' (choose from 'init', 'update', 'list', 'manifest', 'diff', 'status', 'forall', 'help', 'config', 'topdir', 'selfupdate')
    PS C:\Users\Suhas\eclipse-workspace\blinky>

    thank you.

    -suhas

  • Hello Suhas,

    Suhas_MS said:
    I need a freestanding application.

    Got you!

    You might want to have a look at the section Adding your own code in the NCS documentation. I will provide you with an example based on Workflow 4: Application as the manifest repository.

    In the root folder of your freestanding Blinky sample, create a file named west.yml containing the following:

    # Example application-specific west.yml, using manifest imports.
    manifest:
      remotes:
        - name: ncs
          url-base: https://github.com/nrfconnect
      projects:
        - name: nrf
          repo-path: sdk-nrf
          remote: ncs
          revision: v1.6.1
          import: true
      self:
        path: blinky_app

    path should be the root folder name of the Blinky sample, which in this case “blinky_app”. NCS version to be used in this example will be v1.6.1, but this can be changed to basically any other version.

    Now, in your workspace folder where “blinky_app” is the manifest repository, run the following command:

    west init -l blinky_app

    followed by:

    west update

    When finished, you should have a full nRF Connect SDK repository within your workspace. Switching to “blinky_app”, you can now run the build command:

    west build -b thingy91_nrf9160ns

    followed by:

    west flash --erase

    I hope this will help you.

    Regards.

    Markus

  • Hello Markus,

    I have already tried this approach and this downloads the whole SDK again to my workspace.

    I need to implement an application out of the SDK directory as given in - 

    Workflow 2: Out-of-tree application repository

    This approach will help us maintain the application only with our repository and decouple it with NRF SDK. That is the reason why I have added ZYPHER_BASE to my CMakelists.txt

    but this approach doesn't seem to work.

    Please let me know how I can establish the out-of -tree application repository properly.

    Thank You.

    - Suhas

  • Hello Suhas,

    Suhas_MS said:
    Please let me know how I can establish the out-of -tree application repository properly.

    I will demonstrate this based on the Hello World sample on an Ubuntu distribution. The installation path of the nRF Connect SDK is "$HOME/ncs", resulting in:

    ~$ echo $ZEPHYR_BASE
    /home/user/ncs/zephyr

    In addition to all other required tools, the variable has to point to the right Zephyr within your build environment.

    Now I just copy the hello_world folder from "$HOME/ncs/zephyr/samples/hello_world" to a different location, e.g. "$HOME/_work/outoftree/".

    From there, I run:

    ~/_work/outoftree/hello_world$ west build -b nrf9160dk_nrf9160ns
    
    -- west build: generating a build system
    
    ...
    
    ...
    
    -- west build: building application
    
    [1/171] Preparing syscall dependency handling
    
    [6/171] Performing build step for 'spm_subimage'
    
    [1/216] Preparing syscall dependency handling
    
    [209/216] Linking C executable zephyr/zephyr_prebuilt.elf
    
    [216/216] Linking C executable zephyr/zephyr.elf
    
    Memory region Used Size Region Size %age Used
    
    FLASH: 64 KB 64 KB 100.00%
    
    SRAM: 11808 B 64 KB 18.02%
    
    IDT_LIST: 0 GB 2 KB 0.00%
    
    [163/171] Linking C executable zephyr/zephyr_prebuilt.elf
    
    [170/171] Linking C executable zephyr/zephyr.elf
    
    Memory region Used Size Region Size %age Used
    
    FLASH: 28940 B 960 KB 2.94%
    
    SRAM: 6528 B 178968 B 3.65%
    
    IDT_LIST: 0 GB 2 KB 0.00%
    
    [171/171] Generating zephyr/merged.hex

    Regards,

    Markus

Related