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.

Initialize .ebss section

Hi Folks,

I have some structs that are stored in DRAM and would like to have all their members initialized to zero.

I note from SPRU514 that this needs to be done by initializing the memory section they are stored in to zero via the linker command file.

However, looking at SPRU514 and SPRU513, I have not been able to figure out the correct way to make this happen.

My project uses the TI support files cmd files "F2802x_Headers_nonBIOS.cmd" & "F28027.cmd" and I have attempted to modify the latter by inserting 'FILL = 0x0' as follows:

SECTIONS
{
    /* ... */
    .ebss    : > DRAML0    PAGE = 1    FILL = 0x0
    /* ... */
}

SECTIONS
{
    FOO_Struct    : > DRAML0    PAGE = 1
    /* ... */
}

Yet this does not seem to be having any effect... Am I completely on the wrong track here?

  • Hi Toby,

    You'll need to initialise RAM at run time.  The linker can't do that for you.  The way I do it is to clear the RAM contents in a short assembly routine before calling the _c_int00 routine.  There are two things you'll need to do:

    First, specify two region related symbols in the linker command file to fix the start address and size of the .ebss section.  You can refer to these in the assembly routine.  In your case, something like...

    Then, insert an assembly routine in place of the LB _c_int00 instruction.  You're using the TI header files, so you should find this in a file called "DSP2802x_CodeStartBranch.asm".  I attach a file which you can use to replace this  one in your project.

    3872.demo2802x_preboot.asm

    Note that the code disables the watchdog (to prevent it timing out in case the section size very large), so you'll need to re-enable it after boot if needed.

    I hope this helps.

    Best regards,

    Richard