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

how to solve an error which happened for registration of many BLE services

As shown in subject, I tried to register many BLE services, DIS, BAS, HTS, and Custom Service. Then nRF52832(and nrf52840 preview) has stopped by an error of NRF_ERROR_NO_MEM.

I guess the system has not enough memory for registration of many BLE service, because no error happened if decreases BLE services. but I don't know how to increase memory for BLE services.

Of course I tried to change RAM_START and RAM_SIZE, but NRF_ERROR_NO_MEM stll happened.

could anyone tell me how to increase memory for BLE services?

Parents
  • Hi Yoshihiro, 

    could you state which function specifically that returns NRF_ERROR_NO_MEM?

    If its sd_ble_uuid_vs_add that returns NRF_ERROR_NO_MEM then there are no more free VS UUID slots.  If you're adding a custom service then you have to make sure that the Vendor Specific UUID count in sdk_config.h, NRF_SDH_BLE_VS_UUID_COUNT , is set to the number of custom services you are adding. 

    If it is sd_ble_gatts_service_add or sd_ble_gatts_characteristic_add or sd_ble_gatts_descriptor_add that returns NRF_ERROR_NO_MEM, then you're likely exceeding the default GATT table size set in the sdk_config.h file, NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE. Try increasing it, but remember to adjust the RAM_START and RAM_SIZE accordingly.

    SoftDevice will actually tell you if you have allocated to little RAM, i.e. it will return the application RAM start address. You can start a debug session with a breakpoint after the sd_ble_enable() call in nrf_sdh_ble_enable() in nrf_sdh_ble.c

    If you have RTT logging enabled( should be enabled by default in the ble_app_template example) then the RTT output will be displayed in the Debug Terminal in Segger Embedded Studio or in Segger RTT Viewer if your using another IDE.

    <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
    <warning> nrf_sdh_ble: Change the RAM start location from 0x20002210 to 0x20002220.
    <warning> nrf_sdh_ble: Maximum RAM size for application is 0xDDE0.
    <error> nrf_sdh_ble: sd_ble_enable() returned NRF_ERROR_NO_MEM.
    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at C:\Nordic_Semiconductor\SDK_Repository\nRF5_SDK\nRF5_SDK_15.0.0_a53641a\examples\ble_peripheral\custom_ble_service_example\main.c:663
    PC at: 0x0002EF37

    It is also possible to use the UART backend instead of the RTT backend by setting
    NRF_LOG_BACKEND_RTT_ENABLED to 0 and NRF_LOG_BACKEND_UART_ENABLED to 1 in sdk_config.h.
    In both cases you'll see the following output in the Debug Terminal/Serial TErminal/RTT Viewer if you have allocated to little RAM for the SoftDevice.

  • Hello Bjorn,

    Great! Finally I have solved this problem. it changes the value of NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE from 1408(default) to 2000.

    Thanks for your splendid advice.

  • Hello Bjorn,

    this saved me!!!  I consider it the greatest HINT of all time when dealing with adding custom services.

    thank you!!!!!
    Phil

Reply Children
No Data
Related