Hi All !

During use of .noinit section I found that it is very useful to have a
constant
that is the offset between variable addres in .noinit section (RAM) and
address of
variable initializer (in ROM).
E.g.  __noinit_rom_offset=__noinit_start_rom-__noinit_start

You can imlement a function for retrieve default values for any .noinit
variable:

//Somewhere in th .h file
#define NoinitDefault(v) __NoinitDefault(v,sizeof(v))


; function source
.global __NoinitDefault

.func __NoinitDefault

__NoinitDefault:
   ; Address of noinit variable in RAM is in R15, variable size is in R14
   mov.w r15,r13                                    ; noinit data in flash
start
   add.w #__noinit_rom_offset,R13  ; variable initializer address is in R13
.Lcopy_noinit_loop:
   mov.b @r13+,@r15                         ; initialize noinit variable
with default value
   inc.w r15
   dec.w r14
   jnz   .Lcopy_noinit_loop

.endfunc

I have patched ldscripts with string at the bottom of the files
(elf32msp430.sc, elf32msp430_3.sc)

 PROVIDE (__noinit_rom_offset = _etext + SIZEOF (.data)-__noinit_start ) ;

What do you think about this feature ?

All the best,
Oleg.


Reply via email to