Only re-compile version.c as often as necessary

Make bootrom version information pointer a proper symbol (with hacky ld strangeness workaround)
This commit is contained in:
henryk@ploetzli.ch 2009-08-29 06:14:28 +00:00
parent 0fa9ca5b53
commit 4271e82d56
7 changed files with 33 additions and 21 deletions

View file

@ -13,7 +13,6 @@ THUMBSRC = start.c \
lfops.c \
iso15693.c \
util.c \
version.c \
hitag2.c \
usb.c
@ -30,14 +29,14 @@ all: $(OBJDIR)/osimage.s19 $(OBJDIR)/fpgaimage.s19
$(OBJDIR)/fpga.o: fpga.bit
$(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 $^ $@
$(OBJDIR)/fullimage.elf: $(OBJDIR)/fpga.o $(THUMBOBJ) $(ARMOBJ) $(ARMLIB)/libgcc.a
$(OBJDIR)/fullimage.elf: $(VERSIONOBJ) $(OBJDIR)/fpga.o $(THUMBOBJ) $(ARMOBJ) $(ARMLIB)/libgcc.a
$(LD) -g -Tldscript -Map=$(patsubst %.elf,%.map,$@) -o $@ $^
$(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fullimage.elf
$(OBJCOPY) -F elf32-littlearm --only-section fpgaimage $^ $@
$(OBJCOPY) -F elf32-littlearm --only-section .fpgaimage $^ $@
$(OBJDIR)/osimage.elf: $(OBJDIR)/fullimage.elf
$(OBJCOPY) -F elf32-littlearm --remove-section fpgaimage $^ $@
$(OBJCOPY) -F elf32-littlearm --remove-section .fpgaimage $^ $@
clean:
$(DELETE) $(OBJDIR)$(PATHSEP)*.o

View file

@ -238,17 +238,19 @@ void ReadMem(int addr)
/* 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");
/* 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);

View file

@ -3,7 +3,7 @@ INCLUDE ../common/ldscript.common
ENTRY(Vector)
SECTIONS
{
fpgaimage : {
.fpgaimage : {
*(fpga_bit.data)
} >fpgaimage
.start : { *(.startos) } >osimage

View file

@ -2,7 +2,7 @@
# DO NOT use thumb mode in the phase 1 bootloader since that generates a section with glue code
ARMSRC = fromflash.c
THUMBSRC = usb.c version.c bootrom.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}SRC
@ -10,7 +10,7 @@ include ../common/Makefile.common
all: $(OBJDIR)/bootrom.s19
$(OBJDIR)/bootrom.elf: $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)
$(OBJDIR)/bootrom.elf: $(VERSIONOBJ) $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ)
$(LD) -g -Tldscript-flash --oformat elf32-littlearm -Map=$(patsubst %.elf,%.map,$@) -o $@ $^
clean:

View file

@ -5,7 +5,7 @@ SECTIONS
{
. = 0;
bootphase1 : {
.bootphase1 : {
*(.startup)
*(.bootphase1)
@ -15,14 +15,17 @@ SECTIONS
of the version information at the end of the section.
-- Henryk Plötz <henryk@ploetzli.ch> 2009-08-28 */
_version_information_start = .;
_version_information_start = ABSOLUTE(.);
*(.version_information);
. = LENGTH(bootphase1) - 0x4; /* Skip ahead to the end */
/* Why doesn't this work even though _bootphase1_version_pointer = 0x1001fc?
. = _bootphase1_version_pointer - ORIGIN(bootphase1); */
/* This works, apparently it fools the linker into accepting an absolute address */
. = _bootphase1_version_pointer - ORIGIN(bootphase1) + ORIGIN(bootphase1);
LONG(_version_information_start)
} >bootphase1
bootphase2 : {
.bootphase2 : {
__bootphase2_start__ = .;
*(.startphase2)
*(.text)

View 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))
VERSIONOBJ = $(OBJDIR)/version.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 $@ $<
$(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 \
--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 $^ $@
@ -90,9 +94,9 @@ DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
$(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) $< > $@
$(OBJDIR)/%.d: %.s
$(patsubst %.o,%.d,$(ASMOBJ)):$(OBJDIR)/%.d: %.s
@$(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
-include $(DEPENDENCY_FILES)

View file

@ -14,3 +14,7 @@ MEMORY
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);