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

sd_ble_enable return error 18

Hi

I use SDK version 12.2.0 to do a project. I add two 128bit uuid into my project. The one of 128bit uuid is created by myself. The other one of 128bit uuid is used ancs by SDK 12.2.0. I have a problem to get information that error code (0x18) when I call sd_ble_enable.

I tried some test for this condition. I removed ancs service(only use my created service). I set parameter as below and it works.

memset(p_ble_enable_params, 0, sizeof(ble_enable_params_t));
p_ble_enable_params->common_enable_params.vs_uuid_count   = 1;
p_ble_enable_params->gatts_enable_params.attr_tab_size    = SOFTDEVICE_GATTS_ATTR_TAB_SIZE;
p_ble_enable_params->gatts_enable_params.service_changed  = SOFTDEVICE_GATTS_SRV_CHANGED;
p_ble_enable_params->gap_enable_params.periph_conn_count  = 1;
p_ble_enable_params->gap_enable_params.central_conn_count = 0;

On the other hand, I tried to remove a service that create by myself(only use ancs service). I use parameter as below, it also works.

memset(p_ble_enable_params, 0, sizeof(ble_enable_params_t));
p_ble_enable_params->common_enable_params.vs_uuid_count   = 10;
p_ble_enable_params->gatts_enable_params.attr_tab_size    = SOFTDEVICE_GATTS_ATTR_TAB_SIZE;
p_ble_enable_params->gatts_enable_params.service_changed  = SOFTDEVICE_GATTS_SRV_CHANGED;
p_ble_enable_params->gap_enable_params.periph_conn_count  = 1;
p_ble_enable_params->gap_enable_params.central_conn_count = 0;

I merged both of service into a project. I used parameter as below. It has failure of sd_ble_enable err_code (0x12).

memset(p_ble_enable_params, 0, sizeof(ble_enable_params_t));
p_ble_enable_params->common_enable_params.vs_uuid_count   = 11;
p_ble_enable_params->gatts_enable_params.attr_tab_size    = SOFTDEVICE_GATTS_ATTR_TAB_SIZE;
p_ble_enable_params->gatts_enable_params.service_changed  = SOFTDEVICE_GATTS_SRV_CHANGED;
p_ble_enable_params->gap_enable_params.periph_conn_count  = 2;
p_ble_enable_params->gap_enable_params.central_conn_count = 0;

I have no idea. Could you help me to solve this problem? Or tell me what I can do. Thanks.

This is my log for three conditions.

Only add BLE_ANCS_C LOG:

[APP_BUTTON]:INFO:app_button_enable ++++
[APP_BUTTON]:INFO:pin_no = 17
[APP_BUTTON]:INFO:pin_no = 18
[APP_BUTTON]:INFO:pin_no = 19
[APP_BUTTON]:INFO:pin_no = 20
CLOCK:INFO:Function: nrf_drv_clock_init, error code: NRF_SUCCESS.
SDH:INFO:[JOHNLIN][softdevice_enable]: vs_uuid_count = 1, service_changed = 0, periph_conn_count = 1, central_links_count = 0
APP:INFO:[ble_stack_init]: vs_uuid_count = 10, service_changed = 0, periph_conn_count = 1, central_links_count = 0
SDH:INFO:[softdevice_enable]: RAM start at 0x20002078
SDH:INFO:[softdevice_enable]: err_code = 0
SDH:INFO:[softdevice_enable]: vs_uuid_count = 10, service_changed = 0, periph_conn_count = 1, central_links_count = 0
APP:INFO:[softdevice_ble_evt_handler_set]: err_code = 0
APP:INFO:[softdevice_sys_evt_handler_set]: err_code = 0
UFIT_SERVICE:INFO:[db_discovery_init] err_code = 0
UFIT_SERVICE:INFO:[ancs_init] err_code = 0
APP:INFO:BLE ANCS Started
UFIT_SERVICE:INFO:Connected.
UFIT_SERVICE:INFO:Disconnected.

Only BLE_UFIT SERVICE LOG:

