Hi all!When we used malloc of size 2**15 in C code, it does not allocate.uint16_t *out = (uint16_t *)malloc(samples_size * sizeof(uint16_t));if (!out) {fprintf(stderr, "Memory allocation for out failed.\n");exit(1);}unsigned int samples_size = 1 << 15;DTCM 256kb and also ITCM in our chip (ARM Cortex M7) is 256kb.CM7_DTCMCRx 0xE000EF940xE000EF94: 0x00000049CM7_ITCMCRx 0xE000EF900xE000EF90: 0x00000049It seems that I cannot use all 256kb that I have in DTCM.Can you give me insights through this?Based on ARM support, I have to located this (via scatterloading region ARM_LIB_(STACK)HEAP), but I do not know how to do it?Appreciate your kind support and assistance.
Hi againAs a quick test, I added your scatter file above into the "startup_Cortex-M7_AC6" example. With some tweaks, I was able to get the example basically working.Note that the default C library itself uses some heap space for things like printf, so your full "samples_size = 1 << 15" didn't quite fit in the heap space, but "samples_size = 1 << 14" did.I could see a malloc call executing & returning correctly, with "out" being 0x20028060, which looks correct. That's 0x20028000 (your heap base) plus 0x60 bytes of C library private workspace.Stephen
Thank you StephenIt was a great help!The issue is resolved.
Hi again!I have sort of a small question.I have created this scatter file in my C project in ARM DS.The question is when I go to my CMSIS project, can I use the same scatter file, or any changes and modifications should be made on that?And in my file, both stack and heap are created in DTCM. Shall I define ITCM statically in the same scatter file as well?regards
CMSIS Packs typically provide referenc scatter files for the device used, but you can of course edit as appropriate, for example to locate the stack/heap in the DTCM rather than general memory.
HiThank you Ronan and Stephen for providing me the insights, now I changed the scatter file in a way that my code can use the resources in an optimized way!Warm regardsMehran