This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to get memory slot not zeroed

I see options for target

default start      size   Noinit
        0x20000000 0x200
V       0x20000200 0xffff   v

and still a variable @ 0x20001348 zeroes out on reset/run

Erik

what then is the meaning of the noinit checkbox? the variable zeroes out on startup

Erik

Parents
  • Try just the dwPuppyMunch, the same approach you have for the scatter file and the attribute for dwPuppyMunch worked for me. You need the zero_init in the attribute to force a small global into a specific segment but I think you might be assigning conflicting attributes by dropping the zero_init in the next line and then using the #pragma.

    The confusing part is that even though you tell the linker to UNINIT the segment, zero_init is needed to override the default placement algorithm. The default is to silently put small globals into the normal data segment.

    Andrew

Reply
  • Try just the dwPuppyMunch, the same approach you have for the scatter file and the attribute for dwPuppyMunch worked for me. You need the zero_init in the attribute to force a small global into a specific segment but I think you might be assigning conflicting attributes by dropping the zero_init in the next line and then using the #pragma.

    The confusing part is that even though you tell the linker to UNINIT the segment, zero_init is needed to override the default placement algorithm. The default is to silently put small globals into the normal data segment.

    Andrew

Children
  • DWORD dwPuppyMunch __attribute__( ( section( "NoInit"),zero_init) ) ;
    //DWORD dwPuppyFood __attribute__( ( section( "NoInit")) )  ;
    DWORD dwPuppyFood  ;
    
    //#pragma arm section zidata = "NoInit"
    DWORD dwPuppyChow;                        //uninit (in non_init section)
    //#pragma arm section zidata                //back to default (.bss section)
    

    andrew, please do me the favor of checking your reference, the above still initializes dwPuppyMunch

    thanx,

    Erik

  • Hi Erik,

    The program below, compiled with "use micro-lib", uVision 4.22.22:

    #include <stdio.h>
    #include <stdint.h>
    #include "stm32f10x.h"
    
    int32_t NoInit____zero_init __attribute__( ( section( "NoInit"),zero_init) ) ;
    int32_t NoInit __attribute__( ( section( "NoInit")) ) ;
    int32_t simpleGlobal;
    
    int main(void)
    {
            printf("NoInit-zero_init is %d at %x\n", NoInit____zero_init, (int)&NoInit____zero_init);
            printf("NoInit is %d at %x\n", NoInit, (int)&NoInit);
            printf("simpleGlobal is %d at %x\n", simpleGlobal, (int)&simpleGlobal);
    
            return 1;
    }
    

    prints out:

    NoInit-zero_init is 103643149 at 20000004
    NoInit is 0 at 20000000
    simpleGlobal is 0 at 20000200

    using this scatter-load:

    LR_IROM1 0x08000000 0x00100000  {    ; load region size_region
      ER_IROM1 0x08000000 0x00100000  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
      }
      RW_IRAM1 0x20000000 UNINIT 0x00000200  { ;no init section
            *(NoInit)
       }
      RW_IRAM2 0x20000200 0x00018000  {  ; RW data
       .ANY (+RW +ZI)
      }
    }
    

    If you single step in the assembly view before you hit main you'll see that the scatterloader adds code to initialize the NoInit variable but not the NoInit____zero_init variable.

    Andrew

  • thanks a bunch, I'm stuck in meetings for the next 2 days, will report back

    Erik