aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex J Lennon <alex.lennon@s19.tech>2018-08-02 17:59:24 +0100
committerTomas Vanek <vanekt@fbl.cz>2018-11-26 09:28:01 +0000
commit20113201df25475889a3cd9ee22c0397e4fae530 (patch)
tree24da911b471f1b9a8a4361f64fb7c2ab35567337
parent1b864d6e49d634a382ba1ed13f650898872627cf (diff)
downloadriscv-openocd-20113201df25475889a3cd9ee22c0397e4fae530.zip
riscv-openocd-20113201df25475889a3cd9ee22c0397e4fae530.tar.gz
riscv-openocd-20113201df25475889a3cd9ee22c0397e4fae530.tar.bz2
stm32l4x: Fix stm32l4x dual bank support
The dual bank option was being incorrectly read and the bank b base incorrectly set. This is tested with 512kB dual bank configuration but needs checking with other configurations (e.g. 256kb). This fix should remove the need to use a mass_erase command prior to programming with OpenOCD Change-Id: I6e920f11b794c4c1fd34c0e44fb8fa01e7fe8f85 Signed-off-by: Alex J Lennon <alex.lennon@s19.tech> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4641 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Thomas Søhus <soehus@gmail.com>
-rw-r--r--src/flash/nor/stm32l4x.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c
index ad17921..ae0ae26 100644
--- a/src/flash/nor/stm32l4x.c
+++ b/src/flash/nor/stm32l4x.c
@@ -93,7 +93,7 @@
/* STM32_FLASH_OBR bit definitions (reading) */
-#define OPT_DUALBANK 21 /* dual flash bank only */
+#define OPT_DUALBANK (1 << 21) /* dual flash bank only */
/* register unlock keys */
@@ -631,12 +631,6 @@ static int stm32l4_probe(struct flash_bank *bank)
if (retval != ERROR_OK)
return retval;
- /* only devices with < 1024 kiB may be set to single bank dual banks */
- if ((flash_size_in_kb == 1024) || !(options & OPT_DUALBANK))
- stm32l4_info->bank2_start = 256;
- else
- stm32l4_info->bank2_start = flash_size_in_kb << 9;
-
/* did we assign flash size? */
assert((flash_size_in_kb != 0xffff) && flash_size_in_kb);
@@ -646,6 +640,12 @@ static int stm32l4_probe(struct flash_bank *bank)
/* check that calculation result makes sense */
assert(num_pages > 0);
+ /* only devices with < 1024 kiB may be set to single bank dual banks */
+ if ((flash_size_in_kb == 1024) || !(options & OPT_DUALBANK))
+ stm32l4_info->bank2_start = 256;
+ else
+ stm32l4_info->bank2_start = num_pages / 2;
+
if (bank->sectors) {
free(bank->sectors);
bank->sectors = NULL;