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

Trying to add uart functionality to the dimming example

Currently I am trying to add uart functionality to the dimming client from the mesh dimming example, but I just can never seem to get it to compile. I can confirm my uart code works and compiled as I have used it in the nrf5sdk and compiles fine there. I put the code from my project in the nrf5sdk into the files uarte_link.h and uarte_link.c and add it to the dimming client in the nrf5sdk for mesh example and suddenly I just cannot get it to compile no matter what I try

Here are the exact steps that I have done:

1. Added my own file uarte_link.c file to the project

2. Then I tried compiling and get "app_uart.h not found error". To solve this I added the folder that contains this file in my user include directories

3. Tried compiling again, this time i get errors: "undefined reference to app_uart_init" and "undefined reference to "app_uart_get"

4. I realized i needed to add the corresponding source files, so I added the following to my project: "app_fifo.c, app_uart.c, app_uart_fifo.c, nrf_drv_uart.c, nrfx_uarte.c, retarget.c"

5. Compiling after this gives me these errors in nrf_drv_uart.h:

error: unknown type name ‘nrf_uarte_baudrate_t’
error: unknown type name ‘nrf_uarte_error_mask_t’
error: unknown type name ‘nrf_uarte_hwfc_t’
error: unknown type name ‘nrf_uarte_parity_t’
error: unknown type name ‘nrf_uarte_task_t’
error: unknown type name ‘nrf_uarte_event_t’

6. I figured the problem might be in my sdk_config.h file. I set NRFX_UART_ENABLED and NRFX_UARTE_ENABLED. I also add APP_FIFO_ENABLED and APP_UART_ENABLED and set them to 1 in app_config.h since I noticed those settings were set in my original uart code from the other SDK but were not defined in the sdk_config.h. I try compiling again, and I get the same error as above

7. Then at this point I try a bunch of other random stuff including anything I would think would be dependent and screwing around with a lot of settings in general, but to no luck. This is when I got extremely frustrated with the sdk after spending hours on this

I hope someone can help, since I have grown too frustrated at hunting through the SDK to find the files I need. This has overall given me a negative opinion Nordic's SDK organization which is a shame since I found actual programming itself to be relatively straightforward

Parents Reply Children
  • Sorry for the late reply. I am using the the nRF5 SDK 17.0.2 and the nRF5 SDK for Mesh V5.0.0 (I believe those are the latest versions). I have set up my environment as described in the docs (so both the 17.0.2 and Mesh SDK are in the same root folder). I use segger embedded studio to write and build applications.

    The link you sent is exactly how i add my files - manually add the source files and adding the necessary include paths in common->preprocessors->user include directories

    I guess to clarify my problem - basically in this case I am having trouble identifying all the dependencies required for uart from the 17.0.2 nRF5 SDK to add to the current Mesh example, and have tried all the above steps as described in my initial post.

  • UPDATE: Great news, I have managed to successfully build my project. It seems like there was a lot of hoops to jump through in terms of including and adding the necessary source and header files to the project, and I missed a few.

    In my particular case, here is what I did to add my uart code into the dimming client example (although this most likely is applicable to all mesh examples with the same or very similar steps) for others that may take a look at this thread:

    ADD these include paths to the include search paths (in project options->common->preprocessor->user include directories:

    (your nrf5SDK folder)/components/libraries/uart

    (your nrf5SDK folder)/integration/nrfx/legacy

    (your nrf5SDK folder)/components/libraries/fifo

    ADD these source files to the project:

    app_fifo.c

    app_uart_fifo.c

    nrf_drv_uart.c

    nrfx_atomic.c

    nrfx_prs.c

    nrfx_uart.c

    nrfx_uarte.c

    retarget.c

    ADD these directives to either app_config.h or sdk_config.h

    #ifndef APP_FIFO_ENABLED
    #define APP_FIFO_ENABLED 1
    #endif

    #ifndef APP_UART_ENABLED
    #define APP_UART_ENABLED 1
    #endif

    #ifndef APP_UART_DRIVER_INSTANCE
    #define APP_UART_DRIVER_INSTANCE 0
    #endif

    #ifndef NRFX_PRS_ENABLED
    #define NRFX_PRS_ENABLED 1
    #endif

    #ifndef NRFX_PRS_BOX_4_ENABLED
    #define NRFX_PRS_BOX_4_ENABLED 1
    #endif

    Finally, make sure UART_ENABLED is set to 1 and UART0_ENABLED is set to 1. If using easyDMA make sure those are set accordingly as well

    I havent tested my example yet so I am not sure if the uart works properly in practice, but I have already solved my issues with compiling/building so the problem is resolved

Related