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.

TMS570LC4357: No init memory on reset for storing reset information

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi,

I would like to store reset information in SRAM, and read it after a warm reset performed. I've tried every option, but after any kind of reset when the PC set to the reset entry vector all RAM data initialized back to 0.

I've put my variable in noinit section and used the linker script below:

#define NON_VOLATILE_DATA __attribute__ ((section(".noinit")))
NON_VOLATILE_DATA static char data[16];

#define SRAM_SIZE                       0x00080000

#define STACKS_START_ADDR               0x08000000
#define STACKS_SIZE                     0x00004e00

#define KRAM_START_ADDR                 (STACKS_START_ADDR + STACKS_SIZE)
#define KRAM_SIZE                       0x00000800

#define RAM_START_ADDR                  (KRAM_START_ADDR + KRAM_SIZE)
#define RAM_SIZE                        (SRAM_SIZE - NOINIT_RAM_SIZE - KRAM_SIZE - STACKS_SIZE)

#define NOINIT_RAM_START_ADDR           (RAM_START_ADDR + RAM_SIZE)
#define NOINIT_RAM_SIZE                 0x000000100

MEMORY
{
    VECTORS         (X)   : origin = 0x00000000                 length = 0x00000020
    KERNEL          (RX)  : origin = 0x00000020                 length = 0x00008000
    FLASH0          (RX)  : origin = 0x00008020                 length = 0x001F7FE0
    FLASH1          (RX)  : origin = 0x00200000                 length = 0x00200000
    STACKS          (RW)  : origin = STACKS_START_ADDR          length = STACKS_SIZE
    KRAM            (RW)  : origin = KRAM_START_ADDR            length = KRAM_SIZE
    RAM             (RW)  : origin = RAM_START_ADDR             length = RAM_SIZE
    NOINIT_RAM      (RW)  : origin = NOINIT_RAM_START_ADDR      length = NOINIT_RAM_SIZE
}

SECTIONS
{
    .intvecs : {} > VECTORS
    /* FreeRTOS Kernel in protected region of Flash */
    .kernelTEXT  align(32) : {} > KERNEL
    .cinit       align(32) : {} > KERNEL
    .pinit       align(32) : {} > KERNEL
    /* Rest of code to user mode flash region */
    .text        align(32) : {} > FLASH0 | FLASH1
    .const       align(32) : {} > FLASH0 | FLASH1
    /* FreeRTOS Kernel data in protected region of RAM */
    .kernelBSS      : {}  > KRAM
    .kernelHEAP     : {}  > RAM
    .bss            : {}  > RAM
    .data           : {}  > RAM
    .sysmem         : {}  > RAM
    .noinit         : {}  > NOINIT_RAM type=NOINIT
}

I have even tried to disable initialization of the memory block before the reset:

l2ramwREG->MEMINITDOMAIN = 0x7f;

But non of the above was working, the RAM always read 0 after the reset.

Is there any possible way to store data in SRAM without it initializing on reset?

