Difficulty creating a Zephyr-based nRFConnect project within VSCode that contains a custom sensor driver

I have been trying to create an nRFConnect based project using toolchain 2.5.0 and SDK 2.5.0 (also 2.5.99-dev1) that enables me to create an example application that uses a custom external driver.  As a simple example, let's say I want to take the "Blinky" project, add SPI, and then add a custom sensor driver. Let's call that custom sensor driver "my_accel_chip."  While the rules for creating drivers that work with the Zephyr API are straightforward, there's no easy way that I have been able to find that works seamlessly with nrfConnect and VSCode.  For example:

https://iwasz.pl/electronics/2021-06-18-out-of-tree-zephyr-module.md/

https://jdelaney.me/posts/zephyr-oot-modules/

https://blog.golioth.io/adding-an-out-of-tree-sensor-driver-to-zephyr/

Apparently you can't just clone git clone github.com/.../example-application my-app and open up a folder  and build an app either, you need "west" and the venv setup.

../src/main.c: In function 'main':
/opt/nordic/ncs/v2.5.99-dev1/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_DT_N_NODELABEL_examplesensor0_ORD' undeclared (first use in this function)
85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)

Reading through the documentation, it appears there is a "workspace" method that requires WEST to initialize the project that is not supported with nrfConnect/vscode. Trouble is, I don't have the ability to manually open up the .venv and run west  and initialize the project.

So I have two questions:

(1) How do you activate the venv/west workspace so you can run west commands manually within VSCode and nrfConnect

(2) Is there a *WORKING TEMPLATE* for an APP + OUT OF TREE Sensor Driver that I can use within nrfConnect Examples such as Blinky + SPI for an equivalent "my_external_tree_sensor_driver"?  I've tried creating a workspace, then importing an app like Blinky, updating the device tree to support SPI, then copying "my_out_of_tree_driver" as per the structures described in the above links, including CMakeLists.txt, yaml files, Kconfig, etc, then tried to add the driver, both to the workspace, and as an alternative, copying my driver right in "myapp."  

I have had zero success.  This is on MacOS. Toolchains and APIs are stored in /opt/nordic/ncs , while my workspace where my app is stored is in /home/myusername/nordic_apps/

So I'm really not sure how to create a driver structure, as shown in Mike Delaney's Blog as an example, like where to put this file structure, or how to integrate with nRFConnect tools / VSCode.  For example, do I structure my code like this?

  my_app
  |-- src/main.c
|-- prj.conf ...
|-- CMakeLists.txt
  my_out_of_tree_driver
  |-- drivers
        |-- sensor
              |-- bh1750
                    |-- bh1750.c
                    |-- bh1750.h
                    |-- CMakeLists.txt
                    |-- KConfig
              |-- CMakeLists.txt
              |-- Kconfig
        |-- CMakeLists.txt
        |-- Kconfig
  |-- dts
        |-- bindings
              |-- sensor
                    |-- rohm,bh1750-i2c.yaml
  |-- include
        |-- drivers
  |-- Kconfig
  |-- CMakeLists.txt
  |-- zephyr
        |-- module.yml

Or like this?

my_app (driver contained within my_app)

|-- src/main.c
|-- prj.conf ...
|-- CMakeLists.txt

|-- my_out_of_tree_driver
  |-- drivers
        |-- sensor
              |-- bh1750
                    |-- bh1750.c
                    |-- bh1750.h
                    |-- CMakeLists.txt
                    |-- KConfig
              |-- CMakeLists.txt
              |-- Kconfig
        |-- CMakeLists.txt
        |-- Kconfig
  |-- dts
        |-- bindings
              |-- sensor
                    |-- rohm,bh1750-i2c.yaml
  |-- include
        |-- drivers
  |-- Kconfig
  |-- CMakeLists.txt
  |-- zephyr
        |-- module.yml

OR... Can Nordic provide a fully working nRFConnect / VSCode solution with a sample app and sample external sensor driver included in the package, because right now that does not exist!

