This will first attempt a comparison using a CRC checksum, if this fails it will try a binary compare.
@end deffn
+@deffn Command {verify_image_checksum} filename address [@option{bin}|@option{ihex}|@option{elf}]
+Verify @var{filename} against target memory starting at @var{address}.
+The file format may optionally be specified
+(@option{bin}, @option{ihex}, or @option{elf})
+This perform a comparison using a CRC checksum only
+@end deffn
+
@section Breakpoint and Watchpoint commands
@cindex breakpoint
return retval;
}
-static COMMAND_HELPER(handle_verify_image_command_internal, int verify)
+enum verify_mode {
+ IMAGE_TEST = 0,
+ IMAGE_VERIFY = 1,
+ IMAGE_CHECKSUM_ONLY = 2
+};
+
+static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode verify)
{
uint8_t *buffer;
size_t buf_cnt;
break;
}
- if (verify) {
+ if (verify >= IMAGE_VERIFY) {
/* calculate checksum of image */
retval = image_calculate_checksum(buffer, buf_cnt, &checksum);
if (retval != ERROR_OK) {
free(buffer);
break;
}
-
+ if ((checksum != mem_checksum) && (verify == IMAGE_CHECKSUM_ONLY)) {
+ LOG_ERROR("checksum mismatch");
+ free(buffer);
+ retval = ERROR_FAIL;
+ goto done;
+ }
if (checksum != mem_checksum) {
/* failed crc checksum, fall back to a binary compare */
uint8_t *data;
return retval;
}
+COMMAND_HANDLER(handle_verify_image_checksum_command)
+{
+ return CALL_COMMAND_HANDLER(handle_verify_image_command_internal, IMAGE_CHECKSUM_ONLY);
+}
+
COMMAND_HANDLER(handle_verify_image_command)
{
- return CALL_COMMAND_HANDLER(handle_verify_image_command_internal, 1);
+ return CALL_COMMAND_HANDLER(handle_verify_image_command_internal, IMAGE_VERIFY);
}
COMMAND_HANDLER(handle_test_image_command)
{
- return CALL_COMMAND_HANDLER(handle_verify_image_command_internal, 0);
+ return CALL_COMMAND_HANDLER(handle_verify_image_command_internal, IMAGE_TEST);
}
static int handle_bp_command_list(struct command_context *cmd_ctx)
.mode = COMMAND_EXEC,
.usage = "filename address size",
},
+ {
+ .name = "verify_image_checksum",
+ .handler = handle_verify_image_checksum_command,
+ .mode = COMMAND_EXEC,
+ .usage = "filename [offset [type]]",
+ },
{
.name = "verify_image",
.handler = handle_verify_image_command,