Merge linker scripts in bootrom to have a single linker script for the bootloader proper (previously known as bootrom-merged.s19)

Remove the now unnecessary files (merge-srec.pl, ldscript-ram-jtag)
Note that this drops the dependency on perl for bootrom build, so end-users who don't touch the FPGA bitstream will not need perl anymore
This commit is contained in:
henryk@ploetzli.ch 2009-08-27 04:25:34 +00:00
parent 0fc0fca583
commit 8652988d62
9 changed files with 63 additions and 72 deletions

View file

@ -49,8 +49,8 @@ clean:
help:
@echo Multi-OS Makefile, you are running on $(DETECTED_OS)
@echo Possible targets:
@echo + all - Make both:
@echo + osimage.s19 - The OS image
@echo + fpgaimage.s19 - The FPGA image
@echo + clean - Clean $(OBJDIR)
@echo + all - Make both:
@echo + $(OBJDIR)/osimage.s19 - The OS image
@echo + $(OBJDIR)/fpgaimage.s19 - The FPGA image
@echo + clean - Clean $(OBJDIR)

View file

@ -1,36 +1,28 @@
# Makefile for bootrom, see ../common/Makefile.common for common settings
OBJJTAG = $(OBJDIR)/bootrom.o $(OBJDIR)/ram-reset.o $(OBJDIR)/usb.o
OBJFLASH = $(OBJDIR)/flash-reset.o $(OBJDIR)/fromflash.o
THUMBSRC = usb.c fromflash.c bootrom.c
ASMSRC = ram-reset.s flash-reset.s
# DO NOT use thumb mode in the phase 1 bootloader since that generates a section with glue code
ARMSRC = fromflash.c
THUMBSRC = usb.c bootrom.c
ASMSRC = ram-reset.s flash-reset.s
# Do not move this inclusion before the definition of {THUMB,ASM,ARM}{OBJ,SRC}
include ../common/Makefile.common
all: bootrom-merged.s19
all: $(OBJDIR)/bootrom.s19
bootrom-merged.s19: $(OBJDIR)/bootrom.s19 $(OBJDIR)/bootrom-forjtag.s19
perl ../tools/merge-srec.pl $(OBJDIR)/bootrom.s19 $(OBJDIR)/bootrom-forjtag.s19 > bootrom-merged.s19
$(OBJDIR)/bootrom.elf: $(OBJFLASH)
$(OBJDIR)/bootrom.elf: $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)
$(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^
$(OBJDIR)/bootrom-forjtag.elf: $(OBJJTAG)
$(LD) -g -Tldscript-ram-jtag --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^
clean:
$(DELETE) $(OBJDIR)$(PATHSEP)*.o
$(DELETE) $(OBJDIR)$(PATHSEP)*.elf
$(DELETE) $(OBJDIR)$(PATHSEP)*.s19
$(DELETE) $(OBJDIR)$(PATHSEP)*.map
$(DELETE) $(OBJDIR)$(PATHSEP)*.d
$(DELETE) bootrom-merged.s19
.PHONY: all clean help
help:
@echo Multi-OS Makefile, you are running on $(DETECTED_OS)
@echo Possible targets:
@echo + all - Make bootrom-merged.s19, the main bootrom
@echo + all - Make $(OBJDIR)/bootrom.s19, the main bootrom
@echo + clean - Clean $(OBJDIR)

View file

@ -1,11 +1,11 @@
.extern CopyBootToRAM
.text
.code 32
.align 0
.section .startup,"ax"
.code 32
.align 0
.global start
start:
.global flashstart
flashstart:
b Reset
b UndefinedInstruction
b SoftwareInterrupt

View file

@ -1,6 +1,6 @@
#include <proxmark3.h>
void CopyBootToRAM(void)
void __attribute__((section("bootphase1"))) CopyBootToRAM(void)
{
int i;

View file

@ -1,11 +1,43 @@
MEMORY
{
/* AT91SAM7S256 has 256k Flash and 64k RAM */
/* Important note: the correct ORIGIN for bootphase1 is 0x00100000 and for bootphase2 is 0x00100200
However, this will confuse the currently deployed flash code which expects logical and and not
physical addresses and performs no sanity checks at all. If confronted with physical addresses,
it will happily erase everything and brick the device. So for the time being pretend these addresses
to start at 0x0 while updating all the flash code with proper sanity checks, then come back later and
fix the addresses. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27 */
bootphase1 : ORIGIN = 0x00000000, LENGTH = 0x200 /* Phase 1 bootloader: Copies real bootloader to RAM */
bootphase2 : ORIGIN = 0x00000200, LENGTH = 0x2000 - 0x200 /* Main bootloader code, stored in Flash, executed from RAM */
ram : ORIGIN = 0x00200000, LENGTH = 32K
}
SECTIONS
{
. = 0x00000000;
.text : { obj/flash-reset.o(.text) *(.text) }
.rodata : { *(.rodata) }
. = 0x00200000;
.data : { *(.data) }
__bss_start__ = .;
.bss : { *(.bss) }
. = 0;
bootphase1 : {
*(.startup)
*(.bootphase1)
} >bootphase1
bootphase2 : {
__bootphase2_start__ = .;
*(.startphase2)
*(.text)
*(.glue_7)
*(.rodata)
*(.data)
. = ALIGN( 32 / 8 );
__bootphase2_end__ = .;
} >ram AT>bootphase2
.bss : {
__bss_start__ = .;
*(.bss)
} >ram
. = ALIGN( 32 / 8 );
__bss_end__ = .;
}

View file

@ -1,10 +0,0 @@
SECTIONS
{
. = 0x00200000;
.text : { obj/ram-reset.o(.text) *(.text) }
.rodata : { *(.rodata) }
.data : { *(.data) }
__bss_start__ = .;
.bss : { *(.bss) }
__bss_end__ = .;
}

View file

@ -1,10 +1,10 @@
.extern BootROM
.text
.code 32
.align 0
.section .startphase2,"ax"
.code 32
.align 0
.global start
start:
.global ramstart
ramstart:
ldr sp, = 0x0020FFF8
bl BootROM

View file

@ -76,8 +76,8 @@ DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
$(DEPENDENCY_FILES): Makefile ../common/Makefile.common
$(OBJDIR)/%.d: %.c
$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
@$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
$(OBJDIR)/%.d: %.s
$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
@$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
-include $(DEPENDENCY_FILES)

View file

@ -1,23 +0,0 @@
# merge the code that initially executes out of flash with the RAM image
($flashFile, $ramFile) = @ARGV;
open(FLASH, $flashFile) or die "$flashFile: $!\n";
while(<FLASH>) {
print if /^S3/;
$EOF_record = $_ if /^S[789]/;
}
open(RAM, $ramFile) or die "$ramFile: $!\n";
while(<RAM>) {
if(/^S3(..)(........)(.*)([0-9a-fA-F]{2})/) {
$addr = sprintf('%08X', hex($2) - 0x00200000 + 0x200);
$line = "$1$addr$3";
$checksum = 0;
$checksum += $_ foreach map(hex, unpack("a2"x40, $line));
print "S3$line", sprintf("%02X", ($checksum%256)^0xff ), "\n";
}
}
print $EOF_record;