flash/stm32h7x: Use proper flash regs base for bank 1 34/5534/11
authorSasha Kozaruk <alkhozar@gmail.com>
Fri, 20 Mar 2020 01:53:24 +0000 (18:53 -0700)
committerTomas Vanek <vanekt@fbl.cz>
Sun, 5 Apr 2020 13:28:17 +0000 (14:28 +0100)
On stm32h747 writing/erasing bank 1 didn't work. It was because the
flash register base was always set for bank 0.
Tested on STM32H747I-DISCO board.

Change-Id: I7e8c43ecdda9dc70b114905f5ec6a6753ca29d82
Signed-off-by: Sasha Kozaruk <alkhozar@gmail.com>
Reviewed-on: http://openocd.zylin.com/5534
Reviewed-by: Christopher Head <chead@zaber.com>
Tested-by: jenkins
src/flash/nor/stm32h7x.c

index 1e2b35159053cdd40b503b8f208839583345b25f..7b6fdb39ca422d03d7c5c652e95ee0327dedc945 100644 (file)
@@ -118,7 +118,6 @@ struct stm32h7x_part_info {
        uint16_t max_flash_size_kb;
        bool has_dual_bank;
        uint16_t max_bank_size_kb;  /* Used when has_dual_bank is true */
-       uint32_t flash_regs_base;   /* Flash controller registers location */
        uint32_t fsize_addr;        /* Location of FSIZE register */
        uint32_t wps_group_size;    /* write protection group sectors' count */
        uint32_t wps_mask;
@@ -175,7 +174,6 @@ static const struct stm32h7x_part_info stm32h7x_parts[] = {
        .max_flash_size_kb      = 2048,
        .max_bank_size_kb       = 1024,
        .has_dual_bank          = true,
-       .flash_regs_base        = FLASH_REG_BASE_B0,
        .fsize_addr                     = 0x1FF1E880,
        .wps_group_size         = 1,
        .wps_mask                       = 0xFF,
@@ -191,7 +189,6 @@ static const struct stm32h7x_part_info stm32h7x_parts[] = {
        .max_flash_size_kb      = 2048,
        .max_bank_size_kb       = 1024,
        .has_dual_bank          = true,
-       .flash_regs_base        = FLASH_REG_BASE_B0,
        .fsize_addr                     = 0x08FFF80C,
        .wps_group_size         = 4,
        .wps_mask                       = 0xFFFFFFFF,
@@ -763,8 +760,16 @@ static int stm32x_probe(struct flash_bank *bank)
                LOG_INFO("Device: %s", stm32x_info->part_info->device_str);
        }
 
-       /* update the address of controller from data base */
-       stm32x_info->flash_regs_base = stm32x_info->part_info->flash_regs_base;
+       /* update the address of controller */
+       if (bank->base == FLASH_BANK0_ADDRESS)
+               stm32x_info->flash_regs_base = FLASH_REG_BASE_B0;
+       else if (bank->base == FLASH_BANK1_ADDRESS)
+               stm32x_info->flash_regs_base = FLASH_REG_BASE_B1;
+       else {
+               LOG_WARNING("Flash register base not defined for bank %d", bank->bank_number);
+               return ERROR_FAIL;
+       }
+       LOG_DEBUG("flash_regs_base: 0x%" PRIx32, stm32x_info->flash_regs_base);
 
        /* get flash size from target */
        retval = target_read_u16(target, stm32x_info->part_info->fsize_addr, &flash_size_in_kb);

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)