From eea011fe70e235065501527af9a6d3fdbd797519 Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Wed, 2 Aug 2017 16:11:34 -0700 Subject: [PATCH] Allow compile-time override of detected flash size. On the STM32F103C8, as used in the "blue pill" boards, it has been determined that, despite these only officially having 64KiB flash, it is possible to actually use 128KiB of flash. This commit allows for a preprocessor define STM32F103_OVERRIDE_FLASH_SIZE which, when set, is used as the size of flash in KiB instead of reading it from the FLASH_SIZE_REG. --- AUTHORS | 4 ++++ ChangeLog | 5 +++++ regnual/regnual.c | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 1e5c78d..d63138a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,6 +4,10 @@ Anthony Romano: src/main.c src/mod.c +Jeremy Drake: + Modified: + regnual/regnual.c + Kaz Kojima: Added STM32 Primer2 support. diff --git a/ChangeLog b/ChangeLog index 115fcc2..2813c84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-08-03 Jeremy Drake + + * regnual/regnual.c (main): Allow compile time + flash size definition by STM32F103_OVERRIDE_FLASH_SIZE_KB. + 2017-08-02 Jeremy Drake * src/flash.c (flash_terminate): Erase Certificate DO, too. diff --git a/regnual/regnual.c b/regnual/regnual.c index e472669..1ee5c56 100644 --- a/regnual/regnual.c +++ b/regnual/regnual.c @@ -1,7 +1,7 @@ /* * regnual.c -- Firmware installation for STM32F103 Flash ROM * - * Copyright (C) 2012, 2013, 2015, 2016 + * Copyright (C) 2012, 2013, 2015, 2016, 2017 * Free Software Initiative of Japan * Author: NIIBE Yutaka * @@ -365,7 +365,11 @@ main (int argc, char *argv[]) set_led (0); +#if defined(STM32F103_OVERRIDE_FLASH_SIZE_KB) + flash_end = FLASH_START_ADDR + STM32F103_OVERRIDE_FLASH_SIZE_KB*1024; +#else flash_end = FLASH_START_ADDR + (*FLASH_SIZE_REG)*1024; +#endif /* * NVIC interrupt priority was set by Gnuk.