X-Git-Url: https://git.gag.com/?p=fw%2Fopenocd;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstm32lx.c;h=6c3063fc8a9a70b08dbcfdef4559e2969d072174;hp=17ac6f080093b0f5e6f6c36d90e4688c3da35928;hb=7e709eab1cb6ac73dc6e5feae5b1b9387d6e91a5;hpb=08ddb19fd3a708d21057c88e8b86215e04c781ec diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c index 17ac6f080..6c3063fc8 100644 --- a/src/flash/nor/stm32lx.c +++ b/src/flash/nor/stm32lx.c @@ -377,6 +377,12 @@ static int stm32lx_write(struct flash_bank *bank, uint8_t *buffer, uint32_t bytes_written = 0; int retval; + uint8_t *start = buffer; + uint32_t start_address = address; + uint32_t start_count = count; + uint8_t *validate; + uint32_t check; + if (bank->target->state != TARGET_HALTED) { LOG_ERROR("Target not halted"); return ERROR_TARGET_NOT_HALTED; @@ -451,7 +457,26 @@ static int stm32lx_write(struct flash_bank *bank, uint8_t *buffer, if (retval != ERROR_OK) return retval; - return ERROR_OK; + validate = malloc (start_count); + + retval = target_read_buffer(target, start_address, start_count, validate); + if (retval != ERROR_OK) { + free (validate); + return retval; + } + + for (check = 0; check < start_count; check++) { + if (validate[check] != start[check]) { + LOG_ERROR ("flash corrupted at 0x%08x (%02x != %02x)\n", + start_address + check, start[check], validate[check]); + retval = ERROR_FAIL; + break; + } + } + + free (validate); + + return retval; } static int stm32lx_probe(struct flash_bank *bank)