stm32: fix unprotect
authorØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 14 Dec 2010 08:26:08 +0000 (09:26 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Wed, 15 Dec 2010 08:48:37 +0000 (09:48 +0100)
the unprotect fn in stm32 needs to unprotect more sectors
than was requested aligned to some boundary.

Print warning when this happens.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/flash/nor/stm32x.c

index 0edadfd2ae82e90b98eedcd24d8d2f5265b41120..3c49b8be1b3a587e52cfcd4cf86ba8e0c7b52747 100644 (file)
@@ -487,12 +487,19 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last)
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       if ((first && (first % stm32x_info->ppage_size)) || ((last + 1) &&
-                       (last + 1) % stm32x_info->ppage_size))
+       if ((first % stm32x_info->ppage_size) != 0)
        {
-               LOG_WARNING("Error: start and end sectors must be on a %d sector boundary",
+               LOG_WARNING("aligned start protect sector to a %d sector boundary",
                                stm32x_info->ppage_size);
-               return ERROR_FLASH_SECTOR_INVALID;
+               first = first - (first % stm32x_info->ppage_size);
+       }
+       if (((last + 1) % stm32x_info->ppage_size) != 0)
+       {
+               LOG_WARNING("aligned end protect sector to a %d sector boundary",
+                               stm32x_info->ppage_size);
+               last++;
+               last = last - (last % stm32x_info->ppage_size);
+               last--;
        }
 
        /* medium density - each bit refers to a 4bank protection

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)