From: Erik M. <er...@us...> - 2003-02-10 23:07:19
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv9435 Modified Files: Makefile.am chain.S start-ld-script start.S Log Message: The linker magic patch that fixes Kevin O'Neill's BLOB_START_SIZE problem. We basically ask ld to put blob-rest as a binary blob of data in the .data section of blob-rest-piggy.o. Tell the linker we want to link it with the first stage loaders, put a couple of addresses around blob-rest-piggy.o in the linker script, and all is set. I've tested this with the chain loader, but don't have a machine ready to test the real flash loader. It's obviously correct, though (famous last words :) Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- Makefile.am 4 Jan 2003 02:05:53 -0000 1.35 +++ Makefile.am 10 Feb 2003 23:07:03 -0000 1.36 @@ -22,13 +22,11 @@ # bin_PROGRAMS = \ - blob-start-elf32 \ - blob-start \ - blob-start-chain-elf32 \ - blob-start-chain \ blob-rest-elf32 \ blob-rest \ + blob-elf32 \ blob \ + blob-chain-elf32 \ blob-chain @@ -50,75 +48,10 @@ commands.c: ${top_srcdir}/src/commands/make_commands.sh @BLOB_COMMANDS@ > $@ -# ---- Blob first stage loader --------------------------------------- .S.o: $(COMPILE) -D__ASSEMBLY__ -c $< -# WARNING: start.S *must* be the first file, otherwise the target will -# be linked in the wrong order! -blob_start_elf32_SOURCES = \ - start.S \ - ledasm.S \ - testmem.S - -EXTRA_blob_start_elf32_SOURCES = \ - memsetup-sa1100.S \ - memsetup-sa1110.S \ - start-pxa.S \ - start-sa11x0.S - -blob_start_elf32_DEPENDENCIES = \ - @BLOB_MEMSETUP_OBJS@ \ - @BLOB_STARTCODE_OBJS@ \ - start-ld-script - -blob_start_elf32_LDFLAGS += \ - -Wl,-T,${srcdir}/start-ld-script \ - -Wl,-Map,blob-start-elf32.map - -blob_start_elf32_LDADD += \ - @BLOB_MEMSETUP_OBJS@ \ - @BLOB_STARTCODE_OBJS@ \ - -lgcc - - -blob_start_SOURCES = - - -blob-start: blob-start-elf32 - $(OBJCOPY) $(OCFLAGS) $< $@ - - - - -# ---- Blob first stage chain loader -------------------------------- - -# WARNING: chain.S *must* be the first file, otherwise the target will -# be linked in the wrong order! -blob_start_chain_elf32_SOURCES = \ - chain.S \ - ledasm.S - -blob_start_chain_elf32_DEPENDENCIES =\ - start-ld-script - -blob_start_chain_elf32_LDFLAGS += \ - -Wl,-T,${srcdir}/start-ld-script \ - -Wl,-Map,blob-start-chain-elf32.map - -blob_start_chain_elf32_LDADD += \ - -lgcc - - -blob_start_chain_SOURCES = - - -blob-start-chain: blob-start-chain-elf32 - $(OBJCOPY) $(OCFLAGS) $< $@ - - - # ---- Blob second stage --------------------------------------------- @@ -198,33 +131,75 @@ $(OBJCOPY) $(OCFLAGS) $< $@ +# create an object file from the binary so we can link it into the +# first stage loaders +blob-rest-piggy.o: blob-rest + $(LD) -r -o $@ -b binary $< -# ---- Final blob binary --------------------------------------------- +# ---- Blob first stage loader --------------------------------------- -blob_SOURCES = +# WARNING: start.S *must* be the first file, otherwise the target will +# be linked in the wrong order! +blob_elf32_SOURCES = \ + start.S \ + ledasm.S \ + testmem.S +EXTRA_blob_elf32_SOURCES = \ + memsetup-sa1100.S \ + memsetup-sa1110.S \ + start-pxa.S \ + start-sa11x0.S -blob: blob-start blob-rest - rm -f $@ - dd if=blob-start of=$@ bs=1k conv=sync - dd if=blob-rest of=$@ bs=1k seek=1 - chmod +x $@ +blob_elf32_DEPENDENCIES = \ + @BLOB_MEMSETUP_OBJS@ \ + @BLOB_STARTCODE_OBJS@ \ + start-ld-script \ + blob-rest-piggy.o +blob_elf32_LDFLAGS += \ + -Wl,-T,${srcdir}/start-ld-script \ + -Wl,-Map,blob-start-elf32.map +blob_elf32_LDADD += \ + @BLOB_MEMSETUP_OBJS@ \ + @BLOB_STARTCODE_OBJS@ \ + -lgcc -# ---- Final blob chain loader binary -------------------------------- +blob_SOURCES = -blob_chain_SOURCES = -blob-chain: blob-start-chain blob-rest - rm -f $@ - dd if=blob-start-chain of=$@ bs=1k conv=sync - dd if=blob-rest of=$@ bs=1k seek=1 - chmod +x $@ +blob: blob-elf32 + $(OBJCOPY) $(OCFLAGS) $< $@ + + +# ---- Blob first stage chain loader -------------------------------- + +# WARNING: chain.S *must* be the first file, otherwise the target will +# be linked in the wrong order! +blob_chain_elf32_SOURCES = \ + chain.S \ + ledasm.S + +blob_chain_elf32_DEPENDENCIES =\ + start-ld-script \ + blob-rest-piggy.o + +blob_chain_elf32_LDFLAGS += \ + -Wl,-T,${srcdir}/start-ld-script \ + -Wl,-Map,blob-start-chain-elf32.map + +blob_chain_elf32_LDADD += \ + -lgcc +blob_chain_SOURCES = + + +blob-chain: blob-chain-elf32 + $(OBJCOPY) $(OCFLAGS) $< $@ # ---- Automake administrativia -------------------------------------- @@ -234,7 +209,9 @@ rest-ld-script.in -CLEANFILES = ${srcdir}/*~ rest-ld-script commands.c *.map +CLEANFILES = \ + ${srcdir}/*~ rest-ld-script \ + commands.c *.map blob-rest-piggy.o DISTCLEANFILES = ${builddir}/.deps/*.P Index: chain.S =================================================================== RCS file: /cvsroot/blob/blob/src/blob/chain.S,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- chain.S 4 Nov 2001 23:12:50 -0000 1.2 +++ chain.S 10 Feb 2003 23:07:05 -0000 1.3 @@ -72,11 +72,13 @@ relocate: /* get a clue where we are running so we know what to copy */ - ldr r0, START + ldr r1, START /* relocate the second stage loader */ - add r2, r0, #(64 * 1024) /* blob maximum size is 64kB */ - add r0, r0, #0x400 /* skip first 1024 bytes */ + ldr r0, piggy_start + add r0, r0, r1 + ldr r2, piggy_end + add r2, r2, r1 ldr r1, BLOB_START /* r0 = source address @@ -103,3 +105,5 @@ START: .word 0x00000000 BLOB_START: .word BLOB_ABS_BASE_ADDR +piggy_start: .word __piggy_start +piggy_end: .word __piggy_end Index: start-ld-script =================================================================== RCS file: /cvsroot/blob/blob/src/blob/start-ld-script,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- start-ld-script 7 Oct 2001 15:51:01 -0000 1.1 +++ start-ld-script 10 Feb 2003 23:07:06 -0000 1.2 @@ -18,7 +18,13 @@ . = 0x00000000; . = ALIGN(4); - .text : { *(.text) } + .text : { *(.text) + + __piggy_start = .; + blob-rest-piggy.o + . = ALIGN(8); + __piggy_end = .; + } . = ALIGN(4); .rodata : { *(.rodata) } Index: start.S =================================================================== RCS file: /cvsroot/blob/blob/src/blob/start.S,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- start.S 14 Aug 2002 21:04:25 -0000 1.10 +++ start.S 10 Feb 2003 23:07:06 -0000 1.11 @@ -59,6 +59,8 @@ /* some defines to make life easier */ /* main memory starts at 0xc0000000 */ BLOB_START: .word BLOB_ABS_BASE_ADDR +piggy_start: .word __piggy_start +piggy_end: .word __piggy_end .globl normal_boot @@ -80,11 +82,14 @@ relocate: - adr r0, _start - /* relocate the second stage loader */ - add r2, r0, #(64 * 1024) /* blob maximum size is 64kB */ - add r0, r0, #0x400 /* skip first 1024 bytes */ + adr r1, _start + + ldr r0, piggy_start + add r0, r0, r1 + ldr r2, piggy_end + add r2, r2, r1 + ldr r1, BLOB_START /* r0 = source address |