failed = malloc(sizeof(int) * image.num_sections);
- if ((retval = flash_write(target, &image, &written, &error_str, failed, auto_erase)) != ERROR_OK)
+ error_str=NULL;
+ retval = flash_write(target, &image, &written, &error_str, failed, auto_erase);
+
+ if (retval != ERROR_OK)
{
- command_print(cmd_ctx, "failed writing image %s: %s", args[0], error_str);
- free(error_str);
+ if (error_str)
+ {
+ command_print(cmd_ctx, "failed writing image %s: %s", args[0], error_str);
+ free(error_str);
+ }
+ image_close(&image);
+ free(failed);
+ return retval;
}
for (i = 0; i < image.num_sections; i++)
return ERROR_OK;
}
+
part = (idcode & 0xffff000) >> 12;
version = (idcode & 0xf0000000) >> 28;
- DEBUG("JTAG device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x",
+ INFO("JTAG device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x)",
idcode, manufacturer, part, version);
bit_count += 32;
while (target)
{
target->type->deassert_reset(target);
+
+ switch (target->reset_mode)
+ {
+ case RESET_INIT:
+ case RESET_HALT:
+ // If we're already halted, then this is harmless(reducing # of execution paths here)
+ // If nSRST & nTRST are tied together then the halt during reset failed(logged) and
+ // we use this as fallback(there is no other output to tell the user that reset halt
+ // didn't work).
+ target->type->poll(target);
+ target->type->halt(target);
+ break;
+ default:
+ break;
+ }
+
+
target = target->next;
}
jtag_execute_queue();
(*last_target_p)->trace_info->trace_history_overflowed = 0;
(*last_target_p)->dbgmsg = NULL;
-
+
(*last_target_p)->type->target_command(cmd_ctx, cmd, args, argc, *last_target_p);
found = 1;
if (target_continous_poll)
if ((retval = target->type->poll(target)) < 0)
{
- ERROR("couldn't poll target, exiting");
- exit(-1);
+ ERROR("couldn't poll target. It's due for a reset.");
}
}
if (!target)
{
ERROR("no target selected");
- return ERROR_OK;
+ return ERROR_OK;
}
duration_start_measure(&duration);
image.base_address_set = 0;
image.base_address = 0x0;
}
-
+
image.start_address_set = 0;
if (image_open(&image, args[0], (argc == 3) ? args[2] : NULL) != ERROR_OK)
return ERROR_OK;
}
+