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
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;
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:
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;
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:
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();
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;
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;
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()));
}
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:
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);
}
}
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;
}
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;
}
}
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;
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) {
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);
/*
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;
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:
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;
}
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;
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) {
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) {
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;
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;
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) {
*/
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);
{
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);
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);
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:
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;
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 */
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),
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 */
/* 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);
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 */
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;
}
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;
}
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);
}
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),
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),