Skip to content

Commit

Permalink
DAP: Only write to the ABORT register after doing the read.
Browse files Browse the repository at this point in the history
We were seeing reads failing before this change. Additionally scoping the
SWD bus whilst using a Segger SWD debugger had aborts after the read and
not before.
  • Loading branch information
AndrewP committed Apr 10, 2015
1 parent c53d9e3 commit fa28f72
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libswd_dap.c
Expand Up @@ -607,15 +607,15 @@ int libswd_ap_read(libswd_ctx_t *libswdctx, libswd_operation_t operation, char a
}
if (retry==0) return LIBSWD_ERROR_MAXRETRY;
}
// Clear all posisble error flags that may remain, but don't abort transaction.
abort=0xFFFFFFFE;
res=libswd_dap_errors_handle(libswdctx, LIBSWD_OPERATION_EXECUTE, &abort, &ctrlstat);
if (res<0) return res;
res=libswd_dp_read(libswdctx, LIBSWD_OPERATION_EXECUTE, LIBSWD_DP_RDBUFF_ADDR, data);
if (res<0) {
libswd_log(libswdctx, LIBSWD_LOGLEVEL_ERROR, "LIBSWD_E: libswd_ap_read(libswdctx=@%p, operation=%s, addr=0x%X, **data=0x%X/%s) failed: %s.\n", (void*)libswdctx, libswd_operation_string(operation), addr, **data, libswd_bin32_string(*data), libswd_error_string(res));
return res;
}
// Clear all possible error flags that may remain, but don't abort transaction.
abort=0xFFFFFFFE;
res=libswd_dap_errors_handle(libswdctx, LIBSWD_OPERATION_EXECUTE, &abort, &ctrlstat);
if (res<0) return res;
libswd_log(libswdctx, LIBSWD_LOGLEVEL_DEBUG, "LIBSWD_D: libswd_ap_read(libswdctx=@%p, command=%s, addr=0x%X, **data=0x%X/%s) execution OK.\n", (void*)libswdctx, libswd_operation_string(operation), addr, **data, libswd_bin32_string(*data));
return cmdcnt;
} else return LIBSWD_ERROR_BADOPCODE;
Expand Down

0 comments on commit fa28f72

Please sign in to comment.