# HG changeset patch # User Michael Spacefalcon # Date 1377465620 0 # Node ID f459043fae0cb1c759d07618554a177ef47444c3 # Parent 3641e44f044e4f2c1326304a6cd9eddbd92d1f21 nuc-fw config: ld script generation implemented diff -r 3641e44f044e -r f459043fae0c .hgignore --- a/.hgignore Sun Aug 25 20:13:24 2013 +0000 +++ b/.hgignore Sun Aug 25 21:20:20 2013 +0000 @@ -11,7 +11,8 @@ ^nuc-fw/build\.conf$ ^nuc-fw/config\.stamp$ -^nuc-fw/finlink/.*\.map +^nuc-fw/finlink/.*\.ld$ +^nuc-fw/finlink/.*\.map$ ^nuc-fw/include/config\. ^target-utils/.*/crt0\.S$ diff -r 3641e44f044e -r f459043fae0c nuc-fw/finlink/Makefile --- a/nuc-fw/finlink/Makefile Sun Aug 25 20:13:24 2013 +0000 +++ b/nuc-fw/finlink/Makefile Sun Aug 25 21:20:20 2013 +0000 @@ -24,8 +24,14 @@ xipcode.o: ${EXT_PIECES} ${LD} -r -o $@ ${EXT_PIECES} -ramImage.elf: iramcode.o xipcode.o ${LOCAL_LIBS} xram.lds - ${LD} -N -T xram.lds -o $@ -Map ramImage.map iramcode.o xipcode.o \ +flashImage.ld: ld-script.src flash.m4 ../include/config.m4 + m4 flash.m4 ld-script.src > $@ + +ramImage.ld: ld-script.src xram.m4 ../include/config.m4 + m4 xram.m4 ld-script.src > $@ + +ramImage.elf: iramcode.o xipcode.o ${LOCAL_LIBS} ramImage.ld + ${LD} -N -T ramImage.ld -o $@ -Map ramImage.map iramcode.o xipcode.o \ --start-group ${LOCAL_LIBS} --end-group \ --start-group ${LIBC_A} ${LIBGCC_A} --end-group @@ -33,6 +39,6 @@ ${OBJCOPY} -O srec --srec-forceS3 --srec-len=30 $< $@ clean: - rm -f *.o *errs *core *.elf *.bin *.srec + rm -f *.o *errs *core *.elf *.bin *.srec *.ld *.map FRC: diff -r 3641e44f044e -r f459043fae0c nuc-fw/finlink/flash.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nuc-fw/finlink/flash.m4 Sun Aug 25 21:20:20 2013 +0000 @@ -0,0 +1,1 @@ +define(`Buildmem',`FLASH')dnl diff -r 3641e44f044e -r f459043fae0c nuc-fw/finlink/ld-script.src --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nuc-fw/finlink/ld-script.src Sun Aug 25 21:20:20 2013 +0000 @@ -0,0 +1,108 @@ +dnl This ld script source is fed through m4 in order to fill in +dnl those settings which depend on the configuration. +dnl Memory region sizes are set in ../include/config.m4, generated +dnl by the configuration mechanism based on the selected target, +dnl and the Makefile prepends flash.m4 or xram.m4 to select the +dnl type of image we are linking: either the regular flashable image, +dnl or a RAM-only test image (to be loaded via fc-xram) that does not +dnl touch the flash and pretends as if the flash doesn't even exist. + +/* + * FreeCalypso ld script for the Buildmem build + */ + +ENTRY(ifelse(Buildmem,XRAM,_FlashorXram_entry,0)) + +include(`../include/config.m4')dnl +MEMORY { +ifelse(Buildmem,FLASH, +` FLASH_OVERLAY : ORIGIN = 0, LENGTH = 0x2000 + FLASH : ORIGIN = 0x2000, LENGTH = CONFIG_FWFLASH_SIZE - 0x2000') + IRAM : ORIGIN = 0x00800000, LENGTH = CONFIG_IRAM_SIZE + XRAM : ORIGIN = 0x01000000, LENGTH = CONFIG_XRAM_SIZE +} + +SECTIONS { + /* XIP code, going into flash or XRAM emulating flash */ + xip.text : { + *(xip.text*) + xipcode.o(.text*) + *libplus.xip.a:(.text*) + *libsprintf.a:(.text*) + /* let's put the ARM->Thumb veneers in the XIP section */ + *(.glue_7) + } > Buildmem + + /* copy-to-IRAM code */ + iram.text 0x80001C : { + /* the 7 exception and interrupt vectors @ 0x80001C */ + *(iram.vectors) + *(iram.text*) + iramcode.o(.text*) + *libplus.iram.a:(.text*) + *libc.a:(.text*) + *libgcc.a:(.text*) + } > IRAM AT> Buildmem + __iramtext_ram_addr = ADDR(iram.text); + __iramtext_flash_addr = LOADADDR(iram.text); + __iramtext_size = SIZEOF(iram.text); + + /* all .rodata will stay in flash */ + .rodata : { + *(.rodata*) + } > Buildmem + + /* + * All .data will go into XRAM. + * For the flash build we'll have a step that copies + * the .data section from flash to XRAM; for the RAM-only + * build it goes directly into XRAM and stays there. + */ + .data : { + *(.data*) + } > XRAM AT> Buildmem +ifelse(Buildmem,FLASH, +` __initdata_ram_addr = ADDR(.data); + __initdata_flash_addr = LOADADDR(.data); + __initdata_size = SIZEOF(.data); +')dnl + + /* we have two kinds of BSS: internal and external */ + int.bss (NOLOAD) : { + *(int.bss*) + iramcode.o(.bss* COMMON) + *libplus.iram.a:(.bss* COMMON) + *libc.a:(.bss* COMMON) + *libgcc.a:(.bss* COMMON) + . = ALIGN(4); + } > IRAM + __intbss_start = ADDR(int.bss); + __intbss_size = SIZEOF(int.bss); + + ext.bss (NOLOAD) : { + *(ext.bss*) + xipcode.o(.bss* COMMON) + *libplus.xip.a:(.bss* COMMON) + *libsprintf.a:(.bss* COMMON) + . = ALIGN(4); + } > XRAM + __extbss_start = ADDR(ext.bss); + __extbss_size = SIZEOF(ext.bss); + + /* finally, we have "raw RAM": like BSS, but we don't zero it out */ + int.ram (NOLOAD) : { + *(int.ram*) + *(system_stack) + *(irq_stack) + *(fiq_stack) + *(timer_hisr_stack) + . = ALIGN(4); + _iram_end = .; + } > IRAM + + ext.ram (NOLOAD) : { + *(ext.ram*) + . = ALIGN(4); + _xram_end = .; + } > XRAM +} diff -r 3641e44f044e -r f459043fae0c nuc-fw/finlink/xram.lds --- a/nuc-fw/finlink/xram.lds Sun Aug 25 20:13:24 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * This linker script is used when building the ramImage version of - * FreeCalypso firmware: the version which is to be test-run via fc-xram - * without touching the flash. Everything is loaded into IRAM or XRAM, - * and in this ld script we pretend as if the actual flash memory - * does not exist. - */ - -ENTRY(_FlashorXram_entry) - -MEMORY { - IRAM : ORIGIN = 0x00800000, LENGTH = 512K - XRAM : ORIGIN = 0x01000000, LENGTH = 8M -} - -SECTIONS { - /* XIP code, using XRAM to emulate flash */ - xip.text : { - *(xip.text*) - xipcode.o(.text*) - *libplus.xip.a:(.text*) - *libsprintf.a:(.text*) - /* let's put the ARM->Thumb veneers in the XIP section */ - *(.glue_7) - } > XRAM - - /* copy-to-IRAM code */ - iram.text 0x80001C : { - /* the 7 exception and interrupt vectors @ 0x80001C */ - *(iram.vectors) - *(iram.text*) - iramcode.o(.text*) - *libplus.iram.a:(.text*) - *libc.a:(.text*) - *libgcc.a:(.text*) - } > IRAM AT> XRAM - __iramtext_ram_addr = ADDR(iram.text); - __iramtext_flash_addr = LOADADDR(iram.text); - __iramtext_size = SIZEOF(iram.text); - - /* all .rodata will stay in flash */ - .rodata : { - *(.rodata*) - } > XRAM - - /* all .data will go into XRAM */ - .data : { - *(.data*) - } > XRAM - - /* we have two kinds of BSS: internal and external */ - int.bss (NOLOAD) : { - *(int.bss*) - iramcode.o(.bss* COMMON) - *libplus.iram.a:(.bss* COMMON) - *libc.a:(.bss* COMMON) - *libgcc.a:(.bss* COMMON) - . = ALIGN(4); - } > IRAM - __intbss_start = ADDR(int.bss); - __intbss_size = SIZEOF(int.bss); - - ext.bss (NOLOAD) : { - *(ext.bss*) - xipcode.o(.bss* COMMON) - *libplus.xip.a:(.bss* COMMON) - *libsprintf.a:(.bss* COMMON) - . = ALIGN(4); - } > XRAM - __extbss_start = ADDR(ext.bss); - __extbss_size = SIZEOF(ext.bss); - - /* finally, we have "raw RAM": like BSS, but we don't zero it out */ - int.ram (NOLOAD) : { - *(int.ram*) - *(system_stack) - *(irq_stack) - *(fiq_stack) - *(timer_hisr_stack) - . = ALIGN(4); - _iram_end = .; - } > IRAM - - ext.ram (NOLOAD) : { - *(ext.ram*) - . = ALIGN(4); - _xram_end = .; - } > XRAM -} diff -r 3641e44f044e -r f459043fae0c nuc-fw/finlink/xram.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nuc-fw/finlink/xram.m4 Sun Aug 25 21:20:20 2013 +0000 @@ -0,0 +1,1 @@ +define(`Buildmem',`XRAM')dnl