build doesn't recognize zephyr files

Hello,

im trying to do the first exercise in DevAcademy (https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-2-bluetooth-le-advertising/topic/advertising-process/) and i downloaded the relevent git aip file and opened a new project. its path is: C:\nordic\BLEexample\bt-fund\lesson1\blefund_less1_exer1

and my zephyr files are in : C:\ncs\v1.9.0\zephyr\include\sys\printk.h

the CMakeLists.txt are are as downloaded:

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
cmake_minimum_required(VERSION 3.20.0)

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

# NORDIC SDK APP START
target_sources(app PRIVATE
src/main.c
)

# NORDIC SDK APP END
zephyr_library_include_directories(.)

and i the build fails:
Building blefund_less1_exer1
west build --build-dir c:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1/build_1 c:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1

[59/215] Building C object CMakeFiles/app.dir/src/main.c.obj
FAILED: CMakeFiles/app.dir/src/main.c.obj
C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DBUILD_VERSION=v2.7.99-ncs1 -DDEVELOP_IN_NRF52833 -DKERNEL -DNRF52820_XXAA -DNRFX_COREDEP_DELAY_US_LOOP_CYCLES=3 -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I../. -IC:/ncs/v1.9.0/nrf/drivers/mpsl/clock_control -IC:/ncs/v1.9.0/zephyr/include -Izephyr/include/generated -IC:/ncs/v1.9.0/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/ncs/v1.9.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v1.9.0/zephyr/subsys/bluetooth -IC:/ncs/v1.9.0/zephyr/subsys/settings/include -IC:/ncs/v1.9.0/nrf/include -IC:/ncs/v1.9.0/nrf/lib/multithreading_lock/. -IC:/ncs/v1.9.0/nrf/subsys/bluetooth/controller/. -IC:/ncs/v1.9.0/zephyr/drivers/flash -IC:/ncs/v1.9.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v1.9.0/modules/hal/nordic/nrfx -IC:/ncs/v1.9.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v1.9.0/modules/hal/nordic/nrfx/mdk -IC:/ncs/v1.9.0/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v1.9.0/modules/debug/segger/SEGGER -IC:/ncs/v1.9.0/modules/debug/segger/Config -IC:/ncs/v1.9.0/zephyr/modules/segger/. -IC:/ncs/v1.9.0/modules/crypto/tinycrypt/lib/include -IC:/ncs/v1.9.0/nrfxlib/mpsl/include -IC:/ncs/v1.9.0/nrfxlib/mpsl/include/protocol -I../~C:/ncs/v1.9.0/zephyr/include -IC:/ncs/v1.9.0/nrfxlib/softdevice_controller/include -IC:/ncs/v1.9.0/zephyr/include/posix -isystem C:/ncs/v1.9.0/zephyr/lib/libc/minimal/include -isystem c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include -isystem c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed -Os -imacros C:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1/build_1/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -imacros C:/ncs/v1.9.0/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v1.9.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v1.9.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -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
../src/main.c:11:10: fatal error: zephyr/sys/printk.h: No such file or directory
11 | #include <zephyr/sys/printk.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[68/215] Linking C static library zephyr\lib\libc\minimal\liblib__libc__minimal.a
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\nordic\BLEexample\bt-fund\lesson1\blefund_less1_exer1\build_1'

* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.

