From 8a0a0be42602f39db2db13d9e61524dda2fa6e73 Mon Sep 17 00:00:00 2001 From: Francisco Acosta Date: Wed, 2 Jan 2019 13:49:18 +0100 Subject: [PATCH] riotboot: allow to overwrite slot 1 By erasing slot 1 header the slot gets invalidated. This is very useful while debugging, since we can force the bootloader to ignore anything on that slot. --- makefiles/boot/riotboot.mk | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/makefiles/boot/riotboot.mk b/makefiles/boot/riotboot.mk index ff770e4c63..96201509a7 100644 --- a/makefiles/boot/riotboot.mk +++ b/makefiles/boot/riotboot.mk @@ -103,13 +103,27 @@ riotboot/combined-slot0: $(RIOTBOOT_COMBINED_BIN) $(RIOTBOOT_COMBINED_BIN): $(BOOTLOADER_BIN)/riotboot.extended.bin $(SLOT0_RIOT_BIN) $(Q)cat $^ > $@ -# Flashing rule for edbg to flash combined binaries +RIOTBOOT_EXTENDED_BIN = $(BINDIR_APP)-slot0-extended.bin + +# Generate a binary file from slot 0 which covers slot 1 riot_hdr +# in order to invalidate slot 1 +$(RIOTBOOT_EXTENDED_BIN): $(RIOTBOOT_COMBINED_BIN) + $(Q)cp $^ $@.tmp + $(Q)truncate -s $$(($(SLOT0_OFFSET) + $(SLOT0_LEN) + $(RIOTBOOT_HDR_LEN))) $@.tmp + $(Q)mv $@.tmp $@ + +# Flashing rule for edbg to flash combined/extended binaries riotboot/flash-combined-slot0: HEXFILE=$(RIOTBOOT_COMBINED_BIN) -# Flashing rule for openocd to flash combined binaries +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: $(RIOTBOOT_COMBINED_BIN) $(FLASHDEPS) $(FLASHER) $(FFLAGS) +riotboot/flash-extended-slot0: $(RIOTBOOT_EXTENDED_BIN) $(FLASHDEPS) + $(FLASHER) $(FFLAGS) + # Flashing rule for slot 0 riotboot/flash-slot0: export IMAGE_OFFSET=$(SLOT0_OFFSET) # Flashing rule for edbg to flash only slot 0