From: Andreas Fritiofson Date: Wed, 13 Jan 2016 19:39:28 +0000 (+0100) Subject: target: Switch to target_read_buffer() in verify_image fallback X-Git-Tag: v0.11.0-rc1~587 X-Git-Url: https://review.openocd.org/gitweb?a=commitdiff_plain;ds=inline;h=f545044c2a37a44a51e2a07bdcd52df4eed86a4a;p=openocd.git target: Switch to target_read_buffer() in verify_image fallback The current code checks the count to determine whether to read bytes or words. However it fails to consider whether the base address is suitably aligned. Instead use the target_read_buffer() function which is for exactly this purpose and generates optimal accesses with natural alignment. Change-Id: I32ab5417890ee2219902df1529bc220fe353b4c7 Signed-off-by: Andreas Fritiofson Reviewed-on: http://openocd.zylin.com/3217 Tested-by: jenkins Reviewed-by: Tomas Vanek --- diff --git a/src/target/target.c b/src/target/target.c index 51fdff3425..03b6f4eb2c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -3636,14 +3636,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver data = 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_read_memory(target, image.sections[i].base_address, size, count, data); + retval = target_read_buffer(target, image.sections[i].base_address, buf_cnt, data); if (retval == ERROR_OK) { uint32_t t; for (t = 0; t < buf_cnt; t++) {