Initialization of global variables not working

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

Initialization of global variables not working

Jump to solution
1,360 Views
anze
Contributor I

Hello,

 

I have a problem concerning explizit initialization of global variables. Every global variable which I define & declare in a c-File is not getting initialized to the desired value. Before copying them from flash to ram, all the variables are set to 0. After copying, they are filled with "1".

In the .map file I can see, that these variables are in the .data and .sdata sections so i guess something is wrong with my startup code.

I am using CW 10.2 and MPC5643L (Leopard). For initialization I use RAppID generated files.

 

My linker-file, startup-code and the copy-routine are attached.

 

Does anybody know this issue?

Any help would be appreciated.

Thanks in advance.

Original Attachment has been moved to: crt0_p0.s.zip

Original Attachment has been moved to: default5643L.lcf.zip

Original Attachment has been moved to: romcopy.inc.zip

Labels (1)
0 Kudos
1 Solution
774 Views
CrasyCat
Specialist III

Hello

You need to Create a ROM Image for your application.

This is done as follows:

If you are building from the IDE

  1. Open the Project Properties dialog
  2. Go to the C/C++ Build > Settings > PowerPC Linker > Output page.
  3. Check the Generate ROM image check box. 
  4. In the ROM Image Address text box, specify the start address of the area of flash memory. 
  5. In the RAM Buffer Address text box specify the same address as in the ROM Image    


If you are building from the command line

Add the options -romaddr and -rambuffer with the start address of your flash area.

CrasyCat

View solution in original post

0 Kudos
2 Replies
775 Views
CrasyCat
Specialist III

Hello

You need to Create a ROM Image for your application.

This is done as follows:

If you are building from the IDE

  1. Open the Project Properties dialog
  2. Go to the C/C++ Build > Settings > PowerPC Linker > Output page.
  3. Check the Generate ROM image check box. 
  4. In the ROM Image Address text box, specify the start address of the area of flash memory. 
  5. In the RAM Buffer Address text box specify the same address as in the ROM Image    


If you are building from the command line

Add the options -romaddr and -rambuffer with the start address of your flash area.

CrasyCat

0 Kudos
774 Views
anze
Contributor I

Hello,

Thank you very much for your help. After a little trying I got it to work with your suggestion.

The thing is that I have to specify the internal flash adress in both fields (0x00002000 in my case).

Now it works like a charme!

0 Kudos