From 60f71a1c15394de1131632deffcb51b87f56f62c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 1 Mar 2019 16:24:30 +0100 Subject: [PATCH 1/5] tests/riotboot: use 'RIOTBOOT_COMBINED_BIN' variable Use the new variable instead of the composed name. --- tests/riotboot/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/riotboot/Makefile b/tests/riotboot/Makefile index c4b90fa4e379..0ac801232444 100644 --- a/tests/riotboot/Makefile +++ b/tests/riotboot/Makefile @@ -27,8 +27,8 @@ include $(RIOTBASE)/Makefile.include # This is currently hacky as there is no way of specifiying a FLASHFILE all: riotboot/combined-slot0 # openocd -ELFFILE = $(BINDIR_APP)-slot0-combined.bin +ELFFILE = $(RIOTBOOT_COMBINED_BIN) # edbg -HEXFILE = $(BINDIR_APP)-slot0-combined.bin +HEXFILE = $(RIOTBOOT_COMBINED_BIN) # murdock uses ':=' to get the flashfile variable so should also be overwritten -FLASHFILE = $(BINDIR_APP)-slot0-combined.bin +FLASHFILE = $(RIOTBOOT_COMBINED_BIN) From ecfdece104f353af1938561dacd80485a5d3ce4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 1 Mar 2019 16:28:22 +0100 Subject: [PATCH 2/5] Makefile.include: include 'riotboot.mk' before using FLASHFILE Include the 'riotboot.mk' file before using FLASHFILE/ELFFILE/HEXFILE variables. This will allow setting variables to values from riotboot.mk like `FLASHFILE = $(RIOTBOOT_COMBINED_BIN)` before it is evaluated in Makefile.include. It should be included after defining 'BINFILE' for 'riotboot.bin' handling. --- Makefile.include | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From 240e4a3fe2c09670d999ff98a1c6e1d2021758f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 1 Mar 2019 17:34:30 +0100 Subject: [PATCH 3/5] makefiles/riotboot.mk: slots only need to depend on BASELIBS Using 'link' was working too but will introduce a circular dependency when FLASHFILE is one of the slot files. This trims down to the minimal required dependency to work. It is now the same as `ELFFILE` dependencies. --- makefiles/boot/riotboot.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/makefiles/boot/riotboot.mk b/makefiles/boot/riotboot.mk index 96201509a77b..7293fcb0d537 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 From 13e852c58c9386286b2791f113c56146879a7c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 1 Mar 2019 17:36:22 +0100 Subject: [PATCH 4/5] tests/riotboot: use FLASHFILE for the generated file FLASHFILE is now a generated file when doing `make all`. This prepares also for when flashers will use `FLASHFILE` as a file to be flashed. It currently still needs the hack below for openocd and edbg. This also fixes the issue when building 'riotboot' in docker that was being built with the host toolchain. --- tests/riotboot/Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/riotboot/Makefile b/tests/riotboot/Makefile index 0ac801232444..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 = $(RIOTBOOT_COMBINED_BIN) +ELFFILE = $(FLASHFILE) # edbg -HEXFILE = $(RIOTBOOT_COMBINED_BIN) -# murdock uses ':=' to get the flashfile variable so should also be overwritten -FLASHFILE = $(RIOTBOOT_COMBINED_BIN) +HEXFILE = $(FLASHFILE) From 7a88bb4c1f31e3db78f00f30b11b83bb7899a6c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Wed, 19 Dec 2018 18:21:05 +0100 Subject: [PATCH 5/5] riotboot: prepare for when FLASHFILE is used This currently does nothing but setting FLASHFILE when flashing. This will allow passing the variable when flasher will use the FLASHFILE variable. --- makefiles/boot/riotboot.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/makefiles/boot/riotboot.mk b/makefiles/boot/riotboot.mk index 7293fcb0d537..7db04d4b5271 100644 --- a/makefiles/boot/riotboot.mk +++ b/makefiles/boot/riotboot.mk @@ -117,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) @@ -129,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) @@ -138,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)