Skip to content

Commit

Permalink
Merge pull request #1 from andrew-parlane-carallon/master
Browse files Browse the repository at this point in the history
LibSWD changes by Andrew Parlane of Carallon.
  • Loading branch information
cederom committed Apr 15, 2015
2 parents bab6951 + 61ea96c commit 299549e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/libswd.h
Expand Up @@ -744,6 +744,7 @@ static const libswd_arm_register_t libswd_arm_debug_CortexM3_SCS_ComponentID[] =
static const libswd_arm_register_t libswd_arm_debug_CPUID[] = {
{ .address=0xE000ED00, .name="ARM Cortex-M3 r1p2", .default_value=0x411FC231 },
{ .address=0xE000ED00, .name="ARM Cortex-M3 r2p1", .default_value=0x412FC231 },
{ .address=0xE000ED00, .name="ARM Cortex-M0 r0p0", .default_value=0x410CC200 },
0
};

Expand Down
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
12 changes: 12 additions & 0 deletions src/libswd_memap.c
Expand Up @@ -658,6 +658,12 @@ int libswd_memap_write_char(libswd_ctx_t *libswdctx, libswd_operation_t operatio
libswdctx->log.memap.tar=loc;
// Implode and Write data to DRW register.
memcpy((void*)&libswdctx->log.memap.drw, data+i, accsize);
if (accsize == 2 && (loc % 4) == 2)
{
// 16 bit accesses at offsets of 2, use the upper 16 bits
libswdctx->log.memap.drw <<= 16;
}
// TODO probably need something similar for 8 bit accesses
res=libswd_ap_write(libswdctx, LIBSWD_OPERATION_EXECUTE, LIBSWD_MEMAP_DRW_ADDR, &libswdctx->log.memap.drw);
if (res<0) goto libswd_memap_write_char_error;
}
Expand Down Expand Up @@ -688,6 +694,12 @@ int libswd_memap_write_char(libswd_ctx_t *libswdctx, libswd_operation_t operatio
fflush(0);
// Implode and Write data to DRW register.
memcpy((void*)&libswdctx->log.memap.drw, data+(chunk*chunksize)+i, accsize);
if (accsize == 2 && ((loc+i) % 4) == 2)
{
// 16 bit accesses at offsets of 2, use the upper 16 bits
libswdctx->log.memap.drw <<= 16;
}
// TODO probably need something similar for 8 bit accesses
res=libswd_ap_write(libswdctx, LIBSWD_OPERATION_EXECUTE, LIBSWD_MEMAP_DRW_ADDR, &libswdctx->log.memap.drw);
if (res<0) goto libswd_memap_write_char_error;
}
Expand Down

0 comments on commit 299549e

Please sign in to comment.