1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

makefiles/boot/riotboot: refactor file storage and naming

- rename riotboot files so that they are of the form: slot<n>.<version>.bin
- move all generated files under $(BINDIR)/riotboot_files (this can be
  overwritten.
This commit is contained in:
Francisco Molina 2021-09-16 15:46:02 +02:00
parent ce35647f6a
commit 17c6717093
3 changed files with 19 additions and 16 deletions

View File

@ -9,7 +9,10 @@ CFLAGS += -I$(BINDIR)/riotbuild
HEADER_TOOL_DIR = $(RIOTBASE)/dist/tools/riotboot_gen_hdr
HEADER_TOOL ?= $(HEADER_TOOL_DIR)/bin/genhdr
BINDIR_APP = $(BINDIR)/$(APPLICATION)
BINDIR_RIOTBOOT = $(BINDIR)/riotboot_files
$(BINDIR_RIOTBOOT): $(CLEAN)
$(Q)mkdir -p $(BINDIR_RIOTBOOT)
#
export SLOT0_OFFSET SLOT0_LEN SLOT1_OFFSET SLOT1_LEN
@ -19,8 +22,8 @@ EPOCH := $(shell date +%s)
APP_VER ?= $(EPOCH)
# Final target for slot 0 with riot_hdr
SLOT0_RIOT_BIN = $(BINDIR_APP)-slot0.$(APP_VER).riot.bin
SLOT1_RIOT_BIN = $(BINDIR_APP)-slot1.$(APP_VER).riot.bin
SLOT0_RIOT_BIN = $(BINDIR_RIOTBOOT)/slot0.$(APP_VER).bin
SLOT1_RIOT_BIN = $(BINDIR_RIOTBOOT)/slot1.$(APP_VER).bin
SLOT_RIOT_BINS = $(SLOT0_RIOT_BIN) $(SLOT1_RIOT_BIN)
# if RIOTBOOT_SKIP_COMPILE is set to 1, "make riotboot/slot[01](-flash)"
@ -28,7 +31,7 @@ SLOT_RIOT_BINS = $(SLOT0_RIOT_BIN) $(SLOT1_RIOT_BIN)
# This results in the equivalent to "make flash-only" for
# "make riotboot/flash-slot[01]".
ifneq (1, $(RIOTBOOT_SKIP_COMPILE))
$(BINDIR_APP)-%.elf: $(BASELIBS) $(ARCHIVES)
$(BINDIR_RIOTBOOT)/%.elf: $(BASELIBS) $(ARCHIVES) $(BINDIR_RIOTBOOT)
$(Q)$(_LINK) -o $@
endif
@ -37,11 +40,11 @@ SLOT0_IMAGE_OFFSET := $$(($(SLOT0_OFFSET) + $(RIOTBOOT_HDR_LEN)))
SLOT1_IMAGE_OFFSET := $$(($(SLOT1_OFFSET) + $(RIOTBOOT_HDR_LEN)))
# Link slots ELF *after* riot_hdr and limit the ROM to the slots length
$(BINDIR_APP)-slot0.elf: FW_ROM_LEN=$$((SLOT0_LEN - $(RIOTBOOT_HDR_LEN)))
$(BINDIR_APP)-slot0.elf: ROM_OFFSET=$(SLOT0_IMAGE_OFFSET)
$(BINDIR_APP)-slot1.elf: FW_ROM_LEN=$$((SLOT1_LEN - $(RIOTBOOT_HDR_LEN)))
$(BINDIR_APP)-slot1.elf: ROM_OFFSET=$(SLOT1_IMAGE_OFFSET)
SLOT_RIOT_ELFS = $(BINDIR_APP)-slot0.elf $(BINDIR_APP)-slot1.elf
$(BINDIR_RIOTBOOT)/slot0.elf: FW_ROM_LEN=$$((SLOT0_LEN - $(RIOTBOOT_HDR_LEN)))
$(BINDIR_RIOTBOOT)/slot0.elf: ROM_OFFSET=$(SLOT0_IMAGE_OFFSET)
$(BINDIR_RIOTBOOT)/slot1.elf: FW_ROM_LEN=$$((SLOT1_LEN - $(RIOTBOOT_HDR_LEN)))
$(BINDIR_RIOTBOOT)/slot1.elf: ROM_OFFSET=$(SLOT1_IMAGE_OFFSET)
SLOT_RIOT_ELFS = $(BINDIR_RIOTBOOT)/slot0.elf $(BINDIR_RIOTBOOT)/slot1.elf
# ensure both slot elf files are always linked
# this ensures that both "make test" and "make test-murdock" can rely on them
@ -49,7 +52,7 @@ SLOT_RIOT_ELFS = $(BINDIR_APP)-slot0.elf $(BINDIR_APP)-slot1.elf
BUILD_FILES += $(SLOT_RIOT_ELFS)
# Create binary target with RIOT header
$(SLOT_RIOT_BINS): %.$(APP_VER).riot.bin: %.hdr %.bin
$(SLOT_RIOT_BINS): %.$(APP_VER).bin: %.hdr %.bin
@echo "creating $@..."
$(Q)cat $^ > $@
@ -68,8 +71,8 @@ $(HEADER_TOOL): FORCE
%.hdr: $(HEADER_TOOL) %.bin FORCE
$(Q)$(HEADER_TOOL) generate $< $(APP_VER) $$(($(ROM_START_ADDR)+$(OFFSET))) $(RIOTBOOT_HDR_LEN) - > $@
$(BINDIR_APP)-slot0.hdr: OFFSET=$(SLOT0_IMAGE_OFFSET)
$(BINDIR_APP)-slot1.hdr: OFFSET=$(SLOT1_IMAGE_OFFSET)
$(BINDIR_RIOTBOOT)/slot0.hdr: OFFSET=$(SLOT0_IMAGE_OFFSET)
$(BINDIR_RIOTBOOT)/slot1.hdr: OFFSET=$(SLOT1_IMAGE_OFFSET)
# Generic target to create a binary files for both slots
riotboot: $(SLOT_RIOT_BINS)
@ -104,12 +107,12 @@ ifneq ($(BOOTLOADER_BIN)/riotboot.bin,$(BINFILE))
endif
# Create combined binary booloader + RIOT firmware with header
RIOTBOOT_COMBINED_BIN = $(BINDIR_APP)-slot0-combined.bin
RIOTBOOT_COMBINED_BIN = $(BINDIR_RIOTBOOT)/slot0-combined.bin
riotboot/combined-slot0: $(RIOTBOOT_COMBINED_BIN)
$(RIOTBOOT_COMBINED_BIN): $(BOOTLOADER_BIN)/riotboot.extended.bin $(SLOT0_RIOT_BIN)
$(Q)cat $^ > $@
RIOTBOOT_EXTENDED_BIN = $(BINDIR_APP)-slot0-extended.bin
RIOTBOOT_EXTENDED_BIN = $(BINDIR_RIOTBOOT)/slot0-extended.bin
# Generate a binary file from slot 0 which covers slot 1 riot_hdr
# in order to invalidate slot 1

View File

@ -50,6 +50,6 @@ number:
Then send via CoAP, for example, with libcoap's coap_client:
$ coap-client -m post coap://[<ip address of node>]/flashwrite \
-f bin/<board>/tests_riotboot_flashwrite-slot1.riot.bin -b 64
-f bin/<board>/riotboot_files/slot1.bin -b 64
Then reboot the node manually, confirming that it booted from slot 1.

View File

@ -36,7 +36,7 @@ def make_notify(client_url, slot, version):
"POST",
"coap://{}/flashwrite".format(client_url),
"--payload",
"@tests_riotboot_flashwrite-slot{}.{}.riot.bin".format(slot, version),
"@riotboot_files/slot{}.{}.bin".format(slot, version),
"--payload-initial-szx",
"2",
]