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

NRF_ERROR_NO_MEM in sd_ble_gatts_characteristic_add

Hi,

I get NRF_ERROR_NO_MEM calling sd_ble_gatts_characteristic_add when using more than 15 uuids. Can you help mitigating this?

Thanks,

Daniel

Parents
  • As the name "NRF_ERROR_NO_MEM" suggests - you've run out of memory!

    You need to increase NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE  in sdk_config.h

    You may then also need to increase RAM_START in the Project Linker settings > Memory placement macros

  • 1. What is the relationship (formula) between the number of characteristics and NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE? 

    2. How do I calculate if and by how much I need to increase the RAM_START?

    3. Is there a methodical way to know if the RAM_START is too small?

    Thanks,

    Daniel

  • Hi, 

    I think this was answered here: NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE.

    You have to change NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE first, then you compile, flash and run and you should get some logs saying that the RAM regions should be changed to 0xXXXXXXXX. Then you go to your linker file (or memory placement or whatever), and you make the changes as they appear in the log. That should solve your problems.

    -Amanda H.

  • My 1st question was what is the needed NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE as a function of the number of characteristics; then, which log and finally, how to make sure the RAM_START is correct.

    Thanks,

    Daniel 

  • Hi Daniel, 

    The attribute table is stored in Softdevice's RAM region (memory layout) and the debug log will ask you to increase the APP_RAM_BASE address if it is set too low for the current configuration, hence allocate more RAM for the Softdevice.

    When you increase the UUID count you need to adjust your ram settings. Otherwise, Error 4 returned by softdevice_enable corresponds to the NRF_ERROR_NO_MEM error. This error is generated by the sd_ble_enable function which is called within softdevice_enable.

    The easiest way of finding the correct RAM settings is by using a terminal such as putty to read the logs supplied by the chip. First make the changes you need to your code (setting the UUID count to what you need), build and load. If the RAM settings are different from the optimal settings the logs displayed in putty will tell you what the RAM start and size should be set to. Then simply change the RAM settings in the target options.

    -Amanda H.

  • Amenda,

    I couldn't find and documentation about the logging functionality of Softdevice. Can you direct me to it?

    Additionally, it seems you suggest a trial and error approach. Isn't there a documentation about the memory requirements based on the number of characteristics? 

    Thanks,

    Daniel

  • Hi Daniel, 

    If you use S140, you can refer to S140 SoftDevice

    NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE indicates the set amount of memory dedicated to the attribute table (including the characteristic size) in the Softdevice, so this will also vary from project to project. If you exceed the size of it you will receive an NRF_ERROR_NO_MEM error. Modifying the NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE usually means you also need to reconfigure the RAM settings.

    For the RAM_START and the RAM_SIZE, there is no need for an equation or optimal values, as the SoftDevice will tell you if you have allocated too little RAM. You can start a debug session with the RTT logging enable if there is insufficient RAM allocated for the SoftDevice the logs will print a warning with the suggested RAM start address. See bjornspockeli's comment here to find out how to output the log information.

    For log information, you could go to sdk_config.h and enable NRF_LOG_ENABLED and NRF_LOG_BACKEND_RTT_ENABLED. Changing NRF_LOG_DEFAULT_LEVEL to 4 could show the "debug" log. 

    -Amanda H.

Reply
  • Hi Daniel, 

    If you use S140, you can refer to S140 SoftDevice

    NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE indicates the set amount of memory dedicated to the attribute table (including the characteristic size) in the Softdevice, so this will also vary from project to project. If you exceed the size of it you will receive an NRF_ERROR_NO_MEM error. Modifying the NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE usually means you also need to reconfigure the RAM settings.

    For the RAM_START and the RAM_SIZE, there is no need for an equation or optimal values, as the SoftDevice will tell you if you have allocated too little RAM. You can start a debug session with the RTT logging enable if there is insufficient RAM allocated for the SoftDevice the logs will print a warning with the suggested RAM start address. See bjornspockeli's comment here to find out how to output the log information.

    For log information, you could go to sdk_config.h and enable NRF_LOG_ENABLED and NRF_LOG_BACKEND_RTT_ENABLED. Changing NRF_LOG_DEFAULT_LEVEL to 4 could show the "debug" log. 

    -Amanda H.

Children
Related