diff --git a/Makefile.include b/Makefile.include index 9c45a7440fd0..b50a1ef3a835 100644 --- a/Makefile.include +++ b/Makefile.include @@ -407,6 +407,11 @@ ELFFILE ?= $(BINDIR)/$(APPLICATION).elf HEXFILE ?= $(ELFFILE:.elf=.hex) BINFILE ?= $(ELFFILE:.elf=.bin) +# include bootloaders support. It should be included early to allow using +# variables defined in `riotboot.mk` for `FLASHFILE` before it is evaluated. +# It should be included after defining 'BINFILE' for 'riotboot.bin' handling. +include $(RIOTMAKE)/boot/riotboot.mk + # Targets to get given file elffile: $(ELFFILE) hexfile: $(HEXFILE) @@ -442,11 +447,6 @@ else _LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGS) $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map endif # BUILDOSXNATIVE -# include bootloaders support. When trying to overwrite one variable -# like HEXFILE, the value will already have been evaluated when declaring -# the link target. Therefore, it must be placed before `link`. -include $(RIOTMAKE)/boot/riotboot.mk - ifeq ($(BUILD_IN_DOCKER),1) link: ..in-docker-container else diff --git a/makefiles/boot/riotboot.mk b/makefiles/boot/riotboot.mk index 96201509a77b..7db04d4b5271 100644 --- a/makefiles/boot/riotboot.mk +++ b/makefiles/boot/riotboot.mk @@ -35,8 +35,7 @@ SLOT0_RIOT_BIN = $(BINDIR_APP)-slot0.riot.bin SLOT1_RIOT_BIN = $(BINDIR_APP)-slot1.riot.bin SLOT_RIOT_BINS = $(SLOT0_RIOT_BIN) $(SLOT1_RIOT_BIN) -# For slot generation only link is needed -$(BINDIR_APP)-%.elf: link +$(BINDIR_APP)-%.elf: $(BASELIBS) $(Q)$(_LINK) -o $@ # Slot 0 and 1 firmware offset, after header @@ -118,9 +117,12 @@ riotboot/flash-extended-slot0: HEXFILE=$(RIOTBOOT_EXTENDED_BIN) # Flashing rule for openocd to flash combined/extended binaries riotboot/flash-combined-slot0: ELFFILE=$(RIOTBOOT_COMBINED_BIN) riotboot/flash-extended-slot0: ELFFILE=$(RIOTBOOT_EXTENDED_BIN) + +riotboot/flash-combined-slot0: FLASHFILE=$(RIOTBOOT_COMBINED_BIN) riotboot/flash-combined-slot0: $(RIOTBOOT_COMBINED_BIN) $(FLASHDEPS) $(FLASHER) $(FFLAGS) +riotboot/flash-extended-slot0: FLASHFILE=$(RIOTBOOT_EXTENDED_BIN) riotboot/flash-extended-slot0: $(RIOTBOOT_EXTENDED_BIN) $(FLASHDEPS) $(FLASHER) $(FFLAGS) @@ -130,6 +132,7 @@ riotboot/flash-slot0: export IMAGE_OFFSET=$(SLOT0_OFFSET) riotboot/flash-slot0: HEXFILE=$(SLOT0_RIOT_BIN) # openocd riotboot/flash-slot0: ELFFILE=$(SLOT0_RIOT_BIN) +riotboot/flash-slot0: FLASHFILE=$(SLOT0_RIOT_BIN) riotboot/flash-slot0: $(SLOT0_RIOT_BIN) $(FLASHDEPS) $(FLASHER) $(FFLAGS) @@ -139,6 +142,7 @@ riotboot/flash-slot1: export IMAGE_OFFSET=$(SLOT1_OFFSET) riotboot/flash-slot1: HEXFILE=$(SLOT1_RIOT_BIN) # openocd riotboot/flash-slot1: ELFFILE=$(SLOT1_RIOT_BIN) +riotboot/flash-slot1: FLASHFILE=$(SLOT1_RIOT_BIN) riotboot/flash-slot1: $(SLOT1_RIOT_BIN) $(FLASHDEPS) $(FLASHER) $(FFLAGS) diff --git a/tests/riotboot/Makefile b/tests/riotboot/Makefile index c4b90fa4e379..bbc57adf1316 100644 --- a/tests/riotboot/Makefile +++ b/tests/riotboot/Makefile @@ -18,17 +18,15 @@ DEVELHELP ?= 1 # Change this to 0 show compiler invocation lines by default: QUIET ?= 1 -all: riotboot +# Target 'all' will generate the combined file directly. +# It also makes 'flash' and 'flash-only' work without specific command. +FLASHFILE = $(RIOTBOOT_COMBINED_BIN) include ../Makefile.tests_common include $(RIOTBASE)/Makefile.include -# Make 'flash' and 'flash-only' work without specific command. -# This is currently hacky as there is no way of specifiying a FLASHFILE -all: riotboot/combined-slot0 +# This is currently hacky as the flasher are not using 'FLASHFILE' # openocd -ELFFILE = $(BINDIR_APP)-slot0-combined.bin +ELFFILE = $(FLASHFILE) # edbg -HEXFILE = $(BINDIR_APP)-slot0-combined.bin -# murdock uses ':=' to get the flashfile variable so should also be overwritten -FLASHFILE = $(BINDIR_APP)-slot0-combined.bin +HEXFILE = $(FLASHFILE)