Static Variables initialization error.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Static Variables initialization error.

1,904 Views
jk4657
Contributor I

Hi,  we have a product line using MCF5282 Coldfire. We use Gnu tools like

m68k-elf-gcc, m68k-elf-objcopy, m68k-elf-objdump, m68k-elf-nm.

 

All global Static variable initialization doesn't work, so that the SREC .S19 file generated by m68k-elf-objcopy has records related to the global variables that  cause errors when programming MCF5282 flash via Freescales's CF Flasher.

 

CF Flasher programms all records but the ones that have data related to global variable initialization.

 

The MCF5282's flash code is programmed ok, so that I can even execute the code.

However, the global variables are initialized to zero and not the values I need.

 

For example, a the following global static variable initialization

 

int array[] = { 10, 50 };

 

all its elements are set to 0.

 

While programming using a USB to BDM Coldfire programmer and using Freescale's CF Flasher, I get a number of error messages saying that certain Records that map to the global variable could not be programmed.

 

I think this may be a problem with m68k-elf-objcopy or that I have misconfigured the memory map.

 

Thanks for your help.

Labels (1)
0 Kudos
4 Replies

614 Views
bkatt
Contributor IV

jk4657 wrote:

 

However, the global variables are initialized to zero and not the values I need.



Somehow you have fouled up the linker file and/or the initialization code.

 

The normal process is that the linker file assigns these initialized variables addresses in RAM, and also creates a ROM (flash) section with their values, typically after the code section. Then both these sections are burned into flash.

 

Executable code during startup copies the ROM values into RAM as a block. Often this code is right next to the code that clears other parts of RAM to zero.

 

0 Kudos

614 Views
jk4657
Contributor I

Hi Yevgeni Tunik.

 

Thanks for your reply.

 

Unfortunately your suggestion doesn't work.

 

Any more suggestions ?

 

Thanks

 

JMK

0 Kudos

614 Views
admin
Specialist II

> I think this may be a problem with m68k-elf-objcopy or that I have misconfigured the memory map.

 

1. Try to create new project via the wizard. It will respore default project settings, including the memory map rules. Check initialization of the global static variables with the simplest example.

2. If the previous suggestion doen't help, try to reinstall your IDE.

 

I haven't your IDE. Thus, the suggestions are quite generic. 

0 Kudos

614 Views
admin
Specialist II

Try to use:

static int array[] = { 10, 50 };

 

> For example, a the following global static variable initialization

> int array[] = { 10, 50 };

> all its elements are set to 0.

 

 

0 Kudos