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/LAUNCHXL-CC1352P: #pragma NOINIT doesn't seem to work

Part Number: LAUNCHXL-CC1352P
Other Parts Discussed in Thread: CC1310

Tool/software: TI C/C++ Compiler

Hi, I am using  CCS Version: 9.3.0.00012  and have issues with NOINIT

I need to have a variable in RAM that preserves its value after a pin reset.  I tried a few approaches:

1. use NOINIT pragma

#pragma NOINIT(myVar)
int myVar;

The linker would complain with "warning #10247-D: creating output section ".TI.noinit" without a SECTIONS specification" and it can be hashed with

.TI.noinit      :     > SRAM, type = NOINIT  

in the linker command file,  but  myVar would always be zeroed after the reset. 

2. use DATA_SECTION

#pragma DATA_SECTION(myVar, ".myNoInitSect:myVar")
int myVar;

and in the linker cmd file adding this:

myNoInitSect:myVar     :  > SRAM, type = NOINIT

The same result - the variable is always zeroed on reset

3.  Use a  free location in RAM like here

int *myValPtr = (int *)0x20012000;

and later when I need, I would set it to whatever I need like 

*myValPtr = 0x12345;

This worked well in our cc1310 based product in CCS version 6, but doesn't work now - the location is zeroed on reset

The same happens if I use #pragma location =0x20012000

In all the cases the map file says that the section in which I have my variable is UNINITIALIZED, but it still is zeroed on reset. 

What am I doing wrong?

Thanks

Sergey

 

  • I suspect the compiler and linker work correctly.  To verify that run a command similar to this one ...

    % armofd -v --obj_display=none,sections -o file_ofd.txt file.out

    The armofd command is located in the same directory as the compiler.  A typical location is ...

    C:\ti\ccs1000\ccs\tools\compiler\ti-cgt-arm_20.2.0.LTS\bin

    It documented in the ARM assembly tools manual.  The -o option specifies a text file for the output.  Change the last parameter file.out to the final output executable file created by the linker.  Search the output file for the .TI.noinit section.  It will appear similar to ...

        <6> ".TI.noinit"
           Load Address:        0x000000c0  Run Address:        0x000000c0   
           Size:                0x4         Alignment:          4            
           Loaded Onto Device:  Yes         Address Unit Size:  8 bits       
           File Offset:         0xd8        # Relocs:           0            
           Section Type:        SHT_NOBITS  ELF sh_flags:       0x00000003   
           ELF sh_flag:         SHF_WRITE   ELF sh_flag:        SHF_ALLOC    
           TI ext_flags:        0x10        TI ext_flag:        TI_SHF_NOINIT
    

    Do you see the flag TI_SHF_NOINIT?  If so, then the compiler and linker worked correctly.

    Please let me know what you see.  Depending on what that is, I may notify other experts about this thread.

    Thanks and regards,

    -George

  • Hi George,

    Yes, I see that flag, and I still confirm that the variable is cleared after reset. 

    <18> ".TI.noinit"
           Load Address:        0x200000d8  Run Address:        0x200000d8  
           Size:                0x4         Alignment:          4           
           Loaded Onto Device:  Yes         Address Unit Size:  8 bits      
           File Offset:         0x1cc2c     # Relocs:           0           
           Section Type:        SHT_NOBITS  ELF sh_flags:       0x00000003  
           ELF sh_flag:         SHF_WRITE   ELF sh_flag:        SHF_ALLOC   
           TI ext_flags:        0x10        TI ext_flag:        TI_SHF_NOINIT

     

    Sergey

  • Hello Sergey,

    What kind of reset is performed? Board reset?

    Have you tried to detach the debugger and run a test where you print debug over UART?

  • Hello Sergey,

    The RAM is cleared to 0 at boot in CC1352. This does not occur on CC1310. 

    Please refer to section "9.5 SRAM Auto-Initialization" in the TRM:

    The SRAM can be initialized by dedicated auto-initialization hardware. All memory locations are initialized

    to zero and the parity information is initialized as required.

  • Thanks, Eirik, for pointing this out! It didn't even occur to me that it was possible.  As such I didn't check the TRM.  Shame :(

    Best regards, 

    Sergey