Merge branch 'master' into from_upstream

Change-Id: I036350ee06aa396344fb8a80c7dba148ec24c9c8
This commit is contained in:
Tim Newsome
2019-09-27 12:07:00 -07:00
194 changed files with 3445 additions and 4571 deletions
+12 -57
View File
@@ -66,30 +66,6 @@ static int jim_adapter_name(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
return JIM_OK;
}
static int default_khz(int khz, int *jtag_speed)
{
LOG_ERROR("Translation from khz to jtag_speed not implemented");
return ERROR_FAIL;
}
static int default_speed_div(int speed, int *khz)
{
LOG_ERROR("Translation from jtag_speed to khz not implemented");
return ERROR_FAIL;
}
static int default_power_dropout(int *dropout)
{
*dropout = 0; /* by default we can't detect power dropout */
return ERROR_OK;
}
static int default_srst_asserted(int *srst_asserted)
{
*srst_asserted = 0; /* by default we can't detect srst asserted */
return ERROR_OK;
}
COMMAND_HANDLER(interface_transport_command)
{
char **transports;
@@ -114,10 +90,10 @@ COMMAND_HANDLER(handle_interface_list_command)
if (strcmp(CMD_NAME, "interface_list") == 0 && CMD_ARGC > 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX, "The following debug interfaces are available:");
command_print(CMD, "The following debug interfaces are available:");
for (unsigned i = 0; NULL != jtag_interfaces[i]; i++) {
const char *name = jtag_interfaces[i]->name;
command_print(CMD_CTX, "%u: %s", i + 1, name);
command_print(CMD, "%u: %s", i + 1, name);
}
return ERROR_OK;
@@ -150,29 +126,7 @@ COMMAND_HANDLER(handle_interface_command)
jtag_interface = jtag_interfaces[i];
/* LEGACY SUPPORT ... adapter drivers must declare what
* transports they allow. Until they all do so, assume
* the legacy drivers are JTAG-only
*/
if (!jtag_interface->transports)
LOG_WARNING("Adapter driver '%s' did not declare "
"which transports it allows; assuming "
"legacy JTAG-only", jtag_interface->name);
retval = allow_transports(CMD_CTX, jtag_interface->transports
? jtag_interface->transports : jtag_only);
if (ERROR_OK != retval)
return retval;
if (jtag_interface->khz == NULL)
jtag_interface->khz = default_khz;
if (jtag_interface->speed_div == NULL)
jtag_interface->speed_div = default_speed_div;
if (jtag_interface->power_dropout == NULL)
jtag_interface->power_dropout = default_power_dropout;
if (jtag_interface->srst_asserted == NULL)
jtag_interface->srst_asserted = default_srst_asserted;
return ERROR_OK;
return allow_transports(CMD_CTX, jtag_interface->transports);
}
/* no valid interface was found (i.e. the configuration option,
@@ -394,7 +348,7 @@ next:
modes[5] = "";
}
command_print(CMD_CTX, "%s %s%s%s%s%s",
command_print(CMD, "%s %s%s%s%s%s",
modes[0], modes[1],
modes[2], modes[3], modes[4], modes[5]);
@@ -411,7 +365,7 @@ COMMAND_HANDLER(handle_adapter_nsrst_delay_command)
jtag_set_nsrst_delay(delay);
}
command_print(CMD_CTX, "adapter_nsrst_delay: %u", jtag_get_nsrst_delay());
command_print(CMD, "adapter_nsrst_delay: %u", jtag_get_nsrst_delay());
return ERROR_OK;
}
@@ -425,7 +379,7 @@ COMMAND_HANDLER(handle_adapter_nsrst_assert_width_command)
jtag_set_nsrst_assert_width(width);
}
command_print(CMD_CTX, "adapter_nsrst_assert_width: %u", jtag_get_nsrst_assert_width());
command_print(CMD, "adapter_nsrst_assert_width: %u", jtag_get_nsrst_assert_width());
return ERROR_OK;
}
@@ -450,9 +404,9 @@ COMMAND_HANDLER(handle_adapter_khz_command)
return retval;
if (cur_speed)
command_print(CMD_CTX, "adapter speed: %d kHz", cur_speed);
command_print(CMD, "adapter speed: %d kHz", cur_speed);
else
command_print(CMD_CTX, "adapter speed: RCLK - adaptive");
command_print(CMD, "adapter speed: RCLK - adaptive");
return retval;
}
@@ -464,7 +418,7 @@ COMMAND_HANDLER(handle_usb_location_command)
if (CMD_ARGC == 1)
jtag_usb_set_location(CMD_ARGV[0]);
command_print(CMD_CTX, "adapter usb location: %s", jtag_usb_get_location());
command_print(CMD, "adapter usb location: %s", jtag_usb_get_location());
return ERROR_OK;
}
@@ -476,8 +430,8 @@ static const struct command_registration adapter_usb_command_handlers[] = {
.name = "location",
.handler = &handle_usb_location_command,
.mode = COMMAND_CONFIG,
.help = "set the USB bus location of the USB device",
.usage = "<bus>-port[.port]...",
.help = "display or set the USB bus location of the USB device",
.usage = "[<bus>-port[.port]...]",
},
#endif /* HAVE_LIBUSB_GET_PORT_NUMBERS */
COMMAND_REGISTRATION_DONE
@@ -555,6 +509,7 @@ static const struct command_registration interface_command_handlers[] = {
.handler = handle_interface_list_command,
.mode = COMMAND_ANY,
.help = "List all built-in debug adapter interfaces (drivers)",
.usage = "",
},
{
.name = "reset_config",
+4 -4
View File
@@ -150,7 +150,7 @@ static int aice_execute_reset(struct jtag_command *cmd)
static int last_trst;
int retval = ERROR_OK;
DEBUG_JTAG_IO("reset trst: %d", cmd->cmd.reset->trst);
LOG_DEBUG_IO("reset trst: %d", cmd->cmd.reset->trst);
if (cmd->cmd.reset->trst != last_trst) {
if (cmd->cmd.reset->trst)
@@ -269,10 +269,10 @@ COMMAND_HANDLER(aice_handle_aice_info_command)
{
LOG_DEBUG("aice_handle_aice_info_command");
command_print(CMD_CTX, "Description: %s", param.device_desc);
command_print(CMD_CTX, "Serial number: %s", param.serial);
command_print(CMD, "Description: %s", param.device_desc);
command_print(CMD, "Serial number: %s", param.serial);
if (strncmp(aice_port->name, "aice_pipe", 9) == 0)
command_print(CMD_CTX, "Adapter: %s", param.adapter_name);
command_print(CMD, "Adapter: %s", param.adapter_name);
return ERROR_OK;
}
+4 -4
View File
@@ -165,9 +165,9 @@ COMMAND_HANDLER(handle_scan_chain_command)
aice_scan_jtag_chain();
tap = jtag_all_taps();
command_print(CMD_CTX,
command_print(CMD,
" TapName Enabled IdCode Expected IrLen IrCap IrMask");
command_print(CMD_CTX,
command_print(CMD,
"-- ------------------- -------- ---------- ---------- ----- ----- ------");
while (tap) {
@@ -183,7 +183,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
expected = buf_get_u32(tap->expected, 0, tap->ir_length);
expected_mask = buf_get_u32(tap->expected_mask, 0, tap->ir_length);
command_print(CMD_CTX,
command_print(CMD,
"%2d %-18s %c 0x%08x %s %5d 0x%02x 0x%02x",
tap->abs_chain_position,
tap->dotted_name,
@@ -200,7 +200,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
if (tap->ignore_version)
expected_id[2] = '*';
command_print(CMD_CTX,
command_print(CMD,
" %s",
expected_id);
}
+3 -3
View File
@@ -400,7 +400,7 @@ static int aice_usb_write(uint8_t *out_buffer, int out_length)
result = usb_bulk_write_ex(aice_handler.usb_handle, aice_handler.usb_write_ep,
(char *)out_buffer, out_length, AICE_USB_TIMEOUT);
DEBUG_JTAG_IO("aice_usb_write, out_length = %i, result = %i",
LOG_DEBUG_IO("aice_usb_write, out_length = %i, result = %i",
out_length, result);
return result;
@@ -412,7 +412,7 @@ static int aice_usb_read(uint8_t *in_buffer, int expected_size)
int32_t result = usb_bulk_read_ex(aice_handler.usb_handle, aice_handler.usb_read_ep,
(char *)in_buffer, expected_size, AICE_USB_TIMEOUT);
DEBUG_JTAG_IO("aice_usb_read, result = %" PRId32, result);
LOG_DEBUG_IO("aice_usb_read, result = %" PRId32, result);
return result;
}
@@ -2812,7 +2812,7 @@ static int aice_issue_reset_hold(uint32_t coreid)
/* set no_dbgi_pin to 0 */
uint32_t pin_status;
aice_read_ctrl(AICE_READ_CTRL_GET_JTAG_PIN_STATUS, &pin_status);
if (pin_status | 0x4)
if (pin_status & 0x4)
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4));
/* issue restart */
+20 -20
View File
@@ -193,33 +193,33 @@ int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
bit_count = 0;
DEBUG_JTAG_IO("%s num_fields: %i",
LOG_DEBUG_IO("%s num_fields: %i",
cmd->ir_scan ? "IRSCAN" : "DRSCAN",
cmd->num_fields);
for (i = 0; i < cmd->num_fields; i++) {
if (cmd->fields[i].out_value) {
#ifdef _DEBUG_JTAG_IO_
char *char_buf = buf_to_str(cmd->fields[i].out_value,
(cmd->fields[i].num_bits > DEBUG_JTAG_IOZ)
? DEBUG_JTAG_IOZ
: cmd->fields[i].num_bits, 16);
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) {
char *char_buf = buf_to_str(cmd->fields[i].out_value,
(cmd->fields[i].num_bits > DEBUG_JTAG_IOZ)
? DEBUG_JTAG_IOZ
: cmd->fields[i].num_bits, 16);
LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i,
cmd->fields[i].num_bits, char_buf);
free(char_buf);
#endif
LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i,
cmd->fields[i].num_bits, char_buf);
free(char_buf);
}
buf_set_buf(cmd->fields[i].out_value, 0, *buffer,
bit_count, cmd->fields[i].num_bits);
} else {
DEBUG_JTAG_IO("fields[%i].out_value[%i]: NULL",
LOG_DEBUG_IO("fields[%i].out_value[%i]: NULL",
i, cmd->fields[i].num_bits);
}
bit_count += cmd->fields[i].num_bits;
}
/*DEBUG_JTAG_IO("bit_count totalling: %i", bit_count); */
/*LOG_DEBUG_IO("bit_count totalling: %i", bit_count); */
return bit_count;
}
@@ -242,16 +242,16 @@ int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
uint8_t *captured = buf_set_buf(buffer, bit_count,
malloc(DIV_ROUND_UP(num_bits, 8)), 0, num_bits);
#ifdef _DEBUG_JTAG_IO_
char *char_buf = buf_to_str(captured,
(num_bits > DEBUG_JTAG_IOZ)
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) {
char *char_buf = buf_to_str(captured,
(num_bits > DEBUG_JTAG_IOZ)
? DEBUG_JTAG_IOZ
: num_bits, 16);
: num_bits, 16);
LOG_DEBUG("fields[%i].in_value[%i]: 0x%s",
i, num_bits, char_buf);
free(char_buf);
#endif
LOG_DEBUG("fields[%i].in_value[%i]: 0x%s",
i, num_bits, char_buf);
free(char_buf);
}
if (cmd->fields[i].in_value)
buf_cpy(captured, cmd->fields[i].in_value, num_bits);
+29 -24
View File
@@ -1007,7 +1007,7 @@ static bool jtag_examine_chain_match_tap(const struct jtag_tap *tap)
return true;
/* optionally ignore the JTAG version field - bits 28-31 of IDCODE */
uint32_t mask = tap->ignore_version ? ~(0xf << 28) : ~0;
uint32_t mask = tap->ignore_version ? ~(0xfU << 28) : ~0U;
uint32_t idcode = tap->idcode & mask;
/* Loop over the expected identification codes and test for a match */
@@ -1348,19 +1348,6 @@ int adapter_init(struct command_context *cmd_ctx)
return retval;
jtag = jtag_interface;
/* LEGACY SUPPORT ... adapter drivers must declare what
* transports they allow. Until they all do so, assume
* the legacy drivers are JTAG-only
*/
if (!transports_are_declared()) {
LOG_ERROR("Adapter driver '%s' did not declare "
"which transports it allows; assuming "
"JTAG-only", jtag->name);
retval = allow_transports(cmd_ctx, jtag_only);
if (retval != ERROR_OK)
return retval;
}
if (jtag->speed == NULL) {
LOG_INFO("This adapter doesn't support configurable speed");
return ERROR_OK;
@@ -1611,14 +1598,18 @@ static int adapter_khz_to_speed(unsigned khz, int *speed)
{
LOG_DEBUG("convert khz to interface specific speed value");
speed_khz = khz;
if (jtag != NULL) {
LOG_DEBUG("have interface set up");
int speed_div1;
int retval = jtag->khz(jtag_get_speed_khz(), &speed_div1);
if (ERROR_OK != retval)
return retval;
*speed = speed_div1;
if (!jtag)
return ERROR_OK;
LOG_DEBUG("have interface set up");
if (!jtag->khz) {
LOG_ERROR("Translation from khz to jtag_speed not implemented");
return ERROR_FAIL;
}
int speed_div1;
int retval = jtag->khz(jtag_get_speed_khz(), &speed_div1);
if (ERROR_OK != retval)
return retval;
*speed = speed_div1;
return ERROR_OK;
}
@@ -1681,7 +1672,13 @@ int jtag_get_speed_readable(int *khz)
int retval = jtag_get_speed(&jtag_speed_var);
if (retval != ERROR_OK)
return retval;
return jtag ? jtag->speed_div(jtag_speed_var, khz) : ERROR_OK;
if (!jtag)
return ERROR_OK;
if (!jtag->speed_div) {
LOG_ERROR("Translation from jtag_speed to khz not implemented");
return ERROR_FAIL;
}
return jtag->speed_div(jtag_speed_var, khz);
}
void jtag_set_verify(bool enable)
@@ -1712,12 +1709,20 @@ int jtag_power_dropout(int *dropout)
LOG_ERROR("No Valid JTAG Interface Configured.");
exit(-1);
}
return jtag->power_dropout(dropout);
if (jtag->power_dropout)
return jtag->power_dropout(dropout);
*dropout = 0; /* by default we can't detect power dropout */
return ERROR_OK;
}
int jtag_srst_asserted(int *srst_asserted)
{
return jtag->srst_asserted(srst_asserted);
if (jtag->srst_asserted)
return jtag->srst_asserted(srst_asserted);
*srst_asserted = 0; /* by default we can't detect srst asserted */
return ERROR_OK;
}
enum reset_types jtag_get_reset_config(void)
+12 -21
View File
@@ -343,35 +343,27 @@ static int amt_jtagaccel_execute_queue(void)
while (cmd) {
switch (cmd->type) {
case JTAG_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
#endif
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
if (cmd->cmd.reset->trst == 1)
tap_set_state(TAP_RESET);
amt_jtagaccel_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
#endif
LOG_DEBUG_IO("runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
amt_jtagaccel_end_state(cmd->cmd.runtest->end_state);
amt_jtagaccel_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_TLR_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
amt_jtagaccel_end_state(cmd->cmd.statemove->end_state);
amt_jtagaccel_state_move();
break;
case JTAG_SCAN:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
#endif
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
amt_jtagaccel_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
@@ -382,9 +374,7 @@ static int amt_jtagaccel_execute_queue(void)
free(buffer);
break;
case JTAG_SLEEP:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("sleep %" PRIi32, cmd->cmd.sleep->us);
#endif
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:
@@ -548,7 +538,7 @@ COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
}
}
command_print(CMD_CTX, "parport port = %u", amt_jtagaccel_port);
command_print(CMD, "parport port = %u", amt_jtagaccel_port);
return ERROR_OK;
}
@@ -556,7 +546,7 @@ COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
COMMAND_HANDLER(amt_jtagaccel_handle_rtck_command)
{
if (CMD_ARGC == 0) {
command_print(CMD_CTX,
command_print(CMD,
"amt_jtagaccel RTCK feature %s",
(rtck_enabled) ? "enabled" : "disabled");
return ERROR_OK;
@@ -596,6 +586,7 @@ static const struct command_registration amtjtagaccel_command_handlers[] = {
struct jtag_interface amt_jtagaccel_interface = {
.name = "amt_jtagaccel",
.transports = jtag_only,
.commands = amtjtagaccel_command_handlers,
.init = amt_jtagaccel_init,
+11 -10
View File
@@ -106,7 +106,7 @@ static int armjtagew_execute_queue(void)
while (cmd != NULL) {
switch (cmd->type) {
case JTAG_RUNTEST:
DEBUG_JTAG_IO("runtest %i cycles, end in %i",
LOG_DEBUG_IO("runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles, \
cmd->cmd.runtest->end_state);
@@ -115,14 +115,14 @@ static int armjtagew_execute_queue(void)
break;
case JTAG_TLR_RESET:
DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
armjtagew_end_state(cmd->cmd.statemove->end_state);
armjtagew_state_move();
break;
case JTAG_PATHMOVE:
DEBUG_JTAG_IO("pathmove: %i states, end in %i", \
LOG_DEBUG_IO("pathmove: %i states, end in %i", \
cmd->cmd.pathmove->num_states, \
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
@@ -131,12 +131,12 @@ static int armjtagew_execute_queue(void)
break;
case JTAG_SCAN:
DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
armjtagew_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
DEBUG_JTAG_IO("scan input, length = %d", scan_size);
LOG_DEBUG_IO("scan input, length = %d", scan_size);
#ifdef _DEBUG_USB_COMMS_
armjtagew_debug_buffer(buffer, (scan_size + 7) / 8);
@@ -148,7 +148,7 @@ static int armjtagew_execute_queue(void)
break;
case JTAG_RESET:
DEBUG_JTAG_IO("reset trst: %i srst %i",
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
@@ -160,7 +160,7 @@ static int armjtagew_execute_queue(void)
break;
case JTAG_SLEEP:
DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
armjtagew_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;
@@ -490,6 +490,7 @@ static const struct command_registration armjtagew_command_handlers[] = {
.handler = &armjtagew_handle_armjtagew_info_command,
.mode = COMMAND_EXEC,
.help = "query armjtagew info",
.usage = "",
},
COMMAND_REGISTRATION_DONE
};
@@ -646,7 +647,7 @@ static int armjtagew_tap_execute(void)
/* Copy to buffer */
buf_set_buf(tdo_buffer, first, buffer, 0, length);
DEBUG_JTAG_IO("pending scan result, length = %d", length);
LOG_DEBUG_IO("pending scan result, length = %d", length);
#ifdef _DEBUG_USB_COMMS_
armjtagew_debug_buffer(buffer, byte_length);
@@ -746,7 +747,7 @@ static int armjtagew_usb_write(struct armjtagew *armjtagew, int out_length)
result = usb_bulk_write(armjtagew->usb_handle, ARMJTAGEW_EPT_BULK_OUT, \
(char *)usb_out_buffer, out_length, ARMJTAGEW_USB_TIMEOUT);
DEBUG_JTAG_IO("armjtagew_usb_write, out_length = %d, result = %d", out_length, result);
LOG_DEBUG_IO("armjtagew_usb_write, out_length = %d, result = %d", out_length, result);
#ifdef _DEBUG_USB_COMMS_
armjtagew_debug_buffer(usb_out_buffer, out_length);
@@ -760,7 +761,7 @@ static int armjtagew_usb_read(struct armjtagew *armjtagew, int exp_in_length)
int result = usb_bulk_read(armjtagew->usb_handle, ARMJTAGEW_EPT_BULK_IN, \
(char *)usb_in_buffer, exp_in_length, ARMJTAGEW_USB_TIMEOUT);
DEBUG_JTAG_IO("armjtagew_usb_read, result = %d", result);
LOG_DEBUG_IO("armjtagew_usb_read, result = %d", result);
#ifdef _DEBUG_USB_COMMS_
armjtagew_debug_buffer(usb_in_buffer, result);
+3 -1
View File
@@ -183,7 +183,8 @@ static const struct command_registration at91rm9200_command_handlers[] = {
.name = "at91rm9200_device",
.handler = &at91rm9200_handle_device_command,
.mode = COMMAND_CONFIG,
.help = "query armjtagew info",
.help = "Set at91rm9200 device [default \"rea_ecr\"]",
.usage = "<device>",
},
COMMAND_REGISTRATION_DONE
};
@@ -191,6 +192,7 @@ static const struct command_registration at91rm9200_command_handlers[] = {
struct jtag_interface at91rm9200_interface = {
.name = "at91rm9200",
.execute_queue = bitbang_execute_queue,
.transports = jtag_only,
.commands = at91rm9200_command_handlers,
.init = at91rm9200_init,
.quit = at91rm9200_quit,
+28 -12
View File
@@ -199,7 +199,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionums)
return ERROR_COMMAND_SYNTAX_ERROR;
}
command_print(CMD_CTX,
command_print(CMD,
"BCM2835 GPIO config: tck = %d, tms = %d, tdi = %d, tdo = %d",
tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
@@ -211,7 +211,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tck)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tck_gpio);
command_print(CMD_CTX, "BCM2835 GPIO config: tck = %d", tck_gpio);
command_print(CMD, "BCM2835 GPIO config: tck = %d", tck_gpio);
return ERROR_OK;
}
@@ -220,7 +220,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tms)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tms_gpio);
command_print(CMD_CTX, "BCM2835 GPIO config: tms = %d", tms_gpio);
command_print(CMD, "BCM2835 GPIO config: tms = %d", tms_gpio);
return ERROR_OK;
}
@@ -229,7 +229,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tdo)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdo_gpio);
command_print(CMD_CTX, "BCM2835 GPIO config: tdo = %d", tdo_gpio);
command_print(CMD, "BCM2835 GPIO config: tdo = %d", tdo_gpio);
return ERROR_OK;
}
@@ -238,7 +238,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tdi)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdi_gpio);
command_print(CMD_CTX, "BCM2835 GPIO config: tdi = %d", tdi_gpio);
command_print(CMD, "BCM2835 GPIO config: tdi = %d", tdi_gpio);
return ERROR_OK;
}
@@ -247,7 +247,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_srst)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], srst_gpio);
command_print(CMD_CTX, "BCM2835 GPIO config: srst = %d", srst_gpio);
command_print(CMD, "BCM2835 GPIO config: srst = %d", srst_gpio);
return ERROR_OK;
}
@@ -256,7 +256,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_trst)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], trst_gpio);
command_print(CMD_CTX, "BCM2835 GPIO config: trst = %d", trst_gpio);
command_print(CMD, "BCM2835 GPIO config: trst = %d", trst_gpio);
return ERROR_OK;
}
@@ -269,7 +269,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_swd_gpionums)
return ERROR_COMMAND_SYNTAX_ERROR;
}
command_print(CMD_CTX,
command_print(CMD,
"BCM2835 GPIO nums: swclk = %d, swdio = %d",
swclk_gpio, swdio_gpio);
@@ -281,7 +281,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_swd_gpionum_swclk)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swclk_gpio);
command_print(CMD_CTX, "BCM2835 num: swclk = %d", swclk_gpio);
command_print(CMD, "BCM2835 num: swclk = %d", swclk_gpio);
return ERROR_OK;
}
@@ -290,7 +290,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_swd_gpionum_swdio)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swdio_gpio);
command_print(CMD_CTX, "BCM2835 num: swdio = %d", swdio_gpio);
command_print(CMD, "BCM2835 num: swdio = %d", swdio_gpio);
return ERROR_OK;
}
@@ -300,6 +300,9 @@ COMMAND_HANDLER(bcm2835gpio_handle_speed_coeffs)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], speed_coeff);
COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], speed_offset);
}
command_print(CMD, "BCM2835 GPIO: speed_coeffs = %d, speed_offset = %d",
speed_coeff, speed_offset);
return ERROR_OK;
}
@@ -307,6 +310,9 @@ COMMAND_HANDLER(bcm2835gpio_handle_peripheral_base)
{
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], bcm2835_peri_base);
command_print(CMD, "BCM2835 GPIO: peripheral_base = 0x%08x",
bcm2835_peri_base);
return ERROR_OK;
}
@@ -316,74 +322,84 @@ static const struct command_registration bcm2835gpio_command_handlers[] = {
.handler = &bcm2835gpio_handle_jtag_gpionums,
.mode = COMMAND_CONFIG,
.help = "gpio numbers for tck, tms, tdi, tdo. (in that order)",
.usage = "(tck tms tdi tdo)* ",
.usage = "[tck tms tdi tdo]",
},
{
.name = "bcm2835gpio_tck_num",
.handler = &bcm2835gpio_handle_jtag_gpionum_tck,
.mode = COMMAND_CONFIG,
.help = "gpio number for tck.",
.usage = "[tck]",
},
{
.name = "bcm2835gpio_tms_num",
.handler = &bcm2835gpio_handle_jtag_gpionum_tms,
.mode = COMMAND_CONFIG,
.help = "gpio number for tms.",
.usage = "[tms]",
},
{
.name = "bcm2835gpio_tdo_num",
.handler = &bcm2835gpio_handle_jtag_gpionum_tdo,
.mode = COMMAND_CONFIG,
.help = "gpio number for tdo.",
.usage = "[tdo]",
},
{
.name = "bcm2835gpio_tdi_num",
.handler = &bcm2835gpio_handle_jtag_gpionum_tdi,
.mode = COMMAND_CONFIG,
.help = "gpio number for tdi.",
.usage = "[tdi]",
},
{
.name = "bcm2835gpio_swd_nums",
.handler = &bcm2835gpio_handle_swd_gpionums,
.mode = COMMAND_CONFIG,
.help = "gpio numbers for swclk, swdio. (in that order)",
.usage = "(swclk swdio)* ",
.usage = "[swclk swdio]",
},
{
.name = "bcm2835gpio_swclk_num",
.handler = &bcm2835gpio_handle_swd_gpionum_swclk,
.mode = COMMAND_CONFIG,
.help = "gpio number for swclk.",
.usage = "[swclk]",
},
{
.name = "bcm2835gpio_swdio_num",
.handler = &bcm2835gpio_handle_swd_gpionum_swdio,
.mode = COMMAND_CONFIG,
.help = "gpio number for swdio.",
.usage = "[swdio]",
},
{
.name = "bcm2835gpio_srst_num",
.handler = &bcm2835gpio_handle_jtag_gpionum_srst,
.mode = COMMAND_CONFIG,
.help = "gpio number for srst.",
.usage = "[srst]",
},
{
.name = "bcm2835gpio_trst_num",
.handler = &bcm2835gpio_handle_jtag_gpionum_trst,
.mode = COMMAND_CONFIG,
.help = "gpio number for trst.",
.usage = "[trst]",
},
{
.name = "bcm2835gpio_speed_coeffs",
.handler = &bcm2835gpio_handle_speed_coeffs,
.mode = COMMAND_CONFIG,
.help = "SPEED_COEFF and SPEED_OFFSET for delay calculations.",
.usage = "[SPEED_COEFF SPEED_OFFSET]",
},
{
.name = "bcm2835gpio_peripheral_base",
.handler = &bcm2835gpio_handle_peripheral_base,
.mode = COMMAND_CONFIG,
.help = "peripheral base to access GPIOs (RPi1 0x20000000, RPi2 0x3F000000).",
.usage = "[base]",
},
COMMAND_REGISTRATION_DONE
+9 -21
View File
@@ -100,7 +100,7 @@ static int bitbang_execute_tms(struct jtag_command *cmd)
unsigned num_bits = cmd->cmd.tms->num_bits;
const uint8_t *bits = cmd->cmd.tms->bits;
DEBUG_JTAG_IO("TMS: %d bits", num_bits);
LOG_DEBUG_IO("TMS: %d bits", num_bits);
int tms = 0;
for (unsigned i = 0; i < num_bits; i++) {
@@ -315,11 +315,9 @@ int bitbang_execute_queue(void)
while (cmd) {
switch (cmd->type) {
case JTAG_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
#endif
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
if ((cmd->cmd.reset->trst == 1) ||
(cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
tap_set_state(TAP_RESET);
@@ -328,11 +326,9 @@ int bitbang_execute_queue(void)
return ERROR_FAIL;
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %s",
LOG_DEBUG_IO("runtest %i cycles, end in %s",
cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state));
#endif
bitbang_end_state(cmd->cmd.runtest->end_state);
if (bitbang_runtest(cmd->cmd.runtest->num_cycles) != ERROR_OK)
return ERROR_FAIL;
@@ -347,32 +343,26 @@ int bitbang_execute_queue(void)
break;
case JTAG_TLR_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %s",
LOG_DEBUG_IO("statemove end in %s",
tap_state_name(cmd->cmd.statemove->end_state));
#endif
bitbang_end_state(cmd->cmd.statemove->end_state);
if (bitbang_state_move(0) != ERROR_OK)
return ERROR_FAIL;
break;
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("pathmove: %i states, end in %s",
LOG_DEBUG_IO("pathmove: %i states, end in %s",
cmd->cmd.pathmove->num_states,
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
#endif
if (bitbang_path_move(cmd->cmd.pathmove) != ERROR_OK)
return ERROR_FAIL;
break;
case JTAG_SCAN:
bitbang_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("%s scan %d bits; end in %s",
LOG_DEBUG_IO("%s scan %d bits; end in %s",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
scan_size,
tap_state_name(cmd->cmd.scan->end_state));
#endif
type = jtag_scan_type(cmd->cmd.scan);
if (bitbang_scan(cmd->cmd.scan->ir_scan, type, buffer,
scan_size) != ERROR_OK)
@@ -383,9 +373,7 @@ int bitbang_execute_queue(void)
free(buffer);
break;
case JTAG_SLEEP:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("sleep %" PRIi32, cmd->cmd.sleep->us);
#endif
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
case JTAG_TMS:
+8 -25
View File
@@ -59,9 +59,7 @@ static void bitq_in_proc(void)
int tdo = bitq_interface->in();
if (tdo < 0) {
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("bitq in EOF");
#endif
LOG_DEBUG_IO("bitq in EOF");
return;
}
if (in_mask == 0x01)
@@ -228,9 +226,7 @@ int bitq_execute_queue(void)
while (cmd) {
switch (cmd->type) {
case JTAG_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
#endif
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
if ((cmd->cmd.reset->trst == 1) ||
(cmd->cmd.reset->srst &&
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
@@ -241,37 +237,26 @@ int bitq_execute_queue(void)
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state);
#endif
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state);
bitq_end_state(cmd->cmd.runtest->end_state);
bitq_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_TLR_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
bitq_end_state(cmd->cmd.statemove->end_state);
bitq_state_move(tap_get_end_state()); /* uncoditional TAP move */
break;
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
LOG_DEBUG_IO("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
#endif
bitq_path_move(cmd->cmd.pathmove);
break;
case JTAG_SCAN:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
if (cmd->cmd.scan->ir_scan)
LOG_DEBUG("scan ir");
else
LOG_DEBUG("scan dr");
#endif
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
LOG_DEBUG_IO("scan %s", cmd->cmd.scan->ir_scan ? "ir" : "dr");
bitq_end_state(cmd->cmd.scan->end_state);
bitq_scan(cmd->cmd.scan);
if (tap_get_state() != tap_get_end_state())
@@ -279,9 +264,7 @@ int bitq_execute_queue(void)
break;
case JTAG_SLEEP:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
#endif
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
bitq_interface->sleep(cmd->cmd.sleep->us);
if (bitq_interface->in_rdy())
bitq_in_proc();
+26 -16
View File
@@ -171,7 +171,7 @@ static int buspirate_execute_queue(void)
while (cmd) {
switch (cmd->type) {
case JTAG_RUNTEST:
DEBUG_JTAG_IO("runtest %i cycles, end in %s",
LOG_DEBUG_IO("runtest %i cycles, end in %s",
cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest
->end_state));
@@ -181,7 +181,7 @@ static int buspirate_execute_queue(void)
->num_cycles);
break;
case JTAG_TLR_RESET:
DEBUG_JTAG_IO("statemove end in %s",
LOG_DEBUG_IO("statemove end in %s",
tap_state_name(cmd->cmd.statemove
->end_state));
buspirate_end_state(cmd->cmd.statemove
@@ -189,7 +189,7 @@ static int buspirate_execute_queue(void)
buspirate_state_move();
break;
case JTAG_PATHMOVE:
DEBUG_JTAG_IO("pathmove: %i states, end in %s",
LOG_DEBUG_IO("pathmove: %i states, end in %s",
cmd->cmd.pathmove->num_states,
tap_state_name(cmd->cmd.pathmove
->path[cmd->cmd.pathmove
@@ -199,7 +199,7 @@ static int buspirate_execute_queue(void)
cmd->cmd.pathmove->path);
break;
case JTAG_SCAN:
DEBUG_JTAG_IO("scan end in %s",
LOG_DEBUG_IO("scan end in %s",
tap_state_name(cmd->cmd.scan
->end_state));
@@ -214,7 +214,7 @@ static int buspirate_execute_queue(void)
break;
case JTAG_RESET:
DEBUG_JTAG_IO("reset trst: %i srst %i",
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
/* flush buffers, so we can reset */
@@ -226,12 +226,12 @@ static int buspirate_execute_queue(void)
cmd->cmd.reset->srst);
break;
case JTAG_SLEEP:
DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
buspirate_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;
case JTAG_STABLECLOCKS:
DEBUG_JTAG_IO("stable clock %i cycles", cmd->cmd.stableclocks->num_cycles);
LOG_DEBUG_IO("stable clock %i cycles", cmd->cmd.stableclocks->num_cycles);
buspirate_stableclocks(cmd->cmd.stableclocks->num_cycles);
break;
default:
@@ -491,6 +491,7 @@ static const struct command_registration buspirate_command_handlers[] = {
.handler = &buspirate_handle_adc_command,
.mode = COMMAND_EXEC,
.help = "reads voltages on adc pins",
.usage = "",
},
{
.name = "buspirate_vreg",
@@ -623,7 +624,7 @@ static void buspirate_runtest(int num_cycles)
for (i = 0; i < num_cycles; i++)
buspirate_tap_append(0, 0);
DEBUG_JTAG_IO("runtest: cur_state %s end_state %s",
LOG_DEBUG_IO("runtest: cur_state %s end_state %s",
tap_state_name(tap_get_state()),
tap_state_name(tap_get_end_state()));
@@ -1311,7 +1312,7 @@ static int buspirate_swd_switch_seq(enum swd_special_seq seq)
{
const uint8_t *sequence;
int sequence_len;
uint8_t tmp[64];
uint32_t no_bytes, sequence_offset;
switch (seq) {
case LINE_RESET:
@@ -1334,15 +1335,24 @@ static int buspirate_swd_switch_seq(enum swd_special_seq seq)
return ERROR_FAIL;
}
/* FIXME: all above sequences fit into one pirate command for now
* but it may cause trouble later
*/
no_bytes = sequence_len;
sequence_offset = 0;
tmp[0] = 0x10 + ((sequence_len - 1) & 0x0F);
memcpy(tmp + 1, sequence, sequence_len);
while (no_bytes) {
uint8_t tmp[17];
uint32_t to_send;
buspirate_serial_write(buspirate_fd, tmp, sequence_len + 1);
buspirate_serial_read(buspirate_fd, tmp, sequence_len + 1);
to_send = no_bytes > 16 ? 16 : no_bytes;
tmp[0] = 0x10 + ((to_send - 1) & 0x0F);
memcpy(tmp + 1, &sequence[sequence_offset], to_send);
buspirate_serial_write(buspirate_fd, tmp, to_send + 1);
buspirate_serial_read(buspirate_fd, tmp, to_send + 1);
no_bytes -= to_send;
sequence_offset += to_send;
}
return ERROR_OK;
}
+18 -28
View File
@@ -1246,7 +1246,7 @@ static void cmsis_dap_flush(void)
if (!queued_seq_count)
return;
DEBUG_JTAG_IO("Flushing %d queued sequences (%d bytes) with %d pending scan results to capture",
LOG_DEBUG_IO("Flushing %d queued sequences (%d bytes) with %d pending scan results to capture",
queued_seq_count, queued_seq_buf_end, pending_scan_result_count);
/* prep CMSIS-DAP packet */
@@ -1268,7 +1268,7 @@ static void cmsis_dap_flush(void)
}
#ifdef CMSIS_DAP_JTAG_DEBUG
DEBUG_JTAG_IO("USB response buf:");
LOG_DEBUG_IO("USB response buf:");
for (int c = 0; c < queued_seq_buf_end + 3; ++c)
printf("%02X ", buffer[c]);
printf("\n");
@@ -1277,7 +1277,7 @@ static void cmsis_dap_flush(void)
/* copy scan results into client buffers */
for (int i = 0; i < pending_scan_result_count; ++i) {
struct pending_scan_result *scan = &pending_scan_results[i];
DEBUG_JTAG_IO("Copying pending_scan_result %d/%d: %d bits from byte %d -> buffer + %d bits",
LOG_DEBUG_IO("Copying pending_scan_result %d/%d: %d bits from byte %d -> buffer + %d bits",
i, pending_scan_result_count, scan->length, scan->first + 2, scan->buffer_offset);
#ifdef CMSIS_DAP_JTAG_DEBUG
for (uint32_t b = 0; b < DIV_ROUND_UP(scan->length, 8); ++b)
@@ -1302,7 +1302,7 @@ static void cmsis_dap_flush(void)
static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int s_offset,
bool tms, uint8_t *tdo_buffer, int tdo_buffer_offset)
{
DEBUG_JTAG_IO("[at %d] %d bits, tms %s, seq offset %d, tdo buf %p, tdo offset %d",
LOG_DEBUG_IO("[at %d] %d bits, tms %s, seq offset %d, tdo buf %p, tdo offset %d",
queued_seq_buf_end,
s_len, tms ? "HIGH" : "LOW", s_offset, tdo_buffer, tdo_buffer_offset);
@@ -1310,12 +1310,12 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
return;
if (s_len > 64) {
DEBUG_JTAG_IO("START JTAG SEQ SPLIT");
LOG_DEBUG_IO("START JTAG SEQ SPLIT");
for (int offset = 0; offset < s_len; offset += 64) {
int len = s_len - offset;
if (len > 64)
len = 64;
DEBUG_JTAG_IO("Splitting long jtag sequence: %d-bit chunk starting at offset %d", len, offset);
LOG_DEBUG_IO("Splitting long jtag sequence: %d-bit chunk starting at offset %d", len, offset);
cmsis_dap_add_jtag_sequence(
len,
sequence,
@@ -1325,7 +1325,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
tdo_buffer == NULL ? 0 : (tdo_buffer_offset + offset)
);
}
DEBUG_JTAG_IO("END JTAG SEQ SPLIT");
LOG_DEBUG_IO("END JTAG SEQ SPLIT");
return;
}
@@ -1362,7 +1362,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
/* queue a sequence of bits to clock out TMS, executing if the buffer is full */
static void cmsis_dap_add_tms_sequence(const uint8_t *sequence, int s_len)
{
DEBUG_JTAG_IO("%d bits: %02X", s_len, *sequence);
LOG_DEBUG_IO("%d bits: %02X", s_len, *sequence);
/* we use a series of CMD_DAP_JTAG_SEQ commands to toggle TMS,
because even though it seems ridiculously inefficient, it
allows us to combine TMS and scan sequences into the same
@@ -1383,7 +1383,7 @@ static void cmsis_dap_state_move(void)
tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
tms_scan_bits = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
DEBUG_JTAG_IO("state move from %s to %s: %d clocks, %02X on tms",
LOG_DEBUG_IO("state move from %s to %s: %d clocks, %02X on tms",
tap_state_name(tap_get_state()), tap_state_name(tap_get_end_state()),
tms_scan_bits, tms_scan);
cmsis_dap_add_tms_sequence(&tms_scan, tms_scan_bits);
@@ -1395,7 +1395,7 @@ static void cmsis_dap_state_move(void)
/* Execute a JTAG scan operation by queueing TMS and TDI/TDO sequences */
static void cmsis_dap_execute_scan(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
LOG_DEBUG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
jtag_scan_type(cmd->cmd.scan));
/* Make sure there are no trailing fields with num_bits == 0, or the logic below will fail. */
@@ -1429,7 +1429,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
scan_size += field->num_bits;
DEBUG_JTAG_IO("%s%s field %d/%d %d bits",
LOG_DEBUG_IO("%s%s field %d/%d %d bits",
field->in_value ? "in" : "",
field->out_value ? "out" : "",
i,
@@ -1437,7 +1437,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
field->num_bits);
if (i == cmd->cmd.scan->num_fields - 1 && tap_get_state() != tap_get_end_state()) {
DEBUG_JTAG_IO("Last field and have to move out of SHIFT state");
LOG_DEBUG_IO("Last field and have to move out of SHIFT state");
/* Last field, and we're leaving IRSHIFT/DRSHIFT. Clock last bit during tap
* movement. This last field can't have length zero, it was checked above. */
cmsis_dap_add_jtag_sequence(
@@ -1471,7 +1471,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
0);
tap_set_state(tap_state_transition(tap_get_state(), 0));
} else {
DEBUG_JTAG_IO("Internal field, staying in SHIFT state afterwards");
LOG_DEBUG_IO("Internal field, staying in SHIFT state afterwards");
/* Clocking part of a sequence into DR or IR with TMS=0,
leaving TMS=0 at the end so we can continue later */
cmsis_dap_add_jtag_sequence(
@@ -1489,7 +1489,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
cmsis_dap_state_move();
}
DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
LOG_DEBUG_IO("%s scan, %i bits, end in %s",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
tap_state_name(tap_get_end_state()));
}
@@ -1519,7 +1519,7 @@ static void cmsis_dap_pathmove(int num_states, tap_state_t *path)
static void cmsis_dap_execute_pathmove(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("pathmove: %i states, end in %i",
LOG_DEBUG_IO("pathmove: %i states, end in %i",
cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
@@ -1557,7 +1557,7 @@ static void cmsis_dap_runtest(int num_cycles)
static void cmsis_dap_execute_runtest(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
cmsis_dap_end_state(cmd->cmd.runtest->end_state);
@@ -1566,13 +1566,13 @@ static void cmsis_dap_execute_runtest(struct jtag_command *cmd)
static void cmsis_dap_execute_stableclocks(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
LOG_DEBUG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
cmsis_dap_stableclocks(cmd->cmd.runtest->num_cycles);
}
static void cmsis_dap_execute_tms(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
LOG_DEBUG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
cmsis_dap_cmd_DAP_SWJ_Sequence(cmd->cmd.tms->num_bits, cmd->cmd.tms->bits);
}
@@ -1653,15 +1653,6 @@ static int cmsis_dap_khz(int khz, int *jtag_speed)
return ERROR_OK;
}
static int_least32_t cmsis_dap_swd_frequency(int_least32_t hz)
{
if (hz > 0)
cmsis_dap_speed(hz / 1000);
return hz;
}
COMMAND_HANDLER(cmsis_dap_handle_info_command)
{
if (cmsis_dap_get_version_info() == ERROR_OK)
@@ -1790,7 +1781,6 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
static const struct swd_driver cmsis_dap_swd_driver = {
.init = cmsis_dap_swd_init,
.frequency = cmsis_dap_swd_frequency,
.switch_seq = cmsis_dap_swd_switch_seq,
.read_reg = cmsis_dap_swd_read_reg,
.write_reg = cmsis_dap_swd_write_reg,
+1 -1
View File
@@ -136,8 +136,8 @@ static const struct command_registration dummy_command_handlers[] = {
.name = "dummy",
.mode = COMMAND_ANY,
.help = "dummy interface driver commands",
.chain = hello_command_handlers,
.usage = "",
},
COMMAND_REGISTRATION_DONE,
};
+1
View File
@@ -55,6 +55,7 @@ struct jtag_interface ep93xx_interface = {
.supported = DEBUG_CAP_TMS_SEQ,
.execute_queue = bitbang_execute_queue,
.transports = jtag_only,
.init = ep93xx_init,
.quit = ep93xx_quit,
+9 -9
View File
@@ -442,7 +442,7 @@ COMMAND_HANDLER(ft232r_handle_jtag_nums_command)
if (tdo_gpio < 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R nums: TCK = %d %s, TMS = %d %s, TDI = %d %s, TDO = %d %s",
tck_gpio, ft232r_bit_number_to_name(tck_gpio),
tms_gpio, ft232r_bit_number_to_name(tms_gpio),
@@ -462,7 +462,7 @@ COMMAND_HANDLER(ft232r_handle_tck_num_command)
if (tck_gpio < 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R num: TCK = %d %s", tck_gpio, ft232r_bit_number_to_name(tck_gpio));
return ERROR_OK;
@@ -478,7 +478,7 @@ COMMAND_HANDLER(ft232r_handle_tms_num_command)
if (tms_gpio < 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R num: TMS = %d %s", tms_gpio, ft232r_bit_number_to_name(tms_gpio));
return ERROR_OK;
@@ -494,7 +494,7 @@ COMMAND_HANDLER(ft232r_handle_tdo_num_command)
if (tdo_gpio < 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R num: TDO = %d %s", tdo_gpio, ft232r_bit_number_to_name(tdo_gpio));
return ERROR_OK;
@@ -510,7 +510,7 @@ COMMAND_HANDLER(ft232r_handle_tdi_num_command)
if (tdi_gpio < 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R num: TDI = %d %s", tdi_gpio, ft232r_bit_number_to_name(tdi_gpio));
return ERROR_OK;
@@ -526,7 +526,7 @@ COMMAND_HANDLER(ft232r_handle_trst_num_command)
if (ntrst_gpio < 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R num: TRST = %d %s", ntrst_gpio, ft232r_bit_number_to_name(ntrst_gpio));
return ERROR_OK;
@@ -542,7 +542,7 @@ COMMAND_HANDLER(ft232r_handle_srst_num_command)
if (nsysrst_gpio < 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R num: SRST = %d %s", nsysrst_gpio, ft232r_bit_number_to_name(nsysrst_gpio));
return ERROR_OK;
@@ -555,7 +555,7 @@ COMMAND_HANDLER(ft232r_handle_restore_serial_command)
else if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(CMD_CTX,
command_print(CMD,
"FT232R restore serial: 0x%04X (%s)",
ft232r_restore_bitmode, ft232r_restore_bitmode == 0xFFFF ? "disabled" : "enabled");
@@ -675,7 +675,7 @@ static int syncbb_execute_tms(struct jtag_command *cmd)
unsigned num_bits = cmd->cmd.tms->num_bits;
const uint8_t *bits = cmd->cmd.tms->bits;
DEBUG_JTAG_IO("TMS: %d bits", num_bits);
LOG_DEBUG_IO("TMS: %d bits", num_bits);
int tms = 0;
for (unsigned i = 0; i < num_bits; i++) {
+18 -27
View File
@@ -329,7 +329,7 @@ static void move_to_state(tap_state_t goal_state)
int tms_count = tap_get_tms_path_len(start_state, goal_state);
assert(tms_count <= 8);
DEBUG_JTAG_IO("start=%s goal=%s", tap_state_name(start_state), tap_state_name(goal_state));
LOG_DEBUG_IO("start=%s goal=%s", tap_state_name(start_state), tap_state_name(goal_state));
/* Track state transitions step by step */
for (int i = 0; i < tms_count; i++)
@@ -391,7 +391,7 @@ static void ftdi_execute_runtest(struct jtag_command *cmd)
int i;
static const uint8_t zero;
DEBUG_JTAG_IO("runtest %i cycles, end in %s",
LOG_DEBUG_IO("runtest %i cycles, end in %s",
cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state));
@@ -412,14 +412,14 @@ static void ftdi_execute_runtest(struct jtag_command *cmd)
if (tap_get_state() != tap_get_end_state())
move_to_state(tap_get_end_state());
DEBUG_JTAG_IO("runtest: %i, end in %s",
LOG_DEBUG_IO("runtest: %i, end in %s",
cmd->cmd.runtest->num_cycles,
tap_state_name(tap_get_end_state()));
}
static void ftdi_execute_statemove(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("statemove end in %s",
LOG_DEBUG_IO("statemove end in %s",
tap_state_name(cmd->cmd.statemove->end_state));
ftdi_end_state(cmd->cmd.statemove->end_state);
@@ -435,7 +435,7 @@ static void ftdi_execute_statemove(struct jtag_command *cmd)
*/
static void ftdi_execute_tms(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
LOG_DEBUG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
/* TODO: Missing tap state tracking, also missing from ft2232.c! */
DO_CLOCK_TMS_CS_OUT(mpsse_ctx,
@@ -451,7 +451,7 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd)
tap_state_t *path = cmd->cmd.pathmove->path;
int num_states = cmd->cmd.pathmove->num_states;
DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states,
LOG_DEBUG_IO("pathmove: %i states, current: %s end: %s", num_states,
tap_state_name(tap_get_state()),
tap_state_name(path[num_states-1]));
@@ -459,7 +459,7 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd)
unsigned bit_count = 0;
uint8_t tms_byte = 0;
DEBUG_JTAG_IO("-");
LOG_DEBUG_IO("-");
/* this loop verifies that the path is legal and logs each state in the path */
while (num_states--) {
@@ -499,18 +499,18 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd)
static void ftdi_execute_scan(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
LOG_DEBUG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
jtag_scan_type(cmd->cmd.scan));
/* Make sure there are no trailing fields with num_bits == 0, or the logic below will fail. */
while (cmd->cmd.scan->num_fields > 0
&& cmd->cmd.scan->fields[cmd->cmd.scan->num_fields - 1].num_bits == 0) {
cmd->cmd.scan->num_fields--;
DEBUG_JTAG_IO("discarding trailing empty field");
LOG_DEBUG_IO("discarding trailing empty field");
}
if (cmd->cmd.scan->num_fields == 0) {
DEBUG_JTAG_IO("empty scan, doing nothing");
LOG_DEBUG_IO("empty scan, doing nothing");
return;
}
@@ -529,7 +529,7 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
scan_size += field->num_bits;
DEBUG_JTAG_IO("%s%s field %d/%d %d bits",
LOG_DEBUG_IO("%s%s field %d/%d %d bits",
field->in_value ? "in" : "",
field->out_value ? "out" : "",
i,
@@ -579,14 +579,14 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
if (tap_get_state() != tap_get_end_state())
move_to_state(tap_get_end_state());
DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
LOG_DEBUG_IO("%s scan, %i bits, end in %s",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
tap_state_name(tap_get_end_state()));
}
static void ftdi_execute_reset(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("reset trst: %i srst %i",
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
if (cmd->cmd.reset->trst == 1
@@ -622,17 +622,17 @@ static void ftdi_execute_reset(struct jtag_command *cmd)
ftdi_set_signal(srst, 'z');
}
DEBUG_JTAG_IO("trst: %i, srst: %i",
LOG_DEBUG_IO("trst: %i, srst: %i",
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
}
static void ftdi_execute_sleep(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
mpsse_flush(mpsse_ctx);
jtag_sleep(cmd->cmd.sleep->us);
DEBUG_JTAG_IO("sleep %" PRIi32 " usec while in %s",
LOG_DEBUG_IO("sleep %" PRIi32 " usec while in %s",
cmd->cmd.sleep->us,
tap_state_name(tap_get_state()));
}
@@ -656,7 +656,7 @@ static void ftdi_execute_stableclocks(struct jtag_command *cmd)
num_cycles -= this_len;
}
DEBUG_JTAG_IO("clocks %i while in %s",
LOG_DEBUG_IO("clocks %i while in %s",
cmd->cmd.stableclocks->num_cycles,
tap_state_name(tap_get_state()));
}
@@ -1262,7 +1262,7 @@ COMMAND_HANDLER(ftdi_handle_tdo_sample_edge_command)
}
n = Jim_Nvp_value2name_simple(nvp_ftdi_jtag_modes, ftdi_jtag_mode);
command_print(CMD_CTX, "ftdi samples TDO on %s edge of TCK", n->name);
command_print(CMD, "ftdi samples TDO on %s edge of TCK", n->name);
return ERROR_OK;
}
@@ -1558,14 +1558,6 @@ static void ftdi_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_cl
ftdi_swd_queue_cmd(cmd, NULL, value, ap_delay_clk);
}
static int_least32_t ftdi_swd_frequency(int_least32_t hz)
{
if (hz > 0)
freq = mpsse_set_frequency(mpsse_ctx, hz);
return freq;
}
static int ftdi_swd_switch_seq(enum swd_special_seq seq)
{
switch (seq) {
@@ -1594,7 +1586,6 @@ static int ftdi_swd_switch_seq(enum swd_special_seq seq)
static const struct swd_driver ftdi_swd = {
.init = ftdi_swd_init,
.frequency = ftdi_swd_frequency,
.switch_seq = ftdi_swd_switch_seq,
.read_reg = ftdi_swd_read_reg,
.write_reg = ftdi_swd_write_reg,
+8 -19
View File
@@ -297,43 +297,33 @@ static int gw16012_execute_queue(void)
while (cmd) {
switch (cmd->type) {
case JTAG_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
#endif
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
if (cmd->cmd.reset->trst == 1)
tap_set_state(TAP_RESET);
gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
#endif
gw16012_end_state(cmd->cmd.runtest->end_state);
gw16012_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_TLR_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
gw16012_end_state(cmd->cmd.statemove->end_state);
gw16012_state_move();
break;
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
LOG_DEBUG_IO("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
#endif
gw16012_path_move(cmd->cmd.pathmove);
break;
case JTAG_SCAN:
gw16012_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr",
LOG_DEBUG_IO("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr",
type, scan_size, cmd->cmd.scan->end_state);
#endif
gw16012_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
retval = ERROR_JTAG_QUEUE_FAILED;
@@ -341,9 +331,7 @@ static int gw16012_execute_queue(void)
free(buffer);
break;
case JTAG_SLEEP:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
#endif
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:
@@ -515,7 +503,7 @@ COMMAND_HANDLER(gw16012_handle_parport_port_command)
}
}
command_print(CMD_CTX, "parport port = %u", gw16012_port);
command_print(CMD, "parport port = %u", gw16012_port);
return ERROR_OK;
}
@@ -535,6 +523,7 @@ static const struct command_registration gw16012_command_handlers[] = {
struct jtag_interface gw16012_interface = {
.name = "gw16012",
.transports = jtag_only,
.commands = gw16012_command_handlers,
.init = gw16012_init,
+28 -12
View File
@@ -221,7 +221,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionums)
return ERROR_COMMAND_SYNTAX_ERROR;
}
command_print(CMD_CTX,
command_print(CMD,
"imx_gpio GPIO config: tck = %d, tms = %d, tdi = %d, tdo = %d",
tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
@@ -233,7 +233,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tck)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tck_gpio);
command_print(CMD_CTX, "imx_gpio GPIO config: tck = %d", tck_gpio);
command_print(CMD, "imx_gpio GPIO config: tck = %d", tck_gpio);
return ERROR_OK;
}
@@ -242,7 +242,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tms)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tms_gpio);
command_print(CMD_CTX, "imx_gpio GPIO config: tms = %d", tms_gpio);
command_print(CMD, "imx_gpio GPIO config: tms = %d", tms_gpio);
return ERROR_OK;
}
@@ -251,7 +251,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tdo)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdo_gpio);
command_print(CMD_CTX, "imx_gpio GPIO config: tdo = %d", tdo_gpio);
command_print(CMD, "imx_gpio GPIO config: tdo = %d", tdo_gpio);
return ERROR_OK;
}
@@ -260,7 +260,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tdi)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdi_gpio);
command_print(CMD_CTX, "imx_gpio GPIO config: tdi = %d", tdi_gpio);
command_print(CMD, "imx_gpio GPIO config: tdi = %d", tdi_gpio);
return ERROR_OK;
}
@@ -269,7 +269,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_srst)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], srst_gpio);
command_print(CMD_CTX, "imx_gpio GPIO config: srst = %d", srst_gpio);
command_print(CMD, "imx_gpio GPIO config: srst = %d", srst_gpio);
return ERROR_OK;
}
@@ -278,7 +278,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_trst)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], trst_gpio);
command_print(CMD_CTX, "imx_gpio GPIO config: trst = %d", trst_gpio);
command_print(CMD, "imx_gpio GPIO config: trst = %d", trst_gpio);
return ERROR_OK;
}
@@ -291,7 +291,7 @@ COMMAND_HANDLER(imx_gpio_handle_swd_gpionums)
return ERROR_COMMAND_SYNTAX_ERROR;
}
command_print(CMD_CTX,
command_print(CMD,
"imx_gpio GPIO nums: swclk = %d, swdio = %d",
swclk_gpio, swdio_gpio);
@@ -303,7 +303,7 @@ COMMAND_HANDLER(imx_gpio_handle_swd_gpionum_swclk)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swclk_gpio);
command_print(CMD_CTX, "imx_gpio num: swclk = %d", swclk_gpio);
command_print(CMD, "imx_gpio num: swclk = %d", swclk_gpio);
return ERROR_OK;
}
@@ -312,7 +312,7 @@ COMMAND_HANDLER(imx_gpio_handle_swd_gpionum_swdio)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swdio_gpio);
command_print(CMD_CTX, "imx_gpio num: swdio = %d", swdio_gpio);
command_print(CMD, "imx_gpio num: swdio = %d", swdio_gpio);
return ERROR_OK;
}
@@ -322,6 +322,9 @@ COMMAND_HANDLER(imx_gpio_handle_speed_coeffs)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], speed_coeff);
COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], speed_offset);
}
command_print(CMD, "imx_gpio: speed_coeffs = %d, speed_offset = %d",
speed_coeff, speed_offset);
return ERROR_OK;
}
@@ -329,6 +332,9 @@ COMMAND_HANDLER(imx_gpio_handle_peripheral_base)
{
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], imx_gpio_peri_base);
command_print(CMD, "imx_gpio: peripheral_base = 0x%08x",
imx_gpio_peri_base);
return ERROR_OK;
}
@@ -338,74 +344,84 @@ static const struct command_registration imx_gpio_command_handlers[] = {
.handler = &imx_gpio_handle_jtag_gpionums,
.mode = COMMAND_CONFIG,
.help = "gpio numbers for tck, tms, tdi, tdo. (in that order)",
.usage = "(tck tms tdi tdo)* ",
.usage = "[tck tms tdi tdo]",
},
{
.name = "imx_gpio_tck_num",
.handler = &imx_gpio_handle_jtag_gpionum_tck,
.mode = COMMAND_CONFIG,
.help = "gpio number for tck.",
.usage = "[tck]",
},
{
.name = "imx_gpio_tms_num",
.handler = &imx_gpio_handle_jtag_gpionum_tms,
.mode = COMMAND_CONFIG,
.help = "gpio number for tms.",
.usage = "[tms]",
},
{
.name = "imx_gpio_tdo_num",
.handler = &imx_gpio_handle_jtag_gpionum_tdo,
.mode = COMMAND_CONFIG,
.help = "gpio number for tdo.",
.usage = "[tdo]",
},
{
.name = "imx_gpio_tdi_num",
.handler = &imx_gpio_handle_jtag_gpionum_tdi,
.mode = COMMAND_CONFIG,
.help = "gpio number for tdi.",
.usage = "[tdi]",
},
{
.name = "imx_gpio_swd_nums",
.handler = &imx_gpio_handle_swd_gpionums,
.mode = COMMAND_CONFIG,
.help = "gpio numbers for swclk, swdio. (in that order)",
.usage = "(swclk swdio)* ",
.usage = "[swclk swdio]",
},
{
.name = "imx_gpio_swclk_num",
.handler = &imx_gpio_handle_swd_gpionum_swclk,
.mode = COMMAND_CONFIG,
.help = "gpio number for swclk.",
.usage = "[swclk]",
},
{
.name = "imx_gpio_swdio_num",
.handler = &imx_gpio_handle_swd_gpionum_swdio,
.mode = COMMAND_CONFIG,
.help = "gpio number for swdio.",
.usage = "[swdio]",
},
{
.name = "imx_gpio_srst_num",
.handler = &imx_gpio_handle_jtag_gpionum_srst,
.mode = COMMAND_CONFIG,
.help = "gpio number for srst.",
.usage = "[srst]",
},
{
.name = "imx_gpio_trst_num",
.handler = &imx_gpio_handle_jtag_gpionum_trst,
.mode = COMMAND_CONFIG,
.help = "gpio number for trst.",
.usage = "[trst]",
},
{
.name = "imx_gpio_speed_coeffs",
.handler = &imx_gpio_handle_speed_coeffs,
.mode = COMMAND_CONFIG,
.help = "SPEED_COEFF and SPEED_OFFSET for delay calculations.",
.usage = "[SPEED_COEFF SPEED_OFFSET]",
},
{
.name = "imx_gpio_peripheral_base",
.handler = &imx_gpio_handle_peripheral_base,
.mode = COMMAND_CONFIG,
.help = "peripheral base to access GPIOs (0x0209c000 for most IMX).",
.usage = "[base]",
},
COMMAND_REGISTRATION_DONE
+128 -96
View File
@@ -38,6 +38,7 @@
#include <jtag/interface.h>
#include <jtag/swd.h>
#include <jtag/commands.h>
#include <jtag/drivers/jtag_usb_common.h>
#include <libjaylink/libjaylink.h>
@@ -50,6 +51,7 @@ static uint8_t caps[JAYLINK_DEV_EXT_CAPS_SIZE];
static uint32_t serial_number;
static bool use_serial_number;
static bool use_usb_location;
static enum jaylink_usb_address usb_address;
static bool use_usb_address;
static enum jaylink_target_interface iface = JAYLINK_TIF_JTAG;
@@ -122,13 +124,13 @@ static int queued_retval;
static void jlink_execute_stableclocks(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
LOG_DEBUG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
jlink_stableclocks(cmd->cmd.runtest->num_cycles);
}
static void jlink_execute_runtest(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
jlink_end_state(cmd->cmd.runtest->end_state);
@@ -137,7 +139,7 @@ static void jlink_execute_runtest(struct jtag_command *cmd)
static void jlink_execute_statemove(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
jlink_end_state(cmd->cmd.statemove->end_state);
jlink_state_move();
@@ -145,7 +147,7 @@ static void jlink_execute_statemove(struct jtag_command *cmd)
static void jlink_execute_pathmove(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("pathmove: %i states, end in %i",
LOG_DEBUG_IO("pathmove: %i states, end in %i",
cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
@@ -154,7 +156,7 @@ static void jlink_execute_pathmove(struct jtag_command *cmd)
static void jlink_execute_scan(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
LOG_DEBUG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
jtag_scan_type(cmd->cmd.scan));
/* Make sure there are no trailing fields with num_bits == 0, or the logic below will fail. */
@@ -188,7 +190,7 @@ static void jlink_execute_scan(struct jtag_command *cmd)
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
scan_size += field->num_bits;
DEBUG_JTAG_IO("%s%s field %d/%d %d bits",
LOG_DEBUG_IO("%s%s field %d/%d %d bits",
field->in_value ? "in" : "",
field->out_value ? "out" : "",
i,
@@ -240,14 +242,14 @@ static void jlink_execute_scan(struct jtag_command *cmd)
jlink_state_move();
}
DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
LOG_DEBUG_IO("%s scan, %i bits, end in %s",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
tap_state_name(tap_get_end_state()));
}
static void jlink_execute_reset(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst,
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
jlink_flush();
@@ -257,7 +259,7 @@ static void jlink_execute_reset(struct jtag_command *cmd)
static void jlink_execute_sleep(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("sleep %" PRIi32 "", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIi32 "", cmd->cmd.sleep->us);
jlink_flush();
jtag_sleep(cmd->cmd.sleep->us);
}
@@ -534,6 +536,31 @@ static int jaylink_log_handler(const struct jaylink_context *ctx,
return 0;
}
static bool jlink_usb_location_equal(struct jaylink_device *dev)
{
int retval;
uint8_t bus;
uint8_t *ports;
size_t num_ports;
bool equal = false;
retval = jaylink_device_get_usb_bus_ports(dev, &bus, &ports, &num_ports);
if (retval == JAYLINK_ERR_NOT_SUPPORTED) {
return false;
} else if (retval != JAYLINK_OK) {
LOG_WARNING("jaylink_device_get_usb_bus_ports() failed: %s.",
jaylink_strerror(retval));
return false;
}
equal = jtag_usb_location_equal(bus, ports, num_ports);
free(ports);
return equal;
}
static int jlink_init(void)
{
int ret;
@@ -595,7 +622,9 @@ static int jlink_init(void)
return ERROR_JTAG_INIT_FAILED;
}
if (!use_serial_number && !use_usb_address && num_devices > 1) {
use_usb_location = (jtag_usb_get_location() != NULL);
if (!use_serial_number && !use_usb_address && !use_usb_location && num_devices > 1) {
LOG_ERROR("Multiple devices found, specify the desired device.");
jaylink_free_devices(devs, true);
jaylink_exit(jayctx);
@@ -605,8 +634,10 @@ static int jlink_init(void)
found_device = false;
for (i = 0; devs[i]; i++) {
struct jaylink_device *dev = devs[i];
if (use_serial_number) {
ret = jaylink_device_get_serial_number(devs[i], &tmp);
ret = jaylink_device_get_serial_number(dev, &tmp);
if (ret == JAYLINK_ERR_NOT_AVAILABLE) {
continue;
@@ -621,7 +652,7 @@ static int jlink_init(void)
}
if (use_usb_address) {
ret = jaylink_device_get_usb_address(devs[i], &address);
ret = jaylink_device_get_usb_address(dev, &address);
if (ret == JAYLINK_ERR_NOT_SUPPORTED) {
continue;
@@ -635,7 +666,10 @@ static int jlink_init(void)
continue;
}
ret = jaylink_open(devs[i], &devh);
if (use_usb_location && !jlink_usb_location_equal(dev))
continue;
ret = jaylink_open(dev, &devh);
if (ret == JAYLINK_OK) {
found_device = true;
@@ -923,17 +957,17 @@ COMMAND_HANDLER(jlink_usb_command)
int tmp;
if (CMD_ARGC != 1) {
command_print(CMD_CTX, "Need exactly one argument for jlink usb.");
command_print(CMD, "Need exactly one argument for jlink usb.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
if (sscanf(CMD_ARGV[0], "%i", &tmp) != 1) {
command_print(CMD_CTX, "Invalid USB address: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid USB address: %s.", CMD_ARGV[0]);
return ERROR_FAIL;
}
if (tmp < JAYLINK_USB_ADDRESS_0 || tmp > JAYLINK_USB_ADDRESS_3) {
command_print(CMD_CTX, "Invalid USB address: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid USB address: %s.", CMD_ARGV[0]);
return ERROR_FAIL;
}
@@ -950,17 +984,17 @@ COMMAND_HANDLER(jlink_serial_command)
int ret;
if (CMD_ARGC != 1) {
command_print(CMD_CTX, "Need exactly one argument for jlink serial.");
command_print(CMD, "Need exactly one argument for jlink serial.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
ret = jaylink_parse_serial_number(CMD_ARGV[0], &serial_number);
if (ret == JAYLINK_ERR) {
command_print(CMD_CTX, "Invalid serial number: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid serial number: %s.", CMD_ARGV[0]);
return ERROR_FAIL;
} else if (ret != JAYLINK_OK) {
command_print(CMD_CTX, "jaylink_parse_serial_number() failed: %s.",
command_print(CMD, "jaylink_parse_serial_number() failed: %s.",
jaylink_strerror(ret));
return ERROR_FAIL;
}
@@ -979,20 +1013,20 @@ COMMAND_HANDLER(jlink_handle_hwstatus_command)
ret = jaylink_get_hardware_status(devh, &status);
if (ret != JAYLINK_OK) {
command_print(CMD_CTX, "jaylink_get_hardware_status() failed: %s.",
command_print(CMD, "jaylink_get_hardware_status() failed: %s.",
jaylink_strerror(ret));
return ERROR_FAIL;
}
command_print(CMD_CTX, "VTarget = %u.%03u V",
command_print(CMD, "VTarget = %u.%03u V",
status.target_voltage / 1000, status.target_voltage % 1000);
command_print(CMD_CTX, "TCK = %u TDI = %u TDO = %u TMS = %u SRST = %u "
command_print(CMD, "TCK = %u TDI = %u TDO = %u TMS = %u SRST = %u "
"TRST = %u", status.tck, status.tdi, status.tdo, status.tms,
status.tres, status.trst);
if (status.target_voltage < 1500)
command_print(CMD_CTX, "Target voltage too low. Check target power.");
command_print(CMD, "Target voltage too low. Check target power.");
return ERROR_OK;
}
@@ -1003,7 +1037,7 @@ COMMAND_HANDLER(jlink_handle_free_memory_command)
uint32_t tmp;
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_GET_FREE_MEMORY)) {
command_print(CMD_CTX, "Retrieval of free memory is not supported by "
command_print(CMD, "Retrieval of free memory is not supported by "
"the device.");
return ERROR_OK;
}
@@ -1011,12 +1045,12 @@ COMMAND_HANDLER(jlink_handle_free_memory_command)
ret = jaylink_get_free_memory(devh, &tmp);
if (ret != JAYLINK_OK) {
command_print(CMD_CTX, "jaylink_get_free_memory() failed: %s.",
command_print(CMD, "jaylink_get_free_memory() failed: %s.",
jaylink_strerror(ret));
return ERROR_FAIL;
}
command_print(CMD_CTX, "Device has %u bytes of free memory.", tmp);
command_print(CMD, "Device has %u bytes of free memory.", tmp);
return ERROR_OK;
}
@@ -1038,10 +1072,10 @@ COMMAND_HANDLER(jlink_handle_jlink_jtag_command)
return ERROR_FAIL;
}
command_print(CMD_CTX, "JTAG command version: %i", version);
command_print(CMD, "JTAG command version: %i", version);
} else if (CMD_ARGC == 1) {
if (sscanf(CMD_ARGV[0], "%i", &tmp) != 1) {
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
return ERROR_COMMAND_SYNTAX_ERROR;
}
@@ -1053,11 +1087,11 @@ COMMAND_HANDLER(jlink_handle_jlink_jtag_command)
jtag_command_version = JAYLINK_JTAG_VERSION_3;
break;
default:
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
return ERROR_COMMAND_SYNTAX_ERROR;
}
} else {
command_print(CMD_CTX, "Need exactly one argument for jlink jtag.");
command_print(CMD, "Need exactly one argument for jlink jtag.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
@@ -1070,13 +1104,13 @@ COMMAND_HANDLER(jlink_handle_target_power_command)
int enable;
if (CMD_ARGC != 1) {
command_print(CMD_CTX, "Need exactly one argument for jlink "
command_print(CMD, "Need exactly one argument for jlink "
"targetpower.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SET_TARGET_POWER)) {
command_print(CMD_CTX, "Target power supply is not supported by the "
command_print(CMD, "Target power supply is not supported by the "
"device.");
return ERROR_OK;
}
@@ -1086,14 +1120,14 @@ COMMAND_HANDLER(jlink_handle_target_power_command)
} else if (!strcmp(CMD_ARGV[0], "off")) {
enable = false;
} else {
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
return ERROR_FAIL;
}
ret = jaylink_set_target_power(devh, enable);
if (ret != JAYLINK_OK) {
command_print(CMD_CTX, "jaylink_set_target_power() failed: %s.",
command_print(CMD, "jaylink_set_target_power() failed: %s.",
jaylink_strerror(ret));
return ERROR_FAIL;
}
@@ -1101,49 +1135,49 @@ COMMAND_HANDLER(jlink_handle_target_power_command)
return ERROR_OK;
}
static void show_config_usb_address(struct command_context *ctx)
static void show_config_usb_address(struct command_invocation *cmd)
{
if (config.usb_address != tmp_config.usb_address)
command_print(ctx, "USB address: %u [%u]", config.usb_address,
command_print(cmd, "USB address: %u [%u]", config.usb_address,
tmp_config.usb_address);
else
command_print(ctx, "USB address: %u", config.usb_address);
command_print(cmd, "USB address: %u", config.usb_address);
}
static void show_config_ip_address(struct command_context *ctx)
static void show_config_ip_address(struct command_invocation *cmd)
{
if (!memcmp(config.ip_address, tmp_config.ip_address, 4))
command_print(ctx, "IP address: %d.%d.%d.%d",
command_print(cmd, "IP address: %d.%d.%d.%d",
config.ip_address[3], config.ip_address[2],
config.ip_address[1], config.ip_address[0]);
else
command_print(ctx, "IP address: %d.%d.%d.%d [%d.%d.%d.%d]",
command_print(cmd, "IP address: %d.%d.%d.%d [%d.%d.%d.%d]",
config.ip_address[3], config.ip_address[2],
config.ip_address[1], config.ip_address[0],
tmp_config.ip_address[3], tmp_config.ip_address[2],
tmp_config.ip_address[1], tmp_config.ip_address[0]);
if (!memcmp(config.subnet_mask, tmp_config.subnet_mask, 4))
command_print(ctx, "Subnet mask: %d.%d.%d.%d",
command_print(cmd, "Subnet mask: %d.%d.%d.%d",
config.subnet_mask[3], config.subnet_mask[2],
config.subnet_mask[1], config.subnet_mask[0]);
else
command_print(ctx, "Subnet mask: %d.%d.%d.%d [%d.%d.%d.%d]",
command_print(cmd, "Subnet mask: %d.%d.%d.%d [%d.%d.%d.%d]",
config.subnet_mask[3], config.subnet_mask[2],
config.subnet_mask[1], config.subnet_mask[0],
tmp_config.subnet_mask[3], tmp_config.subnet_mask[2],
tmp_config.subnet_mask[1], tmp_config.subnet_mask[0]);
}
static void show_config_mac_address(struct command_context *ctx)
static void show_config_mac_address(struct command_invocation *cmd)
{
if (!memcmp(config.mac_address, tmp_config.mac_address, 6))
command_print(ctx, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x",
command_print(cmd, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x",
config.mac_address[5], config.mac_address[4],
config.mac_address[3], config.mac_address[2],
config.mac_address[1], config.mac_address[0]);
else
command_print(ctx, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x "
command_print(cmd, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x "
"[%.02x:%.02x:%.02x:%.02x:%.02x:%.02x]",
config.mac_address[5], config.mac_address[4],
config.mac_address[3], config.mac_address[2],
@@ -1153,7 +1187,7 @@ static void show_config_mac_address(struct command_context *ctx)
tmp_config.mac_address[1], tmp_config.mac_address[0]);
}
static void show_config_target_power(struct command_context *ctx)
static void show_config_target_power(struct command_invocation *cmd)
{
const char *target_power;
const char *current_target_power;
@@ -1169,24 +1203,24 @@ static void show_config_target_power(struct command_context *ctx)
current_target_power = "on";
if (config.target_power != tmp_config.target_power)
command_print(ctx, "Target power supply: %s [%s]", target_power,
command_print(cmd, "Target power supply: %s [%s]", target_power,
current_target_power);
else
command_print(ctx, "Target power supply: %s", target_power);
command_print(cmd, "Target power supply: %s", target_power);
}
static void show_config(struct command_context *ctx)
static void show_config(struct command_invocation *cmd)
{
command_print(ctx, "J-Link device configuration:");
command_print(cmd, "J-Link device configuration:");
show_config_usb_address(ctx);
show_config_usb_address(cmd);
if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_SET_TARGET_POWER))
show_config_target_power(ctx);
show_config_target_power(cmd);
if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_ETHERNET)) {
show_config_ip_address(ctx);
show_config_mac_address(ctx);
show_config_ip_address(cmd);
show_config_mac_address(cmd);
}
}
@@ -1346,27 +1380,27 @@ COMMAND_HANDLER(jlink_handle_config_usb_address_command)
uint8_t tmp;
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
command_print(CMD_CTX, "Reading configuration is not supported by the "
command_print(CMD, "Reading configuration is not supported by the "
"device.");
return ERROR_OK;
}
if (!CMD_ARGC) {
show_config_usb_address(CMD_CTX);
show_config_usb_address(CMD);
} else if (CMD_ARGC == 1) {
if (sscanf(CMD_ARGV[0], "%" SCNd8, &tmp) != 1) {
command_print(CMD_CTX, "Invalid USB address: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid USB address: %s.", CMD_ARGV[0]);
return ERROR_FAIL;
}
if (tmp > JAYLINK_USB_ADDRESS_3) {
command_print(CMD_CTX, "Invalid USB address: %u.", tmp);
command_print(CMD, "Invalid USB address: %u.", tmp);
return ERROR_FAIL;
}
tmp_config.usb_address = tmp;
} else {
command_print(CMD_CTX, "Need exactly one argument for jlink config "
command_print(CMD, "Need exactly one argument for jlink config "
"usb.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
@@ -1379,32 +1413,32 @@ COMMAND_HANDLER(jlink_handle_config_target_power_command)
int enable;
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
command_print(CMD_CTX, "Reading configuration is not supported by the "
command_print(CMD, "Reading configuration is not supported by the "
"device.");
return ERROR_OK;
}
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SET_TARGET_POWER)) {
command_print(CMD_CTX, "Target power supply is not supported by the "
command_print(CMD, "Target power supply is not supported by the "
"device.");
return ERROR_OK;
}
if (!CMD_ARGC) {
show_config_target_power(CMD_CTX);
show_config_target_power(CMD);
} else if (CMD_ARGC == 1) {
if (!strcmp(CMD_ARGV[0], "on")) {
enable = true;
} else if (!strcmp(CMD_ARGV[0], "off")) {
enable = false;
} else {
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
return ERROR_FAIL;
}
tmp_config.target_power = enable;
} else {
command_print(CMD_CTX, "Need exactly one argument for jlink config "
command_print(CMD, "Need exactly one argument for jlink config "
"targetpower.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
@@ -1420,25 +1454,25 @@ COMMAND_HANDLER(jlink_handle_config_mac_address_command)
const char *str;
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
command_print(CMD_CTX, "Reading configuration is not supported by the "
command_print(CMD, "Reading configuration is not supported by the "
"device.");
return ERROR_OK;
}
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_ETHERNET)) {
command_print(CMD_CTX, "Ethernet connectivity is not supported by the "
command_print(CMD, "Ethernet connectivity is not supported by the "
"device.");
return ERROR_OK;
}
if (!CMD_ARGC) {
show_config_mac_address(CMD_CTX);
show_config_mac_address(CMD);
} else if (CMD_ARGC == 1) {
str = CMD_ARGV[0];
if ((strlen(str) != 17) || (str[2] != ':' || str[5] != ':' || \
str[8] != ':' || str[11] != ':' || str[14] != ':')) {
command_print(CMD_CTX, "Invalid MAC address format.");
command_print(CMD, "Invalid MAC address format.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
@@ -1448,18 +1482,18 @@ COMMAND_HANDLER(jlink_handle_config_mac_address_command)
}
if (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) {
command_print(CMD_CTX, "Invalid MAC address: zero address.");
command_print(CMD, "Invalid MAC address: zero address.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
if (!(0x01 & addr[0])) {
command_print(CMD_CTX, "Invalid MAC address: multicast address.");
command_print(CMD, "Invalid MAC address: multicast address.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
memcpy(tmp_config.mac_address, addr, sizeof(addr));
} else {
command_print(CMD_CTX, "Need exactly one argument for jlink config "
command_print(CMD, "Need exactly one argument for jlink config "
" mac.");
return ERROR_COMMAND_SYNTAX_ERROR;
}
@@ -1508,19 +1542,19 @@ COMMAND_HANDLER(jlink_handle_config_ip_address_command)
uint8_t subnet_bits = 24;
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
command_print(CMD_CTX, "Reading configuration is not supported by the "
command_print(CMD, "Reading configuration is not supported by the "
"device.");
return ERROR_OK;
}
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_ETHERNET)) {
command_print(CMD_CTX, "Ethernet connectivity is not supported by the "
command_print(CMD, "Ethernet connectivity is not supported by the "
"device.");
return ERROR_OK;
}
if (!CMD_ARGC) {
show_config_ip_address(CMD_CTX);
show_config_ip_address(CMD);
} else {
if (!string_to_ip(CMD_ARGV[0], ip_address, &i))
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1565,19 +1599,19 @@ COMMAND_HANDLER(jlink_handle_config_write_command)
int ret;
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
command_print(CMD_CTX, "Reading configuration is not supported by the "
command_print(CMD, "Reading configuration is not supported by the "
"device.");
return ERROR_OK;
}
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_WRITE_CONFIG)) {
command_print(CMD_CTX, "Writing configuration is not supported by the "
command_print(CMD, "Writing configuration is not supported by the "
"device.");
return ERROR_OK;
}
if (!memcmp(&config, &tmp_config, sizeof(struct device_config))) {
command_print(CMD_CTX, "Operation not performed due to no changes in "
command_print(CMD, "Operation not performed due to no changes in "
"the configuration.");
return ERROR_OK;
}
@@ -1602,7 +1636,7 @@ COMMAND_HANDLER(jlink_handle_config_write_command)
}
memcpy(&tmp_config, &config, sizeof(struct device_config));
command_print(CMD_CTX, "The new device configuration applies after power "
command_print(CMD, "The new device configuration applies after power "
"cycling the J-Link device.");
return ERROR_OK;
@@ -1611,12 +1645,12 @@ COMMAND_HANDLER(jlink_handle_config_write_command)
COMMAND_HANDLER(jlink_handle_config_command)
{
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
command_print(CMD_CTX, "Device doesn't support reading configuration.");
command_print(CMD, "Device doesn't support reading configuration.");
return ERROR_OK;
}
if (CMD_ARGC == 0)
show_config(CMD_CTX);
show_config(CMD);
return ERROR_OK;
}
@@ -1732,7 +1766,7 @@ COMMAND_HANDLER(jlink_handle_emucom_read_command)
return ERROR_FAIL;
}
command_print(CMD_CTX, "%s", buf + length);
command_print(CMD, "%s", buf + length);
free(buf);
return ERROR_OK;
@@ -1772,13 +1806,15 @@ static const struct command_registration jlink_config_subcommand_handlers[] = {
.name = "reset",
.handler = &jlink_handle_config_reset_command,
.mode = COMMAND_EXEC,
.help = "undo configuration changes"
.help = "undo configuration changes",
.usage = "",
},
{
.name = "write",
.handler = &jlink_handle_config_write_command,
.mode = COMMAND_EXEC,
.help = "write configuration to the device"
.help = "write configuration to the device",
.usage = "",
},
COMMAND_REGISTRATION_DONE
};
@@ -1820,13 +1856,15 @@ static const struct command_registration jlink_subcommand_handlers[] = {
.name = "freemem",
.handler = &jlink_handle_free_memory_command,
.mode = COMMAND_EXEC,
.help = "show free device memory"
.help = "show free device memory",
.usage = "",
},
{
.name = "hwstatus",
.handler = &jlink_handle_hwstatus_command,
.mode = COMMAND_EXEC,
.help = "show the hardware status"
.help = "show the hardware status",
.usage = "",
},
{
.name = "usb",
@@ -1849,12 +1887,14 @@ static const struct command_registration jlink_subcommand_handlers[] = {
.help = "access the device configuration. If no argument is given "
"this will show the device configuration",
.chain = jlink_config_subcommand_handlers,
.usage = "[<cmd>]",
},
{
.name = "emucom",
.mode = COMMAND_EXEC,
.help = "access EMUCOM channel",
.chain = jlink_emucom_subcommand_handlers
.chain = jlink_emucom_subcommand_handlers,
.usage = "",
},
COMMAND_REGISTRATION_DONE
};
@@ -1865,6 +1905,7 @@ static const struct command_registration jlink_command_handlers[] = {
.mode = COMMAND_ANY,
.help = "perform jlink management",
.chain = jlink_subcommand_handlers,
.usage = "",
},
COMMAND_REGISTRATION_DONE
};
@@ -1888,14 +1929,6 @@ static void jlink_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_c
jlink_swd_queue_cmd(cmd, value, 0, ap_delay_clk);
}
static int_least32_t jlink_swd_frequency(int_least32_t hz)
{
if (hz > 0)
jlink_speed(hz / 1000);
return hz;
}
/***************************************************************************/
/* J-Link tap functions */
@@ -1997,7 +2030,7 @@ static int jlink_flush(void)
buf_set_buf(tdo_buffer, p->first, p->buffer,
p->buffer_offset, p->length);
DEBUG_JTAG_IO("Pending scan result, length = %d.", p->length);
LOG_DEBUG_IO("Pending scan result, length = %d.", p->length);
}
jlink_tap_init();
@@ -2171,7 +2204,6 @@ static void jlink_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint3
static const struct swd_driver jlink_swd = {
.init = &jlink_swd_init,
.frequency = &jlink_swd_frequency,
.switch_seq = &jlink_swd_switch_seq,
.read_reg = &jlink_swd_read_reg,
.write_reg = &jlink_swd_write_reg,
+10 -13
View File
@@ -15,18 +15,18 @@ static char *jtag_usb_location;
* ------
* 16 chars
*/
#define JTAG_USB_MAX_LOCATION_LENGHT 16
#define JTAG_USB_MAX_LOCATION_LENGTH 16
void jtag_usb_set_location(const char *location)
{
if (strnlen(location, JTAG_USB_MAX_LOCATION_LENGHT) ==
JTAG_USB_MAX_LOCATION_LENGHT)
if (strnlen(location, JTAG_USB_MAX_LOCATION_LENGTH) ==
JTAG_USB_MAX_LOCATION_LENGTH)
LOG_WARNING("usb location string is too long!!\n");
if (jtag_usb_location)
free(jtag_usb_location);
jtag_usb_location = strndup(location, JTAG_USB_MAX_LOCATION_LENGHT);
jtag_usb_location = strndup(location, JTAG_USB_MAX_LOCATION_LENGTH);
}
const char *jtag_usb_get_location(void)
@@ -37,13 +37,13 @@ const char *jtag_usb_get_location(void)
bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
size_t path_len)
{
size_t path_step, string_lengh;
size_t path_step, string_length;
char *ptr, *loc;
bool equal = false;
/* strtok need non const char */
loc = strndup(jtag_usb_get_location(), JTAG_USB_MAX_LOCATION_LENGHT);
string_lengh = strnlen(loc, JTAG_USB_MAX_LOCATION_LENGHT);
loc = strndup(jtag_usb_get_location(), JTAG_USB_MAX_LOCATION_LENGTH);
string_length = strnlen(loc, JTAG_USB_MAX_LOCATION_LENGTH);
ptr = strtok(loc, "-");
if (ptr == NULL) {
@@ -51,7 +51,7 @@ bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
goto done;
}
string_lengh -= 1;
string_length -= 1;
/* check bus mismatch */
if (atoi(ptr) != dev_bus)
goto done;
@@ -69,15 +69,12 @@ bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
break;
path_step++;
string_lengh -= 2;
string_length -= 2;
};
/* walked the full path, all elements match */
if (path_step == path_len && !string_lengh)
if (path_step == path_len && !string_length)
equal = true;
else
LOG_WARNING("excluded by device path option: %s\n",
jtag_usb_get_location());
done:
free(loc);
+22 -2
View File
@@ -319,7 +319,7 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
if (retval != ERROR_OK)
return retval;
retval = jtag_vpi_queue_tdi(NULL, cycles, TAP_SHIFT);
retval = jtag_vpi_queue_tdi(NULL, cycles, NO_TAP_SHIFT);
if (retval != ERROR_OK)
return retval;
@@ -328,7 +328,27 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
static int jtag_vpi_stableclocks(int cycles)
{
return jtag_vpi_queue_tdi(NULL, cycles, TAP_SHIFT);
uint8_t tms_bits[4];
int cycles_remain = cycles;
int nb_bits;
int retval;
const int CYCLES_ONE_BATCH = sizeof(tms_bits) * 8;
assert(cycles >= 0);
/* use TMS=1 in TAP RESET state, TMS=0 in all other stable states */
memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, sizeof(tms_bits));
/* send the TMS bits */
while (cycles_remain > 0) {
nb_bits = (cycles_remain < CYCLES_ONE_BATCH) ? cycles_remain : CYCLES_ONE_BATCH;
retval = jtag_vpi_tms_seq(tms_bits, nb_bits);
if (retval != ERROR_OK)
return retval;
cycles_remain -= nb_bits;
}
return ERROR_OK;
}
static int jtag_vpi_execute_queue(void)
+32 -36
View File
@@ -30,26 +30,22 @@
#define LIBUSB_CALL
#endif
#ifdef _DEBUG_JTAG_IO_
#define DEBUG_IO(expr...) LOG_DEBUG(expr)
#define DEBUG_PRINT_BUF(buf, len) \
do { \
char buf_string[32 * 3 + 1]; \
int buf_string_pos = 0; \
for (int i = 0; i < len; i++) { \
buf_string_pos += sprintf(buf_string + buf_string_pos, " %02x", buf[i]); \
if (i % 32 == 32 - 1) { \
LOG_DEBUG("%s", buf_string); \
buf_string_pos = 0; \
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) { \
char buf_string[32 * 3 + 1]; \
int buf_string_pos = 0; \
for (int i = 0; i < len; i++) { \
buf_string_pos += sprintf(buf_string + buf_string_pos, " %02x", buf[i]); \
if (i % 32 == 32 - 1) { \
LOG_DEBUG_IO("%s", buf_string); \
buf_string_pos = 0; \
} \
} \
if (buf_string_pos > 0) \
LOG_DEBUG_IO("%s", buf_string);\
} \
if (buf_string_pos > 0) \
LOG_DEBUG("%s", buf_string);\
} while (0)
#else
#define DEBUG_IO(expr...) do {} while (0)
#define DEBUG_PRINT_BUF(buf, len) do {} while (0)
#endif
#define FTDI_DEVICE_OUT_REQTYPE (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
#define FTDI_DEVICE_IN_REQTYPE (0x80 | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
@@ -459,7 +455,7 @@ static unsigned buffer_read_space(struct mpsse_ctx *ctx)
static void buffer_write_byte(struct mpsse_ctx *ctx, uint8_t data)
{
DEBUG_IO("%02x", data);
LOG_DEBUG_IO("%02x", data);
assert(ctx->write_count < ctx->write_size);
ctx->write_buffer[ctx->write_count++] = data;
}
@@ -467,7 +463,7 @@ static void buffer_write_byte(struct mpsse_ctx *ctx, uint8_t data)
static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset,
unsigned bit_count)
{
DEBUG_IO("%d bits", bit_count);
LOG_DEBUG_IO("%d bits", bit_count);
assert(ctx->write_count + DIV_ROUND_UP(bit_count, 8) <= ctx->write_size);
bit_copy(ctx->write_buffer + ctx->write_count, 0, out, out_offset, bit_count);
ctx->write_count += DIV_ROUND_UP(bit_count, 8);
@@ -477,7 +473,7 @@ static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned
static unsigned buffer_add_read(struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset,
unsigned bit_count, unsigned offset)
{
DEBUG_IO("%d bits, offset %d", bit_count, offset);
LOG_DEBUG_IO("%d bits, offset %d", bit_count, offset);
assert(ctx->read_count + DIV_ROUND_UP(bit_count, 8) <= ctx->read_size);
bit_copy_queued(&ctx->read_queue, in, in_offset, ctx->read_buffer + ctx->read_count, offset,
bit_count);
@@ -501,10 +497,10 @@ void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_of
unsigned in_offset, unsigned length, uint8_t mode)
{
/* TODO: Fix MSB first modes */
DEBUG_IO("%s%s %d bits", in ? "in" : "", out ? "out" : "", length);
LOG_DEBUG_IO("%s%s %d bits", in ? "in" : "", out ? "out" : "", length);
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -577,11 +573,11 @@ void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned
void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in,
unsigned in_offset, unsigned length, bool tdi, uint8_t mode)
{
DEBUG_IO("%sout %d bits, tdi=%d", in ? "in" : "", length, tdi);
LOG_DEBUG_IO("%sout %d bits, tdi=%d", in ? "in" : "", length, tdi);
assert(out);
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -627,10 +623,10 @@ void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_
void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
{
DEBUG_IO("-");
LOG_DEBUG_IO("-");
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -644,10 +640,10 @@ void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t d
void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
{
DEBUG_IO("-");
LOG_DEBUG_IO("-");
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -661,10 +657,10 @@ void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t
void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data)
{
DEBUG_IO("-");
LOG_DEBUG_IO("-");
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -677,10 +673,10 @@ void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data)
void mpsse_read_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t *data)
{
DEBUG_IO("-");
LOG_DEBUG_IO("-");
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -695,7 +691,7 @@ static void single_byte_boolean_helper(struct mpsse_ctx *ctx, bool var, uint8_t
uint8_t val_if_false)
{
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -716,7 +712,7 @@ void mpsse_set_divisor(struct mpsse_ctx *ctx, uint16_t divisor)
LOG_DEBUG("%d", divisor);
if (ctx->retval != ERROR_OK) {
DEBUG_IO("Ignoring command due to previous error");
LOG_DEBUG_IO("Ignoring command due to previous error");
return;
}
@@ -818,7 +814,7 @@ static LIBUSB_CALL void read_cb(struct libusb_transfer *transfer)
}
}
DEBUG_IO("raw chunk %d, transferred %d of %d", transfer->actual_length, res->transferred,
LOG_DEBUG_IO("raw chunk %d, transferred %d of %d", transfer->actual_length, res->transferred,
ctx->read_count);
if (!res->done)
@@ -833,7 +829,7 @@ static LIBUSB_CALL void write_cb(struct libusb_transfer *transfer)
res->transferred += transfer->actual_length;
DEBUG_IO("transferred %d of %d", res->transferred, ctx->write_count);
LOG_DEBUG_IO("transferred %d of %d", res->transferred, ctx->write_count);
DEBUG_PRINT_BUF(transfer->buffer, transfer->actual_length);
@@ -852,13 +848,13 @@ int mpsse_flush(struct mpsse_ctx *ctx)
int retval = ctx->retval;
if (retval != ERROR_OK) {
DEBUG_IO("Ignoring flush due to previous error");
LOG_DEBUG_IO("Ignoring flush due to previous error");
assert(ctx->write_count == 0 && ctx->read_count == 0);
ctx->retval = ERROR_OK;
return retval;
}
DEBUG_IO("write %d%s, read %d", ctx->write_count, ctx->read_count ? "+1" : "",
LOG_DEBUG_IO("write %d%s, read %d", ctx->write_count, ctx->read_count ? "+1" : "",
ctx->read_count);
assert(ctx->write_count > 0 || ctx->read_count == 0); /* No read data without write data */
+15 -13
View File
@@ -185,7 +185,7 @@ COMMAND_HANDLER(opendous_handle_opendous_hw_jtag_command)
{
switch (CMD_ARGC) {
case 0:
command_print(CMD_CTX, "opendous hw jtag %i", opendous_hw_jtag_version);
command_print(CMD, "opendous hw jtag %i", opendous_hw_jtag_version);
break;
case 1: {
@@ -215,6 +215,7 @@ static const struct command_registration opendous_command_handlers[] = {
.handler = &opendous_handle_opendous_info_command,
.mode = COMMAND_EXEC,
.help = "show opendous info",
.usage = "",
},
{
.name = "opendous_hw_jtag",
@@ -235,6 +236,7 @@ static const struct command_registration opendous_command_handlers[] = {
struct jtag_interface opendous_interface = {
.name = "opendous",
.transports = jtag_only,
.commands = opendous_command_handlers,
.execute_queue = opendous_execute_queue,
.init = opendous_init,
@@ -251,7 +253,7 @@ static int opendous_execute_queue(void)
while (cmd != NULL) {
switch (cmd->type) {
case JTAG_RUNTEST:
DEBUG_JTAG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \
cmd->cmd.runtest->end_state);
if (cmd->cmd.runtest->end_state != -1)
@@ -260,7 +262,7 @@ static int opendous_execute_queue(void)
break;
case JTAG_TLR_RESET:
DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
if (cmd->cmd.statemove->end_state != -1)
opendous_end_state(cmd->cmd.statemove->end_state);
@@ -268,7 +270,7 @@ static int opendous_execute_queue(void)
break;
case JTAG_PATHMOVE:
DEBUG_JTAG_IO("pathmove: %i states, end in %i", \
LOG_DEBUG_IO("pathmove: %i states, end in %i", \
cmd->cmd.pathmove->num_states, \
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
@@ -276,13 +278,13 @@ static int opendous_execute_queue(void)
break;
case JTAG_SCAN:
DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
if (cmd->cmd.scan->end_state != -1)
opendous_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
DEBUG_JTAG_IO("scan input, length = %d", scan_size);
LOG_DEBUG_IO("scan input, length = %d", scan_size);
#ifdef _DEBUG_USB_COMMS_
opendous_debug_buffer(buffer, (scan_size + 7) / 8);
@@ -292,7 +294,7 @@ static int opendous_execute_queue(void)
break;
case JTAG_RESET:
DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
opendous_tap_execute();
@@ -302,7 +304,7 @@ static int opendous_execute_queue(void)
break;
case JTAG_SLEEP:
DEBUG_JTAG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
opendous_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;
@@ -527,7 +529,7 @@ void opendous_simple_command(uint8_t command, uint8_t _data)
{
int result;
DEBUG_JTAG_IO("0x%02x 0x%02x", command, _data);
LOG_DEBUG_IO("0x%02x 0x%02x", command, _data);
usb_out_buffer[0] = 2;
usb_out_buffer[1] = 0;
@@ -596,7 +598,7 @@ void opendous_tap_append_step(int tms, int tdi)
void opendous_tap_append_scan(int length, uint8_t *buffer, struct scan_command *command)
{
DEBUG_JTAG_IO("append scan, length = %d", length);
LOG_DEBUG_IO("append scan, length = %d", length);
struct pending_scan_result *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length];
int i;
@@ -678,7 +680,7 @@ int opendous_tap_execute(void)
/* Copy to buffer */
buf_set_buf(tdo_buffer, first, buffer, 0, length);
DEBUG_JTAG_IO("pending scan result, length = %d", length);
LOG_DEBUG_IO("pending scan result, length = %d", length);
#ifdef _DEBUG_USB_COMMS_
opendous_debug_buffer(buffer, byte_length_out);
@@ -769,7 +771,7 @@ int opendous_usb_write(struct opendous_jtag *opendous_jtag, int out_length)
LOG_DEBUG("USB write end: %d bytes", result);
#endif
DEBUG_JTAG_IO("opendous_usb_write, out_length = %d, result = %d", out_length, result);
LOG_DEBUG_IO("opendous_usb_write, out_length = %d, result = %d", out_length, result);
#ifdef _DEBUG_USB_COMMS_
opendous_debug_buffer(usb_out_buffer, out_length);
@@ -795,7 +797,7 @@ int opendous_usb_read(struct opendous_jtag *opendous_jtag)
#ifdef _DEBUG_USB_COMMS_
LOG_DEBUG("USB read end: %d bytes", result);
#endif
DEBUG_JTAG_IO("opendous_usb_read, result = %d", result);
LOG_DEBUG_IO("opendous_usb_read, result = %d", result);
#ifdef _DEBUG_USB_COMMS_
opendous_debug_buffer(usb_in_buffer, result);
+11 -10
View File
@@ -292,7 +292,7 @@ static int openjtag_buf_read_standard(
qty - *bytes_read);
if (retval < 0) {
*bytes_read = 0;
DEBUG_JTAG_IO("ftdi_read_data: %s",
LOG_DEBUG_IO("ftdi_read_data: %s",
ftdi_get_error_string(&ftdic));
return ERROR_JTAG_DEVICE_ERROR;
}
@@ -574,7 +574,7 @@ static int openjtag_execute_tap_queue(void)
while (len > 0) {
if (len <= 8 && openjtag_variant != OPENJTAG_VARIANT_CY7C65215) {
DEBUG_JTAG_IO("bits < 8 buf = 0x%X, will be 0x%X",
LOG_DEBUG_IO("bits < 8 buf = 0x%X, will be 0x%X",
usb_rx_buf[rx_offs], usb_rx_buf[rx_offs] >> (8 - len));
buffer[count] = usb_rx_buf[rx_offs] >> (8 - len);
len = 0;
@@ -609,8 +609,8 @@ static void openjtag_add_byte(char buf)
{
if (usb_tx_buf_offs == OPENJTAG_BUFFER_SIZE) {
DEBUG_JTAG_IO("Forcing execute_tap_queue");
DEBUG_JTAG_IO("TX Buff offs=%d", usb_tx_buf_offs);
LOG_DEBUG_IO("Forcing execute_tap_queue");
LOG_DEBUG_IO("TX Buff offs=%d", usb_tx_buf_offs);
openjtag_execute_tap_queue();
}
@@ -624,8 +624,8 @@ static void openjtag_add_scan(uint8_t *buffer, int length, struct scan_command *
/* Ensure space to send long chains */
/* We add two byte for each eight (or less) bits, one for command, one for data */
if (usb_tx_buf_offs + (DIV_ROUND_UP(length, 8) * 2) >= OPENJTAG_BUFFER_SIZE) {
DEBUG_JTAG_IO("Forcing execute_tap_queue from scan");
DEBUG_JTAG_IO("TX Buff offs=%d len=%d", usb_tx_buf_offs, DIV_ROUND_UP(length, 8) * 2);
LOG_DEBUG_IO("Forcing execute_tap_queue from scan");
LOG_DEBUG_IO("TX Buff offs=%d len=%d", usb_tx_buf_offs, DIV_ROUND_UP(length, 8) * 2);
openjtag_execute_tap_queue();
}
@@ -670,7 +670,7 @@ static void openjtag_add_scan(uint8_t *buffer, int length, struct scan_command *
static void openjtag_execute_reset(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("reset trst: %i srst %i",
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
uint8_t buf = 0x00;
@@ -703,7 +703,7 @@ static void openjtag_set_state(uint8_t openocd_state)
static void openjtag_execute_statemove(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("state move to %i", cmd->cmd.statemove->end_state);
LOG_DEBUG_IO("state move to %i", cmd->cmd.statemove->end_state);
tap_set_end_state(cmd->cmd.statemove->end_state);
@@ -719,7 +719,7 @@ static void openjtag_execute_scan(struct jtag_command *cmd)
int scan_size, old_state;
uint8_t *buffer;
DEBUG_JTAG_IO("scan ends in %s", tap_state_name(cmd->cmd.scan->end_state));
LOG_DEBUG_IO("scan ends in %s", tap_state_name(cmd->cmd.scan->end_state));
/* get scan info */
tap_set_end_state(cmd->cmd.scan->end_state);
@@ -778,7 +778,7 @@ static void openjtag_execute_runtest(struct jtag_command *cmd)
static void openjtag_execute_command(struct jtag_command *cmd)
{
DEBUG_JTAG_IO("openjtag_execute_command %i", cmd->type);
LOG_DEBUG_IO("openjtag_execute_command %i", cmd->type);
switch (cmd->type) {
case JTAG_RESET:
openjtag_execute_reset(cmd);
@@ -894,6 +894,7 @@ static const struct command_registration openjtag_command_handlers[] = {
struct jtag_interface openjtag_interface = {
.name = "openjtag",
.transports = jtag_only,
.commands = openjtag_command_handlers,
.execute_queue = openjtag_execute_queue,
+3 -2
View File
@@ -413,7 +413,7 @@ COMMAND_HANDLER(parport_handle_parport_port_command)
}
}
command_print(CMD_CTX, "parport port = 0x%" PRIx16 "", parport_port);
command_print(CMD, "parport port = 0x%" PRIx16 "", parport_port);
return ERROR_OK;
}
@@ -470,7 +470,7 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command)
}
}
command_print(CMD_CTX, "parport toggling time = %" PRIu32 " ns",
command_print(CMD, "parport toggling time = %" PRIu32 " ns",
parport_toggling_time_ns);
return ERROR_OK;
@@ -517,6 +517,7 @@ static const struct command_registration parport_command_handlers[] = {
struct jtag_interface parport_interface = {
.name = "parport",
.supported = DEBUG_CAP_TMS_SEQ,
.transports = jtag_only,
.commands = parport_command_handlers,
.init = parport_init,
+1
View File
@@ -563,6 +563,7 @@ static int presto_jtag_quit(void)
struct jtag_interface presto_interface = {
.name = "presto",
.transports = jtag_only,
.commands = presto_command_handlers,
.execute_queue = bitq_execute_queue,
+1
View File
@@ -345,6 +345,7 @@ static const struct command_registration remote_bitbang_command_handlers[] = {
struct jtag_interface remote_bitbang_interface = {
.name = "remote_bitbang",
.execute_queue = &bitbang_execute_queue,
.transports = jtag_only,
.commands = remote_bitbang_command_handlers,
.init = &remote_bitbang_init,
.quit = &remote_bitbang_quit,
+11 -22
View File
@@ -1299,11 +1299,9 @@ static int rlink_execute_queue(void)
switch (cmd->type) {
case JTAG_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i",
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
#endif
if ((cmd->cmd.reset->trst == 1) ||
(cmd->cmd.reset->srst &&
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
@@ -1311,37 +1309,29 @@ static int rlink_execute_queue(void)
rlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %i",
LOG_DEBUG_IO("runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
#endif
if (cmd->cmd.runtest->end_state != -1)
rlink_end_state(cmd->cmd.runtest->end_state);
rlink_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_TLR_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
if (cmd->cmd.statemove->end_state != -1)
rlink_end_state(cmd->cmd.statemove->end_state);
rlink_state_move();
break;
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("pathmove: %i states, end in %i",
cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
#endif
LOG_DEBUG_IO("pathmove: %i states, end in %i",
cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
rlink_path_move(cmd->cmd.pathmove);
break;
case JTAG_SCAN:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("%s scan end in %i",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
cmd->cmd.scan->end_state);
#endif
LOG_DEBUG_IO("%s scan end in %i",
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
cmd->cmd.scan->end_state);
if (cmd->cmd.scan->end_state != -1)
rlink_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
@@ -1350,9 +1340,7 @@ static int rlink_execute_queue(void)
retval = ERROR_FAIL;
break;
case JTAG_SLEEP:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
#endif
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:
@@ -1674,6 +1662,7 @@ static int rlink_quit(void)
struct jtag_interface rlink_interface = {
.name = "rlink",
.transports = jtag_only,
.init = rlink_init,
.quit = rlink_quit,
.speed = rlink_speed,
+10 -10
View File
@@ -356,7 +356,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionums)
return ERROR_COMMAND_SYNTAX_ERROR;
}
command_print(CMD_CTX,
command_print(CMD,
"SysfsGPIO nums: tck = %d, tms = %d, tdi = %d, tdo = %d",
tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
@@ -368,7 +368,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tck)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tck_gpio);
command_print(CMD_CTX, "SysfsGPIO num: tck = %d", tck_gpio);
command_print(CMD, "SysfsGPIO num: tck = %d", tck_gpio);
return ERROR_OK;
}
@@ -377,7 +377,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tms)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tms_gpio);
command_print(CMD_CTX, "SysfsGPIO num: tms = %d", tms_gpio);
command_print(CMD, "SysfsGPIO num: tms = %d", tms_gpio);
return ERROR_OK;
}
@@ -386,7 +386,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tdo)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdo_gpio);
command_print(CMD_CTX, "SysfsGPIO num: tdo = %d", tdo_gpio);
command_print(CMD, "SysfsGPIO num: tdo = %d", tdo_gpio);
return ERROR_OK;
}
@@ -395,7 +395,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tdi)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdi_gpio);
command_print(CMD_CTX, "SysfsGPIO num: tdi = %d", tdi_gpio);
command_print(CMD, "SysfsGPIO num: tdi = %d", tdi_gpio);
return ERROR_OK;
}
@@ -404,7 +404,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_srst)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], srst_gpio);
command_print(CMD_CTX, "SysfsGPIO num: srst = %d", srst_gpio);
command_print(CMD, "SysfsGPIO num: srst = %d", srst_gpio);
return ERROR_OK;
}
@@ -413,7 +413,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_trst)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], trst_gpio);
command_print(CMD_CTX, "SysfsGPIO num: trst = %d", trst_gpio);
command_print(CMD, "SysfsGPIO num: trst = %d", trst_gpio);
return ERROR_OK;
}
@@ -426,7 +426,7 @@ COMMAND_HANDLER(sysfsgpio_handle_swd_gpionums)
return ERROR_COMMAND_SYNTAX_ERROR;
}
command_print(CMD_CTX,
command_print(CMD,
"SysfsGPIO nums: swclk = %d, swdio = %d",
swclk_gpio, swdio_gpio);
@@ -438,7 +438,7 @@ COMMAND_HANDLER(sysfsgpio_handle_swd_gpionum_swclk)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swclk_gpio);
command_print(CMD_CTX, "SysfsGPIO num: swclk = %d", swclk_gpio);
command_print(CMD, "SysfsGPIO num: swclk = %d", swclk_gpio);
return ERROR_OK;
}
@@ -447,7 +447,7 @@ COMMAND_HANDLER(sysfsgpio_handle_swd_gpionum_swdio)
if (CMD_ARGC == 1)
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swdio_gpio);
command_print(CMD_CTX, "SysfsGPIO num: swdio = %d", swdio_gpio);
command_print(CMD, "SysfsGPIO num: swdio = %d", swdio_gpio);
return ERROR_OK;
}
+81 -109
View File
@@ -187,12 +187,7 @@ void ulink_clear_queue(struct ulink *device);
int ulink_append_queue(struct ulink *device, struct ulink_cmd *ulink_cmd);
int ulink_execute_queued_commands(struct ulink *device, int timeout);
#ifdef _DEBUG_JTAG_IO_
const char *ulink_cmd_id_string(uint8_t id);
void ulink_print_command(struct ulink_cmd *ulink_cmd);
void ulink_print_queue(struct ulink *device);
static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f);
#endif
static void ulink_print_queue(struct ulink *device);
int ulink_append_scan_cmd(struct ulink *device,
enum scan_type scan_type,
@@ -708,9 +703,8 @@ int ulink_execute_queued_commands(struct ulink *device, int timeout)
int ret, i, index_out, index_in, count_out, count_in, transferred;
uint8_t buffer[64];
#ifdef _DEBUG_JTAG_IO_
ulink_print_queue(device);
#endif
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
ulink_print_queue(device);
index_out = 0;
count_out = 0;
@@ -759,71 +753,69 @@ int ulink_execute_queued_commands(struct ulink *device, int timeout)
return ERROR_OK;
}
#ifdef _DEBUG_JTAG_IO_
/**
* Convert an OpenULINK command ID (\a id) to a human-readable string.
*
* @param id the OpenULINK command ID.
* @return the corresponding human-readable string.
*/
const char *ulink_cmd_id_string(uint8_t id)
static const char *ulink_cmd_id_string(uint8_t id)
{
switch (id) {
case CMD_SCAN_IN:
return "CMD_SCAN_IN";
break;
case CMD_SLOW_SCAN_IN:
return "CMD_SLOW_SCAN_IN";
break;
case CMD_SCAN_OUT:
return "CMD_SCAN_OUT";
break;
case CMD_SLOW_SCAN_OUT:
return "CMD_SLOW_SCAN_OUT";
break;
case CMD_SCAN_IO:
return "CMD_SCAN_IO";
break;
case CMD_SLOW_SCAN_IO:
return "CMD_SLOW_SCAN_IO";
break;
case CMD_CLOCK_TMS:
return "CMD_CLOCK_TMS";
break;
case CMD_SLOW_CLOCK_TMS:
return "CMD_SLOW_CLOCK_TMS";
break;
case CMD_CLOCK_TCK:
return "CMD_CLOCK_TCK";
break;
case CMD_SLOW_CLOCK_TCK:
return "CMD_SLOW_CLOCK_TCK";
break;
case CMD_SLEEP_US:
return "CMD_SLEEP_US";
break;
case CMD_SLEEP_MS:
return "CMD_SLEEP_MS";
break;
case CMD_GET_SIGNALS:
return "CMD_GET_SIGNALS";
break;
case CMD_SET_SIGNALS:
return "CMD_SET_SIGNALS";
break;
case CMD_CONFIGURE_TCK_FREQ:
return "CMD_CONFIGURE_TCK_FREQ";
break;
case CMD_SET_LEDS:
return "CMD_SET_LEDS";
break;
case CMD_TEST:
return "CMD_TEST";
break;
default:
return "CMD_UNKNOWN";
break;
case CMD_SCAN_IN:
return "CMD_SCAN_IN";
break;
case CMD_SLOW_SCAN_IN:
return "CMD_SLOW_SCAN_IN";
break;
case CMD_SCAN_OUT:
return "CMD_SCAN_OUT";
break;
case CMD_SLOW_SCAN_OUT:
return "CMD_SLOW_SCAN_OUT";
break;
case CMD_SCAN_IO:
return "CMD_SCAN_IO";
break;
case CMD_SLOW_SCAN_IO:
return "CMD_SLOW_SCAN_IO";
break;
case CMD_CLOCK_TMS:
return "CMD_CLOCK_TMS";
break;
case CMD_SLOW_CLOCK_TMS:
return "CMD_SLOW_CLOCK_TMS";
break;
case CMD_CLOCK_TCK:
return "CMD_CLOCK_TCK";
break;
case CMD_SLOW_CLOCK_TCK:
return "CMD_SLOW_CLOCK_TCK";
break;
case CMD_SLEEP_US:
return "CMD_SLEEP_US";
break;
case CMD_SLEEP_MS:
return "CMD_SLEEP_MS";
break;
case CMD_GET_SIGNALS:
return "CMD_GET_SIGNALS";
break;
case CMD_SET_SIGNALS:
return "CMD_SET_SIGNALS";
break;
case CMD_CONFIGURE_TCK_FREQ:
return "CMD_CONFIGURE_TCK_FREQ";
break;
case CMD_SET_LEDS:
return "CMD_SET_LEDS";
break;
case CMD_TEST:
return "CMD_TEST";
break;
default:
return "CMD_UNKNOWN";
break;
}
}
@@ -832,7 +824,7 @@ const char *ulink_cmd_id_string(uint8_t id)
*
* @param ulink_cmd pointer to OpenULINK command.
*/
void ulink_print_command(struct ulink_cmd *ulink_cmd)
static void ulink_print_command(struct ulink_cmd *ulink_cmd)
{
int i;
@@ -850,7 +842,7 @@ void ulink_print_command(struct ulink_cmd *ulink_cmd)
*
* @param device pointer to struct ulink identifying ULINK driver instance.
*/
void ulink_print_queue(struct ulink *device)
static void ulink_print_queue(struct ulink *device)
{
struct ulink_cmd *current;
@@ -860,8 +852,6 @@ void ulink_print_queue(struct ulink *device)
ulink_print_command(current);
}
#endif /* _DEBUG_JTAG_IO_ */
/**
* Perform JTAG scan
*
@@ -1367,7 +1357,6 @@ int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay)
return ERROR_OK;
}
#ifdef _DEBUG_JTAG_IO_
/**
* Calculate frequency for a given delay value.
*
@@ -1378,16 +1367,14 @@ int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay)
*
* @param type for which command to calculate the delay value.
* @param delay delay value for which to calculate the resulting TCK frequency.
* @param f where to store the resulting TCK frequency.
* @return on success: ERROR_OK
* @return on failure: ERROR_FAIL
* @return the resulting TCK frequency
*/
static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f)
static long ulink_calculate_frequency(enum ulink_delay_type type, int delay)
{
float t, f_float, f_rounded;
float t, f_float;
if (delay > 255)
return ERROR_FAIL;
return 0;
switch (type) {
case DELAY_CLOCK_TCK:
@@ -1421,17 +1408,12 @@ static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long
t = (float)(4E-6) * (float)(delay) + (float)(1.3132E-5);
break;
default:
return ERROR_FAIL;
break;
return 0;
}
f_float = 1.0 / t;
f_rounded = roundf(f_float);
*f = (long)f_rounded;
return ERROR_OK;
return roundf(f_float);
}
#endif
/******************* Interface between OpenULINK and OpenOCD ******************/
@@ -2065,31 +2047,21 @@ static int ulink_khz(int khz, int *jtag_speed)
return ret;
}
#ifdef _DEBUG_JTAG_IO_
long f_tck = 0, f_tms = 0, f_scan_in = 0, f_scan_out = 0, f_scan_io = 0;
ulink_calculate_frequency(DELAY_CLOCK_TCK, ulink_handle->delay_clock_tck,
&f_tck);
ulink_calculate_frequency(DELAY_CLOCK_TMS, ulink_handle->delay_clock_tms,
&f_tms);
ulink_calculate_frequency(DELAY_SCAN_IN, ulink_handle->delay_scan_in,
&f_scan_in);
ulink_calculate_frequency(DELAY_SCAN_OUT, ulink_handle->delay_scan_out,
&f_scan_out);
ulink_calculate_frequency(DELAY_SCAN_IO, ulink_handle->delay_scan_io,
&f_scan_io);
DEBUG_JTAG_IO("ULINK TCK setup: delay_tck = %i (%li Hz),",
ulink_handle->delay_clock_tck, f_tck);
DEBUG_JTAG_IO(" delay_tms = %i (%li Hz),",
ulink_handle->delay_clock_tms, f_tms);
DEBUG_JTAG_IO(" delay_scan_in = %i (%li Hz),",
ulink_handle->delay_scan_in, f_scan_in);
DEBUG_JTAG_IO(" delay_scan_out = %i (%li Hz),",
ulink_handle->delay_scan_out, f_scan_out);
DEBUG_JTAG_IO(" delay_scan_io = %i (%li Hz),",
ulink_handle->delay_scan_io, f_scan_io);
#endif
LOG_DEBUG_IO("ULINK TCK setup: delay_tck = %i (%li Hz),",
ulink_handle->delay_clock_tck,
ulink_calculate_frequency(DELAY_CLOCK_TCK, ulink_handle->delay_clock_tck));
LOG_DEBUG_IO(" delay_tms = %i (%li Hz),",
ulink_handle->delay_clock_tms,
ulink_calculate_frequency(DELAY_CLOCK_TMS, ulink_handle->delay_clock_tms));
LOG_DEBUG_IO(" delay_scan_in = %i (%li Hz),",
ulink_handle->delay_scan_in,
ulink_calculate_frequency(DELAY_SCAN_IN, ulink_handle->delay_scan_in));
LOG_DEBUG_IO(" delay_scan_out = %i (%li Hz),",
ulink_handle->delay_scan_out,
ulink_calculate_frequency(DELAY_SCAN_OUT, ulink_handle->delay_scan_out));
LOG_DEBUG_IO(" delay_scan_io = %i (%li Hz),",
ulink_handle->delay_scan_io,
ulink_calculate_frequency(DELAY_SCAN_IO, ulink_handle->delay_scan_io));
/* Configure the ULINK device with the new delay values */
ret = ulink_append_configure_tck_cmd(ulink_handle,
+19 -18
View File
@@ -174,7 +174,7 @@ static int ublast_buf_read(uint8_t *buf, unsigned size, uint32_t *bytes_read)
int ret = info.drv->read(info.drv, buf, size, bytes_read);
char *str = hexdump(buf, *bytes_read);
DEBUG_JTAG_IO("(size=%d, buf=[%s]) -> %u", size, str,
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %u", size, str,
*bytes_read);
free(str);
return ret;
@@ -185,7 +185,7 @@ static int ublast_buf_write(uint8_t *buf, int size, uint32_t *bytes_written)
int ret = info.drv->write(info.drv, buf, size, bytes_written);
char *str = hexdump(buf, *bytes_written);
DEBUG_JTAG_IO("(size=%d, buf=[%s]) -> %u", size, str,
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %u", size, str,
*bytes_written);
free(str);
return ret;
@@ -266,7 +266,7 @@ static void ublast_queue_byte(uint8_t abyte)
info.buf[info.bufidx++] = abyte;
if (nb_buf_remaining() == 0)
ublast_flush_buffer();
DEBUG_JTAG_IO("(byte=0x%02x)", abyte);
LOG_DEBUG_IO("(byte=0x%02x)", abyte);
}
/**
@@ -337,7 +337,7 @@ static void ublast_clock_tms(int tms)
{
uint8_t out;
DEBUG_JTAG_IO("(tms=%d)", !!tms);
LOG_DEBUG_IO("(tms=%d)", !!tms);
info.tms = !!tms;
info.tdi = 0;
out = ublast_build_out(SCAN_OUT);
@@ -354,7 +354,7 @@ static void ublast_idle_clock(void)
{
uint8_t out = ublast_build_out(SCAN_OUT);
DEBUG_JTAG_IO(".");
LOG_DEBUG_IO(".");
ublast_queue_byte(out);
}
@@ -375,7 +375,7 @@ static void ublast_clock_tdi(int tdi, enum scan_type type)
{
uint8_t out;
DEBUG_JTAG_IO("(tdi=%d)", !!tdi);
LOG_DEBUG_IO("(tdi=%d)", !!tdi);
info.tdi = !!tdi;
out = ublast_build_out(SCAN_OUT);
@@ -400,7 +400,7 @@ static void ublast_clock_tdi_flip_tms(int tdi, enum scan_type type)
{
uint8_t out;
DEBUG_JTAG_IO("(tdi=%d)", !!tdi);
LOG_DEBUG_IO("(tdi=%d)", !!tdi);
info.tdi = !!tdi;
info.tms = !info.tms;
@@ -430,7 +430,7 @@ static void ublast_queue_bytes(uint8_t *bytes, int nb_bytes)
info.bufidx + nb_bytes);
exit(-1);
}
DEBUG_JTAG_IO("(nb_bytes=%d, bytes=[0x%02x, ...])", nb_bytes,
LOG_DEBUG_IO("(nb_bytes=%d, bytes=[0x%02x, ...])", nb_bytes,
bytes ? bytes[0] : 0);
if (bytes)
memcpy(&info.buf[info.bufidx], bytes, nb_bytes);
@@ -457,7 +457,7 @@ static void ublast_tms_seq(const uint8_t *bits, int nb_bits, int skip)
{
int i;
DEBUG_JTAG_IO("(bits=%02x..., nb_bits=%d)", bits[0], nb_bits);
LOG_DEBUG_IO("(bits=%02x..., nb_bits=%d)", bits[0], nb_bits);
for (i = skip; i < nb_bits; i++)
ublast_clock_tms((bits[i / 8] >> (i % 8)) & 0x01);
ublast_idle_clock();
@@ -469,7 +469,7 @@ static void ublast_tms_seq(const uint8_t *bits, int nb_bits, int skip)
*/
static void ublast_tms(struct tms_command *cmd)
{
DEBUG_JTAG_IO("(num_bits=%d)", cmd->num_bits);
LOG_DEBUG_IO("(num_bits=%d)", cmd->num_bits);
ublast_tms_seq(cmd->bits, cmd->num_bits, 0);
}
@@ -487,7 +487,7 @@ static void ublast_path_move(struct pathmove_command *cmd)
{
int i;
DEBUG_JTAG_IO("(num_states=%d, last_state=%d)",
LOG_DEBUG_IO("(num_states=%d, last_state=%d)",
cmd->num_states, cmd->path[cmd->num_states - 1]);
for (i = 0; i < cmd->num_states; i++) {
if (tap_state_transition(tap_get_state(), false) == cmd->path[i])
@@ -512,7 +512,7 @@ static void ublast_state_move(tap_state_t state, int skip)
uint8_t tms_scan;
int tms_len;
DEBUG_JTAG_IO("(from %s to %s)", tap_state_name(tap_get_state()),
LOG_DEBUG_IO("(from %s to %s)", tap_state_name(tap_get_state()),
tap_state_name(state));
if (tap_get_state() == state)
return;
@@ -541,7 +541,7 @@ static int ublast_read_byteshifted_tdos(uint8_t *buf, int nb_bytes)
unsigned int retlen;
int ret = ERROR_OK;
DEBUG_JTAG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bytes * 8);
LOG_DEBUG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bytes * 8);
ublast_flush_buffer();
while (ret == ERROR_OK && nb_bytes > 0) {
ret = ublast_buf_read(buf, nb_bytes, &retlen);
@@ -573,7 +573,7 @@ static int ublast_read_bitbang_tdos(uint8_t *buf, int nb_bits)
unsigned int retlen;
uint8_t tmp[8];
DEBUG_JTAG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bits);
LOG_DEBUG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bits);
/*
* Ensure all previous bitbang writes were issued to the dongle, so that
@@ -688,7 +688,7 @@ static void ublast_queue_tdi(uint8_t *bits, int nb_bits, enum scan_type scan)
static void ublast_runtest(int cycles, tap_state_t state)
{
DEBUG_JTAG_IO("%s(cycles=%i, end_state=%d)", __func__, cycles, state);
LOG_DEBUG_IO("%s(cycles=%i, end_state=%d)", __func__, cycles, state);
ublast_state_move(TAP_IDLE, 0);
ublast_queue_tdi(NULL, cycles, SCAN_OUT);
@@ -697,7 +697,7 @@ static void ublast_runtest(int cycles, tap_state_t state)
static void ublast_stableclocks(int cycles)
{
DEBUG_JTAG_IO("%s(cycles=%i)", __func__, cycles);
LOG_DEBUG_IO("%s(cycles=%i)", __func__, cycles);
ublast_queue_tdi(NULL, cycles, SCAN_OUT);
}
@@ -727,7 +727,7 @@ static int ublast_scan(struct scan_command *cmd)
ublast_state_move(TAP_DRSHIFT, 0);
log_buf = hexdump(buf, DIV_ROUND_UP(scan_bits, 8));
DEBUG_JTAG_IO("%s(scan=%s, type=%s, bits=%d, buf=[%s], end_state=%d)", __func__,
LOG_DEBUG_IO("%s(scan=%s, type=%s, bits=%d, buf=[%s], end_state=%d)", __func__,
cmd->ir_scan ? "IRSCAN" : "DRSCAN",
type2str[type],
scan_bits, log_buf, cmd->end_state);
@@ -749,7 +749,7 @@ static int ublast_scan(struct scan_command *cmd)
static void ublast_usleep(int us)
{
DEBUG_JTAG_IO("%s(us=%d)", __func__, us);
LOG_DEBUG_IO("%s(us=%d)", __func__, us);
jtag_sleep(us);
}
@@ -1068,6 +1068,7 @@ static const struct command_registration ublast_command_handlers[] = {
struct jtag_interface usb_blaster_interface = {
.name = "usb_blaster",
.transports = jtag_only,
.commands = ublast_command_handlers,
.supported = DEBUG_CAP_TMS_SEQ,
+46 -59
View File
@@ -103,62 +103,50 @@ static int usbprog_execute_queue(void)
while (cmd) {
switch (cmd->type) {
case JTAG_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
#endif
if (cmd->cmd.reset->trst == 1)
tap_set_state(TAP_RESET);
usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
#endif
usbprog_end_state(cmd->cmd.runtest->end_state);
usbprog_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_TLR_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
usbprog_end_state(cmd->cmd.statemove->end_state);
usbprog_state_move();
break;
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("pathmove: %i states, end in %i",
cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
#endif
usbprog_path_move(cmd->cmd.pathmove);
break;
case JTAG_SCAN:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
#endif
usbprog_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
return ERROR_JTAG_QUEUE_FAILED;
if (buffer)
free(buffer);
break;
case JTAG_SLEEP:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
#endif
jtag_sleep(cmd->cmd.sleep->us);
break;
default:
LOG_ERROR("BUG: unknown JTAG command type encountered");
exit(-1);
case JTAG_RESET:
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
if (cmd->cmd.reset->trst == 1)
tap_set_state(TAP_RESET);
usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles,
cmd->cmd.runtest->end_state);
usbprog_end_state(cmd->cmd.runtest->end_state);
usbprog_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_TLR_RESET:
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
usbprog_end_state(cmd->cmd.statemove->end_state);
usbprog_state_move();
break;
case JTAG_PATHMOVE:
LOG_DEBUG_IO("pathmove: %i states, end in %i",
cmd->cmd.pathmove->num_states,
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
usbprog_path_move(cmd->cmd.pathmove);
break;
case JTAG_SCAN:
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
usbprog_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
return ERROR_JTAG_QUEUE_FAILED;
if (buffer)
free(buffer);
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:
LOG_ERROR("BUG: unknown JTAG command type encountered");
exit(-1);
}
cmd = cmd->next;
@@ -270,10 +258,8 @@ static void usbprog_runtest(int num_cycles)
usbprog_write(0, 0, 0);
}
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest: cur_state %s end_state %s", tap_state_name(
LOG_DEBUG_IO("runtest: cur_state %s end_state %s", tap_state_name(
tap_get_state()), tap_state_name(tap_get_end_state()));
#endif
/* finish in end_state */
/*
@@ -612,6 +598,7 @@ static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag)
struct jtag_interface usbprog_interface = {
.name = "usbprog",
.transports = jtag_only,
.execute_queue = usbprog_execute_queue,
.init = usbprog_init,
+30 -27
View File
@@ -82,9 +82,7 @@ struct vsllink {
static int vsllink_usb_open(struct vsllink *vsllink);
static void vsllink_usb_close(struct vsllink *vsllink);
#if defined _DEBUG_JTAG_IO_
static void vsllink_debug_buffer(uint8_t *buffer, int length);
#endif
static int tap_length;
static int tap_buffer_size;
@@ -103,14 +101,14 @@ static int vsllink_execute_queue(void)
enum scan_type type;
uint8_t *buffer;
DEBUG_JTAG_IO("-------------------------------------"
LOG_DEBUG_IO("-------------------------------------"
" vsllink "
"-------------------------------------");
while (cmd != NULL) {
switch (cmd->type) {
case JTAG_RUNTEST:
DEBUG_JTAG_IO("runtest %i cycles, end in %s",
LOG_DEBUG_IO("runtest %i cycles, end in %s",
cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state));
@@ -119,7 +117,7 @@ static int vsllink_execute_queue(void)
break;
case JTAG_TLR_RESET:
DEBUG_JTAG_IO("statemove end in %s",
LOG_DEBUG_IO("statemove end in %s",
tap_state_name(cmd->cmd.statemove->end_state));
vsllink_end_state(cmd->cmd.statemove->end_state);
@@ -127,7 +125,7 @@ static int vsllink_execute_queue(void)
break;
case JTAG_PATHMOVE:
DEBUG_JTAG_IO("pathmove: %i states, end in %s",
LOG_DEBUG_IO("pathmove: %i states, end in %s",
cmd->cmd.pathmove->num_states,
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
@@ -135,7 +133,7 @@ static int vsllink_execute_queue(void)
break;
case JTAG_SCAN:
DEBUG_JTAG_IO("JTAG Scan...");
LOG_DEBUG_IO("JTAG Scan...");
vsllink_end_state(cmd->cmd.scan->end_state);
@@ -143,23 +141,21 @@ static int vsllink_execute_queue(void)
cmd->cmd.scan, &buffer);
if (cmd->cmd.scan->ir_scan)
DEBUG_JTAG_IO(
LOG_DEBUG_IO(
"JTAG Scan write IR(%d bits), "
"end in %s:",
scan_size,
tap_state_name(cmd->cmd.scan->end_state));
else
DEBUG_JTAG_IO(
LOG_DEBUG_IO(
"JTAG Scan write DR(%d bits), "
"end in %s:",
scan_size,
tap_state_name(cmd->cmd.scan->end_state));
#ifdef _DEBUG_JTAG_IO_
vsllink_debug_buffer(buffer,
DIV_ROUND_UP(scan_size, 8));
#endif
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
vsllink_debug_buffer(buffer, DIV_ROUND_UP(scan_size, 8));
type = jtag_scan_type(cmd->cmd.scan);
@@ -169,7 +165,7 @@ static int vsllink_execute_queue(void)
break;
case JTAG_RESET:
DEBUG_JTAG_IO("reset trst: %i srst %i",
LOG_DEBUG_IO("reset trst: %i srst %i",
cmd->cmd.reset->trst,
cmd->cmd.reset->srst);
@@ -183,13 +179,13 @@ static int vsllink_execute_queue(void)
break;
case JTAG_SLEEP:
DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
vsllink_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;
case JTAG_STABLECLOCKS:
DEBUG_JTAG_IO("add %d clocks",
LOG_DEBUG_IO("add %d clocks",
cmd->cmd.stableclocks->num_cycles);
switch (tap_get_state()) {
@@ -219,7 +215,7 @@ static int vsllink_execute_queue(void)
break;
case JTAG_TMS:
DEBUG_JTAG_IO("add %d jtag tms",
LOG_DEBUG_IO("add %d jtag tms",
cmd->cmd.tms->num_bits);
vsllink_tms(cmd->cmd.tms->num_bits, cmd->cmd.tms->bits);
@@ -681,13 +677,11 @@ static int vsllink_jtag_execute(void)
command = pending_scan_result->command;
buf_set_buf(tdo_buffer, src_first, buffer, dest_first, length);
#ifdef _DEBUG_JTAG_IO_
DEBUG_JTAG_IO(
LOG_DEBUG_IO(
"JTAG scan read(%d bits, from src %d bits to dest %d bits):",
length, src_first, dest_first);
vsllink_debug_buffer(buffer + dest_first / 8,
DIV_ROUND_UP(length, 7));
#endif
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
vsllink_debug_buffer(buffer + dest_first / 8, DIV_ROUND_UP(length, 7));
if (last) {
if (jtag_read_buffer(buffer, command)
@@ -895,7 +889,6 @@ static void vsllink_usb_close(struct vsllink *vsllink)
#define BYTES_PER_LINE 16
#if defined _DEBUG_JTAG_IO_
static void vsllink_debug_buffer(uint8_t *buffer, int length)
{
char line[81];
@@ -904,46 +897,57 @@ static void vsllink_debug_buffer(uint8_t *buffer, int length)
int j;
for (i = 0; i < length; i += BYTES_PER_LINE) {
snprintf(line, 5, "%04x", i);
snprintf(line, 5, "%04x", i & 0xffff);
for (j = i; j < i + BYTES_PER_LINE && j < length; j++) {
snprintf(s, 4, " %02x", buffer[j]);
strcat(line, s);
}
LOG_DEBUG("%s", line);
LOG_DEBUG_IO("%s", line);
}
}
#endif /* _DEBUG_JTAG_IO_ */
static const struct command_registration vsllink_command_handlers[] = {
{
.name = "vsllink_usb_vid",
.handler = &vsllink_handle_usb_vid_command,
.mode = COMMAND_CONFIG,
.help = "Set USB VID",
.usage = "<vid>",
},
{
.name = "vsllink_usb_pid",
.handler = &vsllink_handle_usb_pid_command,
.mode = COMMAND_CONFIG,
.help = "Set USB PID",
.usage = "<pid>",
},
{
.name = "vsllink_usb_serial",
.handler = &vsllink_handle_usb_serial_command,
.mode = COMMAND_CONFIG,
.help = "Set or disable check for USB serial",
.usage = "[<serial>]",
},
{
.name = "vsllink_usb_bulkin",
.handler = &vsllink_handle_usb_bulkin_command,
.mode = COMMAND_CONFIG,
.help = "Set USB input endpoint",
.usage = "<ep_in>",
},
{
.name = "vsllink_usb_bulkout",
.handler = &vsllink_handle_usb_bulkout_command,
.mode = COMMAND_CONFIG,
.help = "Set USB output endpoint",
.usage = "<ep_out>",
},
{
.name = "vsllink_usb_interface",
.handler = &vsllink_handle_usb_interface_command,
.mode = COMMAND_CONFIG,
.help = "Set USB output interface",
.usage = "<interface>",
},
COMMAND_REGISTRATION_DONE
};
@@ -952,7 +956,6 @@ static const char * const vsllink_transports[] = {"jtag", "swd", NULL};
static const struct swd_driver vsllink_swd_driver = {
.init = vsllink_swd_init,
.frequency = vsllink_swd_frequency,
.switch_seq = vsllink_swd_switch_seq,
.read_reg = vsllink_swd_read_reg,
.write_reg = vsllink_swd_write_reg,
-8
View File
@@ -1925,13 +1925,6 @@ static int xds110_khz(int khz, int *jtag_speed)
return ERROR_OK;
}
static int_least32_t xds110_swd_frequency(int_least32_t hz)
{
if (hz > 0)
xds110_speed(hz / 1000);
return hz;
}
COMMAND_HANDLER(xds110_handle_info_command)
{
xds110_show_info();
@@ -2032,7 +2025,6 @@ static const struct command_registration xds110_command_handlers[] = {
static const struct swd_driver xds110_swd_driver = {
.init = xds110_swd_init,
.frequency = xds110_swd_frequency,
.switch_seq = xds110_swd_switch_seq,
.read_reg = xds110_swd_read_reg,
.write_reg = xds110_swd_write_reg,
+5 -8
View File
@@ -376,15 +376,13 @@ tap_state_t tap_state_by_name(const char *name)
return TAP_INVALID;
}
#ifdef _DEBUG_JTAG_IO_
#define JTAG_DEBUG_STATE_APPEND(buf, len, bit) \
do { buf[len] = bit ? '1' : '0'; } while (0)
#define JTAG_DEBUG_STATE_PRINT(a, b, astr, bstr) \
DEBUG_JTAG_IO("TAP/SM: %9s -> %5s\tTMS: %s\tTDI: %s", \
LOG_DEBUG_IO("TAP/SM: %9s -> %5s\tTMS: %s\tTDI: %s", \
tap_state_name(a), tap_state_name(b), astr, bstr)
tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf,
unsigned tap_bits, tap_state_t next_state)
{
const uint8_t *tms_buffer;
@@ -401,13 +399,13 @@ tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
/* set startstate (and possibly last, if tap_bits == 0) */
last_state = next_state;
DEBUG_JTAG_IO("TAP/SM: START state: %s", tap_state_name(next_state));
LOG_DEBUG_IO("TAP/SM: START state: %s", tap_state_name(next_state));
tms_buffer = (const uint8_t *)tms_buf;
tdi_buffer = (const uint8_t *)tdi_buf;
tap_bytes = DIV_ROUND_UP(tap_bits, 8);
DEBUG_JTAG_IO("TAP/SM: TMS bits: %u (bytes: %u)", tap_bits, tap_bytes);
LOG_DEBUG_IO("TAP/SM: TMS bits: %u (bytes: %u)", tap_bits, tap_bytes);
tap_out_bits = 0;
for (cur_byte = 0; cur_byte < tap_bytes; cur_byte++) {
@@ -452,11 +450,10 @@ tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
JTAG_DEBUG_STATE_PRINT(last_state, next_state, tms_str, tdi_str);
}
DEBUG_JTAG_IO("TAP/SM: FINAL state: %s", tap_state_name(next_state));
LOG_DEBUG_IO("TAP/SM: FINAL state: %s", tap_state_name(next_state));
return next_state;
}
#endif /* _DEBUG_JTAG_IO_ */
void tap_use_new_tms_table(bool use_new)
{
+10 -14
View File
@@ -56,18 +56,11 @@ void tap_set_state_impl(tap_state_t new_state);
* @param new_state The state we think the TAPs are currently in (or
* are about to enter).
*/
#if defined(_DEBUG_JTAG_IO_)
#define tap_set_state(new_state) \
do { \
LOG_DEBUG("tap_set_state(%s)", tap_state_name(new_state)); \
LOG_DEBUG_IO("tap_set_state(%s)", tap_state_name(new_state)); \
tap_set_state_impl(new_state); \
} while (0)
#else
static inline void tap_set_state(tap_state_t new_state)
{
tap_set_state_impl(new_state);
}
#endif
/**
* This function gets the state of the "state follower" which tracks the
@@ -164,7 +157,7 @@ void tap_use_new_tms_table(bool use_new);
/** @returns True if new TMS table is active; false otherwise. */
bool tap_uses_new_tms_table(void);
#ifdef _DEBUG_JTAG_IO_
/**
* @brief Prints verbose TAP state transitions for the given TMS/TDI buffers.
* @param tms_buf must points to a buffer containing the TMS bitstream.
@@ -173,15 +166,18 @@ bool tap_uses_new_tms_table(void);
* @param start_tap_state must specify the current TAP state.
* @returns the final TAP state; pass as @a start_tap_state in following call.
*/
tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
unsigned tap_len, tap_state_t start_tap_state);
#else
static inline tap_state_t jtag_debug_state_machine(const void *tms_buf,
const void *tdi_buf, unsigned tap_len, tap_state_t start_tap_state)
{
return start_tap_state;
/* Private declaration */
tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf,
unsigned tap_len, tap_state_t start_tap_state);
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
return jtag_debug_state_machine_(tms_buf, tdi_buf, tap_len, start_tap_state);
else
return start_tap_state;
}
#endif /* _DEBUG_JTAG_IO_ */
/**
* Represents a driver for a debugging interface.
-8
View File
@@ -25,14 +25,6 @@
#include <helper/binarybuffer.h>
#include <helper/log.h>
#ifdef _DEBUG_JTAG_IO_
#define DEBUG_JTAG_IO(expr ...) \
do { if (1) LOG_DEBUG(expr); } while (0)
#else
#define DEBUG_JTAG_IO(expr ...) \
do { if (0) LOG_DEBUG(expr); } while (0)
#endif
#ifndef DEBUG_JTAG_IOZ
#define DEBUG_JTAG_IOZ 64
#endif
+1
View File
@@ -28,6 +28,7 @@ struct jtag_interface minidummy_interface = {
.name = "minidummy",
.execute_queue = NULL,
.speed = NULL,
.transports = jtag_only,
.commands = NULL,
.init = NULL,
.quit = NULL,
-18
View File
@@ -232,24 +232,6 @@ struct swd_driver {
*/
int (*init)(void);
/**
* Set the SWCLK frequency of the SWD link.
*
* The driver should round the desired value, downwards if possible, to
* the nearest supported frequency. A negative value should be ignored
* and can be used to query the current setting. If the driver does not
* support a variable frequency a fixed, nominal, value should be
* returned.
*
* If the frequency is increased, it must not apply before the currently
* queued transactions are executed. If the frequency is lowered, it may
* apply immediately.
*
* @param hz The desired frequency in Hz.
* @return The actual resulting frequency after rounding.
*/
int_least32_t (*frequency)(int_least32_t hz);
/**
* Queue a special SWDIO sequence.
*
+37 -15
View File
@@ -307,11 +307,13 @@ static const struct command_registration jtag_command_handlers_to_move[] = {
enum jtag_tap_cfg_param {
JCFG_EVENT
JCFG_EVENT,
JCFG_IDCODE,
};
static Jim_Nvp nvp_config_opts[] = {
{ .name = "-event", .value = JCFG_EVENT },
{ .name = "-idcode", .value = JCFG_IDCODE },
{ .name = NULL, .value = -1 }
};
@@ -404,8 +406,23 @@ static int jtag_tap_configure_cmd(Jim_GetOptInfo *goi, struct jtag_tap *tap)
if (e != JIM_OK)
return e;
break;
case JCFG_IDCODE:
if (goi->isconfigure) {
Jim_SetResultFormatted(goi->interp,
"not settable: %s", n->name);
return JIM_ERR;
} else {
if (goi->argc != 0) {
Jim_WrongNumArgs(goi->interp,
goi->argc, goi->argv,
"NO PARAMS");
return JIM_ERR;
}
}
Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, tap->idcode));
break;
default:
Jim_SetResultFormatted(goi->interp, "unknown event: %s", n->name);
Jim_SetResultFormatted(goi->interp, "unknown value: %s", n->name);
return JIM_ERR;
}
}
@@ -622,6 +639,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
{
struct jtag_tap_event_action *jteap;
int retval;
for (jteap = tap->event_action; jteap != NULL; jteap = jteap->next) {
if (jteap->event != e)
@@ -632,7 +650,11 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
tap->dotted_name, e, nvp->name,
Jim_GetString(jteap->body, NULL));
if (Jim_EvalObj(jteap->interp, jteap->body) != JIM_OK) {
retval = Jim_EvalObj(jteap->interp, jteap->body);
if (retval == JIM_RETURN)
retval = jteap->interp->returnCode;
if (retval != JIM_OK) {
Jim_MakeErrorMessage(jteap->interp);
LOG_USER("%s", Jim_GetString(Jim_GetResult(jteap->interp), NULL));
continue;
@@ -935,9 +957,9 @@ COMMAND_HANDLER(handle_scan_chain_command)
char expected_id[12];
tap = jtag_all_taps();
command_print(CMD_CTX,
command_print(CMD,
" TapName Enabled IdCode Expected IrLen IrCap IrMask");
command_print(CMD_CTX,
command_print(CMD,
"-- ------------------- -------- ---------- ---------- ----- ----- ------");
while (tap) {
@@ -953,7 +975,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
expected = buf_get_u32(tap->expected, 0, tap->ir_length);
expected_mask = buf_get_u32(tap->expected_mask, 0, tap->ir_length);
command_print(CMD_CTX,
command_print(CMD,
"%2d %-18s %c 0x%08x %s %5d 0x%02x 0x%02x",
tap->abs_chain_position,
tap->dotted_name,
@@ -970,7 +992,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
if (tap->ignore_version)
expected_id[2] = '*';
command_print(CMD_CTX,
command_print(CMD,
" %s",
expected_id);
}
@@ -991,7 +1013,7 @@ COMMAND_HANDLER(handle_jtag_ntrst_delay_command)
jtag_set_ntrst_delay(delay);
}
command_print(CMD_CTX, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
command_print(CMD, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
return ERROR_OK;
}
@@ -1005,7 +1027,7 @@ COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command)
jtag_set_ntrst_assert_width(delay);
}
command_print(CMD_CTX, "jtag_ntrst_assert_width: %u", jtag_get_ntrst_assert_width());
command_print(CMD, "jtag_ntrst_assert_width: %u", jtag_get_ntrst_assert_width());
return ERROR_OK;
}
@@ -1030,9 +1052,9 @@ COMMAND_HANDLER(handle_jtag_rclk_command)
return retval;
if (cur_khz)
command_print(CMD_CTX, "RCLK not supported - fallback to %d kHz", cur_khz);
command_print(CMD, "RCLK not supported - fallback to %d kHz", cur_khz);
else
command_print(CMD_CTX, "RCLK - adaptive");
command_print(CMD, "RCLK - adaptive");
return retval;
}
@@ -1131,7 +1153,7 @@ COMMAND_HANDLER(handle_irscan_command)
tap = jtag_tap_by_string(CMD_ARGV[i*2]);
if (tap == NULL) {
free(fields);
command_print(CMD_CTX, "Tap: %s unknown", CMD_ARGV[i*2]);
command_print(CMD, "Tap: %s unknown", CMD_ARGV[i*2]);
return ERROR_FAIL;
}
@@ -1176,7 +1198,7 @@ COMMAND_HANDLER(handle_verify_ircapture_command)
}
const char *status = jtag_will_verify_capture_ir() ? "enabled" : "disabled";
command_print(CMD_CTX, "verify Capture-IR is %s", status);
command_print(CMD, "verify Capture-IR is %s", status);
return ERROR_OK;
}
@@ -1193,7 +1215,7 @@ COMMAND_HANDLER(handle_verify_jtag_command)
}
const char *status = jtag_will_verify() ? "enabled" : "disabled";
command_print(CMD_CTX, "verify jtag capture is %s", status);
command_print(CMD, "verify jtag capture is %s", status);
return ERROR_OK;
}
@@ -1215,7 +1237,7 @@ COMMAND_HANDLER(handle_tms_sequence_command)
tap_use_new_tms_table(use_new_table);
}
command_print(CMD_CTX, "tms sequence is %s",
command_print(CMD, "tms sequence is %s",
tap_uses_new_tms_table() ? "short" : "long");
return ERROR_OK;
+1
View File
@@ -1242,6 +1242,7 @@ struct jtag_interface zy1000_interface = {
.supported = DEBUG_CAP_TMS_SEQ,
.execute_queue = NULL,
.speed = zy1000_speed,
.transports = jtag_only,
.commands = zy1000_commands,
.init = zy1000_init,
.quit = zy1000_quit,