From c67dfd9918ec3f07b86ac6864532167a77a27f7d Mon Sep 17 00:00:00 2001 From: fjmolinas Date: Sat, 8 Jun 2019 20:08:56 +0200 Subject: [PATCH 1/3] stm32f4/Makefile.include: add riotboot requirements - Stm32f4 use sectors instead of pages. They go from 16 KB to 128KB. The bootloader will use the first sector(16Kb). Slots must start at the begining of a sector to not overlap. - Minimum required RIOBOOT_HDR_LEN or stm32f4 is 0x200 to respect vector table alignment --- cpu/stm32f4/Makefile.include | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cpu/stm32f4/Makefile.include b/cpu/stm32f4/Makefile.include index 4d3c26695cbb..e6ee4ee22fce 100644 --- a/cpu/stm32f4/Makefile.include +++ b/cpu/stm32f4/Makefile.include @@ -1,5 +1,22 @@ export CPU_ARCH = cortex-m4f export CPU_FAM = stm32f4 +# STM32F4 uses sectors instead of pages, where the minimum sector length is 16KB +# (the first sector), therefore RIOTBOOT_LEN must be 16KB to cover a whole sector. +RIOTBOOT_LEN ?= 0x4000 + +# CPU_IRQ_NUMOF for STM32F4 boards is < 102+16 so (118*4 bytes = 472 bytes ~= 0x200) +# RIOTBOOT_HDR_LEN can be set to 0x200. +# Details on alignment requirements for M4 in `cpu/cortexm_common/Makefile.include`. +RIOTBOOT_HDR_LEN ?= 0x200 + +# Sectors don't have the same length. Per bank there can be up to 12 sectors. The +# first 4 sectors are 16kB long, the 5th is 64kB and the remaining 7 are 128kB. +# Since flash can only be erased by sector, slots can't overlap over sectors. +# RIOTBOOT_LEN is removed twice, once at the start of the flash for the bootloader, +# and a second time at the end of the flash, to get evenly sized and distributed slots. +SLOT0_LEN ?= $(shell printf "0x%x" $$((($(ROM_LEN:%K=%*1024)-2*$(RIOTBOOT_LEN)) / $(NUM_SLOTS)))) +SLOT1_LEN ?= $(SLOT0_LEN) + include $(RIOTCPU)/stm32_common/Makefile.include include $(RIOTMAKE)/arch/cortexm.inc.mk From 9418eef573ca18fb554bdae4a83160760a4cf46c Mon Sep 17 00:00:00 2001 From: fjmolinas Date: Sat, 8 Jun 2019 19:31:47 +0200 Subject: [PATCH 2/3] boards/stm32f429i-disc1: add riotboot --- boards/stm32f429i-disc1/Makefile.features | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boards/stm32f429i-disc1/Makefile.features b/boards/stm32f429i-disc1/Makefile.features index d99f79cf11ee..f0730e545435 100644 --- a/boards/stm32f429i-disc1/Makefile.features +++ b/boards/stm32f429i-disc1/Makefile.features @@ -4,4 +4,7 @@ FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart +# Put other features for this board (in alphabetical order) +FEATURES_PROVIDED += riotboot + include $(RIOTCPU)/stm32f4/Makefile.features From bfcb963d1ef7e3ae9371364e109f19b05d6803c8 Mon Sep 17 00:00:00 2001 From: francisco Date: Tue, 11 Jun 2019 09:41:13 +0200 Subject: [PATCH 3/3] boards/nucleo-f446re: add riotboot --- boards/nucleo-f446re/Makefile.features | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/nucleo-f446re/Makefile.features b/boards/nucleo-f446re/Makefile.features index f174862bda48..fc96658a9cf1 100644 --- a/boards/nucleo-f446re/Makefile.features +++ b/boards/nucleo-f446re/Makefile.features @@ -10,6 +10,7 @@ FEATURES_PROVIDED += periph_qdec # Various other features (if any) FEATURES_PROVIDED += motor_driver +FEATURES_PROVIDED += riotboot # load the common Makefile.features for Nucleo boards include $(RIOTBOARD)/common/nucleo64/Makefile.features