From e8660b2012694e31023e271d358397b0870ff2ad Mon Sep 17 00:00:00 2001
From: Francisco Acosta <fco.ja.ac@gmail.com>
Date: Fri, 19 Oct 2018 22:25:12 +0200
Subject: [PATCH] cpu/cortex_common: add support for multislot

A second slot is defined with a calculated size, from the
remaining flash after the bootloader and the first slot.
Both slots are defined as equal size, but it can be overriden.
---
 cpu/cortexm_common/Makefile.include | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cpu/cortexm_common/Makefile.include b/cpu/cortexm_common/Makefile.include
index f99c5b6cda..f024eb56bf 100644
--- a/cpu/cortexm_common/Makefile.include
+++ b/cpu/cortexm_common/Makefile.include
@@ -29,6 +29,10 @@ LINKFLAGS += $(if $(FW_ROM_LEN),$(LINKFLAGPREFIX)--defsym=_fw_rom_length=$(FW_RO
 # Configure riotboot bootloader and slot lengths
 # 4KB are currently enough
 RIOTBOOT_LEN ?= 0x1000
-# Take the whole flash minus RIOTBOOT_LEN
-SLOT0_LEN ?= $(shell printf "0x%x" $$(($(ROM_LEN:%K=%*1024)-$(RIOTBOOT_LEN))))
+# Currently 2 slots are supported by default, equals in length
+NUM_SLOTS ?= 2
+# Take the whole flash minus RIOTBOOT_LEN and divide it by NUM_SLOTS
+SLOT0_LEN ?= $(shell printf "0x%x" $$((($(ROM_LEN:%K=%*1024)-$(RIOTBOOT_LEN)) / $(NUM_SLOTS))))
+SLOT1_LEN ?= $(SLOT0_LEN)
 SLOT0_LEN := $(SLOT0_LEN)
+SLOT1_LEN := $(SLOT1_LEN)
-- 
GitLab