stm32l4x: Fix stm32l4x dual bank support 41/4641/3
authorAlex J Lennon <alex.lennon@s19.tech>
Thu, 2 Aug 2018 16:59:24 +0000 (17:59 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Mon, 26 Nov 2018 09:28:01 +0000 (09:28 +0000)
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>
src/flash/nor/stm32l4x.c

index ad179216d86019a213b6a0a8c804a5ac0d6457c6..ae0ae26ac14f74cbaa386fefb8fc8990d78bde91 100644 (file)
@@ -93,7 +93,7 @@
 
 /* STM32_FLASH_OBR bit definitions (reading) */
 
 
 /* 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 */
 
 
 /* register unlock keys */
 
@@ -631,12 +631,6 @@ static int stm32l4_probe(struct flash_bank *bank)
        if (retval != ERROR_OK)
                return retval;
 
        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);
 
        /* 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);
 
        /* 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;
        if (bank->sectors) {
                free(bank->sectors);
                bank->sectors = NULL;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)