jtag: use proper format with uint32_t

Modify the format strings to properly handle uint32_t data types.

Change the prototype of detect_swo_freq_and_prescaler() in
'jlink.c' to avoid an implicit cast in the caller function.

Change the type of the variable retlen in some functions in
'usb_blaster.c' to properly pass their pointer to the local read
and write functions.

Use the proper parser COMMAND_PARSE_NUMBER(u32, ...).

Change-Id: I5227dbce04ee59881f173724db90790b7b9cc7af
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5815
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2020-08-18 18:55:25 +02:00
parent d493b53e8c
commit 2f62883161
18 changed files with 43 additions and 43 deletions

View File

@ -1290,7 +1290,7 @@ static int jtag_examine_chain(void)
if ((idcode & 1) == 0) {
/* Zero for LSB indicates a device in bypass */
LOG_INFO("TAP %s does not have valid IDCODE (idcode=0x%x)",
LOG_INFO("TAP %s does not have valid IDCODE (idcode=0x%" PRIx32 ")",
tap->dotted_name, idcode);
tap->hasidcode = false;
tap->idcode = 0;

View File

@ -374,7 +374,7 @@ static int amt_jtagaccel_execute_queue(void)
free(buffer);
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:

View File

@ -160,7 +160,7 @@ static int armjtagew_execute_queue(void)
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
armjtagew_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;

View File

@ -362,7 +362,7 @@ int bitbang_execute_queue(void)
free(buffer);
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
case JTAG_TMS:

View File

@ -264,7 +264,7 @@ int bitq_execute_queue(void)
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
bitq_interface->sleep(cmd->cmd.sleep->us);
if (bitq_interface->in_rdy())
bitq_in_proc();

View File

@ -214,7 +214,7 @@ static int buspirate_execute_queue(void)
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
buspirate_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;

View File

@ -891,7 +891,7 @@ static int syncbb_execute_queue(void)
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;

View File

@ -555,11 +555,11 @@ static int ftdi_reset(int trst, int srst)
static void ftdi_execute_sleep(struct jtag_command *cmd)
{
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
mpsse_flush(mpsse_ctx);
jtag_sleep(cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIi32 " usec while in %s",
LOG_DEBUG_IO("sleep %" PRIu32 " usec while in %s",
cmd->cmd.sleep->us,
tap_state_name(tap_get_state()));
}

View File

@ -331,7 +331,7 @@ static int gw16012_execute_queue(void)
free(buffer);
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:

View File

@ -254,7 +254,7 @@ static void jlink_execute_scan(struct jtag_command *cmd)
static void jlink_execute_sleep(struct jtag_command *cmd)
{
LOG_DEBUG_IO("sleep %" PRIi32 "", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32 "", cmd->cmd.sleep->us);
jlink_flush();
jtag_sleep(cmd->cmd.sleep->us);
}
@ -480,7 +480,7 @@ static bool adjust_swd_buffer_size(void)
}
if (tmp < 143) {
LOG_ERROR("Not enough free device internal memory: %u bytes.", tmp);
LOG_ERROR("Not enough free device internal memory: %" PRIu32 " bytes.", tmp);
return false;
}
@ -1049,7 +1049,7 @@ COMMAND_HANDLER(jlink_handle_free_memory_command)
return ERROR_FAIL;
}
command_print(CMD, "Device has %u bytes of free memory.", tmp);
command_print(CMD, "Device has %" PRIu32 " bytes of free memory.", tmp);
return ERROR_OK;
}
@ -1288,7 +1288,7 @@ static bool calculate_swo_prescaler(unsigned int traceclkin_freq,
}
static bool detect_swo_freq_and_prescaler(struct jaylink_swo_speed speed,
unsigned int traceclkin_freq, uint32_t *trace_freq,
unsigned int traceclkin_freq, unsigned int *trace_freq,
uint16_t *prescaler)
{
uint32_t divider;
@ -1378,11 +1378,11 @@ static int config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol,
max_freq = speed.freq / speed.min_div;
if (*trace_freq > max_freq) {
LOG_INFO("Given SWO frequency too high, using %u Hz instead.",
LOG_INFO("Given SWO frequency too high, using %" PRIu32 " Hz instead.",
max_freq);
*trace_freq = max_freq;
} else if (*trace_freq < min_freq) {
LOG_INFO("Given SWO frequency too low, using %u Hz instead.",
LOG_INFO("Given SWO frequency too low, using %" PRIu32 " Hz instead.",
min_freq);
*trace_freq = min_freq;
} else if (*trace_freq != speed.freq / divider) {
@ -1420,7 +1420,7 @@ static int config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol,
return ERROR_FAIL;
}
LOG_DEBUG("Using %u bytes device memory for trace capturing.",
LOG_DEBUG("Using %" PRIu32 " bytes device memory for trace capturing.",
buffer_size);
/*

View File

@ -310,7 +310,7 @@ static int opendous_execute_queue(void)
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
opendous_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;

View File

@ -1340,7 +1340,7 @@ static int rlink_execute_queue(void)
retval = ERROR_FAIL;
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:

View File

@ -3092,7 +3092,7 @@ static int stlink_read_dap_register(void *handle, unsigned short dap_port,
retval = stlink_usb_xfer_errcheck(handle, h->databuf, 8);
*val = le_to_h_u32(h->databuf + 4);
LOG_DEBUG_IO("dap_port_read = %d, addr = 0x%x, value = 0x%x", dap_port, addr, *val);
LOG_DEBUG_IO("dap_port_read = %d, addr = 0x%x, value = 0x%" PRIx32, dap_port, addr, *val);
return retval;
}
@ -3107,7 +3107,7 @@ static int stlink_write_dap_register(void *handle, unsigned short dap_port,
if (!(h->version.flags & STLINK_F_HAS_DAP_REG))
return ERROR_COMMAND_NOTFOUND;
LOG_DEBUG_IO("dap_write port = %d, addr = 0x%x, value = 0x%x", dap_port, addr, val);
LOG_DEBUG_IO("dap_write port = %d, addr = 0x%x, value = 0x%" PRIx32, dap_port, addr, val);
stlink_usb_init_buffer(handle, h->rx_ep, 16);
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;
h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_WRITE_DAP_REG;
@ -3531,7 +3531,7 @@ static int stlink_swim_op_read_mem(uint32_t addr, uint32_t size,
int retval;
uint32_t bytes_remaining;
LOG_DEBUG_IO("read at 0x%08x len %d*0x%08x", addr, size, count);
LOG_DEBUG_IO("read at 0x%08" PRIx32 " len %" PRIu32 "*0x%08" PRIx32, addr, size, count);
count *= size;
while (count) {
@ -3554,7 +3554,7 @@ static int stlink_swim_op_write_mem(uint32_t addr, uint32_t size,
int retval;
uint32_t bytes_remaining;
LOG_DEBUG_IO("write at 0x%08x len %d*0x%08x", addr, size, count);
LOG_DEBUG_IO("write at 0x%08" PRIx32 " len %" PRIu32 "*0x%08" PRIx32, addr, size, count);
count *= size;
while (count) {

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);
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %u", size, str,
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %" PRIu32, 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);
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %u", size, str,
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %" PRIu32, size, str,
*bytes_written);
free(str);
return ret;
@ -198,7 +198,7 @@ static int nb_buf_remaining(void)
static void ublast_flush_buffer(void)
{
unsigned int retlen;
uint32_t retlen;
int nb = info.bufidx, ret = ERROR_OK;
while (ret == ERROR_OK && nb > 0) {
@ -538,7 +538,7 @@ static void ublast_state_move(tap_state_t state, int skip)
*/
static int ublast_read_byteshifted_tdos(uint8_t *buf, int nb_bytes)
{
unsigned int retlen;
uint32_t retlen;
int ret = ERROR_OK;
LOG_DEBUG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bytes * 8);
@ -570,7 +570,7 @@ static int ublast_read_bitbang_tdos(uint8_t *buf, int nb_bits)
{
int nb1 = nb_bits;
int i, ret = ERROR_OK;
unsigned int retlen;
uint32_t retlen;
uint8_t tmp[8];
LOG_DEBUG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bits);
@ -902,7 +902,7 @@ static int ublast_init(void)
static int ublast_quit(void)
{
uint8_t byte0 = 0;
unsigned int retlen;
uint32_t retlen;
ublast_buf_write(&byte0, 1, &retlen);
return info.drv->close(info.drv);

View File

@ -141,7 +141,7 @@ static int usbprog_execute_queue(void)
free(buffer);
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
jtag_sleep(cmd->cmd.sleep->us);
break;
default:

View File

@ -165,7 +165,7 @@ static int vsllink_execute_queue(void)
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
vsllink_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;

View File

@ -655,7 +655,7 @@ static bool xds_execute(uint32_t out_length, uint32_t in_length,
if (bytes_read != in_length) {
/* Unexpected amount of data returned */
success = false;
LOG_DEBUG("XDS110: command 0x%02x return %d bytes, expected %d",
LOG_DEBUG("XDS110: command 0x%02x return %" PRIu32 " bytes, expected %" PRIu32,
xds110.write_payload[0], bytes_read, in_length);
} else {
/* Extract error code from return packet */
@ -1389,7 +1389,7 @@ static void xds110_show_info(void)
uint32_t firmware = xds110.firmware;
LOG_INFO("XDS110: vid/pid = %04x/%04x", xds110.vid, xds110.pid);
LOG_INFO("XDS110: firmware version = %d.%d.%d.%d",
LOG_INFO("XDS110: firmware version = %" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32,
(((firmware >> 28) & 0xf) * 10) + ((firmware >> 24) & 0xf),
(((firmware >> 20) & 0xf) * 10) + ((firmware >> 16) & 0xf),
(((firmware >> 12) & 0xf) * 10) + ((firmware >> 8) & 0xf),
@ -1399,10 +1399,10 @@ static void xds110_show_info(void)
LOG_INFO("XDS110: serial number = %s", xds110.serial);
if (xds110.is_swd_mode) {
LOG_INFO("XDS110: connected to target via SWD");
LOG_INFO("XDS110: SWCLK set to %d kHz", xds110.speed);
LOG_INFO("XDS110: SWCLK set to %" PRIu32 " kHz", xds110.speed);
} else {
LOG_INFO("XDS110: connected to target via JTAG");
LOG_INFO("XDS110: TCK set to %d kHz", xds110.speed);
LOG_INFO("XDS110: TCK set to %" PRIu32 " kHz", xds110.speed);
}
/* Alert user that there's a better firmware to use */
@ -1756,7 +1756,7 @@ static void xds110_queue_scan(struct jtag_command *cmd)
/* Check if this single request is too large to fit */
if ((1 + total_bytes + sizeof(end_state) + 1) > MAX_DATA_BLOCK) {
LOG_ERROR("BUG: JTAG scan request is too large to handle (%d bits)",
LOG_ERROR("BUG: JTAG scan request is too large to handle (%" PRIu32 " bits)",
total_bits);
/* Failing to run this scan mucks up debug on this target */
exit(-1);
@ -2057,7 +2057,7 @@ COMMAND_HANDLER(xds110_handle_supply_voltage_command)
uint32_t voltage = 0;
if (CMD_ARGC == 1) {
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], voltage);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], voltage);
if (voltage == 0 || (voltage >= XDS110_MIN_VOLTAGE && voltage
<= XDS110_MAX_VOLTAGE)) {
/* Requested voltage is in range */

View File

@ -82,7 +82,7 @@ static int xlnx_pcie_xvc_write_reg(const int offset, const uint32_t val)
err = pwrite(xlnx_pcie_xvc->fd, &val, sizeof(val),
xlnx_pcie_xvc->offset + offset);
if (err != sizeof(val)) {
LOG_ERROR("Failed to write offset: %x with value: %x",
LOG_ERROR("Failed to write offset: %x with value: %" PRIx32,
offset, val);
return ERROR_JTAG_DEVICE_ERROR;
}
@ -112,10 +112,10 @@ static int xlnx_pcie_xvc_transact(size_t num_bits, uint32_t tms, uint32_t tdi,
return err;
if (tdo)
LOG_DEBUG_IO("Transact num_bits: %zu, tms: %x, tdi: %x, tdo: %x",
LOG_DEBUG_IO("Transact num_bits: %zu, tms: %" PRIx32 ", tdi: %" PRIx32 ", tdo: %" PRIx32,
num_bits, tms, tdi, *tdo);
else
LOG_DEBUG_IO("Transact num_bits: %zu, tms: %x, tdi: %x, tdo: <null>",
LOG_DEBUG_IO("Transact num_bits: %zu, tms: %" PRIx32 ", tdi: %" PRIx32 ", tdo: <null>",
num_bits, tms, tdi);
return ERROR_OK;
}
@ -304,7 +304,7 @@ static void xlnx_pcie_xvc_execute_reset(struct jtag_command *cmd)
static void xlnx_pcie_xvc_execute_sleep(struct jtag_command *cmd)
{
LOG_DEBUG("sleep %" PRIi32 "", cmd->cmd.sleep->us);
LOG_DEBUG("sleep %" PRIu32 "", cmd->cmd.sleep->us);
usleep(cmd->cmd.sleep->us);
}
@ -405,7 +405,7 @@ static int xlnx_pcie_xvc_init(void)
err = xlnx_pcie_xvc_read_reg(XLNX_XVC_EXT_CAP, &cap);
if (err != ERROR_OK)
return err;
LOG_DEBUG("Checking capability at 0x%x; id=0x%04x version=0x%x next=0x%x",
LOG_DEBUG("Checking capability at 0x%x; id=0x%04" PRIx32 " version=0x%" PRIx32 " next=0x%" PRIx32,
xlnx_pcie_xvc->offset,
PCI_EXT_CAP_ID(cap),
PCI_EXT_CAP_VER(cap),
@ -414,7 +414,7 @@ static int xlnx_pcie_xvc_init(void)
err = xlnx_pcie_xvc_read_reg(XLNX_XVC_VSEC_HDR, &vh);
if (err != ERROR_OK)
return err;
LOG_DEBUG("Checking possible match at 0x%x; id: 0x%x; rev: 0x%x; length: 0x%x",
LOG_DEBUG("Checking possible match at 0x%x; id: 0x%" PRIx32 "; rev: 0x%" PRIx32 "; length: 0x%" PRIx32,
xlnx_pcie_xvc->offset,
PCI_VNDR_HEADER_ID(vh),
PCI_VNDR_HEADER_REV(vh),