Adding nRF library (app_timer.c) to already existing project. (undefined reference error)

Hi,

I had an idea for a hobby project and that's how i got into the whole MCU world. Please keep in mind, that i am fairly new.

I bought an evaluation/development board for a UWB sensor (https://www.qorvo.com/products/p/DWM1001-DEV#overview), that has a nRF52832 at it's core.
I am using Segger Embedded Studio 4.12 (SES), with which I got the examples to work on the board (with some minor difficulties).
(Examples if relevant: https://github.com/Decawave/dwm1001-examples/tree/master/examples, ss_twr_init is the one I am having trouble with)

Now I want to change some minor stuff in the example. I want to print out a timestamp. In arduino IDE there is the millis() function, so I googled if there is some sort of easy equivalent, but it seems not. I got to this post:  Milliseconds since startup?  and read and googled a bit more and ended up on this guide: nRF5 SDK Application Timer Tutorial . 
In the section "Add required files and includes" there isn't much explanation on how to add the app_timer.c to the project. In SES I just right clicked on the nRF_libraries folder in the ss_twr_init example project and clicked "add existing file", and chose the app_timer.c from the nRF SDK 17.1 zip-file I downloaded. Sadly I am still getting the same errors from before I added the app_timer.c to the project, namely "undefined reference to 'app_timer_init'" and "app_timer_cnt_get".

Was this whole "copy from nRF SDK, paste into project"-procedure the right way? Is the error unrelated to the existence of the app_timer.c file in the project?

Thank you!

  • Hi 

    It seems like you are trying to run an example written for the nRF5 SDK in the nRF Connect SDK (NCS)?

    This will surely fail in some way or the other. 

    The app_timer library for instance is designed for the nRF5 SDK, and will not work in NCS. 

    tiko said:
    I will probably have to read up a bit in the Nordic Devacademy you linked how this devicetree thing works.

    I think this is a good place to start, yes. You want to make sure that the project you try to build in NCS doesn't have any code designed for the nRF5 SDK. 

    If you still can't make sense of it after going through the DevAcademy feel free to zip and share your project with me, and I will do my best to point out any problems with it. 

    Best regards
    Torbjørn

  • Hi

    So i just created a post on the qorvo forum here. I might try my luck with the qorvo support if I don't get an (official) answer there.

    Back to my problem:
    The example I am using right now is the one you linked from the qorvo forum post here. The repo is zephyr based so I guess they are not written for the nRF5 SDK, but also not for NCS, because the examples use Zephyr 2.0 and NCS is based on Zephyr 3.X (?)

    I read through some lessons in the Nordic Devacademy (relevant topics: devicetree, devicetree bindings), and the problem is, as far as I understand caused by the devicetree bindings yaml file being not in a dts/bindings/... folder, and also just the whole devicetree thing being for the older Zephyr 2.X version...
    For reference the yaml file for the dwm1001 Zephyr 2.X project you linked here and one from the same developer for the dwm3000 which runs on Zephyr 3.X here

    In case my qorvo post doesn't get an answer, how would I go on about this and port the Zephyr 2.X project to Zephyr 3.X? Will I have enough knowledge if I go through every Nordic Devacademy lesson and understand some blinky/bluetooth/...  examples for the nRF52832? Is this a fairly big task or once I know what I am doing is it manageable?

    Also big thanks again for all your help so far!

    Best regards
    Timo

  • Hi Timo

    Different NCS versions will use different Zephyr versions. If you open the documentation here you can find the relation between the NCS version and the Zephyr version by selecting the NCS version you are interested in top right and seeing which Zephyr version it includes, as shown here:

    It seems I have to go back to NCS v1.8.0 to find one that uses Zephyr v2.7.0, which is a pretty old version. 

    Possibly the code will build in newer versions of NCS/Zephyr as well, but this hasn't been tested any you might run into build or runtime errors. 

    tiko said:
    In case my qorvo post doesn't get an answer, how would I go on about this and port the Zephyr 2.X project to Zephyr 3.X? Will I have enough knowledge if I go through every Nordic Devacademy lesson and understand some blinky/bluetooth/...  examples for the nRF52832? Is this a fairly big task or once I know what I am doing is it manageable?

    This is a bit hard to answer, but I expect it will be a complicated task even if you go through all the DevAcademy lessons. My recommendation would be to start by getting it to run in a supported version, and then try to update it one major SDK version at a time. Trying to jump multiple major versions at the same time can be very challenging, since there might be a large number of changes to handle at one time. 

    Best regards
    Torbjørn

1 2