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.

Compiler/TMS320C5534: Accessing a linker .cmd defined area from C code

Part Number: TMS320C5534

Tool/software: TI C/C++ Compiler

Hello,

I am trying to access an area of memory from my C-code.

in my .cmd file, i have:

SECTIONS {

        .text:    {} > SARAM PAGE 0
        .switch:    {} > SARAM PAGE 0
        .bss: block(0x20000)    {} > SARAM PAGE 0
        .cinit: block(0x20000)    {} > SARAM PAGE 0
        .pinit: block(0x20000)    {} > SARAM PAGE 0

    
        error_buf: block(0x400) {} > SARAM PAGE 0
}

then in my C code, i tried various versions, but here is the one i would think works:

extern char error_buf;

void error_handler (char *fmt, void* params)
{
.......

.......



    uint32_t * msg_buf = _symval(&error_buf);

}

But, whatever variations i try, i invariably get the following linker error:

undefined  first referenced   
  symbol        in file        
 ---------  ----------------   
 _error_buf ./src/main.obj

Is there a know pattern for doing just that ? The motivation is to dump an area of memory before exiting the app

Thanks,

Jacques

  • Hi Jacques,

    C5000 SW team looking on this. The feedback will be posted here.

    BR
    Tsvetolin Shulev
  • Jacques,

    In order to get an understanding of defining a memory region in your .cmd file, please see  the example in the CSL at C:\ti\c55_lp\c55_csl_3.08\demos\audio-preprocessing\c5517\VC5505_I2S.cmd

      i2sDmaWriteBufLeft     : > DARAM
    
    
    #pragma DATA_ALIGN(i2sDmaWriteBufLeft, 8);
    Uint32 i2sDmaWriteBufLeft[I2S_DMA_BUF_LEN];  // left Tx write ping/pong buffer

    Lali

  • Hi Lali,

    well, this direction is easy, i.e. defining a buffer or a section in C and mapping it correctly thu the cmd file.

    However, the other way around does work for me:

    1. I define a trace in DSP/BIOS with the .tcf file as follows:
    var trace2 = bios.LOG.create("error");

    2. as a consequence, tconf and dsp/bios generation tool would create an "error$buf" object as follows (in the generated .cmd file)
    SECTIONS {
    .....
    .......
    .error$buf: block(0x20000) align = 0x200 {} > DARAM PAGE 0
    ....
    ...
    }

    3. I am interested to get the address of this error$buf buffer from my C code in order to read it.
    This is waht is not working for me.

    Not that, i am successful in doing it in assembly as follows:

    .ref error$buf

    _getErrorBaseAddr:
    XAR0 = #(error$buf)
    RETURN

    and from my C code, i just call this function :)
    Surely there must be a way to do the same directly in C ?

    regards,
    Jacques
  • Hi Jacques,

    error_buf is an array, not a section while the CMD file is using the memories and sections. You will need to assign the error_buf to a section by doing the following in your code:

    #pragma DATA_SECTION(error_buf, ".error_buf");
    char error_buf[1000];

    In CMD using:

    .error_buf: block(0x400) {} > SARAM PAGE 0

    Best regards,

    Ming
  • Thanks Ming,

    that clarifies a lot ... now i realise that my remaining problem is to force DSP/BIOS to use this buffer instead of the traditionnal error$buf

    regards,
    Jacques
  • Hi Jacques,

    If you have to make the BIOS recognize/use the NOR flash area, you will have to modify the *tcf file to add a new "memory" (bios.MEM) as NOR and specify the starting address and size. You can then assign the error$buf to the NOR area using the BIOS configuration tool (GUI for updating the tcf file).

    The other way, is you can do it by yourself, i.e. put the error info into the error_buf. Of course, this way, you will not be able to use the BIOS LOG function, but sprintf should be able to do tha same. This way, BIOS have no idea the NOR flash exists.

    Ming
  • Thanks for this, it solved my issue
    regards,
    Jacques