Thank you!

  • Hi,

    Memory HW initialization will clear the memory content, and RAM PBIST will also clear the content too.

     NOINIT_RAM      (RW)  : origin = NOINIT_RAM_START_ADDR      length = NOINIT_RAM_SIZE  

    This is out of the valid range of SRAM which is 0x0800_0000~0x0808_0000

  • Hi,

    I don't think my NOINIT_RAM section is out of valid range. NOINIT_RAM_START_ADDR is RAM_START_ADDR + RAM_SIZE which is 0x08005600+0x0007A900=0x0807FF00 and NOINIT_RAM_SIZE is 0x000000100. So it should fit in the valid RAM, that is not an issue. Also I could validate these sections in the map file:

      STACKS                08000000   00004e00  00000000  00004e00  RW  
      KRAM                  08004e00   00000800  00000168  00000698  RW  
      RAM                   08005600   0007a900  0006b5cf  0000f331  RW  
      NOINIT_RAM            0807ff00   00000100  00000070  00000090  RW  

    About the HW memory initialization and the RAM PBIST: as I can see these are performed during the c_init inside the mem_init function. Before even getting to this point with the debugger the content of the NOINIT_RAM section is cleared right on the reset trigger.

    In the reference manual at section 8.3.8 L2RAMW Memory Initialization Domain Register (MEMINIT_DOMAIN) I ound that the MEMINIT_ENA bits are all set to enabled on reset. Could this cause the ram to be initialized?

    So, is there any other settings to prevent clearing the ram on warm reset?

  • Hi Marton,

    Sorry for my wrong calculation.

    the MEMINIT_ENA bits are all set to enabled on reset. Could this cause the ram to be initialized?

    No, this doesn't initiate the SRAM auto-Initialization. The MEMINIT_ENA bits are used to turn on the RAM domains (8 domains in total), and those domains are enabled by default. The auto-init starts when MINITGENA is set (0xA) , and MSINENA[0] is set. So the default settings of MEMINIT_ENA doesn't start the memory init.

    Do you enable the cache by calling  _cacheEnable_() before your read the variable? When you enable cache, it will first invalidate all data in the cache memory. Your data is first stored in the level-2 SRAM. As the data is read, it is then stored in cache for fast access in the future. When you do a reset, the CPU starts from _c_init00() and will execute the _cacheEnable_() to invalidate the cache. The data in cache is cleared while the level-2 SRAM is not updated  due to the cache write-back scheme.

    One question for you:

    I am not sure if the following declaration is valid or not, and I don't have HW board to try now.

    #define NON_VOLATILE_DATA __attribute__ ((section(".noinit")))
    NON_VOLATILE_DATA static char data[16];

    Before I try them, can you use the following way which is listed in compiler (TI ARMCL compiler) user guide:

    https://www.ti.com/lit/ug/spnu151v/spnu151v.pdf

    #pragma NOINIT (x )
    int x;

     

  • Hi,

    Thanks for the link, but I think my problem is not linker related.

    I've tried the #pragma NOINIT (x ) declaration, and according to the map file my non volatile variable will be placed in a section called .TI.noinit, but it is still initialized to zero upon reset.

    This is what I see from the debug session when the non volatile variable have been written:

    And this is right after the warm reset, the PC is still on the resetEntry before c_init, and the non volatile variable is cleared:

  • This is what I see from the debug session when the non volatile variable have been written

    Is the non volatile variable in an address which is Write-Back cacheable?

    If so, after the warm reset occurs the variable might not have been written to actual SRAM before the warm reset occurred.

  • I've checked my mpu configurations, the cache is enabled but all mpu regions are set to default in Halcogen, and the cache has been disabled for the SRAM range.

    I even tried to create a new mpu region with parameters: shared and the cache disabled:

    The issue is the same as before, after reset the PC is on the reset vector, and the RAM has been cleared.

    Is there any way to disable Write-Back cache for this memory region?

  • Hi Marton,

    If the memory region (#7) is "Normal_OINC_SHARED", the data in this region will not be cleared if this region is type=NOINT

    If the memory region (#7) is "Normal_OIWTNOWA_NONSHARED", the data in this region will not be cleared if this region is type=NOINT

    sys_main.c:

    #define NON_VOLATILE_DATA __attribute__ ((section(".noinit")))
    NON_VOLATILE_DATA static char data[16];

    sys_link.cmd:

    .noinit : {} > NOINIT_RAM  type=NOINIT

    sys_startup.c:

    the _memInit_() should be commented out

    // _memInit_();

    You can select the OIWT (write-through) or OIWB(write-back) from the drop-down menu:

  • I've disabled the cache write back for the whole SRAM region, and the result is the same: after the warm reset the debugger is on the "resetEntry:b   _c_int00" and the RAM has been cleared.

    I have also tried with the above configurations with memInit() commented out, the RAM still has been cleared.

    I have no clue what would I have missing.
    I'm starting to doubt that no-init ram on warm reset on this MCU is not possible.

    Are there any working example for this scenario? (for no-init ram to store data on warm reset)?

  • Hi Marton,

    I don't have a working standalone project. I will create a simple one for you later.

  • After reset, the variables at 0x0807f000 memory region are not cleared:

  • TMS570LC43x_GlobalVariables_NoInit.zip

    Here is the ccs project used for my test

  • In my CCS example project:

    MPU settings:

    1. cache is enabled

    2. NOINIT_RAM is mapped to 0x0807F000, MPU region 15, write through

    Linker CMD:

    The NOINIT_RAM is mapped to 0x0807F000, 4KB size

    The sections (defined in sys_main.c) .noinit0 and .noinit1 are allocated to NOINT_RAM with type=NOINIT

    sys_main():

    Three global variables are declared and defined in sys_main.c. Those three variables are placed in two no-initialized sections: .noinit0 and .noinit1

    1. add breakpoints at while(i==0); and while(1) in main()

    2. run the code to while(i==0), then suspend the code execution, change i to 1 manually in Expression window

    3. run the code to while(1); All the three variables are assigned, and they are located at MPU region 15  (from 0x0807F0000). Check the variables in this region:

    4. click CCS--Tools--reset --> System reset, then CCS--Tools --> restart, execution will stop at the first breakpoint while(i==0), please check the value in MPU region 15. The value should be unchanged.

    5. Press nRST button on your board, when execution stops at the first while(), please check the value in MPU region 15. The value should be unchanged.

  • Hi QJ,

    Thank you for the example, it is working just fine. I tried to modify my own project with the settings from this example and it still not worked for me for the first time.

    Then I realized that I am using FreeRTOS in my project and in the rtos port implementation the MPU has been re-initialized by the RTOS, so that was the cause of my changes in the MPU settings were not working.

    With changing the RTOS mpu settings everything works fine.
    Thank you for the support!

    Best regards,
    Marton

  • Nice to know, thanks