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:
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
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
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
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.
由于贝恩德•
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