This is an automated email from Gerrit.

"Tarek BOCHKATI <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6538

-- gerrit

commit 3a73b22cd1c4299e894eabf5987ad9dc2fb94956
Author: Tarek BOCHKATI <[email protected]>
Date:   Thu Sep 2 12:03:59 2021 +0100

    flash/stm32l4x: fix dual bank support for STM32L552xC devices
    
    For STM32L552xC devices with 256K flash:
      dual bank mode is activated if DB256 is set
      page size is 2KB if DBANK is set
    
    For parts with 512K (aka STM32L5x2xE):
      DBANK controls both of dual/single bank mode and page size as well.
    
    Change-Id: I8be668d5552fefe81acffaf2e3e35ef5e938162e
    Signed-off-by: Tarek BOCHKATI <[email protected]>
    Reported-by: Patrik Bachan <[email protected]>
    Fixes: https://sourceforge.net/p/openocd/tickets/317/

diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c
index f16d457cf..eaa553467 100644
--- a/src/flash/nor/stm32l4x.c
+++ b/src/flash/nor/stm32l4x.c
@@ -1921,15 +1921,21 @@ static int stm32l4_probe(struct flash_bank *bank)
                /* STM32L55/L56xx can be single/dual bank:
                 *   if size = 512K check DBANK bit
                 *   if size = 256K check DB256K bit
+                * if DBANK = 1, the page size is 2kb (applies to 512K and 256K 
devices)
                 */
                page_size_kb = 4;
                num_pages = flash_size_kb / page_size_kb;
                stm32l4_info->bank1_sectors = num_pages;
+
+               /* if DBANK bit is set, the page size is 2 kb */
+               if (stm32l4_info->optr & FLASH_L5_DBANK) {
+                       page_size_kb = 2;
+                       num_pages = flash_size_kb / page_size_kb;
+               }
+
                if ((is_max_flash_size && (stm32l4_info->optr & 
FLASH_L5_DBANK)) ||
                        (!is_max_flash_size && (stm32l4_info->optr & 
FLASH_L5_DB256))) {
                        stm32l4_info->dual_bank_mode = true;
-                       page_size_kb = 2;
-                       num_pages = flash_size_kb / page_size_kb;
                        stm32l4_info->bank1_sectors = num_pages / 2;
                }
                break;

-- 

Reply via email to