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.

How to use Memory_alloc to allocate heap memery on internal L2-Ram

Other Parts Discussed in Thread: SYSBIOS

Dear all,

In CCS(5.2), i use *.cfg script to config the the bios(6.33) and want to allocate the heap space on internal L2-Ram..my platform is DM8168.

in ,my c source file. i call Memory_alloc as below:

#include <xdc/std.h>
#include <xdc/runtime/IHeap.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Memory.h>
#include <xdc/runtime/Error.h>

#include <xdc/cfg/global.h>

extern IHeap_Handle DSP_HEAPINT_MEM;

g_img_sobel_x0.yuv_y = (char*)Memory_alloc(DSP_HEAPINT_MEM,sizeof(char)*PRE_PCAND_WIDTH*PRE_PCAND_HEIGHT,4,NULL);

but the linker gets a error:

undefined first referenced
symbol in file
--------- ----------------
DSP_HEAPINT_MEM ./ITG_PlSys.obj

attached the cfg file

----------------------------------------------------------------------------------------------------

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');

var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params;

/* use modules */
var Program = xdc.useModule("xdc.cfg.Program");

heapMemParams.size = 0x00020000;
heapMemParams.sectionName = ".internalHeap";
Program.global.DSP_HEAPINT_MEM = HeapMem.create(heapMemParams);
Program.sectMap[".internalHeap"] = "IRAM";
/*
* Program.argSize sets the size of the .args section.
* The examples don't use command line args so argSize is set to 0.
*/
Program.argSize = 0x0;

/*
* Uncomment this line to globally disable Asserts.
* All modules inherit the default from the 'Defaults' module. You
* can override these defaults on a per-module basis using Module.common$.
* Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
*/

/*
* Uncomment this line to keep module names from being loaded on the target.
* The module name strings are placed in the .const section. Setting this
* parameter to false will save space in the .const section. Error and
* Assert messages will contain an "unknown module" prefix instead
* of the actual module name.
Defaults.common$.namedModule = false;
*/

/*
* Minimize exit handler array in System. The System module includes
* an array of functions that are registered with System_atexit() to be
* called by System_exit().
*/
System.maxAtexitHandlers = 4;

/*
* Uncomment this line to disable the Error print function.
* We lose error information when this is disabled since the errors are
* not printed. Disabling the raiseHook will save some code space if
* your app is not using System_printf() since the Error_print() function
* calls System_printf().
Error.raiseHook = null;
*/

/*
* Uncomment this line to keep Error, Assert, and Log strings from being
* loaded on the target. These strings are placed in the .const section.
* Setting this parameter to false will save space in the .const section.
* Error, Assert and Log message will print raw ids and args instead of
* a formatted message.
Text.isLoaded = false;
*/

/*
* Uncomment this line to disable the output of characters by SysMin
* when the program exits. SysMin writes characters to a circular buffer.
* This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
*/

/*
* The BIOS module will create the default heap for the system.
* Specify the size of this default heap.
*/
BIOS.heapSize = 0x4600000;//0x8000000;

/* System stack size (used by ISRs and Swis) */
Program.stack = 0x1000;

/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x400;

/*
* Create and install logger for the whole system
*/
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 32;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

System.SupportProxy = SysMin;

---------------------------------------------------------------------------------------------------------------------------------------------

  • Forest,

    In my .c file if I do the following:

    extern IHeap_Handle DSP_HEAPINT_MEM;

    Memory_alloc(DSP_HEAPINT_MEM, 128, 4, NULL);

    I get the following compile error:

    "../hello.c", line 16: error #148: declaration is incompatible with "const ti_sysbios_heaps_HeapMem_Handle DSP_HEAPINT_MEM" (declared at line 11 of "C:/Documents and Settings/workspace_v5_1/malloc1/Debug/configPkg/package/cfg/hello_pe66.h")

    Now what did work for me is if I do the following:

    Remove the line "extern IHeap_Handle ...."

    Then do Memory_alloc((IHeap_Handle)DSP_HEAPINT_MEM, 128, 4, NULL);

    Judah

  • Hi Judah,

    if I did as you suggested, i got the error 

    "../ITG_PlSys.c", line 723: error #20: identifier "DSP_HEAPINT_MEM" is undefined
    1 error detected in the compilation of "../ITG_PlSys.c".

    i cant figure out the reason.

    pls help.

    many thanks.

  • Forest,

    In your ITG_PISys.c file you are doing the following right?

    #include <xdc/cfg/global.h>

    Judah

  • Hi Judah,

    in my ITG_PlSys.c, i include the header file as below:

    #include <xdc/std.h>
    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Memory.h>
    #include <xdc/runtime/Error.h>

    #include <xdc/cfg/global.h>

    is it enough?

  • Forest,
    when you include <xdc/cfg/global.h> you don't need an extern declaration for DSP_HEAPINT_MEM in your C file. If you go to your project directory, and then to Debug/configPkg/package/cfg, there should be a file with the extension .h in there. Open that file and check if it contains an extern declaration for DSP_HEAPINT_MEM. Then, open a file with the extension .c in that same directory, and search for DSP_HEAPINT_MEM. There should be a definition of it in that file.

    Also, please post the complete console output of your build. Before you build, go to project properties, then CCS Build->XDCtools->Advanced Options and enable "Show details during build -v".

  • Hi Ssha,

    I enabled the -v option, below is the whole build log. and my cfg and cmd file.

    3580.build.txt

    1854.ITG_PLD.cfg

    /*my linkercmd file*/

    /*
    * Copyright 2010 by Spectrum Digital Incorporated.
    * All rights reserved. Property of Spectrum Digital Incorporated.
    */

    /*
    * Linker command file
    *
    */

    SECTIONS
    {
    .g_stack_section > DDR3_RAM
    .g_src_section > OCMC_0
    .g_dst_section > OCMC_1
    .bss > DDR3_RAM
    .cinit > DDR3_RAM
    .cio > DDR3_RAM
    .const > DDR3_RAM
    .stack > DDR3_RAM
    .sysmem > DDR3_RAM
    .text > DDR3_RAM
    .far > DDR3_RAM
    .switch > DDR3_RAM
    .heap > DDR3_RAM
    .fardata > DDR3_RAM
    .neardata > DDR3_RAM
    .rodata > DDR3_RAM
    }


  • Forest,
    thanks for posting your cfg script and the linker command file, but the files I was asking about are configPkg/package/cfg/ITG_PLD_pe674.h and configPkg/package/cfg/ITG_PLD_pe674.c.

  • yep, i checked the files. no DSP_HEAPINT_MEM there. so i did'nt attched the files.

     here are the files.

  • 2318.c and header.zip

    last post upload the attachment failed.

  • Forest,
    I don't think we ever had a problem of something from Program.global not showing up in the generated .h and .c files. Can you check if you have multiple versions of your CFG script ITG_PLD.cfg, and if you are possibly using a version without Program.global assignment? Can you also check that when you clean your project, the directory 'configPkg' is removed?

    If none of these helps, I think I'll need to see your whole project. You can make a copy of the whole project directory somewhere else, and then remove your C sources. They are probably proprietary and I don't need to look into them anyway. Then, please zip up the copy of the project and post to this thread.

  • Hi Sasha,

    many thanks.

    i can't figure out the problem. just remover all and re-create a project.

    then it works. weird.

    thanks again.