PPC : Locating variables at fixed addresses

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

PPC : Locating variables at fixed addresses

4,096 Views
admin
Specialist II
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 :
Code:
#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 :

Code:
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:
Code:
-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) :

Code:
#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 ?

 

Thanks.

 
 
Labels (1)
0 Kudos
Reply
4 Replies

823 Views
admin
Specialist II
Funny thing : I was about to post that it works well with LOAD command !
 
Thanks a lot for your help !
And one more time, thank you for your answering so fast.
 
 
0 Kudos
Reply

823 Views
stanish
NXP Employee
NXP Employee
Hi Sil,

I assume you 'd like to treat string boot_version_string[] as a constant. Perhaps due to the small data thresholds settings the placement is different then expected.
So I'd suggest you to modify data definition to:

Code:
Code:#define BOOT_VERISON "0.8"...#pragma push#pragma section sconst_type const_type ".boot_version" ".boot_version" data_mode=far_absconst unsigned char boot_version_string[]=BOOT_VERSION;const unsigned long dummy_try=0x55AA55AA;#pragma pop

where

 -sconst_type option forces linker to place even constants which size is less then small data threshold into ".boot_version" section.
  - I've defined data objects within pragmas as the constants

There are two threshold that could be set either directly in CW IDE (Alt+F7 Project settings -> "EPPC Target" -> "Small Data" and "Small Data2" editboxes) or in the command line ( -sdata[threshold] xx,  -sdata2[threshold] xx) in order to separate data objects into small data sections.


Stanish

0 Kudos
Reply

823 Views
admin
Specialist II
Hi Stanish, and thanks for your fast reply !
 
Your suggestion sounds good to me.
string is now located into .boot_version section. (thus there was an issue with data size trheshold in my first try)
 
But unfortunatly, boot_info section is still considered as non constant data section by linker.
Here is debug.map generated with your suggestion :
Code:
Memory map:                   Starting Size     File     ROM      RAM Buffer                   address           Offset   Address  Address           .reset  00000000 00003224 00000380 00000000 02800000            .init  00003224 00000828 000035a4 00003224 02803224            .text  00004000 000295ec 00003dd0 00004000 02804000          .rodata  0002d5f0 00001810 0002d3c0 0002d5f0 0282d5f0           .ctors  0002ee00 00000008 0002ebd0 0002ee00 0282ee00           .dtors  0002ee08 00000008 0002ebd8 0002ee08 0282ee08            extab  0002ee10 00000888 0002ebe0 0002ee10 0282ee10       extabindex  0002f698 00000cfc 0002f468 0002f698 0282f698       .boot_info  000ffff0 00000008 00030164 00030394 02830394...

 
Virtual address of .boot_info section is 0x000ffff0 (internal flash) as expected, but ROM address is 0x00030394 (internal flash too).
"c_init" still tries to initialize .boot_info section as if it was in RAM.
 
 
0 Kudos
Reply

823 Views
stanish
NXP Employee
NXP Employee
Sil,

I'd suggest you to adjust your linker command file using LOAD command in order to get correct ROM image adresses.

Code:
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 LOAD(0x000FFFF0): {} > boot_info
...
}

LOAD linker command should be implemented since v8.0.
I've attached PPC release notes for more details about the LOAD command.

Hope it will help you.



Message Edited by stanish on 2009-01-14 05:27 PM
0 Kudos
Reply