summaryrefslogtreecommitdiff
path: root/src/target/target.c
diff options
context:
space:
mode:
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-12-20 16:19:10 +0000
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-12-20 16:19:10 +0000
commit55f2fe830a541a297d6bf3906c6a28df81acbf05 (patch)
treec95e8986ea95270728b2d193fada78a8a6abc30f /src/target/target.c
parent79f25814fe1b84e47d10d0063850062b1e65a9ed (diff)
downloadopenocd+libswd-55f2fe830a541a297d6bf3906c6a28df81acbf05.tar.gz
openocd+libswd-55f2fe830a541a297d6bf3906c6a28df81acbf05.tar.bz2
openocd+libswd-55f2fe830a541a297d6bf3906c6a28df81acbf05.tar.xz
openocd+libswd-55f2fe830a541a297d6bf3906c6a28df81acbf05.zip
- removed flash write_image - binary compare function has been moved to verify_image command
- minor code reformat and cleanup - updated docs to include new commands git-svn-id: svn://svn.berlios.de/openocd/trunk@243 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target/target.c')
-rw-r--r--src/target/target.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 0874010c..53022dff 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1876,7 +1876,7 @@ int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, ch
if (!target)
{
ERROR("no target selected");
- return ERROR_OK;
+ return ERROR_OK;
}
duration_start_measure(&duration);
@@ -1915,27 +1915,59 @@ int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, ch
/* calculate checksum of image */
image_calculate_checksum( buffer, buf_cnt, &checksum );
- free(buffer);
retval = target_checksum_memory(target, image.sections[i].base_address, buf_cnt, &mem_checksum);
if( retval != ERROR_OK )
{
command_print(cmd_ctx, "image verify failed, verify aborted");
+ free(buffer);
image_close(&image);
return ERROR_OK;
}
if( checksum != mem_checksum )
{
- command_print(cmd_ctx, "image verify failed, verify aborted");
- image_close(&image);
- return ERROR_OK;
- }
+ /* failed crc checksum, fall back to a binary compare */
+ u8 *data;
+
+ command_print(cmd_ctx, "image verify checksum failed - attempting binary compare");
+ data = (u8*)malloc(buf_cnt);
+
+ /* Can we use 32bit word accesses? */
+ int size = 1;
+ int count = buf_cnt;
+ if ((count % 4) == 0)
+ {
+ size *= 4;
+ count /= 4;
+ }
+ retval = target->type->read_memory(target, image.sections[i].base_address, size, count, data);
+
+ if (retval == ERROR_OK)
+ {
+ int t;
+ for (t = 0; t < buf_cnt; t++)
+ {
+ if (data[t] != buffer[t])
+ {
+ command_print(cmd_ctx, "Verify operation failed address 0x%08x. Was 0x%02x instead of 0x%02x\n", t + image.sections[i].base_address, data[t], buffer[t]);
+ free(data);
+ free(buffer);
+ image_close(&image);
+ return ERROR_OK;
+ }
+ }
+ }
+
+ free(data);
+ }
+
+ free(buffer);
image_size += buf_cnt;
}
-
+
duration_stop_measure(&duration, &duration_text);
command_print(cmd_ctx, "verified %u bytes in %s", image_size, duration_text);
free(duration_text);