Mark Butcher

Conditional assembly and linking (M5223X / CW6.3 / CW6.4)

Discussion created by Mark Butcher on Aug 27, 2007
Latest reply on Aug 28, 2007 by Mark Butcher
Hi

I am wondering whether there is a method to solve a configuration which presently has to be performed carefully by hand.

I have a boot loader which has two settings - it either programs the FLASH from code which has been uploaded to a specific area in internal FLASH or else to an external SPI FLASH memory.

The project is configured to work with either, by setting a define which solves all C-code and assembler code issues. However there is still one issue which is open:

- the linker script defining where the code is linked to must set the FLASH to either 0x800 or 0x1000

Are there any possibilities to add define dependent linker script code?

EG:
#ifdef SPI_FLASH
MEMORY
{
    flash   (RX)   : ORIGIN = 0x0001000, LENGTH = 0x0003F000  /* Use this for boot loader with SPI FLASH */
    vectorram(RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
    sram    (RWX)  : ORIGIN = 0x20000400, LENGTH = 0x00007C00        
    ipsbar  (RWX)  : ORIGIN = 0x40000000, LENGTH = 0x0
}
#else
MEMORY
{
    flash   (RX)   : ORIGIN = 0x0000800, LENGTH = 0x0003F800    /* Use this for boot loader from internal FLASH */
    vectorram(RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
    sram    (RWX)  : ORIGIN = 0x20000400, LENGTH = 0x00007C00        
    ipsbar  (RWX)  : ORIGIN = 0x40000000, LENGTH = 0x0
}
#endif


Regards

Mark Butcher

Outcomes