AnsweredAssumed Answered

URGENT: __init_data not working

Question asked by Maher MALAK on Sep 20, 2016
Latest reply on Oct 4, 2016 by Martin Kovar

Hi all,

 

I am working using CW_for_MPC55xx_and_MPC56xx_2.10

 

I have an initialized variable "numOfTests" that is mapped to RAM. As you can see in the attached linker file (XPC560XB_flash.lcf).

 

As it is an initialized variable, then it will be mapped to the ".sdata" section (small data with read/write permission).

uint16 numOfTests = 14;

So after flashing the ECU using a debugger, the value of "numOfTests" will be in ROM.

And to get the correct value, during startup, I need to copy that value from ROM and store it at the address of the variable "numOfTests" in RAM.

The variable "numOfTests" has an address "0x40000f08" as you can see in the attached map file (PA_XPC560XB_FLASH_ConTest_Standard.MAP).

 

I looked up in the example codes provided by Freescale, and I found the function "__init_data" in the "__start.c" file.

I added this file to my project, alongside other dependent files (__mem.h__ppc_eabi_init.c__ppc_eabi_init.h__ppc_eabi_linker.h -> all attached) and it compiles.

 

As I understood from the code, there is a table "_rom_copy_info" that is mapped to the section ".init": 

__declspec(section ".init") extern __rom_copy_info _rom_copy_info[]; /* An array of all initialized (data, text or mixed) sections */

As i guess and I don't know how, but this table is generated by the compiler.

 

 

When debugging :

The table "_rom_copy_info" has wrong values.

As we see below the rom is equal to addr (ram)

having this case and the condition in the function "__copy_rom_section" :

if (size && (dst != src)) {
memcpy(dst, src, size);
__flush_cache( dst, size );
}

where :

  • dst = addr
  • src = rom
  • size = size

Then the values of section ".sdata" will never be copied from ROM to RAM.

 

My questions are:

  1. Am I using correctly the example code?
  2. Am I defining correctly the sections in the linker file?
  3. How the compiler generates the variable "_rom_copy_info"?
  4. How can I know where are the values of the ".sdata" section are flashed in ROM, so I can manually copy them to RAM?
  5. is there a solution to my problem ?

 

PS: I also attached the compiler's options (PA_XPC560XB_mwerks_cfg.mak)

 

Thank you

Maher

Original Attachment has been moved to: PA_XPC560XB_mwerks_cfg.mak.zip

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

Original Attachment has been moved to: __start.c.zip

Original Attachment has been moved to: __ppc_eabi_linker.h.zip

Original Attachment has been moved to: __ppc_eabi_init.h.zip

Original Attachment has been moved to: __ppc_eabi_init.c.zip

Original Attachment has been moved to: __mem.h.zip

Original Attachment has been moved to: PA_XPC560XB_FLASH_ConTest_Standard.MAP.zip

Attachments

Outcomes