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.

Parents
  • Hi

    I suspect you are out of RAM. Check if the problem goes away if you decrease the amount of services and/or characteristics. One solution is to get a chip with larger RAM, i.e. the nRF51822 QFAC variant which has 32kB of RAM. Another solution, if possible, is to put the application on RAM diet, see this thread.

    Update 4.3.2015 For explanation about RAM space on nRF51, look at the answer here.

    I do not know yet what nRF51 variant you have or what softdevice you are using, but if I assume you are using the S110 softdevice, the RAM usage is as follows:

    • S110: 8kB
    • Stack: 2kB (combined S110 and application)
    • Heap: 2kB
    • Space left for application 4kB

    As you point out, your RAM and ROM usage is

    Code=30484 RO-data=432 RW-data=204 ZI-data=5964 
    

    Your application is consuming 204 + 5964 = 6168 bytes of RAM, which includes the 2048 bytes allocated for the stack. You could remove the heap by configuring the arm_startup_nrf51.s file if you do not have any dynamic memory allocation.

    What softdevice and hardware are you actually using?

    Update 10.3.2015 I suspect now that the NRF_ERROR_NO_MEM error that you see when creating a service is because of limited RAM size for the GATT table in the softdevice. For softdevices prior to version 8.0.0, the size of the GATT table is limited to 0x700 bytes. The maximum size of the GATT table can however be configured in S110 8.0.0, see the release notes that come with S110 8.0.0 and the migration document. Note that increasing the GATT table size will decrease the RAM available for the application.

    So, I suspect the solution to this problem is at least one of the three:

    • Get a nRF51 QFAC chip which has 32kB RAM
    • Decrease the number of services and/or characteristics created by your application
    • Increase the maximum size of the GATT table
  • I'm using Softdevice S110 v7.1.0 on the nrf51822qfaag0 device. But, what I do not understand is having such RAM consumption: I have started from Heart-Rate demo and, by proceeding in the same way, I have created 5 custem services: 1st one with 3 characteristics, 2nd with 2, 3rd with 2, 4th with 3 and 5th with 1. And I have not implemented more code, yet. A lot of RAM consumption just with 5 services, right?? And the 5964 bytes of RAM, are not included inside the 8KB available for the S110? Furthermore, for the ble_app_hrs demo parameters are quite similar: Program Size: Code=23656 RO-data=360 RW-data=280 ZI-data=5664

Reply
  • I'm using Softdevice S110 v7.1.0 on the nrf51822qfaag0 device. But, what I do not understand is having such RAM consumption: I have started from Heart-Rate demo and, by proceeding in the same way, I have created 5 custem services: 1st one with 3 characteristics, 2nd with 2, 3rd with 2, 4th with 3 and 5th with 1. And I have not implemented more code, yet. A lot of RAM consumption just with 5 services, right?? And the 5964 bytes of RAM, are not included inside the 8KB available for the S110? Furthermore, for the ble_app_hrs demo parameters are quite similar: Program Size: Code=23656 RO-data=360 RW-data=280 ZI-data=5664

Children
No Data
Related