]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge linker scripts in bootrom to have a single linker script for the bootloader...
authorhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 27 Aug 2009 04:25:34 +0000 (04:25 +0000)
committerhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 27 Aug 2009 04:25:34 +0000 (04:25 +0000)
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

armsrc/Makefile
bootrom/Makefile
bootrom/flash-reset.s
bootrom/fromflash.c
bootrom/ldscript-flash
bootrom/ldscript-ram-jtag [deleted file]
bootrom/ram-reset.s
common/Makefile.common
tools/merge-srec.pl [deleted file]

index ce1ad087d3b7021e06b1fee4afe4a8b0730d138d..567c8d1232fe97670ebb0499422b458babce203e 100644 (file)
@@ -49,8 +49,8 @@ clean:
 help:\r
        @echo Multi-OS Makefile, you are running on $(DETECTED_OS)\r
        @echo Possible targets:\r
 help:\r
        @echo Multi-OS Makefile, you are running on $(DETECTED_OS)\r
        @echo Possible targets:\r
-       @echo + all           - Make both:\r
-       @echo + osimage.s19   - The OS image\r
-       @echo + fpgaimage.s19 - The FPGA image\r
-       @echo + clean         - Clean $(OBJDIR)\r
+       @echo + all               - Make both:\r
+       @echo + $(OBJDIR)/osimage.s19   - The OS image\r
+       @echo + $(OBJDIR)/fpgaimage.s19 - The FPGA image\r
+       @echo + clean             - Clean $(OBJDIR)\r
 \r
 \r
index 2ab91286d90fde201ef02d661e1ab5efea707009..43e2533fd0b674250302d61a9fea9dcb647dc0d9 100644 (file)
@@ -1,36 +1,28 @@
 # Makefile for bootrom, see ../common/Makefile.common for common settings\r
 \r
 # Makefile for bootrom, see ../common/Makefile.common for common settings\r
 \r
-OBJJTAG = $(OBJDIR)/bootrom.o $(OBJDIR)/ram-reset.o $(OBJDIR)/usb.o\r
-OBJFLASH = $(OBJDIR)/flash-reset.o $(OBJDIR)/fromflash.o\r
-\r
-THUMBSRC = usb.c fromflash.c bootrom.c\r
-ASMSRC   = ram-reset.s flash-reset.s\r
+# DO NOT use thumb mode in the phase 1 bootloader since that generates a section with glue code\r
+ARMSRC = fromflash.c \r
+THUMBSRC = usb.c bootrom.c\r
+ASMSRC = ram-reset.s flash-reset.s\r
 \r
 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}{OBJ,SRC}\r
 include ../common/Makefile.common\r
 \r
 \r
 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}{OBJ,SRC}\r
 include ../common/Makefile.common\r
 \r
-all: bootrom-merged.s19\r
-\r
-bootrom-merged.s19: $(OBJDIR)/bootrom.s19 $(OBJDIR)/bootrom-forjtag.s19\r
-       perl ../tools/merge-srec.pl $(OBJDIR)/bootrom.s19 $(OBJDIR)/bootrom-forjtag.s19 > bootrom-merged.s19\r
+all: $(OBJDIR)/bootrom.s19\r
 \r
 \r
