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

Parents
  • Fixed,

    It was missing a cast to uint16_t in the following line:

    "bx r14" : : "I" ((uint16_t)number) : "r0" \

    The cast was present in the 7.2.0 SDK, I replaced it, and it now compiles.

    Perhaps Windows gcc 4.9 is a bit less picky

  • 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.

Reply
  • 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.

Children
No Data
Related