Joseph Stepien

Coldfire: Locating variables at fixed addresses

Discussion created by Joseph Stepien on Aug 9, 2006
Latest reply on Jan 14, 2008 by Arev
I'm using CodeWarrior 6.2 for a ColdFire processor.  I'm trying to locate variables at specific locations in FLASH.  According to several different methods I can use:
 
1.
    MATRIX stMatrixInNVM:0x0001e000;
or
2.
#pragma define_section matrixdb ".matrixdb" RW
__declspec(matrixdb) MATRIX stMatrixInNVM; 
// where  above in .lcf
MEMORY
{
//  flash       (RX)  : ORIGIN = 0x00000000, LENGTH = 0x0001df80
  flash       (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00040000
  versioninfo (RW)  : ORIGIN = 0x0001df80, LENGTH = 0x00000080
  matrixdb   (RW)   : ORIGIN = 0x0001e000, LENGTH = 0x00002000
 vectorsram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
 sram      (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00007c00
 ipsbar     (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0
}
SECTIONS
{
    .matrixdb   : {} > matrixdb
}
 
or
3.
#pragma section .matrixdb begin
MATRIX stMatrixInNVM;
#pragma section .matrixdb end
 
Number 3. above is rejected by the compiler/linker/locator failing at the '.'  Absent the '.' it fails at the "end" identifier.
Numbers 1 and 2 are accepted but stMatrixInNVM doesn't appear in the memory map .xMAP file at the expected address as defined.  I thought perhaps it's there but just doesn't appear properly in the .xMap file.  I examined the code in Mixed mode and the address used for stMatrixInNVM is 0x00000000 so it looks as though the linker never reconciled it to the defined address.
 
Can anyone help me out here and tell me how to make variables appear at specific addresses in FLASH with initial values. 
 
This is fairly straightforward on the HCS08 by using the @ qualifier,
eg
MATRIX stMatrixInNVM @ 0xfd00; or
const char sApp_VersionNum[] @0xf3b0= "00.02";
Thanks.

Message Edited by CrasyCat on 2007-04-13 11:14 AM

Outcomes