Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_drv_clock module - undefined reference error

In nRF5_SDK_15.3.0 some undefined reference error reported when using nrf_drv_clock module (example: undefined reference to `nrf_drv_clock_hfclk_release)

The problem is in SDK_ROOT\integration\nrfx\legacy\nrf_drv_clock.c. Instead of nordic_common.h, sdk_common.h should be included

existing:

#include <nordic_common.h>
#include "nrf_drv_clock.h"

#if NRF_MODULE_ENABLED(NRF_CLOCK)

fixed:

#include "sdk_common.h"
#if NRF_MODULE_ENABLED(NRF_CLOCK)
#include "nrf_drv_clock.h"

Parents
  • Hello,

    The reason that the nrf_drv_clock_hfclk_release is not defined is either because you didn't include the nrf_drv_clock.c or that you haven't enabled it (defined NRF_CLOCK_ENABLED somewhere, typically in the sdk_config.h file). 

    Do you know what place the define is included when you use sdk_common.h instead of the nordic_common.h?

Reply
  • Hello,

    The reason that the nrf_drv_clock_hfclk_release is not defined is either because you didn't include the nrf_drv_clock.c or that you haven't enabled it (defined NRF_CLOCK_ENABLED somewhere, typically in the sdk_config.h file). 

    Do you know what place the define is included when you use sdk_common.h instead of the nordic_common.h?

Children
  • You probably mean nrf_drv_clock.h instead of nrf_drv_clock.c?

    I have definitely enabled NRF_CLOCK_ENABLED in sdk_config.h.

    I think that there is a bug in nrf_drv_clock.c file because you can see that in sdk_common.h the "sdk_config.h" and also "nordic_common.h" headers are included.

    Because of that the content of the nrf_drv_clock.c is not included in compilation and you get the undefined reference error.

    If you look at other legacy drivers you can see that before #if NRF_MODULE_ENABLED always the "sdk_common.h" is included which then indirectly includes also sdk_config.h and app_config.h.

  • Hello,

    I meant nrf_drv_clock.c. If you are missing the .h file, it will say that the function is undeclared, but if you miss the .c file (or if it is not included because of an #if that isn't true) then you get the message from the compiler saying "undefined reference to `nrf_drv_clock_hfclk_release´ " that you got.

    The reason I thought it wasn't a but is that most of our examples use this file, and they work, so the sdk_config.h must be included somewhere. Do you get any other compiler errors before the undefined reference to `nrf_drv_clock_hfclk_release?

    From nrf_drv_clock.c I can read this include path:

    nrf_drv_clock.c ->  #include "nrf_drv_clock.h" -> #include <nrfx_clock.h> -> #include <nrfx.h> -> #include <nrfx_config.h> -> #include <sdk_config.h>

    One possible reason that you see the behavior that you see is that the #include <nrfx_glue.h> is included in nrfx.h, which includes apply_old_config.h. If you have both NRFX_CLOCK_ENABLED and NRF_CLOCK_ENABLED defined in sdk_config.h, it will use the NRF_CLOCK_... defines. So maybe you have both defined, and they are not defined as the same?

  • if I compare include paths for nrf_drv_clock.c I see that all includes are like you said until <nrfx_config.h> -> #include <sdk_config.h>. There is no #include <sdk_config.h> in nrfx_config.h file.

  • This is the nrfx_config.h from a fresh unzip of the SDK15.3.0:

    nrfx_config.h

    Maybe you edited it at one point. If you replace the nrfx_config.h file with this one, it should work. If you suspect that you changed some other files, it may be a good idea to copy your projects into a newly unzipped version of the SDK.

    Best regards,

    Edvin

  • from where did you took nrfx_config.h file from? I took it from SDK->modules->nrfx->templates->nRF52840 and placed it to config folder inside target.

    I am using SDK version 15.3.0.

Related