Make bootrom version information pointer a proper symbol (with hacky ld strangeness workaround)
lfops.c \\r
iso15693.c \\r
util.c \\r
- version.c \\r
hitag2.c \\r
usb.c\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
- $(OBJCOPY) -F elf32-littlearm --only-section fpgaimage $^ $@ \r
+ $(OBJCOPY) -F elf32-littlearm --only-section .fpgaimage $^ $@ \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
/* 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);
ENTRY(Vector)\r
SECTIONS\r
{\r
- fpgaimage : {\r
+ .fpgaimage : {\r
*(fpga_bit.data)\r
} >fpgaimage\r
.start : { *(.startos) } >osimage\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
\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
{\r
. = 0;\r
\r
- bootphase1 : {\r
+ .bootphase1 : {\r
*(.startup) \r
*(.bootphase1)\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
- . = 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
- bootphase2 : {\r
+ .bootphase2 : {\r
__bootphase2_start__ = .;\r
*(.startphase2)\r
*(.text)\r
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 $@ $<
$(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 $^ $@
$(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)
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