New make environment for new bootloader

Compatible with old bootloader. Adds an additional section with a copy
of the interrupt vector table to the end of the image. This is needed by
the new bootloader and should be ok for the old bootloader.

Note that for this to work, everybody needs python installed with
the IntelHex python package. On Linux this can be achieved with

pip install IntelHex
This commit is contained in:
Ralf Schlatterbeck 2017-08-20 20:57:17 +02:00
parent d890a492bb
commit edc7a59091
5 changed files with 37 additions and 14 deletions

View file

@ -220,12 +220,12 @@ symbols.c:
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
# Generic rules for .hex, .eep and .sz (size) file:
%.$(TARGET).hex: %.$(TARGET)
%.$(TARGET)$(CUSTOM_SUFFIX).hex: %.$(TARGET)$(CUSTOM_SUFFIX)
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.$(TARGET).eep: %.$(TARGET)
%.$(TARGET)$(CUSTOM_SUFFIX).eep: %.$(TARGET)$(CUSTOM_SUFFIX)
$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex $< $@
%.$(TARGET).sz: %.$(TARGET)
%.$(TARGET)$(CUSTOM_SUFFIX).sz: %.$(TARGET)$(CUSTOM_SUFFIX)
$(ELF_SIZE) $<

View file

@ -2,3 +2,5 @@
*.eep
*.osd-merkur-128
*.osd-merkur-256
*.osd-merkur-256.0
*.osd-merkur-256.1

View file

@ -2,7 +2,6 @@
SKETCH=sketch
EXE=ota
all: $(EXE)
CONTIKI=../../..
@ -39,11 +38,4 @@ APPS += arduino json-resource json #time
include $(CONTIKI)/Makefile.include
include $(CONTIKI)/apps/arduino/Makefile.include
avr-size: $(EXE).$(TARGET).sz
flash: $(EXE).$(TARGET).u # $(EXE).$(TARGET).eu
.PHONY: flash avr-size
.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep
AVRDUDE_PORT=/dev/ttyUSB1

View file

@ -99,6 +99,8 @@ else
TEXT_SECTION_START=0x1ef00
endif
CUSTOM_SUFFIX=.$(BOOTLOADER_PARTITION)
LDFLAGS += -Wl,--defsym,bootloader_get_mac=$(BOOTLOADER_GET_MAC) \
-Wl,--defsym,_bootloader_write_page_to_flash=$(BOOTLOADER_WRITE_PAGE_TO_FLASH) \
-Wl,--defsym,bootloader_get_part_count=$(BOOTLOADER_GET_PART_COUNT) \
@ -123,3 +125,31 @@ MODULES += core/net/mac core/net core/net/mac/sicslowmac \
# core/net/ipv6 core/net/ipv4 core/net/ip \
# core/net/rime \
# core/net/rpl \
CUSTOM_RULE_LINK=1
%.$(TARGET)$(CUSTOM_SUFFIX): %.co $(PROJECT_OBJECTFILES) \
$(PROJECT_LIBRARIES) contiki-$(TARGET).a
$(TRACE_LD)
$(Q)$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \
${filter %.a,$^} $(TARGET_LIBFILES) -o $@
%: %.$(TARGET)
%: %.$(TARGET)$(CUSTOM_SUFFIX)
@
%.$(TARGET)$(CUSTOM_SUFFIX)-combined.hex: %.$(TARGET)$(CUSTOM_SUFFIX).hex
$(CONTIKI)/tools/genbackupisr.py $< > $@
flash: $(EXE).$(TARGET)$(CUSTOM_SUFFIX)-combined.u
avr-size: $(EXE).$(TARGET)$(CUSTOM_SUFFIX).sz
.PHONY: flash avr-size
.PRECIOUS: %.$(TARGET)$(CUSTOM_SUFFIX) \
$(EXE).$(TARGET)$(CUSTOM_SUFFIX).hex \
$(EXE).$(TARGET)$(CUSTOM_SUFFIX).eep \
$(EXE).$(TARGET)$(CUSTOM_SUFFIX)-combined.hex

View file

@ -10,6 +10,5 @@ import intelhex
ihex = intelhex.IntelHex (sys.argv [1])
bin = ihex.tobinstr () [:0x200]
hex2 = intelhex.IntelHex ()
hex2.puts (0x1ed00, bin)
hex2.tofile ("out.hex", format="hex")
ihex.puts (0x1ed00, bin)
ihex.tofile (sys.stdout, format="hex")