[APP_BUTTON]:INFO:app_button_enable ++++
[APP_BUTTON]:INFO:pin_no = 17
[APP_BUTTON]:INFO:pin_no = 18
[APP_BUTTON]:INFO:pin_no = 19
[APP_BUTTON]:INFO:pin_no = 20
CLOCK:INFO:Function: nrf_drv_clock_init, error code: NRF_SUCCESS.
SDH:INFO:[softdevice_enable]: vs_uuid_count = 1, service_changed = 0, periph_conn_count = 1, central_links_count = 0
APP:INFO:[ble_stack_init]: vs_uuid_count = 1, service_changed = 0, periph_conn_count = 1, central_links_count = 0
SDH:INFO:[softdevice_enable]: RAM start at 0x20002078
SDH:INFO:[softdevice_enable]: err_code = 0
SDH:INFO:[softdevice_enable]: vs_uuid_count = 1, service_changed = 0, periph_conn_count = 1, central_links_count = 0
SDH:WARNING:sd_ble_enable: RAM start should be adjusted to 0x20001fe8
SDH:WARNING:RAM size should be adjusted to 0x6018
APP:INFO:[softdevice_ble_evt_handler_set]: err_code = 0
APP:INFO:[softdevice_sys_evt_handler_set]: err_code = 0
UFIT_SERVICE:INFO:[db_discovery_init] err_code = 0
UFIT_SERVICE:INFO:[ufit_init] err_code = 0
APP:INFO:BLE ANCS Started

Both of UUID 128bit services LOG:

[APP_BUTTON]:INFO:app_button_enable ++++
[APP_BUTTON]:INFO:pin_no = 17
[APP_BUTTON]:INFO:pin_no = 18
[APP_BUTTON]:INFO:pin_no = 19
[APP_BUTTON]:INFO:pin_no = 20
CLOCK:INFO:Function: nrf_drv_clock_init, error code: NRF_SUCCESS.
SDH:INFO:[softdevice_enable]: vs_uuid_count = 1, service_changed = 0, periph_conn_count = 2, central_links_count = 0
APP:INFO:[ble_stack_init]: vs_uuid_count = 11, service_changed = 0, periph_conn_count = 2, central_links_count = 0
SDH:INFO:[softdevice_enable]: RAM start at 0x20002078
SDH:INFO:[softdevice_enable]: err_code = 18
SDH:INFO:[softdevice_enable]: vs_uuid_count = 11, service_changed = 0, periph_conn_count = 2, central_links_count = 0
SDH:ERROR:sd_ble_enable: error 0x12
APP_ERROR:ERROR:Fatal
Parents
  • Look into header files describing sd_ble_enable function and you will learn that error 0x00000012 (= 18 in decimal, note that error codes are 32-bit and they can code different error classes in higher bytes so better to expand them at least to 16 bits!) means NRF_ERROR_CONN_COUNT. Also this seems strange because even you don't say which SD family and version you are using it seems impossible that it wouldn't handle 1 peripheral connection count. Are you sure with the error type? Isn't it usual problem with RAM memory region size (you are demanding (G)ATT stack with lot of custom UUIDs, this will require some adjustments. In general suggested exercise is to take 100% working example from nRF5 SDK, recompile it, change single parameter, recompile again, run in debug (UART or RTT) on dev kit or other trusted HW and see what is happening according to debug trace during SD init. It typically complains about RAM size so you will need to change it in LD script (or other project settings if you don't use GCC - this is linker specific and IAR or Keil are using their own), recompile it and test again. With this debug loop you can find some stable configuration and use it in other projects (where you e.g. start from scratch or from some different example/template).

Reply
  • Look into header files describing sd_ble_enable function and you will learn that error 0x00000012 (= 18 in decimal, note that error codes are 32-bit and they can code different error classes in higher bytes so better to expand them at least to 16 bits!) means NRF_ERROR_CONN_COUNT. Also this seems strange because even you don't say which SD family and version you are using it seems impossible that it wouldn't handle 1 peripheral connection count. Are you sure with the error type? Isn't it usual problem with RAM memory region size (you are demanding (G)ATT stack with lot of custom UUIDs, this will require some adjustments. In general suggested exercise is to take 100% working example from nRF5 SDK, recompile it, change single parameter, recompile again, run in debug (UART or RTT) on dev kit or other trusted HW and see what is happening according to debug trace during SD init. It typically complains about RAM size so you will need to change it in LD script (or other project settings if you don't use GCC - this is linker specific and IAR or Keil are using their own), recompile it and test again. With this debug loop you can find some stable configuration and use it in other projects (where you e.g. start from scratch or from some different example/template).

Children
No Data
Related