Thanks, Josh
  • Hello Josh,

    Thank you for contacting DevZone at NordicSemi.

    1) I created a folder named "case_customOTD" in a local folder (C:/ZTEMP)

    then I opened this folder with the VS Code (you can select SDK version from the VS Code extension icon on the left)

    I just opened a "nrf Connect" terminal in the VS Code, and typed the same git clone command that you have provided

    It worked flawlessly and after that the repo is cloned in the folder

    (I am on Windows OS)

    2) Zephyr Out of Tree Driver sample is present in NCS 2.4.2.

    I started with the VSCode, and selected NCS 2.4.2 as the SDK and the toolchain 2.4.2

    I created a new application from samples and chose "Out of Tree Driver" sample from zephyr.

    After creation of the application, I changed the SDK and toolchain version to 2.5.0

    I built the application, and it is building just fine. 

    /BR, Naeem

  • Hi Naeem,  unfortunately the "Out of Tree Driver" sample is missing all the DT bindings, etc.  It's not a great example.

    When I clone "my-app" to a custom folder such as: /Users/my-username/nordic I can open the folder in VSCode but when I go to "open an existing application" I receive the following error:

    The directory "/Users/my-username/nordic/my-app" does not contain an application source. 

    If I open app folder within my-app:

    The app opens up

    I create a new build configuration: If you use 2.4.2 the failure is different then when using 2.5.0

    Building with 2.5.0 you get this error:

    Building app
    /bin/sh -c west build --build-dir /Users/my_username/nordic/my-app/app/build /Users/my_username/nordic/my-app/app --pristine --board nrf52dk_nrf52832 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="/Users/my_username/nordic/my-app" -DCONF_FILE:STRING="/Users/my_username/nordic/my-app/app/prj.conf"

    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: /Users/my_username/nordic/my-app/app
    -- CMake version: 3.20.5
    -- Found Python3: /opt/nordic/ncs/toolchains/20d68df7e5/opt/[email protected]/bin/python3.9 (found suitable version "3.9.6", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: /Users/my_username/Library/Caches/zephyr
    -- Zephyr version: 3.4.99 (/opt/nordic/ncs/v2.5.0/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf52dk_nrf52832
    -- Found host-tools: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found Dtc: /opt/nordic/ncs/toolchains/20d68df7e5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
    -- Found BOARD.dts: /opt/nordic/ncs/v2.5.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
    -- Generated zephyr.dts: /Users/my_username/nordic/my-app/app/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /Users/my_username/nordic/my-app/app/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /Users/my_username/nordic/my-app/app/build/zephyr/dts.cmake
    Parsing /Users/my_username/nordic/my-app/app/Kconfig
    Loaded configuration '/opt/nordic/ncs/v2.5.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
    Merged configuration '/Users/my_username/nordic/my-app/app/prj.conf'
    Configuration saved to '/Users/my_username/nordic/my-app/app/build/zephyr/.config'
    Kconfig header saved to '/Users/my_username/nordic/my-app/app/build/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/my_username/nordic/my-app/app/build
    -- west build: building application
    [1/141] Preparing syscall dependency handling

    [2/141] Generating include/generated/app_version.h
    [3/141] Generating ../../zephyr/include/generated/ncs_version.h
    [4/141] Generating misc/generated/syscalls_subdirs.trigger
    [5/141] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
    [6/141] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
    [7/141] Generating include/generated/driver-validation.h
    [8/141] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h, include/generated/otype-to-size.h
    [9/141] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
    [10/141] Generating include/generated/offsets.h
    [11/141] Generating include/generated/version.h
    -- Zephyr version: 3.4.99 (/opt/nordic/ncs/v2.5.0/zephyr), build: 2e2523efe52a
    [12/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/dec.c.obj
    [13/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/hex.c.obj
    [14/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
    [15/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/multi_heap.c.obj
    [16/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_complete.c.obj
    [17/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.obj
    [18/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
    [19/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
    [20/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
    [21/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/bitarray.c.obj
    [22/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
    [23/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_packaged.c.obj
    [24/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
    [25/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
    [26/141] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
    [27/141] Building ASM object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/common/soc_nrf_common.S.obj
    [28/141] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/tracing/tracing_none.c.obj
    [29/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/cpu_idle.S.obj
    [30/141] Building C object zephyr/arch/common/CMakeFiles/arch__common.dir/sw_isr_common.c.obj
    [31/141] Building C object zephyr/arch/common/CMakeFiles/isr_tables.dir/isr_tables.c.obj
    [32/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
    [33/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
    [34/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi_on_reset.S.obj
    [35/141] Generating linker_zephyr_pre0.cmd
    [36/141] Building C object zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj
    [37/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap_helper.S.obj
    [38/141] Linking C static library zephyr/arch/common/libisr_tables.a
    [39/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/reboot.c.obj
    [40/141] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/assert.c.obj
    [41/141] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi.c.obj
    [42/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/isr_wrapper.S.obj
    [43/141] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/validate_enabled_instances.c.obj
    [44/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault_s.S.obj
    [45/141] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/prep_c.c.obj
    [46/141] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/validate_base_addresses.c.obj
    [47/141] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap.c.obj
    [48/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/reset.S.obj
    [49/141] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/irq_init.c.obj
    [50/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/exc_exit.S.obj
    [51/141] Linking C static library zephyr/arch/common/libarch__common.a
    [52/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/__aeabi_read_tp.S.obj
    [53/141] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/vector_table.S.obj
    [54/141] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/thread.c.obj
    [55/141] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/irq_manage.c.obj
    [56/141] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/__/common/tls.c.obj
    [57/141] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fpu.c.obj
    [58/141] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/scb.c.obj
    [59/141] Linking C static library zephyr/libzephyr.a
    [60/141] Building C object zephyr/soc/soc/arm/common/cortex_m/CMakeFiles/soc__arm__common__cortex_m.dir/arm_mpu_regions.c.obj
    [61/141] Building C object zephyr/drivers/console/CMakeFiles/drivers__console.dir/uart_console.c.obj
    [62/141] Building C object zephyr/lib/libc/picolibc/CMakeFiles/lib__libc__picolibc.dir/libc-hooks.c.obj
    [63/141] Building C object zephyr/arch/arch/arm/core/aarch32/mpu/CMakeFiles/arch__arm__core__aarch32__mpu.dir/arm_core_mpu.c.obj
    [64/141] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/thread_abort.c.obj
    [65/141] Building C object zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/source/stdlib/abort.c.obj
    [66/141] Linking C static library zephyr/soc/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a
    [67/141] Linking C static library zephyr/lib/libc/picolibc/liblib__libc__picolibc.a
    [68/141] Linking C static library zephyr/drivers/console/libdrivers__console.a
    [69/141] Building C object zephyr/drivers/clock_control/CMakeFiles/drivers__clock_control.dir/clock_control_nrf.c.obj
    [70/141] Building C object zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/source/stdlib/malloc.c.obj
    [71/141] Building C object zephyr/soc/soc/arm/nordic_nrf/nrf52/CMakeFiles/soc__arm__nordic_nrf__nrf52.dir/soc.c.obj
    [72/141] Building C object zephyr/drivers/pinctrl/CMakeFiles/drivers__pinctrl.dir/common.c.obj
    [73/141] Linking C static library zephyr/soc/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a
    [74/141] Linking C static library zephyr/drivers/clock_control/libdrivers__clock_control.a
    [75/141] Linking C static library zephyr/lib/libc/common/liblib__libc__common.a
    [76/141] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/fatal.c.obj
    [77/141] Building C object zephyr/drivers/timer/CMakeFiles/drivers__timer.dir/sys_clock_init.c.obj
    [78/141] Linking C static library zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a
    [79/141] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/mdk/system_nrf52.c.obj
    [80/141] Building C object zephyr/arch/arch/arm/core/aarch32/mpu/CMakeFiles/arch__arm__core__aarch32__mpu.dir/arm_mpu.c.obj
    [81/141] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/helpers/nrfx_flag32_allocator.c.obj
    [82/141] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/nrfx_glue.c.obj
    [83/141] Building C object modules/nrf/lib/fatal_error/CMakeFiles/..__nrf__lib__fatal_error.dir/fatal_error.c.obj
    [84/141] Linking C static library zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a
    [85/141] Building C object CMakeFiles/app.dir/src/main.c.obj
    FAILED: CMakeFiles/app.dir/src/main.c.obj
    ccache /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DNRF52832_XXAA -DPICOLIBC_INTEGER_PRINTF_SCANF -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/opt/nordic/ncs/v2.5.0/zephyr/include -Izephyr/include/generated -I/opt/nordic/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/nrf52 -I/opt/nordic/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/common/. -I/opt/nordic/ncs/v2.5.0/nrf/include -I/opt/nordic/ncs/v2.5.0/nrf/tests/include -I/opt/nordic/ncs/v2.5.0/modules/hal/cmsis/CMSIS/Core/Include -I/opt/nordic/ncs/v2.5.0/zephyr/modules/cmsis/. -I/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx -I/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/include -I/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/mdk -I/opt/nordic/ncs/v2.5.0/zephyr/modules/hal_nordic/nrfx/. -I/opt/nordic/ncs/v2.5.0/modules/debug/segger/SEGGER -I/opt/nordic/ncs/v2.5.0/modules/debug/segger/Config -fno-strict-aliasing -Os -imacros /Users/my_username/nordic/my-app/app/build/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/Users/my_username/nordic/my-app/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nordic/ncs/v2.5.0=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
    In file included from /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/toolchain/gcc.h:92,
    from /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/toolchain.h:50,
    from /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/kernel_includes.h:19,
    from /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/kernel.h:17,
    from /Users/my_username/nordic/my-app/app/src/main.c:6:
    ../src/main.c: In function 'main':
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_DT_N_NODELABEL_examplesensor0_ORD' undeclared (first use in this function)
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
    132 | #define _DO_CONCAT(x, y) x ## y
    | ^
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:33: note: in expansion of macro '_CONCAT'
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:211:37: note: in expansion of macro 'DEVICE_NAME_GET'
    211 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
    | ^~~~~~~~~~~~~~~
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:228:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    228 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    /Users/my_username/nordic/my-app/app/src/main.c:20:18: note: in expansion of macro 'DEVICE_DT_GET'
    20 | sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0));
    | ^~~~~~~~~~~~~
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:41: note: each undeclared identifier is reported only once for each function it appears in
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
    132 | #define _DO_CONCAT(x, y) x ## y
    | ^
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:33: note: in expansion of macro '_CONCAT'
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:211:37: note: in expansion of macro 'DEVICE_NAME_GET'
    211 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
    | ^~~~~~~~~~~~~~~
    /opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:228:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    228 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    /Users/my_username/nordic/my-app/app/src/main.c:20:18: note: in expansion of macro 'DEVICE_DT_GET'
    20 | sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0));
    | ^~~~~~~~~~~~~
    [86/141] Building C object zephyr/drivers/sensor/nrf5/CMakeFiles/drivers__sensor__nrf5.dir/temp_nrf5.c.obj
    [87/141] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/helpers/nrfx_gppi_ppi.c.obj
    [88/141] Linking C static library modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a
    [89/141] Building C object zephyr/drivers/timer/CMakeFiles/drivers__timer.dir/nrf_rtc_timer.c.obj
    [90/141] Building C object modules/segger/CMakeFiles/modules__segger.dir/opt/nordic/ncs/v2.5.0/modules/debug/segger/SEGGER/SEGGER_RTT.c.obj
    [91/141] Building C object modules/segger/CMakeFiles/modules__segger.dir/SEGGER_RTT_zephyr.c.obj
    [92/141] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault.c.obj
    [93/141] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj
    [94/141] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c.obj
    [95/141] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/src/nrfx_ppi.c.obj
    [96/141] Building C object zephyr/drivers/pinctrl/CMakeFiles/drivers__pinctrl.dir/pinctrl_nrf.c.obj
    [97/141] Building C object zephyr/drivers/gpio/CMakeFiles/drivers__gpio.dir/gpio_nrfx.c.obj
    [98/141] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/opt/nordic/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/src/nrfx_gpiote.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/20d68df7e5/bin/cmake --build /Users/my_username/nordic/my-app/app/build
    So it seems I am unable to get the example cloned with 
    "git clone github.com/.../example-application my-app" to build, when using nrf52832 DK.

  • It appears that the device "examplesensor0" is not being added to the device tree. Am I missing some kind of Device Tree overlay step?

  • Adding the following overlay did not fix the problem:

    /{
        examplesensor0 {
            compatible = "zephyr,examplesensor";
            input-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
        };
    };
    

  • So for Item #1, all you show above is that you cloned the project.  Were you able to build it successfully?  If so, how? I'd like to see the steps to take that example project, clone it, open it, configure for nrf52832, and build it.  That way we have the full successful chain.  

Related