X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstm32f2x.c;h=422eac1b4f28f3cf4b4fb67044497c16e72c264c;hp=be96d98195ab50bfcd2a12b14cced2ea42d4c97f;hb=9d745a0690f6f5c24d914ebfa3c1d6b824a19a5e;hpb=ba2fbe22470915359e1905aaad4c613eacbdf6dc diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c index be96d98195..422eac1b4f 100644 --- a/src/flash/nor/stm32f2x.c +++ b/src/flash/nor/stm32f2x.c @@ -344,8 +344,8 @@ static int stm32x_write_options(struct flash_bank *bank) /* rebuild option data */ optiondata = stm32x_info->option_bytes.user_options; - buf_set_u32(&optiondata, 8, 8, stm32x_info->option_bytes.RDP); - buf_set_u32(&optiondata, 16, 12, stm32x_info->option_bytes.protection); + optiondata |= stm32x_info->option_bytes.RDP << 8; + optiondata |= (stm32x_info->option_bytes.protection & 0x0fff) << 16; /* program options */ retval = target_write_u32(target, STM32_FLASH_OPTCR, optiondata); @@ -355,7 +355,7 @@ static int stm32x_write_options(struct flash_bank *bank) if (stm32x_info->has_large_mem) { uint32_t optiondata2 = 0; - buf_set_u32(&optiondata2, 16, 12, stm32x_info->option_bytes.protection >> 12); + optiondata2 |= (stm32x_info->option_bytes.protection & 0x00fff000) << 4; retval = target_write_u32(target, STM32_FLASH_OPTCR1, optiondata2); if (retval != ERROR_OK) return retval; @@ -372,7 +372,7 @@ static int stm32x_write_options(struct flash_bank *bank) return retval; /* relock registers */ - retval = target_write_u32(target, STM32_FLASH_OPTCR, OPT_LOCK); + retval = target_write_u32(target, STM32_FLASH_OPTCR, optiondata | OPT_LOCK); if (retval != ERROR_OK) return retval; @@ -481,7 +481,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last) return ERROR_OK; } -static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, +static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) { struct target *target = bank->target; @@ -608,7 +608,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, return retval; } -static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, +static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) { struct target *target = bank->target; @@ -779,6 +779,10 @@ static int stm32x_probe(struct flash_bank *bank) case 0x423: max_flash_size_in_kb = 256; break; + case 0x431: + case 0x433: + max_flash_size_in_kb = 512; + break; default: LOG_WARNING("Cannot identify target as a STM32 family."); return ERROR_FAIL; @@ -927,6 +931,8 @@ static int get_stm32x_info(struct flash_bank *bank, char *buf, int buf_size) break; case 0x423: + case 0x431: + case 0x433: device_str = "STM32F4xx (Low Power)"; switch (rev_id) {