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.

TMS320F28035: How to initialize RAM?

Part Number: TMS320F28035


Dear Champs,

I am asking this for our customer.

As we know, compilers do not initialize RAM for COFF, which is used on F2803x.

From the previous post, F2803x boot codes do not initialize RAM either.

Do you have any comment how the user can initialize or clear RAM except doing it in their initialization codes in main()?

Wayne Huang

  • Please search the C28x compiler manual for the sub-chapter titled Initializing Static and Global Variables in COFF ABI Mode.

    Thanks and regards,

    -George

  • Dear George,

    I am confused.

    The sub-chapter you showed is about initializing static and global variables.

    But here, we want to initialize whole RAM.

    Can we still use .ebss for the whole RAM during compiler stage for default flash boot, that is, every time F28035 is powered on and reset?

    SECTIONS {

    ...

    .ebss: {} = 0x00;

    ...

    }

    Or this is not possible with COFF?

    Wayne Huang

  • Dear George,

    If the above answer is "not possible",

    One more question, can F28035 support EABI? As I know, at that time, our libraries are with COFF.

    Wayne Huang

  • In this post, I demonstrate a method for filling a memory range with 0.  Please understand this method is specific to the linker command file in use.  It is not a general technique which always works in every case.

    I presume you use this linker command file ...

    C:\ti\ccs1011\ccs\ccs_base\c2000\include\F28035.cmd

    Inspect this file to see which memory range is used by the section .ebss, and what other sections use that same memory range.  The following lines are relevant ...

       .ebss               : > RAML2       PAGE = 1
       .esysmem            : > RAML2       PAGE = 1
    

    Please note no other sections use the memory range RAML2.  If that were the case, the method shown in this post probably does not work.  Since both of these sections are uninitialized, it is OK to fill RAML2 with 0 after program load, but before execution begins.

    The definition of RAML2 is ...

       RAML2       : origin = 0x008C00, length = 0x000400

    Code to fill this memory range with 0 must use these same constant values.  It is good programming practice to define such values in one place, then automatically propagate the values from there.  In this case, make use of the preprocessor feature supported in linker command files.  Create a header file with these definitions ...

    /* memory_definitions.h */
    #define EBSS_RANGE_BASE   0x008c00
    #define EBSS_RANGE_LENGTH 0x000400

    Include that file at the beginning of F28035.cmd, and change RAML2 ...

    #include "memory_definitions.h"
    ...
       RAML2       : origin = EBSS_RANGE_BASE, length = EBSS_RANGE_LENGTH

    The code to fill this memory range with 0 must run in the first stages of system startup.  Make use of the boot hook named _system_pre_init.  For more details, please search the C28x compiler manual for the sub-chapter titled Boot Hook Functions for System Pre-Initialization.

    Add a file to the program with code similar to the following ...

    #include "memory_definitions.h"
    #include <string.h> /* for memset */
    
    int _system_pre_init()
    {
       memset((void *) EBSS_RANGE_BASE, 0, (size_t) EBSS_RANGE_LENGTH);
       return 1;
    }

    This function causes the memory range that contains the section .ebss to be filled with 0.  It runs after the stack is configured, but before any other part of the C environment is configured or initialized.  Note this code also causes the memory corresponding to the section .esysmem to be filled with 0.  This does not cause any problems.  Code to initialize the heap runs after _system_pre_init.

    Please let me know if this suggestion resolves the problem.

    Thanks and regards,

    -George

  • Wayne Huang said:
    can F28035 support EABI? As I know, at that time, our libraries are with COFF.

    You are correct to note that, before changing from COFF ABI to EABI, it is best to make sure all the libraries used have support for EABI.  Please see this article about EABI on C28x.

    Thanks and regards,

    -George