This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reusing the init-code for heap purpose

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:

  1. Using TConf define the section for dynamic heap:
    section MEM0 of start address 0x11830000, size 0x10000, heap-size 0, and label "_HeapDyn"
  2. Add linker command file (let's say "link_heap.cmd") to project in order to control placing the C-functions there:
    SECTIONS
    {
    SectCodeForSyHeap > MEM0
    }
  3. To-be-reused functions get pragma, like following example:
    #pragma CODE_SECTION(setupXXX,"SectCodeForSyHeap");
    void setupXXX(void)
    { }
  4. 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

  • Hi Mladen,

    I've created a testcase to reproduce your setup. And I get the same error as you when using CGT 6.1.5! But with CGT 6.1.23, the latest version of the 6.1 branch, the error didn't occur and the project built fine.

    Can you please try again with CGT 6.1.23?

    Thanks,
      Robert

  • Hi Robert,

    your proposal of switching to last compiler of 6 generation-branch, namely 6.1.23 was a solution to my problem. 

    Now dynamic heap usage works properly!

    Till now I've used CGT v6.1.5 due to "DSP/BIOS 5.42.01.09 Release Notes" validation information:

    Validation Information

    This release was built using the following components:

    * C6x Code Generation Tools version 6.0.14 (except 674x)
    * C674x Code Generation Tools version 6.1.5

    Many thanks!

    Mladen