- fix bug with stm32 high density write protection
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 22 Jul 2008 14:30:52 +0000 (14:30 +0000)
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 22 Jul 2008 14:30:52 +0000 (14:30 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@858 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/stm32x.c
src/tcl/cpu/arm/cortex_m3.tcl

index a8125f4766d26dd53fe1115abdef140719ef1a2c..899dad99b1d17004a683bab5c85074f590ac58cd 100644 (file)
@@ -385,15 +385,43 @@ int stm32x_protect(struct flash_bank_s *bank, int set, int first, int last)
        prot_reg[2] = (u16)(protection >> 16);
        prot_reg[3] = (u16)(protection >> 24);
        
-       for (i = first; i <= last; i++)
+       if (stm32x_info->ppage_size == 2)
        {
-               reg = (i / stm32x_info->ppage_size) / 8;
-               bit = (i / stm32x_info->ppage_size) - (reg * 8);
+               /* high density flash */
                
-               if( set )
-                       prot_reg[reg] &= ~(1 << bit);
-               else
-                       prot_reg[reg] |= (1 << bit);
+               /* bit 7 controls sector 62 - 255 protection */
+               if (first > 61 || last <= 255)
+                       prot_reg[3] |= (1 << 7);
+               
+               if (first > 61)
+                       first = 61;
+               if (last > 61)
+                       last = 61;
+               
+               for (i = first; i <= last; i++)
+               {
+                       reg = (i / stm32x_info->ppage_size) / 8;
+                       bit = (i / stm32x_info->ppage_size) - (reg * 8);
+                       
+                       if( set )
+                               prot_reg[reg] &= ~(1 << bit);
+                       else
+                               prot_reg[reg] |= (1 << bit);
+               }
+       }
+       else
+       {
+               /* medium density flash */
+               for (i = first; i <= last; i++)
+               {
+                       reg = (i / stm32x_info->ppage_size) / 8;
+                       bit = (i / stm32x_info->ppage_size) - (reg * 8);
+                       
+                       if( set )
+                               prot_reg[reg] &= ~(1 << bit);
+                       else
+                               prot_reg[reg] |= (1 << bit);
+               }
        }
        
        if ((status = stm32x_erase_options(bank)) != ERROR_OK)
index b4bbcce1a2da32a7099cb7309dcc943b7772c2a0..166af847db84122bce55524ee6372d3058cb52b5 100644 (file)
@@ -1,6 +1,6 @@
-set CPU_TYPE   arm\r
-set CPU_NAME   cortex_m3\r
-set CPU_ARCH   armv7\r
-set CPU_MAX_ADDRESS 0xFFFFFFFF\r
-set CPU_NBITS  32\r
-\r
+set CPU_TYPE   arm
+set CPU_NAME   cortex_m3
+set CPU_ARCH   armv7
+set CPU_MAX_ADDRESS 0xFFFFFFFF
+set CPU_NBITS  32
+

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)