/*************** jtag lowlevel functions ********************/
-static void kitprog_execute_reset(struct jtag_command *cmd)
+static int kitprog_reset(int trst, int srst)
{
int retval = ERROR_OK;
- if (cmd->cmd.reset->srst == 1) {
+ if (trst == 1) {
+ LOG_ERROR("KitProg: Interface has no TRST");
+ return ERROR_FAIL;
+ }
+
+ if (srst == 1) {
retval = kitprog_reset_target();
/* Since the previous command also disables SWCLK output, we need to send an
* SWD bus reset command to re-enable it. For some reason, running
if (retval != ERROR_OK)
LOG_ERROR("KitProg: Interface reset failed");
+ return retval;
}
static void kitprog_execute_sleep(struct jtag_command *cmd)
static void kitprog_execute_command(struct jtag_command *cmd)
{
switch (cmd->type) {
- case JTAG_RESET:
- kitprog_execute_reset(cmd);
- break;
case JTAG_SLEEP:
kitprog_execute_sleep(cmd);
break;
COMMAND_HANDLER(kitprog_handle_serial_command)
{
if (CMD_ARGC == 1) {
- size_t len = strlen(CMD_ARGV[0]);
- kitprog_serial = calloc(len + 1, sizeof(char));
+ kitprog_serial = strdup(CMD_ARGV[0]);
if (kitprog_serial == NULL) {
LOG_ERROR("Failed to allocate memory for the serial number");
return ERROR_FAIL;
}
- strncpy(kitprog_serial, CMD_ARGV[0], len + 1);
} else {
LOG_ERROR("expected exactly one argument to kitprog_serial <serial-number>");
return ERROR_FAIL;
.swd = &kitprog_swd,
.execute_queue = kitprog_execute_queue,
.init = kitprog_init,
- .quit = kitprog_quit
+ .quit = kitprog_quit,
+ .reset = kitprog_reset,
};