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

Bug with RAM when adding new services and characteristics

Hi all!

I am working on the SDK 15.2, with S132 6.0, and i use the SES IDE. 

I have created a custom service with 32 characteristics for now. The goal in the future is to have 3 custom services and to use few SIG-adopted services. 

I have met a problem about when adding my characteristics, I have the error NO_MEM. After searching on the forum, I have followed the instructions from this thread . I am using the SoftDevice Handler library, andnrf_sdh_ble_default_cfg_set() to configure the SoftDevice, so i have modified  the attribute table size in NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE define in sdk_config.h.

My first question is: How do we know which size do we have to choose  when adding new services? First it was at 1408, i have put at 2000. Is there a proper way to calculate it ?

So I have also changed the RAM size and RAM start, and my app is working, I have no more problem with the NO_MEMORY message and the stack_init but I have met another problem: normally every minute, my processor receive data through UART from another processor. Normally it works, but now not amymore. Because I have changed only the RAM part, I think the problem come from there.

My second question is How many minimum RAM size do we need  for the program to work ? I think now there is not enough RAM to do that and I don't know what to do. 

My third question is, is there a way to know what constitues each partition in the RAM? With SES I can see this picture of my RAM:

I would like to know what there is in each partirtion. Indeed, with that, one of the things that I would like to know is: I have taken an existing program, and the programmer modified the RAM size and start, but there were only the NUS custom Service, otherwise the others services were the SIG adopted ones GAP, Generic Attribute, and Device Information. The NUS service needs a lot of memory ?

When I have done these changes, the .reserved_ram was modified, 600 bytes were effectlively added. I can see that there is 31.5kb free, so normally there is enough memory available.

Thanks !

