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

NRF9160DK_NRF9160 vs. NRF9160DK_NRF9160ns build

Hi,

I have an application and I want to send the output of the application via CoAP LTE connection. My plan is to modify the nrf-sdk CoAP Client sample to achieve this.  I am using Ubuntu 20.04 and build/program from the terminal by using west build  and west flash commands.

I am using the tinycbor from the zepyhr modules and I add it with the following line in the CMakeLists.txt:

zephyr_include_directories( $ENV{ZEPHYR_BASE}/../modules/lib/tinycbor/src)

When I build the application with (west build -b nrf9160dk_nrf9160) I don't get any error and I can (west flash) and see that it is working.

However, when I build it with (west build -b nrf9160dk_nrf9160ns) I get the error: 

fatal error: cbor.h: No such file or directory
19 | #include <cbor.h>
     |               ^~~~~~~~

This error makes me think that the tinycbor module is not included when building for the non-secure region.

I know that in order to reach the modem and start an LTE connection, I need to be able to build it for the non-secure region.

So my question is: what might be the reason that this is happening and what can I do about it?

Thanks in advance

  • I was able to include cbor.h in zephyr/sample/hello_world (NCS 1.4.2) and built it for the nRF9160 nonsecure board without any errors.

    I did the following:

    • Added CONFIG_TINYCBOR=y to zephyr\samples\hello_world\prj.conf
    • Added #include <tinycbor/cbor.h> to the top of zephyr\samples\hello_world\src\main.c
    • Built it: west build -b nrf9160dk_nrf9160ns -d build_9160dk_cbor

    Best regards,

    Simon

  • I also tried it with the hello_world sample and verified that it works.

    However, I tried the very same for ncs/nrf/samples/nrf9160/coap_client and I got the following error:

    ../src/main.c:9:10: fatal error: tinycbor/cbor.h: No such file or directory
    9 | #include <tinycbor/cbor.h>
       | ^~~~~~~~~~~~~~~~~

  • I tested the same with the coap_client and NCS v1.4.2 and did not see that error. Try to delete build folder (or use -p for pristine build) and rebuild it.

    Here is a patch of the changes I made to the coap_client:

    diff --git a/samples/nrf9160/coap_client/prj.conf b/samples/nrf9160/coap_client/prj.conf
    index 0670cb80..36869347 100644
    --- a/samples/nrf9160/coap_client/prj.conf
    +++ b/samples/nrf9160/coap_client/prj.conf
    @@ -30,3 +30,5 @@ CONFIG_COAP=y
     
     # Main thread
     CONFIG_MAIN_STACK_SIZE=4096
    +
    +CONFIG_TINYCBOR=y
    \ No newline at end of file
    diff --git a/samples/nrf9160/coap_client/src/main.c b/samples/nrf9160/coap_client/src/main.c
    index f7809275..e939ae15 100644
    --- a/samples/nrf9160/coap_client/src/main.c
    +++ b/samples/nrf9160/coap_client/src/main.c
    @@ -7,6 +7,8 @@
     #include <stdio.h>
     #include <string.h>
     
    +#include <tinycbor/cbor.h>
    +
     #include <zephyr.h>
     #include <net/coap.h>
     #include <net/socket.h>
    

    Best regards,

    Simon

  • Thank you for the answer. I was using Tinycbor with sha 31ae89e4b768612722620cb6cb173a0de4a19cc9. This time I tried it with sha 40daca97b478989884bffb5226e9ab73ca54b8c4 and it started working. 

Related