From 7cb421e866ce4bb3c2970db3c0e25fe7ac679d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=81yszczek?= Date: Fri, 29 Jul 2022 00:13:47 +0200 Subject: [PATCH] boards/stm32wl5/flash: add support to define bootloader partition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Łyszczek --- boards/arm/stm32wl5/nucleo-wl55jc/Kconfig | 13 +++++++++++++ .../stm32wl5/nucleo-wl55jc/src/stm32_flash.c | 19 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/boards/arm/stm32wl5/nucleo-wl55jc/Kconfig b/boards/arm/stm32wl5/nucleo-wl55jc/Kconfig index 134d59c7ae..b22834bb01 100644 --- a/boards/arm/stm32wl5/nucleo-wl55jc/Kconfig +++ b/boards/arm/stm32wl5/nucleo-wl55jc/Kconfig @@ -46,6 +46,19 @@ comment "FLASH partitioning and mounting requires !DISABLE_MOUNTPOINT" if ARCH_BOARD_FLASH_MOUNT +config ARCH_BOARD_FLASH_BL_PROG_SIZE + int "Size reserved for bootloader program code" + default 0 + ---help--- + How much memory to reserve for bootloader program code. + If you are using bootloader in your application, specify + max size of bootloader partition. This memory will be + reserved at the beginning of flash, and CPU1 progmem will + be right after bootloader. + + If you don't use bootloader and just want to run program + directly after reset, set this to 0. + config ARCH_BOARD_FLASH_CPU1_PROG_SIZE int "Size reserved for CPU1 program code" default 127 diff --git a/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c b/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c index 1906580d35..e9e7ed5891 100644 --- a/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c +++ b/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c @@ -41,6 +41,10 @@ /* Define default values to silent compiler warning about undefined macro */ +#ifndef CONFIG_ARCH_BOARD_FLASH_BL_PROG_SIZE +#define CONFIG_ARCH_BOARD_FLASH_BL_PROG_SIZE 0 +#endif + #ifndef CONFIG_ARCH_BOARD_FLASH_CPU1_PROG_SIZE #define CONFIG_ARCH_BOARD_FLASH_CPU1_PROG_SIZE 0 #endif @@ -65,7 +69,8 @@ #define CONFIG_ARCH_BOARD_FLASH_PART4_SIZE 0 #endif -#if (CONFIG_ARCH_BOARD_FLASH_CPU1_PROG_SIZE + \ +#if (CONFIG_ARCH_BOARD_FLASH_BL_PROG_SIZE + \ + CONFIG_ARCH_BOARD_FLASH_CPU1_PROG_SIZE + \ CONFIG_ARCH_BOARD_FLASH_CPU2_PROG_SIZE + \ CONFIG_ARCH_BOARD_FLASH_PART1_SIZE + \ CONFIG_ARCH_BOARD_FLASH_PART2_SIZE + \ @@ -74,7 +79,8 @@ # error "Sum of all flash pertitions cannot be bigger than 128" #endif -#if (CONFIG_ARCH_BOARD_FLASH_CPU1_PROG_SIZE + \ +#if (CONFIG_ARCH_BOARD_FLASH_BL_PROG_SIZE + \ + CONFIG_ARCH_BOARD_FLASH_CPU1_PROG_SIZE + \ CONFIG_ARCH_BOARD_FLASH_CPU2_PROG_SIZE + \ CONFIG_ARCH_BOARD_FLASH_PART1_SIZE + \ CONFIG_ARCH_BOARD_FLASH_PART2_SIZE + \ @@ -101,6 +107,15 @@ struct part_table static const struct part_table part_table[] = { +#if CONFIG_ARCH_BOARD_FLASH_BL_PROG_SIZE > 0 + { + .size = CONFIG_ARCH_BOARD_FLASH_BL_PROG_SIZE, + .name = "bl-progmem", + .mnt = NULL, + .fs = "rawfs" + }, +#endif + { .size = CONFIG_ARCH_BOARD_FLASH_CPU1_PROG_SIZE, .name = "cpu1-progmem",