-$(OBJDIR)/bootrom.elf: $(OBJFLASH)\r
+$(OBJDIR)/bootrom.elf: $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)\r
        $(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
 \r
        $(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
 \r
-$(OBJDIR)/bootrom-forjtag.elf: $(OBJJTAG)\r
-       $(LD) -g -Tldscript-ram-jtag --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
-\r
 clean:\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.o\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.elf\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.s19\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.map\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.d\r
 clean:\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.o\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.elf\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.s19\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.map\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.d\r
-       $(DELETE) bootrom-merged.s19\r
 \r
 .PHONY: all clean help\r
 help:\r
        @echo Multi-OS Makefile, you are running on $(DETECTED_OS)\r
        @echo Possible targets:\r
 \r
 .PHONY: all clean help\r
 help:\r
        @echo Multi-OS Makefile, you are running on $(DETECTED_OS)\r
        @echo Possible targets:\r
-       @echo + all   - Make bootrom-merged.s19, the main bootrom\r
+       @echo + all   - Make $(OBJDIR)/bootrom.s19, the main bootrom\r
        @echo + clean - Clean $(OBJDIR)\r
        @echo + clean - Clean $(OBJDIR)\r
index afb658a430b0aa012cffb6b0e2191068994bc4eb..48c111a703315260758b01c0b076a02b1dd5a8df 100644 (file)
@@ -1,11 +1,11 @@
 .extern CopyBootToRAM\r
     \r
 .extern CopyBootToRAM\r
     \r
-.text\r
-.code 32\r
-.align 0\r
+.section .startup,"ax"\r
+         .code 32\r
+         .align 0\r
 \r
 \r
-.global start\r
-start:\r
+.global flashstart\r
+flashstart:\r
     b       Reset\r
     b       UndefinedInstruction\r
     b       SoftwareInterrupt\r
     b       Reset\r
     b       UndefinedInstruction\r
     b       SoftwareInterrupt\r
index e6868092fdc9d4e050cdfaf68af7478b203dd211..f6d5237cb7002843b4f69d5e4907e8ebfcfab8f0 100644 (file)
@@ -1,6 +1,6 @@
 #include <proxmark3.h>\r
 \r
 #include <proxmark3.h>\r
 \r
-void CopyBootToRAM(void)\r
+void __attribute__((section("bootphase1"))) CopyBootToRAM(void)\r
 {\r
        int i;\r
 \r
 {\r
        int i;\r
 \r
index 0d5d732561bfacfe524dcd571cf0c46693a2c2d0..fa6fb26e4fec6cc4ce2dfe83a72a0eada3fdd75e 100644 (file)
@@ -1,11 +1,43 @@
+MEMORY \r
+{\r
+       /* AT91SAM7S256 has 256k Flash and 64k RAM */\r
+       /* Important note: the correct ORIGIN for bootphase1 is 0x00100000 and for bootphase2 is 0x00100200\r
+          However, this will confuse the currently deployed flash code which expects logical and and not\r
+          physical addresses and performs no sanity checks at all. If confronted with physical addresses, \r
+          it will happily erase everything and brick the device. So for the time being pretend these addresses\r
+          to start at 0x0 while updating all the flash code with proper sanity checks, then come back later and\r
+          fix the addresses. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27 */\r
+        bootphase1 : ORIGIN = 0x00000000, LENGTH = 0x200 /* Phase 1 bootloader: Copies real bootloader to RAM */\r
+        bootphase2 : ORIGIN = 0x00000200, LENGTH = 0x2000 - 0x200 /* Main bootloader code, stored in Flash, executed from RAM */\r
+        ram     : ORIGIN = 0x00200000, LENGTH = 32K\r
+}\r
+\r
+\r
 SECTIONS\r
 {\r
 SECTIONS\r
 {\r
-    . = 0x00000000;\r
-    .text : { obj/flash-reset.o(.text) *(.text) }\r
-    .rodata : { *(.rodata) }\r
-    . = 0x00200000;\r
-    .data : { *(.data) }\r
-    __bss_start__ = .;\r
-    .bss : { *(.bss) }\r
+    . = 0;\r
+    \r
+    bootphase1 : {\r
+       *(.startup) \r
+       *(.bootphase1)\r
+    } >bootphase1\r
+    \r
+    bootphase2 : {\r
+       __bootphase2_start__ = .;\r
+       *(.startphase2)\r
+       *(.text)\r
+       *(.glue_7)\r
+       *(.rodata)\r
+        *(.data)\r
+       . = ALIGN( 32 / 8 );\r
+       __bootphase2_end__ = .;\r
+    } >ram AT>bootphase2\r
+    \r
+    .bss : {\r
+       __bss_start__ = .; \r
+       *(.bss)\r
+    } >ram\r
+    \r
+    . = ALIGN( 32 / 8 );\r
     __bss_end__ = .;\r
 }\r
     __bss_end__ = .;\r
 }\r
diff --git a/bootrom/ldscript-ram-jtag b/bootrom/ldscript-ram-jtag
deleted file mode 100644 (file)
index 5dd5706..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-SECTIONS\r
-{\r
-    . = 0x00200000;\r
-    .text : { obj/ram-reset.o(.text) *(.text) }\r
-    .rodata : { *(.rodata) }\r
-    .data : { *(.data) }\r
-    __bss_start__ = .;\r
-    .bss : { *(.bss) }\r
-    __bss_end__ = .;\r
-}\r
index 56bf36e3834fe88fd99e02b94feb3e286da89788..6155b0026abead31b125d0582bd4cbd63c130b3e 100644 (file)
@@ -1,10 +1,10 @@
 .extern BootROM\r
     \r
 .extern BootROM\r
     \r
-.text\r
-.code 32\r
-.align 0\r
+.section .startphase2,"ax"\r
+         .code 32\r
+         .align 0\r
 \r
 \r
-.global start\r
-start:\r
+.global ramstart\r
+ramstart:\r
     ldr     sp,     = 0x0020FFF8\r
     bl      BootROM\r
     ldr     sp,     = 0x0020FFF8\r
     bl      BootROM\r
index c4da75e15a06dd0a415564b5c980519b89f623a3..eab96080e6a9757a220de8d19cfeb9717d963dcb 100644 (file)
@@ -76,8 +76,8 @@ DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
 
 $(DEPENDENCY_FILES): Makefile ../common/Makefile.common
 $(OBJDIR)/%.d: %.c
 
 $(DEPENDENCY_FILES): Makefile ../common/Makefile.common
 $(OBJDIR)/%.d: %.c
-       $(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
+       @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
 $(OBJDIR)/%.d: %.s
 $(OBJDIR)/%.d: %.s
-       $(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
+       @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
 
 -include $(DEPENDENCY_FILES)
 
 -include $(DEPENDENCY_FILES)
diff --git a/tools/merge-srec.pl b/tools/merge-srec.pl
deleted file mode 100644 (file)
index 683e6d3..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# merge the code that initially executes out of flash with the RAM image\r
-\r
-($flashFile, $ramFile) = @ARGV;\r
-\r
-open(FLASH, $flashFile) or die "$flashFile: $!\n";\r
-\r
-while(<FLASH>) {\r
-       print if /^S3/;\r
-       $EOF_record = $_ if /^S[789]/;\r
-}\r
-\r
-open(RAM, $ramFile) or die "$ramFile: $!\n";\r
-\r
-while(<RAM>) {\r
-       if(/^S3(..)(........)(.*)([0-9a-fA-F]{2})/) {\r
-               $addr = sprintf('%08X', hex($2) - 0x00200000 + 0x200);\r
-               $line = "$1$addr$3";\r
-               $checksum = 0;\r
-               $checksum += $_ foreach map(hex, unpack("a2"x40, $line));\r
-               print "S3$line", sprintf("%02X", ($checksum%256)^0xff ), "\n";\r
-       }\r
-}\r
-print $EOF_record;\r
Impressum, Datenschutz