PPC : Locating variables at fixed addresses

Discussion created by Guest on Jan 14, 2009
Latest reply on Jan 14, 2009 by Guest
A similar thread "Coldfire: Locating variables at fixed addresses " is already opened.
But to avoid confusion between architectures, I open a new thread for ppc.
I am using  codewarrior V8.1, and more precisly linker V3.0.4, for mpc565.
Yes , this is an old project.
I simply try to put a string in a specific area of flash.
I have already searched FAQ and forum for a solution, but I still can't manage to do it.
Here is  what I currently have in a source file :
#define BOOT_VERISON "0.8"...#pragma push#pragma section data_type const_type ".boot_version" ".boot_version" data_mode=far_absunsigned char boot_version_string[]=BOOT_VERSION;unsigned long dummy_try=0x55AA55AA;#pragma pop

 and here is the interesting part of my .lcf file :

MEMORY {  ram : org = 0xFFF70000, len = 0x00020000 //data en ram externe  rom : org = 0x00000000, len = 0x000FDFFE //Code en flash interne  boot_info : org = 0x000FFFF0, len = 0x0000000F // Bootloader version}FORCEACTIVE{boot_version_string, dummy_try } SECTIONS { ...
      //.boot_version (CONST) BIND(0x000FFFF0): {} > boot_info  .boot_info:  {    *(.boot_version)  }>boot_info

With linker command line options:
-lcf $(IRFDIR)5xx_Axiom_ROM_winidea.lcf -L$(CMPDIR)PowerPC_EABI_Support\MSL\MSL_C\PPC_EABI\Lib -fp hard -o  $(OUTPUTDIR)$(OUTPUTFILE) -nostdlib -big -proc 56x -g -romaddr 0x00000000 -map debug.map @obj_list.txt -sdata2 2


The "boot_version_string" is locate in .sdata :smileysad:



I previously tried with this source file extract (and the same .lcf) :

#pragma push//#pragma readonly_strings//#pragma options(no_conststringconv)//#pragma const_strings on#pragma force_active on#pragma section const_type ".boot_version"__declspec(section ".boot_version") const UINT8 boot_version_string[]=BOOT_VERSION;#pragma section const_type#pragma force_active reset#pragma pop

 This way, "boot_version_string" is well located in .boot_info section,  but debug.map show that linker has put the variable elswhere in flash and try to copy it at c_init into the desired location (which is obviously not possible, and not what is expected)


Now, If I remove the -romaddr 0x000000 from command line tool, the "boot_version_string" is located at the chosen address 0x000FFFF0  (I verified with ICD probe), but I don't have .data section initialized anymore (all is linked without considering it is a rom image ?). Obvously, nothing works correctly wihtout .data initialization.


I have tried many things... But still can't manage to locate my string into a specific flash area.


Any idea ?