This is an automated email from Gerrit.

Paul Fertser (fercer...@gmail.com) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2490

-- gerrit

commit 52492620f455e7acf88ad15dba0c969e331ca651
Author: Paul Fertser <fercer...@gmail.com>
Date:   Fri Jan 23 12:33:50 2015 +0300

    flash/nor/stm32l: fix mass erase
    
    Topaz reports on http://sourceforge.net/p/openocd/tickets/87/ that
    protection level constants are mixed up. This leads to device ending
    up in protection level 1 after mass erase.
    
    Change-Id: I9a838909458039bb0114d3019723bf134fa4d7c9
    Signed-off-by: Paul Fertser <fercer...@gmail.com>

diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c
index e5b66cf..bacf4a0 100644
--- a/src/flash/nor/stm32lx.c
+++ b/src/flash/nor/stm32lx.c
@@ -95,8 +95,8 @@
 /* option bytes */
 #define OPTION_BYTES_ADDRESS 0x1FF80000
 
-#define OPTION_BYTE_0_PR1 0x015500AA
-#define OPTION_BYTE_0_PR0 0x01FF0011
+#define OPTION_BYTE_0_PR1 0xFFFF0000
+#define OPTION_BYTE_0_PR0 0xFF5500AA
 
 static int stm32lx_unlock_program_memory(struct flash_bank *bank);
 static int stm32lx_lock_program_memory(struct flash_bank *bank);
@@ -1240,14 +1240,21 @@ static int stm32lx_mass_erase(struct flash_bank *bank)
        if (retval != ERROR_OK)
                return retval;
 
-       /* mass erase flash memory, write 0x015500AA option byte address 0*/
-       /* pass the RDP privilege to 1 */
+       /* mass erase flash memory */
+       /* set the RDP protection level to 1 */
        retval = target_write_u32(target, OPTION_BYTES_ADDRESS, 
OPTION_BYTE_0_PR1);
+       if (retval != ERROR_OK)
+               return retval;
+
+       retval = stm32lx_wait_status_busy(bank, 30000);
+       if (retval != ERROR_OK)
+               return retval;
 
-       /* restore the RDP privilege to 0 */
+       /* set the RDP protection level to 0 */
        retval = target_write_u32(target, OPTION_BYTES_ADDRESS, 
OPTION_BYTE_0_PR0);
+       if (retval != ERROR_OK)
+               return retval;
 
-       /* the mass erase occur when the privilege go back to 0 */
        retval = stm32lx_wait_status_busy(bank, 30000);
        if (retval != ERROR_OK)
                return retval;

-- 

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to