EmbeddedRelated.com
Forums

IAR linker setting for bootloader

Started by liew...@kenetics-group.com September 23, 2008
Hi all,

I have a bootloader which is located at flash memory 0x0000 to 0x4000 and ram memory 0x0000 to 0x2000. The bootloader itself has enabled the remap feature. Now, I wish to write my application in IAR but I have no idea on how to write my linker setting (*.xcl). Here is my non-working example. Any expert who can hint what was wrong? All kind of hints will be greatly appreciated.

//************************************************
// Inform the linker about the CPU family used.
// AT91SAM7S256 Memory mapping
// No remap
// ROMSTART
// Start address 0x0000 0000
// Size 256 Kbo 0x0004 0000
// RAMSTART
// Start address 0x0020 0000
// Size 64 Kbo 0x0001 0000
// Remap done
// RAMSTART
// Start address 0x0000 0000
// Size 64 Kbo 0x0001 0000
// ROMSTART
// Start address 0x0010 0000
// Size 256 Kbo 0x0004 0000

//************************************************
-carm

//* turn on segment map
-xs
//*************************************************************************
// Internal Ram segments mapped AFTER REMAP 64 K.
//*************************************************************************
-Z(CONST)INTRAMSTART_REMAP104000
-Z(CONST)INTRAMEND_REMAP105000

//*************************************************************************
// Read-only segments mapped to Flash 256 K.
//*************************************************************************
-DROMSTART104000
-DROMEND105000
-DROMSTART2105100
-DROMEND2137BFF

-DOEMCFGSTART137C00
-DOEMCFGEND13FFFF
-DOEMCFGLEN008400

//*************************************************************************
// Read/write segments mapped to 64 K RAM.
//*************************************************************************
-DRAMSTART202000
-DRAMEND20FFFF

//************************************************
// Address range for reset and exception
// vectors (INTVEC).
// The vector area is 32 bytes,
// an additional 32 bytes is allocated for the
// constant table used by ldr PC in cstartup.s79.
//************************************************
-Z(CODE)INTVEC 2000-20203F

//************************************************
// Startup code and exception routines (ICODE).
//************************************************
-Z(CODE)ICODE,DIFUNCT=ROMSTART-ROMEND,ROMSTART2-ROMEND2
-Z(CODE)SWITAB=ROMSTART-ROMEND,ROMSTART2-ROMEND2

//************************************************
// Code segments may be placed anywhere.
//************************************************
-Z(CODE)CODE=ROMSTART-ROMEND,ROMSTART2-ROMEND2

//************************************************
// Various constants and initializers.
//************************************************
-Z(CONST)INITTAB,DATA_ID,DATA_C=ROMSTART-ROMEND,ROMSTART2-ROMEND2
-Z(CONST)CHECKSUM=ROMSTART-ROMEND,ROMSTART2-ROMEND2

//************************************************
// Data segments.
//************************************************
-Z(DATA)DATA_I,DATA_Z,DATA_N=RAMSTART-RAMEND

//************************************************
// __ramfunc code copied to and executed from RAM.
//************************************************
-Z(DATA)CODE_I=RAMSTART-RAMEND
-Z(CONST)CODE_ID=ROMSTART-ROMEND,ROMSTART2-ROMEND2 // Initializer for
-QCODE_I=CODE_ID

//************************************************
// ICCARM produces code for __ramfunc functions in
// CODE_I segments. The -Q XLINK command line
// option redirects XLINK to emit the code in the
// debug information associated with the CODE_I
// segment, where the code will execute.
//************************************************

//*************************************************************************
// Stack and heap segments. (hex values)
//*************************************************************************
//-D_CSTACK_SIZE=(100*4)
// ASIDSING - made stack 4k (400*4) or 8k(800*4)
-D_CSTACK_SIZE=(400*4)
-D_IRQ_STACK_SIZE=(3*8*4)
-D_ABT_STACK_SIZE0

// ASIDSING note that these stacks are initialized in Cstartup.s79
// and are stuck at the end of RAM
-Z(DATA)CSTACK+_CSTACK_SIZE=RAMSTART-RAMEND
-Z(DATA)IRQ_STACK+_IRQ_STACK_SIZE=RAMSTART-RAMEND
-Z(DATA)ABT_STACK+_ABT_STACK_SIZE=RAMSTART-RAMEND
Additional information: I think also need to change assembler directive
ORG to "ORG 0x4000"