Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Memory allocation Issue

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_DTCMCR
x 0xE000EF94
0xE000EF94: 0x00000049

CM7_ITCMCR
x 0xE000EF90
0xE000EF90: 0x00000049

It 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.

Parents
  • Hi again

    As 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

Reply
  • Hi again

    As 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

Children