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

GATTS table size - inconsistant RAM start

Hello,

I am developing a profile which includes 39 characteristics spread over 4 services on nRF52840/SD140/SDK13. When I add one too many, sd_ble_gatts_characteristic_add() returns NRF_ERROR_NO_MEM. Reading upon this issue led me to believe that I could simply tweak the GATTS table size until all my data fits in.

By default, I don't specify the table size and my RAM starts at 0x20002128. If I then specify the size to be BLE_GATTS_ATTR_TAB_SIZE_DEFAULT (1408), I am advised by a NRF_LOG warning to start at 0x20002888. Doubling that size (2816), I am advised to start at 0x20002088 which is much lower. Increasing then to 3000, I am advised to start at 0x20002c08. 5000 will advice me to start at 0x20002908 which weirdly is lower again.

In any case, the same error always occurs on the same characteristic (except on the case of the much reduced start size when it fails much earlier), and I am unable to allocate enough space for my profile data.

Increasing vs_uuid_count from BLE_UUID_VS_COUNT_DEFAULT to BLE_UUID_VS_COUNT_MAX does not change the behaviour, except in the case where the table size is unspecified where I am advised to start at 0x20003068 instead.

Is this behaviour expected? How can I configure the SoftDevice to be able to include all my characteristics?

Thank you in advance.

  • Sounds strange. Could you tell me how to reproduce this? I did a quick test with one of the examples from the SDK, and if I increase the attribute table size it seems to increase the RAM start as well.

  • My bad. I converted some old code from back when it was a "struct ble_enable_params_t" and added the vs_uuid_count configuration in the same block of code. Since ble_cfg_t is a union of the values, I was actually configuring only one of them with a mess made from both values.

    Doing the correct thing by calling sd_ble_cfg_set() separately fixed the problem. Here is what the configuration procedure should look like if someone stumbles upon here with the same issue:

    // Configure the number of custom UUIDs.
    memset(&ble_cfg, 0, sizeof(ble_cfg));
    ble_cfg.common_cfg.vs_uuid_cfg.vs_uuid_count = BLE_UUID_VS_COUNT_DEFAULT;
    err_code = sd_ble_cfg_set(BLE_COMMON_CFG_VS_UUID, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);
    
    // Change GATTS table size
    memset(&ble_cfg, 0, sizeof(ble_cfg));
    ble_cfg.gatts_cfg.attr_tab_size.attr_tab_size = BLE_GATTS_TABLE_SIZE;
    err_code = sd_ble_cfg_set(BLE_GATTS_CFG_ATTR_TAB_SIZE, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);
    
Related