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

sdk_config confusion

I was trying to create my own sdk_config based on "$NRF_SDK/config/nrf52840/config/sdk_config.h".

I noticed it contains both the "NRFX" config and "Legacy" configs.

For example, both NRFX_RTC_ENABLED and RTC_ENABLED.

I thought that NRFX_RTC_ENABLED shall have precedence over the "legacy" one so I only defined the NRFX ones.

To my surprise the compiled .o file is empty. Then I traced to "nrfx_glue.h" and "apply_old_config.h". I noticed the legacy settings wil override the NRFX settings.

Why do you put to settings in the same file?

For example:

#if defined(RTC_ENABLED)



#undef NRFX_RTC_ENABLED

#define NRFX_RTC_ENABLED  RTC_ENABLED



#if defined(RTC0_ENABLED)

#undef NRFX_RTC0_ENABLED

#define NRFX_RTC0_ENABLED  RTC0_ENABLED

#endif

#if defined(RTC1_ENABLED)

#undef NRFX_RTC1_ENABLED

#define NRFX_RTC1_ENABLED  RTC1_ENABLED

#endif

#if defined(RTC2_ENABLED)

#undef NRFX_RTC2_ENABLED

#define NRFX_RTC2_ENABLED  RTC2_ENABLED

#endif

  • Hello,

    I noticed it contains both the "NRFX" config and "Legacy" configs.

    For example, both NRFX_RTC_ENABLED and RTC_ENABLED.

    I thought that NRFX_RTC_ENABLED shall have precedence over the "legacy" one so I only defined the NRFX ones.

    As you have already discovered, this is not correct. The apply_old_config file will replace your NRFX_ configuration with the legacy configuration if the legacy definitions are defined.
    You should therefore remove the legacy definitions all together from your sdk_config, to avoid this being an issue.

    Why do you put to settings in the same file?

    This is a good questions, with a not-so-good answer unfortunately - the reason for the apply_old_config at introduction was to provide backwards compatibility for the legacy drivers when the nrfx drivers were introduced years ago. While this might have been a suitable addition at the time, it has since been known to cause quite some confusion now that the legacy drivers are macro-forwarded to the nrfx_ implementations behind the scenes anyways.
    Apologies for any confusion or inconvenienc this might have caused.

    Best regards,
    Karl

  • Thanks Karl, I suspected that it was the case.

    But from the conversations on this forum, I think the sdk_config.h is the standard template provided by NRF and it is encouraged that developers use it for customization.

    I would suggest you provide a standard version of template file without the legacy stuff, otherwise developers will be forced to keep using the legacy settings because it only makes sense. And it defeats the purpose.

Related