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

Trouble updating vendor specific UUID count on BLE stack init

Hi --

I am using the ble_peripheral/ble_app_hrs example project. And if I try to update the vs_uuid_count param to 2. It proceeds to fail the softdevice_enable with error code: NRF_ERROR_NO_MEM. Any suggestions on what needs to change?

Using softdevice v3, and 10040/s132 with nrf52832 and SDK 12.2.

static void ble_stack_init(void)
{
uint32_t err_code;

nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

// Initialize the SoftDevice handler module.
SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

ble_enable_params_t ble_enable_params;
err_code = softdevice_enable_get_default_config(NRF_BLE_CENTRAL_LINK_COUNT,
                                                NRF_BLE_PERIPHERAL_LINK_COUNT,
                                                &ble_enable_params);
APP_ERROR_CHECK(err_code);

// setting vs_uuid_count to 2
ble_enable_params.common_enable_params.vs_uuid_count = 2;

// Check the ram settings against the used number of links
CHECK_RAM_START_ADDR(NRF_BLE_CENTRAL_LINK_COUNT, NRF_BLE_PERIPHERAL_LINK_COUNT);

// Enable BLE stack.
ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;

err_code = softdevice_enable(&ble_enable_params);
APP_ERROR_CHECK(err_code);

// Register with the SoftDevice handler module for BLE events.
err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
APP_ERROR_CHECK(err_code);

// Register with the SoftDevice handler module for BLE events.
err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
APP_ERROR_CHECK(err_code);
}
Parents
  • Ahoj Karle,

    Number of custom UUIDs has impact on ATT table size which is allocated by SoftDevice during init. So any change to this (as well as number or bandwidth of connections you want to use later in the runtime etc.) must be reflected in SD RAM size typically specified in LD file (applies to GCC, there is similar setting for linker in other toolchains) otherwise you get this kind of runtime error during SD init. Now unfortunately there are too many parameters that Nordic don't provide any "magic" formula how to get this before compile time but luckily SD will tell you during init exactly how much space it needs. Use this (or similar) code, run your project once with UART debug (or Tracing) enabled and you will get your value. After using it for linking all should be fine. (Note that __data_start__ is available in GCC, other toolchains have similar variables but with different name - refer to sd_check_ram_start(...) function in SDK\components\softdevice\common\softdevice_handler\softdevice_handler.c file for more details.)

    extern uint8_t __data_start__;    
    
    //...
    
        app_ram_base = (uint32_t) &__data_start__;
        err_code = sd_ble_enable(&ble_enable_params, &app_ram_base);
        // Check if we do memory allocation correctly.
        if (err_code == NRF_SUCCESS) {
            // Verify that value provided in linked script (LD file) matches
            // the SD calculations.
            if (app_ram_base == (uint32_t) &__data_start__) {
                LOG_INFO("Soft Device enabled, __data_start__ is set correctly.");
            }
            else {
                LOG_INFO("Soft Device enabled, __data_start__ is set incorrectly (should be = 0x%08X instead of 0x%08X).", app_ram_base, (uint32_t) &__data_start__);
                APP_ERROR_CHECK(NRF_ERROR_FORBIDDEN);
            }
        }
        else if (err_code == NRF_ERROR_NO_MEM) {
            // Not enough memory for the Soft Device (value provided is too low).
            LOG_INFO("Soft Device failed to enabled, __data_start__ is set incorrectly (should be = 0x%08X instead of 0x%08X).", app_ram_base, (uint32_t) &__data_start__);
        }
        APP_ERROR_CHECK(err_code);
    
    //...
    
  • Yes, BLE stack init and API is the same for S130 V2 and S132 V2.

Reply Children
No Data
Related