From 0736da8aa3ab4891524a47bf9452b58ca5b7cce2 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Tue, 21 Feb 2023 15:06:40 +0000 Subject: [PATCH] Move FLASH_PAGE_SIZE definition to CPU specific target.h files (#12394) * Never block use of SWD pins * Split the AT-START-F435 and REVO-AT configs out from AT32F435/target.h * Move FLASH_PAGE_SIZE definition to CPU specific target.h files --------- Co-authored-by: J Blackman --- src/main/config/config_streamer.c | 43 +------------------------------------- src/main/target/AT32F435/target.h | 2 ++ src/main/target/SITL/target.h | 2 ++ src/main/target/STM32F405/target.h | 2 ++ src/main/target/STM32F411/target.h | 2 ++ src/main/target/STM32F745/target.h | 2 ++ src/main/target/STM32F7X2/target.h | 2 ++ src/main/target/STM32G47X/target.h | 1 + src/main/target/STM32H723/target.h | 2 ++ src/main/target/STM32H730/target.h | 6 ++++++ src/main/target/STM32H743/target.h | 2 ++ src/main/target/STM32H750/target.h | 6 ++++++ 12 files changed, 30 insertions(+), 42 deletions(-) diff --git a/src/main/config/config_streamer.c b/src/main/config/config_streamer.c index dc512d3ae..cf2b35fe3 100644 --- a/src/main/config/config_streamer.c +++ b/src/main/config/config_streamer.c @@ -36,49 +36,8 @@ uint8_t eepromData[EEPROM_SIZE]; #endif -#if (defined(STM32H750xx) || defined(STM32H730xx)) && !(defined(CONFIG_IN_EXTERNAL_FLASH) || defined(CONFIG_IN_MEMORY_MAPPED_FLASH) || defined(CONFIG_IN_RAM) || defined(CONFIG_IN_SDCARD)) -#error "The configured MCU only has one flash page which contains the bootloader, no spare flash pages available, use external storage for persistent config or ram for target testing" -#endif -// @todo this is not strictly correct for F4/F7, where sector sizes are variable #if !defined(FLASH_PAGE_SIZE) -// F4 -#if defined(STM32F40_41xxx) -# define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors -# elif defined(STM32F411xE) -# define FLASH_PAGE_SIZE ((uint32_t)0x4000) -# elif defined(STM32F427_437xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x4000) -# elif defined(STM32F446xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x4000) -# elif defined(AT32F435ZMT7) || defined(AT32F435RMT7) -# define FLASH_PAGE_SIZE ((uint32_t)0x1000) // 4K sectors -# elif defined(AT32F435RGT7) -# define FLASH_PAGE_SIZE ((uint32_t)0x0800) // 2K sectors -// F7 -#elif defined(STM32F722xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors -# elif defined(STM32F745xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x8000) // 32K sectors -# elif defined(STM32F746xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x8000) -# elif defined(STM32F765xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x8000) -# elif defined(UNIT_TEST) -# define FLASH_PAGE_SIZE (0x400) -// H7 -# elif defined(STM32H743xx) || defined(STM32H750xx) || defined(STM32H723xx) || defined(STM32H725xx) || defined(STM32H730xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x20000) // 128K sectors -# elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ) -# define FLASH_PAGE_SIZE ((uint32_t)0x2000) // 8K sectors -// G4 -# elif defined(STM32G4) -# define FLASH_PAGE_SIZE ((uint32_t)0x800) // 2K page -// SIMULATOR -# elif defined(SIMULATOR_BUILD) -# define FLASH_PAGE_SIZE (0x400) -# else -# error "Flash page size not defined for target." -# endif +#error "Flash page size not defined for target." #endif void config_streamer_init(config_streamer_t *c) diff --git a/src/main/target/AT32F435/target.h b/src/main/target/AT32F435/target.h index 80a160359..3f50749e4 100644 --- a/src/main/target/AT32F435/target.h +++ b/src/main/target/AT32F435/target.h @@ -87,3 +87,5 @@ #undef USE_FLASH #undef USE_FLASHFS #undef USE_FLASH_CHIP + +#define FLASH_PAGE_SIZE ((uint32_t)0x1000) // 4K sectors diff --git a/src/main/target/SITL/target.h b/src/main/target/SITL/target.h index bc75d4dd2..aaf8677dd 100644 --- a/src/main/target/SITL/target.h +++ b/src/main/target/SITL/target.h @@ -155,6 +155,8 @@ #define DEFIO_NO_PORTS // suppress 'no pins defined' warning +#define FLASH_PAGE_SIZE (0x400) + // belows are internal stuff extern uint32_t SystemCoreClock; diff --git a/src/main/target/STM32F405/target.h b/src/main/target/STM32F405/target.h index 4de47a259..67182bc70 100644 --- a/src/main/target/STM32F405/target.h +++ b/src/main/target/STM32F405/target.h @@ -80,3 +80,5 @@ #define USE_CUSTOM_DEFAULTS #define USE_EXTI + +#define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors diff --git a/src/main/target/STM32F411/target.h b/src/main/target/STM32F411/target.h index cb5a213ed..6d8e6f34d 100644 --- a/src/main/target/STM32F411/target.h +++ b/src/main/target/STM32F411/target.h @@ -77,3 +77,5 @@ #define USE_CUSTOM_DEFAULTS #define USE_EXTI + +#define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors diff --git a/src/main/target/STM32F745/target.h b/src/main/target/STM32F745/target.h index f1e7c54eb..4d39c06a3 100644 --- a/src/main/target/STM32F745/target.h +++ b/src/main/target/STM32F745/target.h @@ -87,3 +87,5 @@ #define USE_CUSTOM_DEFAULTS #define USE_EXTI + +#define FLASH_PAGE_SIZE ((uint32_t)0x8000) // 32K sectors diff --git a/src/main/target/STM32F7X2/target.h b/src/main/target/STM32F7X2/target.h index 62a63d2cf..c4980bd9f 100644 --- a/src/main/target/STM32F7X2/target.h +++ b/src/main/target/STM32F7X2/target.h @@ -79,3 +79,5 @@ #define USE_CUSTOM_DEFAULTS #define USE_EXTI + +#define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors diff --git a/src/main/target/STM32G47X/target.h b/src/main/target/STM32G47X/target.h index d3bd73b4c..76c665fe8 100644 --- a/src/main/target/STM32G47X/target.h +++ b/src/main/target/STM32G47X/target.h @@ -79,3 +79,4 @@ #define USE_CUSTOM_DEFAULTS #define USE_EXTI #define USE_TIMER_UP_CONFIG + diff --git a/src/main/target/STM32H723/target.h b/src/main/target/STM32H723/target.h index 9e87c51fb..eaa67ec45 100644 --- a/src/main/target/STM32H723/target.h +++ b/src/main/target/STM32H723/target.h @@ -102,3 +102,5 @@ #define USE_EXTI #define USE_TIMER_UP_CONFIG + +#define FLASH_PAGE_SIZE ((uint32_t)0x20000) // 128K sectors diff --git a/src/main/target/STM32H730/target.h b/src/main/target/STM32H730/target.h index 528768ff8..35ca8b289 100644 --- a/src/main/target/STM32H730/target.h +++ b/src/main/target/STM32H730/target.h @@ -114,3 +114,9 @@ #define USE_EXTI #define USE_TIMER_UP_CONFIG + +#if !(defined(CONFIG_IN_EXTERNAL_FLASH) || defined(CONFIG_IN_MEMORY_MAPPED_FLASH) || defined(CONFIG_IN_RAM) || defined(CONFIG_IN_SDCARD)) +#error "The configured MCU only has one flash page which contains the bootloader, no spare flash pages available, use external storage for persistent config or ram for target testing" +#endif + +#define FLASH_PAGE_SIZE ((uint32_t)0x20000) // 128K sectors diff --git a/src/main/target/STM32H743/target.h b/src/main/target/STM32H743/target.h index 9b6ae57ac..2f38f1865 100644 --- a/src/main/target/STM32H743/target.h +++ b/src/main/target/STM32H743/target.h @@ -88,3 +88,5 @@ #define USE_CUSTOM_DEFAULTS #define USE_EXTI #define USE_TIMER_UP_CONFIG + +#define FLASH_PAGE_SIZE ((uint32_t)0x20000) // 128K sectors diff --git a/src/main/target/STM32H750/target.h b/src/main/target/STM32H750/target.h index 6adc709c9..09ab77365 100644 --- a/src/main/target/STM32H750/target.h +++ b/src/main/target/STM32H750/target.h @@ -109,3 +109,9 @@ #define USE_EXTI #define USE_TIMER_UP_CONFIG + +#if !(defined(CONFIG_IN_EXTERNAL_FLASH) || defined(CONFIG_IN_MEMORY_MAPPED_FLASH) || defined(CONFIG_IN_RAM) || defined(CONFIG_IN_SDCARD)) +#error "The configured MCU only has one flash page which contains the bootloader, no spare flash pages available, use external storage for persistent config or ram for target testing" +#endif + +#define FLASH_PAGE_SIZE ((uint32_t)0x20000) // 128K sectors -- 2.11.4.GIT