Initialization of BSS section to zero in the Linker command file

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Initialization of BSS section to zero in the Linker command file

3,154 次查看
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 回复数

991 次查看
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 项奖励
回复

991 次查看
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 项奖励
回复