]> git.sur5r.net Git - openocd/commitdiff
flash: change stm32lx driver probe behaviour
authorSpencer Oliver <spen@spen-soft.co.uk>
Fri, 17 Feb 2012 14:33:48 +0000 (14:33 +0000)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 29 Feb 2012 11:19:58 +0000 (11:19 +0000)
Currently stm32lx flash driver will remove the readout protection if set
during a probe.

This may not be what the user wants, so let them decide.

Change-Id: I8575e3b339b10a4f7bac57cca9586dcab513d347
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/465
Tested-by: jenkins
src/flash/nor/stm32lx.c

index 58a2a80b02edb8a1010ee21342b7a41e94ded778..3bc825acdff051ff68896044a94993d2fc2d864f 100644 (file)
@@ -463,7 +463,6 @@ static int stm32lx_probe(struct flash_bank *bank)
        int i;
        uint16_t flash_size;
        uint32_t device_id;
-       uint32_t reg32;
 
        stm32lx_info->probed = 0;
 
@@ -479,64 +478,6 @@ static int stm32lx_probe(struct flash_bank *bank)
                return ERROR_FAIL;
        }
 
-       /* Read the RDP byte and check if it is 0xAA */
-       uint8_t rdp;
-       retval = target_read_u32(target, FLASH_OBR, &reg32);
-       if (retval != ERROR_OK)
-               return retval;
-       rdp = reg32 & 0xFF;
-       if (rdp != 0xAA) {
-               /*
-                * Unlocking the option byte is done by unlocking the PECR, then
-                * by writing the 2 option byte keys to OPTKEYR
-                */
-
-               /* To unlock the PECR write the 2 PEKEY to the PEKEYR register */
-               retval = target_write_u32(target, FLASH_PEKEYR, PEKEY1);
-               if (retval != ERROR_OK)
-                       return retval;
-
-               retval = target_write_u32(target, FLASH_PEKEYR, PEKEY2);
-               if (retval != ERROR_OK)
-                       return retval;
-
-               /* Make sure it worked */
-               retval = target_read_u32(target, FLASH_PECR, &reg32);
-               if (retval != ERROR_OK)
-                       return retval;
-
-               if (reg32 & FLASH_PECR__PELOCK)
-                       return ERROR_FLASH_OPERATION_FAILED;
-
-               retval = target_write_u32(target, FLASH_OPTKEYR, OPTKEY1);
-               if (retval != ERROR_OK)
-                       return retval;
-               retval = target_write_u32(target, FLASH_OPTKEYR, OPTKEY2);
-               if (retval != ERROR_OK)
-                       return retval;
-
-               retval = target_read_u32(target, FLASH_PECR, &reg32);
-               if (retval != ERROR_OK)
-                       return retval;
-
-               if (reg32 & FLASH_PECR__OPTLOCK) {
-                       LOG_ERROR("OPTLOCK is not cleared");
-                       return ERROR_FLASH_OPERATION_FAILED;
-               }
-
-               /* Then, write RDP to 0x00 to set level 1 */
-               reg32 = ((~0xAA) << 16) | (0xAA);
-               retval = target_write_u32(target, OB_RDP, reg32);
-               if (retval != ERROR_OK)
-                       return retval;
-
-               /* Set Automatic update of the option byte, by setting OBL_LAUNCH in FLASH_PECR */
-               reg32 = FLASH_PECR__OBL_LAUNCH;
-               retval = target_write_u32(target, FLASH_PECR, reg32);
-               if (retval != ERROR_OK)
-                       return retval;
-       }
-
        /* get flash size from target. */
        retval = target_read_u16(target, F_SIZE, &flash_size);
        if (retval != ERROR_OK)