any idea why?

  • Hello,

    That is odd. Are you able to simply build a default sample from the SDK?

    Regards,

    Elfving

  • Hey Elfving,

    Yes i am able to build and flash an example of BME sample sensor, that is located in C:\bme680

    and its CMakeList.txt is:

    #
    # Copyright (c) 2018 Bosch Sensortec GmbH
    #
    # SPDX-License-Identifier: Apache-2.0
    #

    cmake_minimum_required(VERSION 3.20.0)
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(bme680)

    FILE(GLOB app_sources src/*.c)
    target_sources(app PRIVATE ${app_sources})
     
    i tried to include the same librarys that where unable to include and build in the original issue file:
    #include <zephyr/sys/printk.h>
    #include <zephyr/sys/byteorder.h>
    #include <zephyr/kernel.h>
    #include <zephyr/drivers/gpio.h>
    #include <soc.h>

    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/hci.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/uuid.h>
    #include <zephyr/bluetooth/gatt.h>
    but i get the same errors as i mentioned before.

     

     

  • Hello again,

    Ah yes. I see that you are running it in NCS version 1.9. I think the newer versions are the ones that are tested/supported with this course. Try NCS NCS 2.4.0 and above. There are a few changes made inbetween these NCS versions, and 1.9 is starting to get old. If you have a larger ongoing project I would understand if you stick to one NCS version for a longer period of time, but for learning NCS and BLE I would recommend upgrading to the latest NCS versions. 

    When it comes to the issue itself, it seems that you need to write #include </sys/printk.h> in NCS1.9, not #include <zephyr/sys/printk.h>. But nevermind that, just install a newer version.

    Regards,

    Elfving

  • i removed NCS version 1.9. I and installed the newer version 2.5.2.

    and still im unable to build:

    * Executing task: nRF Connect: Build: blefund_less1_exer1/build (active)

    Building blefund_less1_exer1
    west build --build-dir c:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1/build c:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1

    [4/74] Performing build step for 'mcuboot_subimage'
    ninja: no work to do.
    [14/74] Building C object zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj
    FAILED: zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj
    C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF52840_XXAA -DPICOLIBC_INTEGER_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -IC:/ncs/v2.5.2/zephyr/subsys/bluetooth -IC:/ncs/v2.5.2/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.5.2/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/ncs/v2.5.2/zephyr/include/zephyr/posix -IC:/ncs/v2.5.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.5.2/zephyr/subsys/settings/include -IC:/ncs/v2.5.2/nrf/include -IC:/ncs/v2.5.2/nrf/tests/include -IC:/ncs/v2.5.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.5.2/zephyr/modules/cmsis/. -IC:/ncs/v2.5.2/modules/hal/nordic/nrfx -IC:/ncs/v2.5.2/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.5.2/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.5.2/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.5.2/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.5.2/nrfxlib/softdevice_controller/include -isystem C:/ncs/v2.5.2/nrfxlib/crypto/nrf_cc310_platform/include -Wshadow -fno-strict-aliasing -Os -imacros C:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1/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=C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.5.2/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=C:/nordic/BLEexample/bt-fund/lesson1/blefund_less1_exer1=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.5.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.5.2=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -D_POSIX_THREADS -std=c99 -MD -MT zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj -MF zephyr\drivers\bluetooth\CMakeFiles\drivers__bluetooth.dir\hci\h4.c.obj.d -o zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj -c C:/ncs/v2.5.2/zephyr/drivers/bluetooth/hci/h4.c
    In file included from C:/ncs/v2.5.2/zephyr/include/zephyr/toolchain/gcc.h:92,
    from C:/ncs/v2.5.2/zephyr/include/zephyr/toolchain.h:50,
    from C:/ncs/v2.5.2/zephyr/include/zephyr/kernel_includes.h:19,
    from C:/ncs/v2.5.2/zephyr/include/zephyr/kernel.h:17,
    from C:/ncs/v2.5.2/zephyr/drivers/bluetooth/hci/h4.c:12:
    C:/ncs/v2.5.2/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_DT_CHOSEN_zephyr_bt_uart_ORD' undeclared here (not in a function)
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    C:/ncs/v2.5.2/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
    132 | #define _DO_CONCAT(x, y) x ## y
    | ^
    C:/ncs/v2.5.2/zephyr/include/zephyr/device.h:85:33: note: in expansion of macro '_CONCAT'
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~
    C:/ncs/v2.5.2/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))
    | ^~~~~~~~~~~~~~~
    C:/ncs/v2.5.2/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))
    | ^~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.2/zephyr/drivers/bluetooth/hci/h4.c:74:44: note: in expansion of macro 'DEVICE_DT_GET'
    74 | static const struct device *const h4_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_uart));
    | ^~~~~~~~~~~~~
    [23/74] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/ncs/v2.5.2/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\nordic\BLEexample\bt-fund\lesson1\blefund_less1_exer1\build'

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

     plus i tried in 1.9.1 version to remove the /zephyr/ path in the include, but it didnt help.

  • Could you try placing BLEexample/bt-fund/ in /ncs/, maybe there is something strange going on with the west workspace.

    What HW are you building the sample for?

    Could you check and make sure that you are using a corresponding newer toolchain?

     

    Regards,

    Elfving

Related