]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Only re-compile version.c as often as necessary
authorhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 29 Aug 2009 06:14:28 +0000 (06:14 +0000)
committerhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 29 Aug 2009 06:14:28 +0000 (06:14 +0000)
Make bootrom version information pointer a proper symbol (with hacky ld strangeness workaround)

armsrc/Makefile
armsrc/appmain.c
armsrc/ldscript
bootrom/Makefile
bootrom/ldscript-flash
common/Makefile.common
common/ldscript.common

index 00e99b1f42f61eae3c7c0eb432d59f6d6a6a3121..bc15aeb9d568f48a6b8161dde7e06b20d04e4a6e 100644 (file)
@@ -13,7 +13,6 @@ THUMBSRC = start.c \
        lfops.c \\r
        iso15693.c \\r
        util.c \\r
        lfops.c \\r
        iso15693.c \\r
        util.c \\r
-       version.c \\r
        hitag2.c \\r
        usb.c\r
 \r
        hitag2.c \\r
        usb.c\r
 \r
@@ -30,14 +29,14 @@ all: $(OBJDIR)/osimage.s19 $(OBJDIR)/fpgaimage.s19
 $(OBJDIR)/fpga.o: fpga.bit\r
        $(OBJCOPY) -O elf32-littlearm -I binary -B arm --redefine-sym _binary____fpga_fpga_bit_start=_binary_fpga_bit_start --redefine-sym _binary____fpga_fpga_bit_end=_binary_fpga_bit_end --prefix-sections=fpga_bit  $^ $@\r
 \r
 $(OBJDIR)/fpga.o: fpga.bit\r
        $(OBJCOPY) -O elf32-littlearm -I binary -B arm --redefine-sym _binary____fpga_fpga_bit_start=_binary_fpga_bit_start --redefine-sym _binary____fpga_fpga_bit_end=_binary_fpga_bit_end --prefix-sections=fpga_bit  $^ $@\r
 \r
