Initialization of BSS section to zero in the Linker command file

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Initialization of BSS section to zero in the Linker command file

3,152件の閲覧回数
chr
Contributor I
Hi,
I am working with MCF5282 Controller.
The problem is :
 
  I need to initialize the total bss section to zero(default  data)in the Linker command file
 I used the FILL attribute for output section but it is giving error.
  Section
  {
     data :
     {
      *(.bss)
      *(COMMON)
 
     }> Data_Memory = 0x0000
 }
  
  How to use that?
 can anybody give the correct syntax?
 
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

989件の閲覧回数
sjmelnikoff
Contributor III
The FILL attribute is used primarily to fill unused areas of flash and EEPROM when the device is programmed; it won't work for RAM.
 
If you want to zero the RAM at startup, you need to write some code to do it. To avoid messing up the stack, it may be best to do it right at the start of initialisation, and in assembler so you can ensure that any variables you use are stored in registers, not RAM.
 
In any case, the default startup code already does this, so you might want to have a look at that.
 
Steve.
0 件の賞賛
返信

989件の閲覧回数
Kremer
Contributor I
 You need something like:
 
register uint32 n;
register uint8  *sp;
 
 if (__BSS_START != __BSS_END)
 {
  sp = (uint8 *)__BSS_START;
  n = (uint32)(__BSS_END - __BSS_START);
  while (n--)
   *sp++ = 0;
 }
 
 Courtesy code by freescale.
 
 Regards
 
0 件の賞賛
返信