Hello,
please allow me following question related to the topic of re-using the C6000 startup code (from main) for "dynamic" heap purposes at runtime.
I have successfully been using this mechanism for years, but in conjunction with older CCS3.3 and DSP/BIOS 5.31.02.
Now I've switched to CCSv5.5 and DSP/BIOS 5.42.1.09; using the same method didn't work due to linker problems.
Here the steps I perform:
- Using TConf define the section for dynamic heap:
section MEM0 of start address 0x11830000, size 0x10000, heap-size 0, and label "_HeapDyn" - Add linker command file (let's say "link_heap.cmd") to project in order to control placing the C-functions there:
SECTIONS
{
SectCodeForSyHeap > MEM0
} - To-be-reused functions get pragma, like following example:
#pragma CODE_SECTION(setupXXX,"SectCodeForSyHeap");
void setupXXX(void)
{ } - MEM_redefine part in main():
#define HEAP_INIT_BASE 0x11830000
#define HEAP_INIT_SIZE 0x10000
{
extern Int HeapDyn;
MEM_redefine (HeapDyn, (void *) HEAP_INIT_BASE, HEAP_INIT_SIZE );
}
Linker properly places "setupXX into MEM0 section (according to .MAP file), but failes to allocate memory for the section ".MEM0$heap":
<Linking>
"./audio_edma_c6747cfg.cmd", line 435: error #10099-D: run placement fails for
object ".MEM0$heap"
error #10010: errors encountered during linking; "audio_edma_c6747.out" not
built
>> Compilation failure
gmake: *** [audio_edma_c6747.out] Error 1
gmake: Target `all' not remade because of errors.
**** Build Finished ****
The steps from above result in the following TConf changes:
bios.MEM.create("MEM0");
bios.MEM.instance("MEM0").space = "code/data";
bios.MEM.instance("MEM0").heapSize = 0x00000000;
bios.MEM.instance("MEM0").base = 0x11830000;
bios.MEM.instance("MEM0").len = 0x00010000;
bios.MEM.instance("MEM0").enableHeapLabel = 1;
bios.MEM.instance("MEM0").comment = "Dynamic Heap";
bios.MEM.instance("MEM0").heapLabel = prog.extern("HeapDyn");
If I simplify the alternatively simplify the situation and setup the heap in IRAM instead (and do not use MEM0 memory section):
bios.MEM.instance("IRAM").len = 0x00040000;
bios.MEM.instance("IRAM").enableHeapLabel = 1;
bios.MEM.instance("IRAM").heapLabel = prog.extern("HeapDyn");
bios.MEM.instance("IRAM").heapSize = 0x00010000;
everything works fine. Unfortunately this method doesn't allow re-using the init code for heap purposes.
Can it be a DSP/BIOS issue?
Is there a workaround for this problem?
Thanks,
Mladen