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

Problem including ble_advdata.h compiling with gcc

Hi,

I'm trying to transition my application from SDK 7.2.0 to SDK_9.0.0 and am having some issues when including ble_advdata.h compiling with gcc:

In file included from Nordic/nRF51_SDK_9.0.0_2e23562/components/softdevice/s110/headers/ble_gap.h:48:0, from Nordic/nRF51_SDK_9.0.0_2e23562/components/softdevice/s110/headers/ble.h:52, from Nordic/nRF51_SDK_9.0.0_2e23562/components/ble/common/ble_advdata.h:28, from src/old_service.cc:10: Nordic/nRF51_SDK_9.0.0_2e23562/components/softdevice/s110/headers/ble_gatts.h: In function 'uint32_t sd_ble_gatts_service_add(uint8_t, const ble_uuid_t*, uint16_t*)': Nordic/nRF51_SDK_9.0.0_2e23562/components/softdevice/s110/headers/nrf_svc.h:57:6: warning: asm operand 0 probably doesn't match constraints );
^

Nordic/nRF51_SDK_9.0.0_2e23562/components/softdevice/s110/headers/ble_gatts.h:382:1: note: in expansion of macro 'SVCALL' SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle)); ^ Nordic/nRF51_SDK_9.0.0_2e23562/components/softdevice/s110/headers/nrf_svc.h:57:6: error: impossible constraint in 'asm' );
^

And many more similar warnings to the first one, only one instance of the error though. The problem seems to be with the construction of the SVCALL macro in nrf_svc.h

Any pointers in the right direction greatly appreciated, Thanks

  • OK, yes I understood that bit - I meant whether it would still work correctly, whether there are any caveats to defining them as a normal function.

    Yesterday I managed to get everything to compile with SVCALL_AS_NORMAL_FUNCTION defined, but it would not link. Ultimately I had to fix the problem this post was originally about in nrf_svc.h (by adding the cast) to get a compiled and linked binary. So for me at least, SVCALL_AS_NORMAL_FUNCTION did not achieve what I expected.

  • This define is used in serialization. Where the nRF_Serialization API has exact same function API like softdevice API. but instead of SVC calls they are normal functions.

    In your case, All sd_xx translate to a call to SVC hence you do not see the implementation of sd_xxx calls anywhere. If you define when you define SVCALL_AS_NORMAL_FUNCTION , then the macro

    #define SVCALL(number, return_type, signature) return_type signature. Taking sd_flash_write as example
    

    SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size));

    This translate to

    SVCALL_AS_NORMAL_FUNCTION not defined

    __asm( \
        "svc %0\n" \
        "bx r14" : : "I" (number) : "r0" \
    ); \
    

    SVCALL_AS_NORMAL_FUNCTION defined

    uint32_t sd_flash_write(uint32_t * const p_dst, uint32_t const * const)

    For the former, the compiler is not looking for implementation of functions. For the later, it needs implementation of the function definition that the macro defined.

  • Thankyou for the clarification - This explains why I had problems with linking when defining SVCALL_AS_NORMAL_FUNCTION.

    In fact, the name is misleading, it is not possible to call them as normal functions because the implementation only exists for the serialisation case.

    In summary, the softdevice API functions can only be called as SVC calls, and there is no corresponding 'normal' function.

    Thanks again.

  • I think you only get the error when compiling c++, which might explain why Aryan wasn't seeing it and why TheBarrelShifter was the first to see it. The cast should be there, I just modified my SDK.

  • I have created a ticket for the SDK team to investigate this, i am not sure why the cast is needed in C++ (that is because i know C++ very little), can you enlighten me RK.

Related