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

NRF_ERROR_NO_MEM

Hi, I have created up to 5 custom services with several characteristics (4 at maximum) each one. They all use the same base UUID. The problem I'm facing now is that when I execute 'services_init' function, the function 'sd_ble_gatts_service_add' gives error 0x000004 (NRF_ERROR_NO_MEM). I have changed services ordes inside 'services_init' function and then the same error is given but now by the 'sd_ble_gatts_characteristic_add' function. (This is maybe due to the fact that not all the services have the same number of characteristics). Do you know which is the reason of this problem? Best regards, Dani.

  • No, the S110 will keep the reserved 8kB totally for itself. For experimental purposes, try to remove some of the services or characteristics to see what effect it has on the RAM usage of the application, i.e. ZI-data.

  • I just took the ble_app_hrs demo in the 7.2.0 SDK and compiled it 1) with gcc and 2) in Crossworks which is the IDE I use. GCC, with optimization turned off gives me

     text	   data	    bss	    dec	    hex	
    34016	    100	   1892	  36008	   8ca8	
    

    Crossworks gives me similar code size and 1776 bytes of bss. BSS is Zi, it's the zeroed data. So I don't know where your 5880 is coming from, I don't get anything like that much.

    I've stopped believing this is the problem. If there was too much static RAM usage the link should fail or the program would crash, the softdevice doesn't use any heap at all anyway so it's not dynamically allocating memory so this isn't a malloc() failure. I can only think you are exhausting a fixed buffer in the softdevice, the only one of those I know of is the 0x700 byte limit for GATT server table but there might be others.

  • .. and I wish comments weren't so limited to 900 chars ..

    So I'd try removing a service or characteristic until it doesn't crash, you may be right on the limit and just removing one or two would work.

    The new Softdevice 8.0.0 allows you to change that 0x700 byte limit. You could try that, although there's so many changes in that version and the SDK isn't out yet you may run into other issues, probably better to wait for SDK v8

    I don't have the code for the softdevice else I could look at see exactly in what circumstances NRF_ERROR_NO_MEM is returned from those two calls. Basically that's a controlled error message, so it's an internal check inside the softdevice against its own memory usage.

  • Yesterday I spent all day trying to make the Keil working with GCC but I have not succeeded. Do you have any guide explaining how to setup GCC/CNU with Keil? Furthermore, at the same time, I have built the same ble_app_hrs in another computer with Keil (keil compiler) and I get the same results I wrote some comments above: 5664 in ZI-Data. Do you know what is the reason of such figures?

  • Don't have Keil - don't use Keil, no interest in Keil at all, know absolutely nothing about the product. I don't even know if you can make Keil work with GCC or not, I thought it used its own internal compiler.

    Either way this still isn't the problem, the softdevice is running out of memory inside the softdevice, which is why it's reporting the out of memory condition. The size of your code doesn't affect the softdevice, it uses 8Kb in a fixed place, it doesn't allocate dynamic memory so the only way it can report that it's out of memory is because it's run out of memory out of its fixed allocation.

    Have you yet tried removing services and characteristics until you don't run out of memory?

Related