Post Go back to editing

I have a question about SDRAM heap on ADSP-214xx

Hey guys, 

I recently started a project to do an AEC (Acoustic Echo Cancellation) module processing on top of ADSP-21489, where the output of channel 1 is processed by AEC, ANS (20ms per frame) and the output of channel 2 is processed by ANS, ECHO/REVERB (5ms per frame).
Then my problem is that the processing of the first channel almost exhausts the on-chip heap, so I want to put some variables from the AEC into SDRAM, but the problem is that all the parameters in the AEC are malloced and initialized inside the function, and then passed through pointers. At the moment I found a function set_alloc_type(char * heap_name) that can reset the current heap location, but it only works for variables of type int, and it doesn't work because it conflicts with the type of many variables in my AEC.

Any help is greatly appreciated.

  • I'm sorry I didn't describe the problem clearly. Now the AEC I use is WebRtc's AEC module, and the WebRtc_Create() in the AEC uses up 0x000e 4020 memory space (some function in the delay estimation module use malloc several times), the 21489 internal heap size is 0x000e 0000 ~ 0x000e7fff, the first The processing of the first channel has used the memory space of 0x000e 7200, resulting in the processing of the second channel can't work normally. I am new to the 21489 and haven't encountered the problem of insufficient memory in previous projects. I am not very knowledgeable about this piece of 21489 memory manipulation, so I would like to ask for advice on how to reasonably reduce the internal heap usage of the AEC.

  • Hi,

    The SHARC C/C++ run-time library supports the standard heap management functions calloc, free, malloc, and realloc. By default, these functions access the default heap, which is defined in the standard Linker Description File and the run-time header.

    The free function deallocates a pointer previously allocated to a range of memory (by calloc or malloc) to the free memory heap.

    You can refer the section "free" on page no:1-163 in the below linked Run-Time Library Manual for more details on free function, which might be helpful to you.
    www.analog.com/.../50_21k_rtl_mn_rev_1.5.pdf

    As you might known ,It is possible to have multiple heaps in your application, one mapped to internal memory and one to external memory. You can then use a wrapper function which will try to allocate memory from the internal heap, resorting to external heap if the internal one is unable to service the request for memory. Memory can be deallocated using the free() function, regardless of the heap it was allocated from.

    The attached project contains an example of the above approach. But it is for ADSP-21369. Please refer the example and try modify in your project for ADSP-21489.

    Additional heaps can be set up by including the file "seg_init.asm" into your project and an additional entry to the ___lib_heap_descriptions table, and by providing a corresponding mapping in the linker description file. This is also demonstrated with the modified seg_init.asm in the attached project.

    These additional heaps can be accessed either by the standard calloc, free, malloc, and realloc functions, or via the Analog Devices extensions heap_calloc, heap_free, heap_malloc, and heap_realloc.

    For more details please refer section "Using Multiple Heaps" in below linked compiler manual.
    www.analog.com/.../50_21k_cc_mn_rev_1.5.pdf

    Regards,
    Santhakumari.K

    Multiple_Heap.zip