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 disable auto initial variables in tiva c M4F

Hi All

In the CMD, customer created a NVRAM_DATA block, which is mapped to a external NVRAM to store data.

MEMORY
{
FLASH (RX) : origin = APP_BASE, length = 0x00100000

SRAM      (RWX) : origin = 0x20000000, length = 0x00040000

NVRAM_DATA   (RWX) : origin = 0xA0000000, length = 0x00020000

}

SECTIONS
{

.intvecs: > APP_BASE
.text : > FLASH
.const : > FLASH
.cinit : > FLASH
.pinit : > FLASH

.bss    :   > SRAM

.nv_dat : > NVRAM_DATA 

}

In the main, customer map some special variables to .nv_dat, these variable will save data before power off.

#pragma DATA_SECTION(ui32Loop1, ".nv_dat");
uint32_t ui32Loop1;

As in Tiva C device, it will auto initialize variable, but customer don't want to initialize the  .nv_dat.

Do someone know how to deal the variable initialization in this condition? That is initialized the default global variables in .bss, but not initialized custom variables. 

Eric

  • Hi,

    Maybe there is not need to declare a special linker section since the user has a physical starting address where to store data. The solutions depends somewhat on what the user will do with that data. If the data in nv_ram needs to be read back to application then an object (structure, array, words) may be declared as initialized with zero or 0xFF as needed and when the application starts up, read back the data into that object. Or just read it from known locations without any other problems.

    Petrei

  • That will depend strongly on what compiler you are using.

    In general the link and locate functions of the linker and the startup of the runtime are both involved. Some compilers already have a noinit section setup, you just need to join the NVRAM space to it, others you will need to create such a section and make sure the startup ignores it.

    Robert
  • Robert Adsett said:
    and make sure the startup ignores it.   

    Might one (sure) way to achieve that be to name that section, "PF0/PD7 Removed from (harmful & near useless) NMI Default!"

    Such implorings here are (always) ignored...

  • Hi all
    Thanks for your suggestions. Now I find there is a zero init setting in CCS. While set zero init as off, the variables mapped to nv_dat would not be auto initialized. Of course, these variables will not have initialized value when defined.

    Eric