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

-DNRF52 ambiguous and incompatible with -DNRF52832_XXAB

When working on adapting the bootloader for NRF52832_XXAB I noticed that -DNRF52 seems to define NRF52832_XXAA and later defining -DNRF52832_XXAB does not override it. I suppose -DNRF52 should be removed alltogether and the more specific -DNRF52832_XXAA or -DNRF52832_XXAB be used.

Parents
  • Hello,

    Thank you for your feedback.

    The only reference I can find to NRF52 is in nrf.h on line 51 (at least in SDK15.3.0). What SDK version do you use?

    I agree that it isn't too intuitive to check here, and I'll report this to our SDK team.

    As the description says:

    /* Redefine "old" too-generic name NRF52 to NRF52832_XXAA to keep backwards compatibility. */

    So it was introduced to ease the porting from older SDKs.

    You can remove these lines, or alternatively change it to use the XXAB, if that is what you are using.

    Best regards,

    Edvin

  • Exactly, that is precisely the problem.

    Let's say I define NRF52 and NRF52840_XXAA. This shouldn't be a problem because the NRF52840 is an NRF52.

    This code will define NRF52832_XXAA:

    #if defined (NRF52)
        #ifndef NRF52832_XXAA
            #define NRF52832_XXAA
        #endif
    #endif

    Then this code will include NRF52832 files instead of NRF52840 ones, because the NRF52832 #elif is processed:

    /* Device selection for device includes. */
    #if defined (NRF51)
        #include "nrf51.h"
        #include "nrf51_bitfields.h"
        #include "nrf51_deprecated.h"
    
    #elif defined (NRF52810_XXAA)
        #include "nrf52810.h"
        #include "nrf52810_bitfields.h"
        #include "nrf51_to_nrf52810.h"
        #include "nrf52_to_nrf52810.h"
    #elif defined (NRF52832_XXAA) || defined (NRF52832_XXAB)
        #include "nrf52.h"
        #include "nrf52_bitfields.h"
        #include "nrf51_to_nrf52.h"
        #include "nrf52_name_change.h"
    #elif defined (NRF52840_XXAA)
        #include "nrf52840.h"
        #include "nrf52840_bitfields.h"
        #include "nrf51_to_nrf52840.h"
        #include "nrf52_to_nrf52840.h"

    As I said, this once caused me to lose days debugging - I'm sure it will happen to someone else in the future if this issue is not addressed.

  • This happened to me when I was porting a project from an NRF52832 to an NRF52840. When I was changing the preprocessor definitions I just changed -DNRF52832_XXAA to -DNRF52840_XXAA and I left -DNRF52 there as I thought it was necessary for something.

    I can see this happening to other people, as I believe porting a project from the 832 to the 840 isn't such a rare case. I hope you can see how this is a problem.

  • absolutely. As mentioned, I have reported this. The fix, however, is to remove the DNRF52 define all together, and use the NRF52XXX_XXXX define that suits your project.

    Best regards,

    Edvin

  • Sure, the fix is easy, but very hard to troubleshoot if it happens. I don't know about SDK15.3 since I'm still in 15.2, but in 15.2 -DNRF52 is defined along -DNRF52832_XXAA in a lot of example projects.

    I think the redefinition doesn't do as much damage as including the "old" NRF52 definition in newer example projects.

Reply Children
No Data
Related