-$(OBJDIR)/fullimage.elf: $(OBJDIR)/fpga.o $(THUMBOBJ) $(ARMOBJ) $(ARMLIB)/libgcc.a\r
+$(OBJDIR)/fullimage.elf: $(VERSIONOBJ) $(OBJDIR)/fpga.o $(THUMBOBJ) $(ARMOBJ) $(ARMLIB)/libgcc.a\r
        $(LD) -g -Tldscript -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
 \r
 $(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fullimage.elf\r
        $(LD) -g -Tldscript -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
 \r
 $(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fullimage.elf\r
-       $(OBJCOPY) -F elf32-littlearm --only-section fpgaimage $^ $@  \r
+       $(OBJCOPY) -F elf32-littlearm --only-section .fpgaimage $^ $@  \r
 \r
 $(OBJDIR)/osimage.elf: $(OBJDIR)/fullimage.elf\r
 \r
 $(OBJDIR)/osimage.elf: $(OBJDIR)/fullimage.elf\r
-       $(OBJCOPY) -F elf32-littlearm --remove-section fpgaimage $^ $@\r
+       $(OBJCOPY) -F elf32-littlearm --remove-section .fpgaimage $^ $@\r
 \r
 clean:\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.o\r
 \r
 clean:\r
        $(DELETE) $(OBJDIR)$(PATHSEP)*.o\r
index 59cc6dead3bf6a5bbbf99ad96c15dfae2cc640f7..72d8789e75af6a10637d82bbc2b401bb83a89371 100644 (file)
@@ -238,17 +238,19 @@ void ReadMem(int addr)
 
 /* osimage version information is linked in */
 extern struct version_information version_information;
 
 /* osimage version information is linked in */
 extern struct version_information version_information;
+/* bootrom version information is pointed to from _bootphase1_version_pointer */
+extern char _bootphase1_version_pointer, _flash_start, _flash_end;
 void SendVersion(void)
 {
        char temp[48]; /* Limited data payload in USB packets */
        DbpString("Prox/RFID mark3 RFID instrument");
        
 void SendVersion(void)
 {
        char temp[48]; /* Limited data payload in USB packets */
        DbpString("Prox/RFID mark3 RFID instrument");
        
-       /* Try to find the bootrom version information. For the time being, expect
-        * to find a pointer at address 0x1001fc, perform slight sanity checks on 
-        * the pointer, then use it.
+       /* Try to find the bootrom version information. Expect to find a pointer at 
+        * symbol _bootphase1_version_pointer, perform slight sanity checks on the
+        * pointer, then use it.
         */
         */
-       void *bootrom_version = *(void**)0x1001fc;
-       if( bootrom_version < (void*)0x100000 || bootrom_version > (void*)0x101000 ) {
+       void *bootrom_version = *(void**)&_bootphase1_version_pointer;
+       if( bootrom_version < (void*)&_flash_start || bootrom_version >= (void*)&_flash_end ) {
                DbpString("bootrom version information appears invalid");
        } else {
                FormatVersionInformation(temp, sizeof(temp), "bootrom: ", bootrom_version);
                DbpString("bootrom version information appears invalid");
        } else {
                FormatVersionInformation(temp, sizeof(temp), "bootrom: ", bootrom_version);
index b99cea2f2116479b3cf78e9afb9b069c6e2a5a6d..3a01a68fcbd8ecc3d8c252aaa1930573d3482441 100644 (file)
@@ -3,7 +3,7 @@ INCLUDE ../common/ldscript.common
 ENTRY(Vector)\r
 SECTIONS\r
 {\r
 ENTRY(Vector)\r
 SECTIONS\r
 {\r
-       fpgaimage : {\r
+       .fpgaimage : {\r
                *(fpga_bit.data)\r
        } >fpgaimage\r
        .start : { *(.startos) } >osimage\r
                *(fpga_bit.data)\r
        } >fpgaimage\r
        .start : { *(.startos) } >osimage\r
index 30b55466b8f7b17404d2b48265ca268df6108e06..c80b650c670385a291e680226a5d664671a426e7 100644 (file)
@@ -2,7 +2,7 @@
 \r
 # DO NOT use thumb mode in the phase 1 bootloader since that generates a section with glue code\r
 ARMSRC = fromflash.c \r
 \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 version.c bootrom.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}SRC\r
 ASMSRC = ram-reset.s flash-reset.s\r
 \r
 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC\r
@@ -10,7 +10,7 @@ include ../common/Makefile.common
 \r
 all: $(OBJDIR)/bootrom.s19\r
 \r
 \r
 all: $(OBJDIR)/bootrom.s19\r
 \r
-$(OBJDIR)/bootrom.elf: $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)\r
+$(OBJDIR)/bootrom.elf: $(VERSIONOBJ) $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)\r
        $(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
 \r
 clean:\r
        $(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^\r
 \r
 clean:\r
index d2e6648b8c8210528a7f5d1ff8c592f97dc06f25..37bfaaa1060bf7f7b9b99bb3ed182a75ce119d4e 100644 (file)
@@ -5,7 +5,7 @@ SECTIONS
 {\r
     . = 0;\r
     \r
 {\r
     . = 0;\r
     \r
-    bootphase1 : {\r
+    .bootphase1 : {\r
        *(.startup) \r
        *(.bootphase1)\r
        \r
        *(.startup) \r
        *(.bootphase1)\r
        \r
@@ -15,14 +15,17 @@ SECTIONS
           of the version information at the end of the section.\r
           -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-28 */\r
           \r
           of the version information at the end of the section.\r
           -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-28 */\r
           \r
-       _version_information_start = .;\r
+       _version_information_start = ABSOLUTE(.);\r
        *(.version_information);\r
        \r
        *(.version_information);\r
        \r
-       . = LENGTH(bootphase1) - 0x4; /* Skip ahead to the end */\r
+       /* Why doesn't this work even though _bootphase1_version_pointer = 0x1001fc?
+         . = _bootphase1_version_pointer - ORIGIN(bootphase1); */\r
+       /* This works, apparently it fools the linker into accepting an absolute address */\r
+       . = _bootphase1_version_pointer - ORIGIN(bootphase1) + ORIGIN(bootphase1);\r
        LONG(_version_information_start)\r
     } >bootphase1\r
     \r
        LONG(_version_information_start)\r
     } >bootphase1\r
     \r
-    bootphase2 : {\r
+    .bootphase2 : {\r
        __bootphase2_start__ = .;\r
        *(.startphase2)\r
        *(.text)\r
        __bootphase2_start__ = .;\r
        *(.startphase2)\r
        *(.text)\r
index 04b0b330cf58742ae4c2893fbe62ad987443093b..901ce2e155d44ba5f06fed91a87128a07efa01e1 100644 (file)
@@ -58,6 +58,7 @@ CFLAGS =  -c $(INCLUDE) -Wall $(APP_CFLAGS)
 THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
 ARMOBJ   = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
 ASMOBJ   = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
 THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
 ARMOBJ   = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
 ASMOBJ   = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
+VERSIONOBJ = $(OBJDIR)/version.o
 
 $(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
        $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $< 
 
 $(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
        $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $< 
@@ -68,13 +69,16 @@ $(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
 $(ASMOBJ): $(OBJDIR)/%.o: %.s
        $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
 
 $(ASMOBJ): $(OBJDIR)/%.o: %.s
        $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
 
+$(VERSIONOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
+       $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $< 
+
 # This objcopy call translates physical flash addresses to logical addresses
 # See ldscript.common. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27
 $(OBJDIR)/%.s19: $(OBJDIR)/%.elf
        $(OBJCOPY) -Osrec --srec-forceS3  --no-change-warnings \
 # This objcopy call translates physical flash addresses to logical addresses
 # See ldscript.common. -- Henryk Plötz <henryk@ploetzli.ch> 2009-08-27
 $(OBJDIR)/%.s19: $(OBJDIR)/%.elf
        $(OBJCOPY) -Osrec --srec-forceS3  --no-change-warnings \
-       --change-section-address bootphase1-0x100000 \
-       --change-section-address bootphase2-0x100000 \
-       --change-section-address fpgaimage-0x100000 \
+       --change-section-address .bootphase1-0x100000 \
+       --change-section-address .bootphase2-0x100000 \
+       --change-section-address .fpgaimage-0x100000 \
        --change-section-address .start-0x100000 \
        --change-section-address .text-0x100000 \
        --change-section-address .rodata-0x100000 $^ $@
        --change-section-address .start-0x100000 \
        --change-section-address .text-0x100000 \
        --change-section-address .rodata-0x100000 $^ $@
@@ -90,9 +94,9 @@ DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
        $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
 
 $(DEPENDENCY_FILES): Makefile ../common/Makefile.common
        $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
 
 $(DEPENDENCY_FILES): Makefile ../common/Makefile.common
-$(OBJDIR)/%.d: %.c
+$(patsubst %.o,%.d,$(THUMBOBJ) $(ARMOBJ)): $(OBJDIR)/%.d: %.c
        @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
        @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
-$(OBJDIR)/%.d: %.s
+$(patsubst %.o,%.d,$(ASMOBJ)):$(OBJDIR)/%.d: %.s
        @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
 
 -include $(DEPENDENCY_FILES)
        @$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
 
 -include $(DEPENDENCY_FILES)
index 4c4bd3906127eebe0f6f7315e0c4aff20fd41e0d..4379d40c8511ec26dd4c1d6a5206c74be5a6b955 100644 (file)
@@ -14,3 +14,7 @@ MEMORY
         ram        : ORIGIN = 0x00200000, LENGTH = 64K
 }
 
         ram        : ORIGIN = 0x00200000, LENGTH = 64K
 }
 
+/* Export some information that can be used from within the firmware */
+_bootphase1_version_pointer = ORIGIN(bootphase1) + LENGTH(bootphase1) - 0x4;
+_flash_start = ORIGIN(bootphase1);
+_flash_end = ORIGIN(osimage) + LENGTH(osimage);
\ No newline at end of file
Impressum, Datenschutz