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?

Parents
  • 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.

     

     

  • Hey Elfving,


    A little background:
    My main goal is to advertise my BME sample sensor to the app and to be able to control the sensor activation using BLE, meaning nrf connect app for mobile.


    Im using the thingy91. I tried to build it in an thingy91_nrf9160_ns board settings.
    However i then saw that the exercise is suitable only to nrf52.


    So i switch the SWD to nrf 52 in my thingy91 and build using thingy91_nrf52840 board settings
    and it is still unable to build with the same errors as i mentioned before even after moved the directory to the path you mentioned.

    Also, yes I checked the toolchain I'm using and it is exactly like you added in the your attached screenshot.

  • Just to make sure that there is nothing wrong with the SDK, toolchain, environment, etc., could you try simply building it for an nRF52DK?

    Raz_k said:
    So i switch the SWD to nrf 52 in my thingy91 and build using thingy91_nrf52840 board settings

    I believe it actually should work for the nRF52840 on the Thingy91, though the nRF9160 itself does not have BLE capabilities, which might be reason why it failed - though from the error it doesn't seem like that is the main issue.

    Regards,

    Elfving

  • I used the bme680 example and created it in the ncs directory, defined a thingy91_nrf52840 board.


    But still the same errors:


    Building bme680_nrf52
    west build --build-dir c:/ncs/bme680_nrf52/build c:/ncs/bme680_nrf52

    [6/94] 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 -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__=1 -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/soc/arm/nordic_nrf/common/. -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/. -isystem C:/ncs/v2.5.2/nrfxlib/crypto/nrf_cc310_platform/include -fno-strict-aliasing -Os -imacros C:/ncs/bme680_nrf52/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:/ncs/bme680_nrf52=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 -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 C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_macro.h:34,
    from C:/ncs/v2.5.2/zephyr/include/zephyr/sys/atomic.h:16,
    from C:/ncs/v2.5.2/zephyr/include/zephyr/kernel_includes.h:21,
    from C:/ncs/v2.5.2/zephyr/include/zephyr/kernel.h:17,
    from ../src/main.c:7:
    ../src/main.c: In function 'main':
    C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util.h:93:55: error: size of unnamed array is negative
    93 | #define ZERO_OR_COMPILE_ERROR(cond) ((int) sizeof(char[1 - 2 * !(cond)]) - 1)
    | ^
    C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_internal.h:72:26: note: in definition of macro '__DEBRACKET'
    72 | #define __DEBRACKET(...) __VA_ARGS__
    | ^~~~~~~~~~~
    C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_internal.h:64:9: note: in expansion of macro '__GET_ARG2_DEBRACKET'
    64 | __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
    | ^~~~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_internal.h:59:9: note: in expansion of macro '__COND_CODE'
    59 | __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
    | ^~~~~~~~~~~
    C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_macro.h:180:9: note: in expansion of macro 'Z_COND_CODE_1'
    180 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
    | ^~~~~~~~~~~~~
    C:/ncs/v2.5.2/zephyr/include/zephyr/device.h:279:9: note: in expansion of macro 'COND_CODE_1'
    279 | COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat), \
    | ^~~~~~~~~~~
    C:/ncs/v2.5.2/zephyr/include/zephyr/device.h:281:22: note: in expansion of macro 'ZERO_OR_COMPILE_ERROR'
    281 | (ZERO_OR_COMPILE_ERROR(0)))
    | ^~~~~~~~~~~~~~~~~~~~~
    ../src/main.c:14:42: note: in expansion of macro 'DEVICE_DT_GET_ONE'
    14 | const struct device *const dev = DEVICE_DT_GET_ONE(bosch_bme680);
    | ^~~~~~~~~~~~~~~~~
    [15/94] Building C object zephyr/CMakeFiles/zephyr.dir/C_/ncs/v2.5.2/nrfxlib/crypto/nrf_cc310_platform/src/nrf_cc3xx_platform_mutex_zephyr.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\ncs\bme680_nrf52\build'

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

  • When building it for the "nRF52DK_nrf52832" though?

    Regards,

    Elfving 

  • When defining nRF52DK_nrf52832 I get the same errors.

    However, when i build with the nRF52840DK_nrf52840 it is able to build and flash(using J-link) successfully.

    But im having trouble understanding how to test the program, since im connected via J-link and there is no outputs in the viewer app. In addition the device doesnt recognize my USB data cable.

Reply
  • When defining nRF52DK_nrf52832 I get the same errors.

    However, when i build with the nRF52840DK_nrf52840 it is able to build and flash(using J-link) successfully.

    But im having trouble understanding how to test the program, since im connected via J-link and there is no outputs in the viewer app. In addition the device doesnt recognize my USB data cable.

Children
  • I am running into the same problem, which is good in a way. Then we know that this isn't really a symptom of there being anything wrong with your SDK.  

    Raz_k said:

    However, when i build with the nRF52840DK_nrf52840 it is able to build and flash(using J-link) successfully.

    So you do have a DK on hand as well?

    The nRF9160 doesn't have BLE capabilities, so you shouldn't build anything in the BLE fundamentals course for that SoC. Another thing is that the Thingies (Thingy91 and Thingy53) might be a bit harder to work with. I would recommend using a development kit (DK) instead. For parhaps a better breakdown of the difference between the two, see here.

    Raz_k said:
    But im having trouble understanding how to test the program, since im connected via J-link and there is no outputs in the viewer app. In addition the device doesnt recognize my USB data cable.

    Is this to the Thingy or the DK? The Thingy does not have an OB debugger, which might be the issue.

    Regards,

    Elfving

Related