Hi,
I am unable to understand the purpose/meaning of below macros in da1458x_config_advanced.h file. Can you explain what each one means:
#define DB_HEAP_SZ
#define ENV_HEAP_SZ
#define MSG_HEAP_SZ
#define NON_RET_HEAP_SZ
Actually, I am sending the GATT database from a different controller over UART and allocating the services, characteristics and descriptors using TASK_APP and using KE_MSG_ALLOC.
After adding some, the control transfers to wrap_platform_reset(). When I read some answers on Dialog support I found that this happens when memory is low.
So, I increased the values of all of these and now my GATT database works fine.
Although, I want to understand exactly the purpose or for what each of the above macros is used.
Thanks,
Hrishikesh
Device:
Hi dhrishi,
These macros define the sizes of memory sections which are for different usage. For example, calling KE_MSG_ALLOC will allocate memory of the requested amount from the MSG section whose size is defined by MSG_HEAP_SZ. DB is for GATT database, ENV is for the kernel and the BLE stack internal usage while NON_RET is for general purpose.
I have a large number of services and characteristics (6 services and 33 characteristics). The total size for each service on my end is:
S1: 1278 bytes bytes
S2: 570 bytes
S3: 751 bytes
S4: 1455 bytes
S5: 745 bytes
S6: 214 bytes
The characteristics in each service are of TLV8 type and hence their sizes are greater.
Could you please suggest the values of the size macros that can be used. Current values I use:
#define DB_HEAP_SZ 2048
#define ENV_HEAP_SZ 1536
#define MSG_HEAP_SZ 2048
#define NON_RET_HEAP_SZ 1024
With these values, when I add service S4, then the DA14580 becomes non responsive. I think it is a memory issue.
I have tried increasing these in some combinations but no luck.
I could finally make it work with following values:
#定义DB_HEAP_SZ 3072
#define ENV_HEAP_SZ 3584
#define MSG_HEAP_SZ 1600
#define NON_RET_HEAP_SZ 1024
Could you please justify these values and let me know in case of any problems (like max size etc)
Hi,
We need to add a couple of new services and around 10 characteristics. With this what is happening is that the increased sizes of the macros (mentioned above) are going out of bounds for the execution region ZI_RET20. What is the correct way of handling this?
While compiling, I am getting the error:
Error: L6220E: Execution region ZI_RET20 size (9764 bytes) exceeds limit (8888 bytes) Region contains 0 bytes of padding and 0 bytes of veeners
Error: L6221E: Execution region ZI_RET20 with execution range () overlaps with execution region ZI_RET21 with execution range ()
I need atleast 2kB more memory. How to do increase the region size and till how much maximum can I do that.
Hello dhrishi,
I apologize for the delay.
So, inorder to get a better idea, you are now having multiple services which include 2 custom services (allowed on 580) and rest are standard services.
When you mentioned, the DA14580 becomes non resposive, did you try to debug if it is due to stack issue rather than that of a Heap. Please verify if there is any issues related to the stack crash. You can do that by simply filling up the memory with a pattern and see upto which section it is modified.
The total memories will be as per the description will be just the sum of all the dynamic allocations in each type.
Best,
LC
No. All my services and characteristics are custom having 128 bit UUIDs.
We have large number of services (8-10), characteristics (50-55) and the characteristic value sizes are also pretty big (almost 150 bytes per characteristic)
No I could not debug that failure since DA14580 is a part of a module (which has our MCU and DA14580). So we cannot debug it. Although, I could verify that it is related to memory as, when I reduce the input services and characteristics it works fine. Only, when I introduce a service or characteristic, the DA14580 does not respond after a certain command while adding the GATT database over UART
Hello dhrishi,
The DA14580 has 8 kB of Retention RAM. You can only hold so much of Data in the Ret RAMs. This can be monitored from the MAP file and the application can be tuned as per the available memory. Please forward me your MAP file so that I can check on the memory usage.
Also, does your application go to deep sleep? and do you need all the Services/Chars in the Retention memory? I wanted find out if data can moved to regular RAM if you are not operating deep sleep to free up some of the retention RAM.
Just to confirm, are you using a DA14581 over HCI?
Best,
LC
Hi,
Thanks a lot for your support. Sorry for the late reply.
As of now, we are planning to use extended sleep. As per my understanding, the 8kB retention RAM along with entire sys RAM is retained during this sleep mode. Right?
So, I think it should be fine to move some data to regular RAM. I will try to move stuff on my own first. In case of any issues, I would send over the map file. Could you please share your email id for the same.
Additionally, I would also like to understand a few things:
1. While adding a service, a total size is given and I assume that the stack allocates that much amount of memory for the characteristic values (as per the size) of that service. So out of the below, which type of heap is used for storing this:
DB_HEAP_SZ or ENV_HEAP_SZ or MSG_HEAP_SZ
2. If we decide to use extended sleep, Is it ok if I keep the env heap and msg heap in the retention RAM (utilizing the 8KB available) and move the db heap to sys RAM (or some other combination)? Will there be any problems in such a scenario?
3. If we decide to use deepsleep mode, can we retain more than 8kB of memory by modifying EM_MAP configuration in API SystemInit() between values 0-23. If yes, how much maximum amount of memory can be retained by using such a configuration.
On a different note, could you please let me know the current values for a standard BLE peripheral using extended sleep mode and deep sleep mode. I just want to understand the difference in current ratings.
Thanks,
Hrishikesh
Hello dhrishi,
Please provide your email and I will forward a secure folder tp you. This can be use to upload the map file.
1. Adding any Services/Chars, the memory is allocated from DB_HEAP_SZ. However, since the overall code and data increases, the RAM usage (other heaps) will aslo increase accordingly.
2. It does not differ where you retain the memory in Extended sleep. So you can use any combination that fits the Memory organization.
3. When in Deep Sleep, all you can retain is only 8kB.
4. On a DA14580, typically the Extended Sleep currents range in between 1.2 - 1.4 uA and that of a Deep Sleep is approximately around 650nA. But please keep in mind, this can differ by the hardware design and the components used.
Best,
LC
Hi,
Thanks for your reply. With this I assume that all the memory is retained in extended sleep mode. I am planning to use the extended sleep mode.
So, in terms of functionality what is the difference between extended and deep sleep mode? If there are any pointers for the same. then it would be useful for me to understand.
I have created my application based on ble_app_barebone sample app (SDK: 5.0.4). So, by default what is the power mode that is used in there?
Also, I have set the pointer "app_on_system_powered" to a function that I need to call periodically. I see that it either returns GOTO_SLEEP and KEEP_POWERED. Is it related to the power modes (extended sleep in this case)?
What would happen if I continuously return KEEP_POWERED from this function?
如果我返回GOTO_SLEEP,然后将任何activity on the UART or the BLE wake it up?
In short, I need to understand what these return values indicate and result into.
Thanks,
Hrishikesh
Hi dhrishi,
The sleep modes are explained in our Data sheets and User manuals. For a brief reference you can check out the7.1.1 Sleep Modesin ourUM-B-051_DA1458x_Software_Platform_Referencedocument.
The sleep mode is defined in theuser_config.hfile in the projects. The default inble_app_bareboneisARCH_SLEEP_OFFwhich is usually the default in our SDK. That means it is in Active mode.
The.app_on_system_poweredis called when the Application wants to keep the system active after the BLE is powered off. This is intended to provide the application with additional processing time for some data/background processing. Based on what the function that is called here will determine if the application will have to be kept powered or can go to sleep. If you go to sleep, then it will be woken up at the end of the sleep mode for addressing BLE event. Please refer to our UM's for ways to wakeup the DA14580. But by default, the UART will not wake up the system whereas the BLE does.
Best,
LC
Hi,
Thanks for your reply. Two things:
1. If I modify the user_config.h to use extended sleep mode but throughout return KEEP_POWERED from my app_on_system_powered callback, will there be any use of extended sleep mode? Or the BLE can still go into extended sleep mode?
Setup: Our module is a peripheral solution that has an external MCU and DA14580. The external MCU sends over the GATT database and advertisement data over UART to DA14580 so that it can start advertising.
Now, ideally DA14580 can go in extended sleep. Going ahead, it might receive:
从单片机(ov。事件er UART) like indication (req to be sent to BLE central), updated advertisement data, disconnection request OR
ii. BLE central might send GATT read write commands to DA14580.
So, how do we handle all these appropriately and still keep the DA14580 in extended sleep for power saving.
2. Is there an app note which helps take readings of ble_app_peripheral in extended sleep mode. The configuration, pins, scenarios and other details? We can first try that on DA14580 and then replicate it on our module to take actual current readings. I see Training_04_sleep_modes_current_measurement_v1.0.pdf. I will check through this.
Hello dhrishi,
1. If you keep the application to be active during theapp_on_system_poweredprocedure, the system will not go into sleep irrespective of what sleep mode is enabled.
Also, if let's say you gave the system permission to sleep just before the next BLE event is about to happen, it is intelligent enough to determine if that it's economical to go to sleep for that duration. If it's not it will stay active.
For your application,
from your explanation I understand that you are using the HCI implementation over the UART. In this case you can use the external wakeup mechanism to wake the system from an external event. To setup this, you will enable the interrupt on a specifically allocated GPIO before going to sleep. During the sleep, if the MCU send an event on this GPIO, the system will wakeup and you can do the requried processing.
Note: If short of GPIOs, you can use one of the interface (UART) pins that you will make it as GPIO before sleep and modify to UART after wakeup. Please refer to theSystem Softwaresection inUM-B-051 : DA14580for further understanding on how this mechanism works.
2. Yes there is an app noteAN-B-051 SmartSnippets Power Profiler Calibrationfor guiding you through the current measurements. Also refer toAN-B-051 SmartSnippets Power Profiler Calibrationfor callibration of the dev kit to get acurate results.
Best,
LC