Post Go back to editing

How to allocate memory from L3 using malloc() on ADSP-21835

Category: Software
Product Number: ADSP-21835

Hello,

We are currently working with the ADSP-21835 and would like to ask how to allocate memory from the L3 memory region using malloc().

Issue:

  • We are having trouble getting malloc() to allocate memory from the L3 region.

What we have done / confirmed:

  • We set the heap entry in the system.svc file to L3_ram (please see the red highlighted area in the attached image).
  • We confirmed that "HEAP" was added to the L3_ram section in the memmap.xmm file (also shown in the attached image).
  • However, even after these changes, malloc() still allocates memory from the L2 region instead of the L3 region.

LSPmemmap.xmm

What we would like to know:

  • How can we make malloc() allocate memory from the L3 region?

Environment:

  • Processor: SHARC-FX (on the ADSP-21835)
  • IDE: CrossCore Embedded Studio 3.0.4

We would appreciate any advice or guidance you can provide.

Best regards,
MrKK

  • Hello,

    We have attached sample code (ZIP-compressed) for verifying operation.

    sample_malloc.zip

    #include <stdio.h>
    #include <stdlib.h>
    
    void* ptr1;
    void* ptr2;
    
    ptr1 = malloc(4 * 1024 * 1024);
    ptr2 = malloc(4 * 1024);
    
    printf("ptr1=%p, ptr2=%p\n", ptr1, ptr2);
    
    if (ptr2) free(ptr2);
    if (ptr1) free(ptr1);

    The expected behavior is to allocate 4KB and 4MB regions from the L3 memory area (0x80000000 to 0xC0000000).
    However, in actual operation, a 4KB region is allocated from the L2 memory area, while the allocation of 4MB of memory fails.

    Please kindly advise me on the settings and procedures required to achieve the expected operation.
    Thank you in advance.

    Best regards,
    MrKK