stm32f1x: fix stm32f0/f3 broken unlock 84/984/3
authorSpencer Oliver <spen@spen-soft.co.uk>
Mon, 19 Nov 2012 12:46:33 +0000 (12:46 +0000)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Mon, 31 Dec 2012 19:08:10 +0000 (19:08 +0000)
The STM32F0 and F3 devices use a different default RDP to configure a
unlocked device, make sure we use that.

Change-Id: I170779461412c4c202c2cfc8d90baedb7e388150
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/984
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/flash/nor/stm32f1x.c

index ab6cca9c1171701c3f2945d76fd7cd8ceeb51f11..2d86e56655ae3af6e4f9a456eccec936c484f61d 100644 (file)
@@ -122,6 +122,7 @@ struct stm32x_flash_bank {
        bool has_dual_banks;
        /* used to access dual flash bank stm32xl */
        uint32_t register_base;
+       uint16_t default_rdp;
        int user_data_offset;
 };
 
@@ -291,7 +292,7 @@ static int stm32x_erase_options(struct flash_bank *bank)
 
        /* clear readout protection and complementary option bytes
         * this will also force a device unlock if set */
-       stm32x_info->option_bytes.RDP = 0x5AA5;
+       stm32x_info->option_bytes.RDP = stm32x_info->default_rdp;
 
        return ERROR_OK;
 }
@@ -857,6 +858,9 @@ static int stm32x_probe(struct flash_bank *bank)
        stm32x_info->register_base = FLASH_REG_BASE_B0;
        stm32x_info->user_data_offset = 10;
 
+       /* default factory protection level */
+       stm32x_info->default_rdp = 0x5AA5;
+
        /* read stm32 device id register */
        int retval = stm32x_get_device_id(bank, &device_id);
        if (retval != ERROR_OK)
@@ -896,6 +900,7 @@ static int stm32x_probe(struct flash_bank *bank)
                stm32x_info->ppage_size = 2;
                max_flash_size_in_kb = 256;
                stm32x_info->user_data_offset = 16;
+               stm32x_info->default_rdp = 0x55AA;
                break;
        case 0x428: /* value line High density */
                page_size = 2048;
@@ -913,12 +918,14 @@ static int stm32x_probe(struct flash_bank *bank)
                stm32x_info->ppage_size = 2;
                max_flash_size_in_kb = 256;
                stm32x_info->user_data_offset = 16;
+               stm32x_info->default_rdp = 0x55AA;
                break;
        case 0x440: /* stm32f0x */
                page_size = 1024;
                stm32x_info->ppage_size = 4;
                max_flash_size_in_kb = 64;
                stm32x_info->user_data_offset = 16;
+               stm32x_info->default_rdp = 0x55AA;
                break;
        default:
                LOG_WARNING("Cannot identify target as a STM32 family.");

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)