Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

#if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT

Hello,

I am not using the latest SDK, but it seems this has not changed (to be checked…). In file ./components/libraries/util/app_error_weak.c I have this sort of code: 

#if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT

   some code specific to case with SoftDevice

#endif

In the rest of the SDK, this is just like this: 

#ifdef SOFTDEVICE_PRESENT

   some code specific to case with SoftDevice

#endif

OK, when you pass SOFTDEVICE_PRESENT from the command line like this:

arm-none-eabi-gcc -DSOFTDEVICE_PRESENT ...

this does not make a difference, because actually this will be equivalent to:

#define SOFTDEVICE_PRESENT 1

but if ever you would make the setting in the sdk_config.h file like this:

#define SOFTDEVICE_PRESENT /* empty */

then there would be some compilation error « error: operator '&&' has no right operand »

So, my question is the following : is there some trick ? Do you want to force SOFTDEVICE_PRESENT to be defined, if ever, always as 1 ? And is there some use to do -DSOFTDEVICE_PRESENT=0, so to unselect only the app_error_weak.c stuff, but not the others.

  • Hi,

    When setting configurations in sdk_config.h you should do so by setting the config to 1, i.e:

    #define SOFTDEVICE_PRESENT 1

    If your application is using the SoftDevice, then you should make sure that this is always enabled. You can do this by enabling it in sdk_config.h, but you can also set in your Makefile:

    CFLAGS += -DSOFTDEVICE_PRESENT
    ASMFLAGS += -DSOFTDEVICE_PRESENT

    Or add SOFTDEVICE_PRESENT to preprocessor definitions in SES if you are using that to build. Setting it in the Makefile or preprocessor definitions is how it is done by default in the examples.

    And is there some use to do -DSOFTDEVICE_PRESENT=0, so to unselect only the app_error_weak.c stuff, but not the others.

    No, if you are using SoftDevice then it should be set to 1. If you want to change how application errors are handled you should instead overwrite app_error_fault_handler and create a custom handler, as the function is weak.

    Best regards,

    Marte

  • Dear Marte,

    Thank you for your kind answer.

    I understand that by following your instructions there won't be any problems. However, I would like to suggest you that in the next version of the SDK you replace the #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT in components/libraries/util/app_error_weak.c by just #ifdef SOFTDEVICE_PRESENT for the sake of consistency with the rest of the code and for not having people wonder, as I did, whether there is anything special in app_error_weak.c.

  • Dear Marte,

    Replying to myself : while I am at it with making suggestions about app_error_weak.c, instead of using formatter %u for p_info->err_code, it would be preferable to use 0x%08x, this would make easier to decode manually the meaning of an error code.

  • Hi,

    Thank you for the inputs. The nRF5 SDK is in maintenance mode, so the only updates it will receive will be for bug fixes and security updates as needed.

    Best regards,

    Marte

Related