diff --git a/makefiles/boot/riotboot.mk b/makefiles/boot/riotboot.mk index 5724116cb8..bca34b714e 100644 --- a/makefiles/boot/riotboot.mk +++ b/makefiles/boot/riotboot.mk @@ -10,22 +10,8 @@ HEADER_TOOL_DIR = $(RIOTBASE)/dist/tools/riotboot_gen_hdr HEADER_TOOL ?= $(HEADER_TOOL_DIR)/bin/genhdr BINDIR_APP = $(BINDIR)/$(APPLICATION) -# Indicate the reserved space for a header, 256B by default -# Notice that it must be 256B aligned. This is restricted by -# the Cortex-M0+/3/4/7 architecture -RIOTBOOT_HDR_LEN ?= 0x100 - -# Export variables for 'riotboot_slot' -export SLOT0_LEN -export SLOT1_LEN -export NUM_SLOTS - -# By default, slot 0 is found just after RIOTBOOT_LEN. Slot 1 after -# slot 0. The values might be overridden to add more or less offset -# if needed. -export SLOT0_OFFSET ?= $(RIOTBOOT_LEN) -# export does not work properly with variables using '$(( ))' so evaluate it in a shell -export SLOT1_OFFSET ?= $(shell echo $$(($(SLOT0_OFFSET) + $(SLOT0_LEN)))) +# +export SLOT0_OFFSET SLOT0_LEN SLOT1_OFFSET SLOT1_LEN # Mandatory APP_VER, set to epoch by default APP_VER ?= $(shell date +%s) diff --git a/sys/Makefile.include b/sys/Makefile.include index ae261c840b..d4b5b1b83d 100644 --- a/sys/Makefile.include +++ b/sys/Makefile.include @@ -88,6 +88,10 @@ ifneq (,$(filter printf_float,$(USEMODULE))) endif endif +ifneq (,$(filter riotboot_%,$(USEMODULE))) + include $(RIOTBASE)/sys/riotboot/Makefile.include +endif + ifneq (,$(filter ssp,$(USEMODULE))) include $(RIOTBASE)/sys/ssp/Makefile.include endif diff --git a/sys/riotboot/Makefile b/sys/riotboot/Makefile index b673cb4f82..cd1af2456e 100644 --- a/sys/riotboot/Makefile +++ b/sys/riotboot/Makefile @@ -1,11 +1,3 @@ SUBMODULES := 1 -ifneq (,$(filter riotboot_slot,$(USEMODULE))) - CFLAGS += -DSLOT0_LEN=$(SLOT0_LEN) - CFLAGS += -DSLOT0_OFFSET=$(SLOT0_OFFSET) - CFLAGS += -DSLOT1_LEN=$(SLOT1_LEN) - CFLAGS += -DSLOT1_OFFSET=$(SLOT1_OFFSET) - CFLAGS += -DNUM_SLOTS=$(NUM_SLOTS) -endif - include $(RIOTBASE)/Makefile.base diff --git a/sys/riotboot/Makefile.include b/sys/riotboot/Makefile.include new file mode 100644 index 0000000000..4e2d9b6c62 --- /dev/null +++ b/sys/riotboot/Makefile.include @@ -0,0 +1,16 @@ +# Indicate the reserved space for a header, 256B by default +# Notice that it must be 256B aligned. This is restricted by +# the Cortex-M0+/3/4/7 architecture +RIOTBOOT_HDR_LEN ?= 0x100 + +# By default, slot 0 is found just after RIOTBOOT_LEN. Slot 1 after +# slot 0. The values might be overridden to add more or less offset +# if needed. +SLOT0_OFFSET ?= $(RIOTBOOT_LEN) +SLOT1_OFFSET ?= $(shell echo $$(($(SLOT0_OFFSET) + $(SLOT0_LEN)))) + +CFLAGS += -DSLOT0_LEN=$(SLOT0_LEN) +CFLAGS += -DSLOT0_OFFSET=$(SLOT0_OFFSET) +CFLAGS += -DSLOT1_LEN=$(SLOT1_LEN) +CFLAGS += -DSLOT1_OFFSET=$(SLOT1_OFFSET) +CFLAGS += -DNUM_SLOTS=$(NUM_SLOTS)