Parents
  • My first question is: How do we know which size do we have to choose  when adding new services? First it was at 1408, i have put at 2000. Is there a proper way to calculate it ?

     I am sorry. I don't have a way of calculating this. Set it high enough, and decrease it until it complains again.

     

    So I have also changed the RAM size and RAM start, and my app is working, I have no more problem with the NO_MEMORY message and the stack_init but I have met another problem: normally every minute, my processor receive data through UART from another processor. Normally it works, but now not amymore. Because I have changed only the RAM part, I think the problem come from there.

     What are your RAM settings, and how do you set up the UART? I can see if I can find any conflicts.

     

    My second question is How many minimum RAM size do we need  for the program to work ? I think now there is not enough RAM to do that and I don't know what to do.

     Do you mean how much RAM the softdevice needs? Or your application? In case of the softdevice, this depends heavily on what services and characteristics you have, how long the data field of the characteristics are, what MTU you use, how many connections you support, to mention some.

     

    My third question is, is there a way to know what constitues each partition in the RAM? With SES I can see this picture of my RAM:

     I am not sure I understood this question. Doesn't the picture show you what the partitions of the RAM consists of?

     

    I would like to know what there is in each partirtion. Indeed, with that, one of the things that I would like to know is: I have taken an existing program, and the programmer modified the RAM size and start, but there were only the NUS custom Service, otherwise the others services were the SIG adopted ones GAP, Generic Attribute, and Device Information. The NUS service needs a lot of memory ?

     The NUS service doesn't require more RAM than most services, but it supports a large packet size, so it needs to set aside RAM in the softdevice for this. Other than that, the custom BLE services requires more RAM than the Bluetooth SIG services. The reason for this is that the UUIDs which identify the services are shorter in the Bluetooth defined services, while they are longer in the custom services. Bluetooth SIG services have a UUID consisting of 16 bit, while custom services have a UUID of 128 bit.

    So the difference here is 14 bytes, so it doesn't really take up a lot, but the main reason you need more for the NUS service is the characteristic's max length (data). Check out ble_nus.c and the lines saying:

        add_char_params.max_len                  = BLE_NUS_MAX_RX_CHAR_LEN;
    and
        add_char_params.max_len           = BLE_NUS_MAX_TX_CHAR_LEN;

    Both of these are 247 bytes, so that is where most of your RAM went Slight smile

    Best regards,

    Edvin

  • I am sorry. I don't have a way of calculating this. Set it high enough, and decrease it until it complains again.

    Good idea. 

    What are your RAM settings, and how do you set up the UART? I can see if I can find any conflicts.

    My RAM Settings are : 

    RAM_START=0x20002CF8

    RAM_SIZE=0xd308

    The uart is initialized with the uart_host_init function from the uart_host library. Normally the Nordic is in low power mode, but when we receive an interruption signal on pin 3, we switch on the nordic and activate the uart handler. We use the uart_host_data_receive function to receive the data and uart_cde_treatment to process it. 

    Do you mean how much RAM the softdevice needs? Or your application? In case of the softdevice, this depends heavily on what services and characteristics you have, how long the data field of the characteristics are, what MTU you use, how many connections you support, to mention some.

    I mean, I want to know if there is enough memory allocated. 

    I am not sure I understood this question. Doesn't the picture show you what the partitions of the RAM consists of?

    Yes, but I don't know the content of every partition, and their goal. 

    he NUS service doesn't require more RAM than most services, but it supports a large packet size, so it needs to set aside RAM in the softdevice for this.

    oh ok. 

    When I get the program, there were only one custom service ( NUS). At this time, my RAM values were : 

    RAM_START = 2000 2A98

    RAM_SIZE = d568

    I think that the default value is 

    RAM_START = 2000 2218

    RAM_SIZE = dde8

    Is it coherent ?

    Best Regards,

    Antoine Kristanek

  • Beldramma said:
    Yes, but I don't know the content of every partition, and their goal. 

     To be honest, I am not sure what all of the sections mean. They are partly compiler (IDE) specific and partly Nordic specific. the important thing is to set the ram start and size according to what is printed in the log.

     

    Beldramma said:

    When I get the program, there were only one custom service ( NUS). At this time, my RAM values were : 

    RAM_START = 2000 2A98

    RAM_SIZE = d568

    I think that the default value is 

    RAM_START = 2000 2218

    RAM_SIZE = dde8

    Is it coherent ?

     If you change it back, does the log suggest that you should change it to start: 0x20002a98 and size:  0xd568?

    So the underlying issue here is that you have some issues with the UART, right?

    Can you set a breakpoint after you enable the UART, and read out the register 0x40002544 and 0x40002534? These should point to the UART TX and RX buffer. In Segger Embedded Studio, you should be able to see them directly in the IDE if you click "Groups" under the "Registers"  window. Depending on what UART you are using, select that one:

    BR,
    Edvin

  • To be honest, I am not sure what all of the sections mean. They are partly compiler (IDE) specific and partly Nordic specific. the important thing is to set the ram start and size according to what is printed in the log.

    Hum Ok. Do you know if there is a way to know the content of the GATT Table ?

    So the underlying issue here is that you have some issues with the UART, right?

    Yes I had, but today, idk why it works back. I hope it is due to flashing problem. But I am still interested about RAM content, and particularly my previous question. Also, I have seen that the NUS service use the MTU,what is it exactly ?

    Best Regards,

    Antoine Kristanek

  • MTU (Maximum Transmission Unit) is the maximum allowed packet size in a BLE connection. Basically how long messages you can send. In BLE4.0 this was fixed to 23 bytes, which means 3 bytes of header, and 20 bytes of payload. 

    In BLE4.2 this was updated to support up to 247 bytes, allowing for a lot higher throughput and lower current consumption, because you can send longer packets with higher payload/headers ratio. 

     

    Beldramma said:
    Do you know if there is a way to know the content of the GATT Table ?

     The GATT table is stored in the softdevice, so you can't access it directly. 

Reply
  • MTU (Maximum Transmission Unit) is the maximum allowed packet size in a BLE connection. Basically how long messages you can send. In BLE4.0 this was fixed to 23 bytes, which means 3 bytes of header, and 20 bytes of payload. 

    In BLE4.2 this was updated to support up to 247 bytes, allowing for a lot higher throughput and lower current consumption, because you can send longer packets with higher payload/headers ratio. 

     

    Beldramma said:
    Do you know if there is a way to know the content of the GATT Table ?

     The GATT table is stored in the softdevice, so you can't access it directly. 

Children
No Data
Related