X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstm32f2x.c;h=aa749a510a1228819dfbbd47266b6090b4aa273d;hb=ece28927017614a20b80fdc203584ca919f81878;hp=7201914dc1ee7b9a9d938915052bfebc36dd3add;hpb=86cc37183a9f5f7f86a9e20d9e8c3460d22aca50;p=openocd.git
diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c
index 7201914dc1..aa749a510a 100644
--- a/src/flash/nor/stm32f2x.c
+++ b/src/flash/nor/stm32f2x.c
@@ -158,6 +158,7 @@ struct stm32x_flash_bank {
struct stm32x_options option_bytes;
int probed;
bool has_large_mem; /* stm32f42x/stm32f43x family */
+ uint32_t user_bank_size;
};
/* flash bank stm32x 0 0
@@ -173,6 +174,7 @@ FLASH_BANK_COMMAND_HANDLER(stm32x_flash_bank_command)
bank->driver_priv = stm32x_info;
stm32x_info->probed = 0;
+ stm32x_info->user_bank_size = bank->size;
return ERROR_OK;
}
@@ -558,7 +560,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
};
armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
- armv7m_info.core_mode = ARMV7M_MODE_ANY;
+ armv7m_info.core_mode = ARM_MODE_THREAD;
init_reg_param(®_params[0], "r0", 32, PARAM_IN_OUT); /* buffer start, status (out) */
init_reg_param(®_params[1], "r1", 32, PARAM_OUT); /* buffer end */
@@ -791,6 +793,13 @@ static int stm32x_probe(struct flash_bank *bank)
flash_size_in_kb = max_flash_size_in_kb;
}
+ /* if the user sets the size manually then ignore the probed value
+ * this allows us to work around devices that have a invalid flash size register value */
+ if (stm32x_info->user_bank_size) {
+ LOG_INFO("ignoring flash probed value, using configured bank size");
+ flash_size_in_kb = stm32x_info->user_bank_size / 1024;
+ }
+
LOG_INFO("flash size = %dkbytes", flash_size_in_kb);
/* did we assign flash size? */