wrap_platform_reset after ke_malloc

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
beckel
Offline
Last seen:2 years 4 months ago
加入:2016-05-24 08:58
wrap_platform_reset after ke_malloc

Hi,

I try to modify the ble_app_peripheral example. I would like to use a part of dsps code for serial communication. In the file user_buffer.c there the function user_buffer_create(...).
After executing the line:
buffer->data_ptr = ke_malloc((long)(buffer->buffer_size)*sizeof(uint8_t), KE_MEM_NON_RETENTION);
The execution stops with wrap_platform_reset.
I think there is something wrong with memory allocation.
Do you have a solution?

Best regards
Bernd

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi beckel,

Hi beckel,

There is nothing wrong with the memory allocation, but it depends how much memory you are trying to allocate, apparently you are trying to allocate more memory than what is available and you get that assertion. The DSPS that you took as a reference sets up different size of heaps in order to manage the allocation of the buffers, check the da1458x_config_advanced.h file and check the values of MSG_HEAP_SZ and NON_RET_HEAP_SZ, if those definitions do not exist the SDK will apply a default value which apparently is not sufficient for your implementation.

Thanks MT_dialog

beckel
Offline
Last seen:2 years 4 months ago
加入:2016-05-24 08:58
Hi MT_dialog,

Hi MT_dialog,

I already changed the values of MSG_HEAP_SZ and NON_RET_HEAP_SZ to the same values are used in DSPS. I also tried to reduce the malloc size to a value of 10. But the error was the same. Is it possible to check the size of reserved RETENTION MEMORY? Maybe there is something wrong with the conditional compilation, if some defines are wrong.

Thanks
Bernd

MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi beckel,

Hi beckel,

The ke_malloc, doesn't reserve memory only from the RETENTION MEMORY, the heaps that are for the enviroment, the messages and the database (heap_env_area, heap_msg_area and heap_db_area) are stored in the retention memory the non retention heap is stored in the sysram, you can check the sizes of those heaps in the .map file of the application that you have builded. If you tried to allocate a size of 10 bytes and you end up in the fail allocation assertion, then perhaps there is a memory leak on your implementation. Tested the ke_malloc on the ble_app_peripheral, allocated 2048 bytes (with the proper mods in the heap sizes) and had no issue.

Thanks MT_dialog

beckel
Offline
Last seen:2 years 4 months ago
加入:2016-05-24 08:58
Hi MT_dialog,

Hi MT_dialog,

how did you test ke_malloc on the ble_app_peripheral? Where did you put the ke_malloc? I think there is a problem calling ke_malloc. If I reserving the space using malloc, then it works.

由于贝恩德•

MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
Hi beckel,

Hi beckel,

I expanded the heaps in order to fit the allocated space and i invoked the ke_malloc in the user_app_adv_start().

Thanks MT_dialog