This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Merging two or more examples

Hello

I am getting started on nRF SDK and I went through all the examples (at least those I'm interested about) successfully. 

Now, I need to merge couple of examples together. For simplicity let's say I'm merging an uart example into the twi_scanner one.

What I did, was

  • to compare "Options" of two projects, and added missing include paths. For this example, I added /libraries/uart and /libraries/uart paths into the twi example
  • Added required #includes, in my case these were #include "app_uart.h" and #include "nrf_uart.h"
  • I've checked sdk_config.h and found that UART was enabled.

And it wasn't enough. For some reason linker fails, and complains it cant find references to any app_uart functions. Funny, since "Go to definitions" finds the file easily. 

So what am I missing? What else should be done?

P.S. I have already searched for help in the DevZone, and found useful threads like this one, but all the links in it are outdated and not working anymore. 

  • Hello,

    I've checked sdk_config.h and found that UART was enabled.

    I suspect that this is an artifact of the apply_old_config.h file. Are you using the NRFX drivers in your project?
    If so, you need to make sure that no legacy peripheral definitions are defined in your sdk_config.h, as this will cause the apply_old_config to overwrite your nrfx configuration.

    As an example, in the UART case you must make sure that UART_ENABLED is not defined (it is not enough to define it to 0, it must be undefined) so that your NRFX_UART_* configurations are not overwritten.

    Are you using the app uart library, or the nrfx driver directly?

    Best regards,
    Karl

  • Are you using the app uart library, or the nrfx driver directly?

    well uart example has the #include "app_uart.h" so I guess im using the app library.

    As an example, in the UART case you must make sure that UART_ENABLED is not defined (it is not enough to define it to 0, it must be undefined) so that your NRFX_UART_* configurations are not overwritten.

    Unfortunately, it doesn't work this way. Commenting out the statement  #define UART_ENABLED 1, makes even more errors to pop up.

    Additionally, in the perihperal/uart example, the UART_ENABLED is defined, and I want to use it that way. Why is this more complicated than it needs to be?

    The errors I'm facing are with the linker: 

    Building ‘MERS_twi_scanner’ from solution ‘MERS_twi_scanner’ in configuration ‘Debug’
    Linking MERS_twi_scanner.elf
    Output/Debug/Obj/MERS_twi_scanner/main.o: in function `main':
    undefined reference to `app_uart_init'
    D:\Nordic\nRF5_SDK_17.1.0\examples\MERS\MERS_twi_scanner/main.c:185: undefined reference to `app_uart_get'
    D:\Nordic\nRF5_SDK_17.1.0\examples\MERS\MERS_twi_scanner/main.c:186: undefined reference to `app_uart_put'
    Build failed

    So I assume that it is the project settings that needs to be fixed so that linker sees those missing function symbols. How do I set those?

  • Oh, and btw the thing I noticed is even though I have included app_uart library into my include path:

    I still dont see uart lib app_uart.c/.h files in the project explorer:

    So, I cant help but think this is some kind of project settings issue, rather than the sdk_config.h issue.

  • Could you share with me your sdk_config.h file?
    I still suspect that this is an sdk_config issue, since the editor is able to find the file - meaning the paths are correct - but not the linker.
    Do you have APP_UART_ENABLED defined to 1 in your sdk_config?

    Best regards,
    Karl

  • Do you have APP_UART_ENABLED defined to 1 in your sdk_config?

    yes, sir!

    Could you share with me your sdk_config.h file?

    Of course, be my guest:

     24036.sdk_config.h

    I still suspect that this is an sdk_config issue, since the editor is able to find the file

    What do you mean by this? I made the last post to show specifically that editor did not, in fact, find the files.

Related