X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstm32lx.c;h=3bc825acdff051ff68896044a94993d2fc2d864f;hb=38dc2530013a992b98e7926447378dae4f33ed59;hp=58a2a80b02edb8a1010ee21342b7a41e94ded778;hpb=6dfd56a7432fd7daa60ef8caa78f13576049de03;p=fw%2Fopenocd diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c index 58a2a80b0..3bc825acd 100644 --- a/src/flash/nor/stm32lx.c +++ b/src/flash/nor/stm32lx.c @@ -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, ®32); - 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, ®32); - 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, ®32); - 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)