Each one of CMSIS-DAP command handlers was responsible for setting
HID report number, which in case of USB bulk transport was not used
at all. The command had to be filled with 1 byte offset whereas
the response was read without an offset.
Introduce 'command' and 'response' pointers into struct cmsis_dap.
Use them for filling the command and read the response respectively.
CMSIS-DAP command parameter are now at positions as documented in
https://arm-software.github.io/CMSIS_5/DAP/html/group__DAP__Commands__gr.html
Adjust buffer allocation for HID and USB bulk transports.
While on it, use h_u32_to_le() and h_u16_to_le() instead of per-byte
writes.
Change-Id: Ib0808d6826ba0e254c1007ace8b743405536332a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6120
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
static int cmsis_dap_cmd_DAP_SWJ_Pins(uint8_t pins, uint8_t mask, uint32_t delay, uint8_t *input)
{
int retval;
static int cmsis_dap_cmd_DAP_SWJ_Pins(uint8_t pins, uint8_t mask, uint32_t delay, uint8_t *input)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
-
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_SWJ_PINS;
- buffer[2] = pins;
- buffer[3] = mask;
- buffer[4] = delay & 0xff;
- buffer[5] = (delay >> 8) & 0xff;
- buffer[6] = (delay >> 16) & 0xff;
- buffer[7] = (delay >> 24) & 0xff;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 8);
+ uint8_t *command = cmsis_dap_handle->command;
+
+ command[0] = CMD_DAP_SWJ_PINS;
+ command[1] = pins;
+ command[2] = mask;
+ h_u32_to_le(&command[3], delay);
+
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 7);
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command CMD_DAP_SWJ_PINS failed.");
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command CMD_DAP_SWJ_PINS failed.");
+ *input = cmsis_dap_handle->response[1];
static int cmsis_dap_cmd_DAP_SWJ_Clock(uint32_t swj_clock)
{
int retval;
static int cmsis_dap_cmd_DAP_SWJ_Clock(uint32_t swj_clock)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
/* set clock in Hz */
swj_clock *= 1000;
/* set clock in Hz */
swj_clock *= 1000;
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_SWJ_CLOCK;
- buffer[2] = swj_clock & 0xff;
- buffer[3] = (swj_clock >> 8) & 0xff;
- buffer[4] = (swj_clock >> 16) & 0xff;
- buffer[5] = (swj_clock >> 24) & 0xff;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 6);
- if (retval != ERROR_OK || buffer[1] != DAP_OK) {
+ command[0] = CMD_DAP_SWJ_CLOCK;
+ h_u32_to_le(&command[1], swj_clock);
+
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 5);
+
+ if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK) {
LOG_ERROR("CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
LOG_ERROR("CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
static int cmsis_dap_cmd_DAP_SWJ_Sequence(uint8_t s_len, const uint8_t *sequence)
{
int retval;
static int cmsis_dap_cmd_DAP_SWJ_Sequence(uint8_t s_len, const uint8_t *sequence)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
#ifdef CMSIS_DAP_JTAG_DEBUG
LOG_DEBUG("cmsis-dap TMS sequence: len=%d", s_len);
#ifdef CMSIS_DAP_JTAG_DEBUG
LOG_DEBUG("cmsis-dap TMS sequence: len=%d", s_len);
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_SWJ_SEQ;
- buffer[2] = s_len;
- bit_copy(&buffer[3], 0, sequence, 0, s_len);
+ command[0] = CMD_DAP_SWJ_SEQ;
+ command[1] = s_len;
+ bit_copy(&command[2], 0, sequence, 0, s_len);
- retval = cmsis_dap_xfer(cmsis_dap_handle, DIV_ROUND_UP(s_len, 8) + 3);
-
- if (retval != ERROR_OK || buffer[1] != DAP_OK)
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 2 + DIV_ROUND_UP(s_len, 8));
+ if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK)
return ERROR_FAIL;
return ERROR_OK;
return ERROR_FAIL;
return ERROR_OK;
static int cmsis_dap_cmd_DAP_Info(uint8_t info, uint8_t **data)
{
int retval;
static int cmsis_dap_cmd_DAP_Info(uint8_t info, uint8_t **data)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_INFO;
- buffer[2] = info;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 3);
+ command[0] = CMD_DAP_INFO;
+ command[1] = info;
+
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 2);
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command CMD_INFO failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command CMD_INFO failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
+ *data = &cmsis_dap_handle->response[1];
static int cmsis_dap_cmd_DAP_LED(uint8_t led, uint8_t state)
{
int retval;
static int cmsis_dap_cmd_DAP_LED(uint8_t led, uint8_t state)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_LED;
- buffer[2] = led;
- buffer[3] = state;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 4);
+ command[0] = CMD_DAP_LED;
+ command[1] = led;
+ command[2] = state;
+
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 3);
- if (retval != ERROR_OK || buffer[1] != 0x00) {
+ if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK) {
LOG_ERROR("CMSIS-DAP command CMD_LED failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
LOG_ERROR("CMSIS-DAP command CMD_LED failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
static int cmsis_dap_cmd_DAP_Connect(uint8_t mode)
{
int retval;
static int cmsis_dap_cmd_DAP_Connect(uint8_t mode)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_CONNECT;
- buffer[2] = mode;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 3);
+ command[0] = CMD_DAP_CONNECT;
+ command[1] = mode;
+
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 2);
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command CMD_CONNECT failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command CMD_CONNECT failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
- if (buffer[1] != mode) {
+ if (cmsis_dap_handle->response[1] != mode) {
LOG_ERROR("CMSIS-DAP failed to connect in mode (%d)", mode);
return ERROR_JTAG_DEVICE_ERROR;
}
LOG_ERROR("CMSIS-DAP failed to connect in mode (%d)", mode);
return ERROR_JTAG_DEVICE_ERROR;
}
static int cmsis_dap_cmd_DAP_Disconnect(void)
{
int retval;
static int cmsis_dap_cmd_DAP_Disconnect(void)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_DISCONNECT;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 2);
+ command[0] = CMD_DAP_DISCONNECT;
+
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 1);
- if (retval != ERROR_OK || buffer[1] != DAP_OK) {
+ if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK) {
LOG_ERROR("CMSIS-DAP command CMD_DISCONNECT failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
LOG_ERROR("CMSIS-DAP command CMD_DISCONNECT failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
static int cmsis_dap_cmd_DAP_TFER_Configure(uint8_t idle, uint16_t retry_count, uint16_t match_retry)
{
int retval;
static int cmsis_dap_cmd_DAP_TFER_Configure(uint8_t idle, uint16_t retry_count, uint16_t match_retry)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
-
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_TFER_CONFIGURE;
- buffer[2] = idle;
- buffer[3] = retry_count & 0xff;
- buffer[4] = (retry_count >> 8) & 0xff;
- buffer[5] = match_retry & 0xff;
- buffer[6] = (match_retry >> 8) & 0xff;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 7);
+ uint8_t *command = cmsis_dap_handle->command;
+
+ command[0] = CMD_DAP_TFER_CONFIGURE;
+ command[1] = idle;
+ h_u16_to_le(&command[2], retry_count);
+ h_u16_to_le(&command[4], match_retry);
- if (retval != ERROR_OK || buffer[1] != DAP_OK) {
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 6);
+
+ if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK) {
LOG_ERROR("CMSIS-DAP command CMD_TFER_Configure failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
LOG_ERROR("CMSIS-DAP command CMD_TFER_Configure failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
static int cmsis_dap_cmd_DAP_SWD_Configure(uint8_t cfg)
{
int retval;
static int cmsis_dap_cmd_DAP_SWD_Configure(uint8_t cfg)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_SWD_CONFIGURE;
- buffer[2] = cfg;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 3);
+ command[0] = CMD_DAP_SWD_CONFIGURE;
+ command[1] = cfg;
- if (retval != ERROR_OK || buffer[1] != DAP_OK) {
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 2);
+
+ if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK) {
LOG_ERROR("CMSIS-DAP command CMD_SWD_Configure failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
LOG_ERROR("CMSIS-DAP command CMD_SWD_Configure failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
static int cmsis_dap_cmd_DAP_Delay(uint16_t delay_us)
{
int retval;
static int cmsis_dap_cmd_DAP_Delay(uint16_t delay_us)
{
int retval;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
+
+ command[0] = CMD_DAP_DELAY;
+ h_u16_to_le(&command[1], delay_us);
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_DELAY;
- buffer[2] = delay_us & 0xff;
- buffer[3] = (delay_us >> 8) & 0xff;
- retval = cmsis_dap_xfer(cmsis_dap_handle, 4);
+ retval = cmsis_dap_xfer(cmsis_dap_handle, 3);
- if (retval != ERROR_OK || buffer[1] != DAP_OK) {
+ if (retval != ERROR_OK || cmsis_dap_handle->response[1] != DAP_OK) {
LOG_ERROR("CMSIS-DAP command CMD_Delay failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
LOG_ERROR("CMSIS-DAP command CMD_Delay failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap)
{
static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap)
{
- uint8_t *buffer = dap->packet_buffer;
+ uint8_t *command = cmsis_dap_handle->command;
struct pending_request_block *block = &pending_fifo[pending_fifo_put_idx];
LOG_DEBUG_IO("Executing %d queued transactions from FIFO index %d", block->transfer_count, pending_fifo_put_idx);
struct pending_request_block *block = &pending_fifo[pending_fifo_put_idx];
LOG_DEBUG_IO("Executing %d queued transactions from FIFO index %d", block->transfer_count, pending_fifo_put_idx);
if (block->transfer_count == 0)
goto skip;
if (block->transfer_count == 0)
goto skip;
- size_t idx = 0;
- buffer[idx++] = 0; /* report number */
- buffer[idx++] = CMD_DAP_TFER;
- buffer[idx++] = 0x00; /* DAP Index */
- buffer[idx++] = block->transfer_count;
+ command[0] = CMD_DAP_TFER;
+ command[1] = 0x00; /* DAP Index */
+ command[2] = block->transfer_count;
+ size_t idx = 3;
for (int i = 0; i < block->transfer_count; i++) {
struct pending_transfer_result *transfer = &(block->transfers[i]);
for (int i = 0; i < block->transfer_count; i++) {
struct pending_transfer_result *transfer = &(block->transfers[i]);
- buffer[idx++] = (cmd >> 1) & 0x0f;
+ command[idx++] = (cmd >> 1) & 0x0f;
if (!(cmd & SWD_CMD_RnW)) {
if (!(cmd & SWD_CMD_RnW)) {
- buffer[idx++] = (data) & 0xff;
- buffer[idx++] = (data >> 8) & 0xff;
- buffer[idx++] = (data >> 16) & 0xff;
- buffer[idx++] = (data >> 24) & 0xff;
+ h_u32_to_le(&command[idx], data);
+ idx += 4;
static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, int timeout_ms)
{
static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, int timeout_ms)
{
- uint8_t *buffer = dap->packet_buffer;
struct pending_request_block *block = &pending_fifo[pending_fifo_get_idx];
if (pending_fifo_block_count == 0)
struct pending_request_block *block = &pending_fifo[pending_fifo_get_idx];
if (pending_fifo_block_count == 0)
- if (buffer[2] & 0x08) {
- LOG_DEBUG("CMSIS-DAP Protocol Error @ %d (wrong parity)", buffer[1]);
+ uint8_t *resp = dap->response;
+ uint8_t transfer_count = resp[1];
+ uint8_t ack = resp[2] & 0x07;
+ if (resp[2] & 0x08) {
+ LOG_DEBUG("CMSIS-DAP Protocol Error @ %d (wrong parity)", transfer_count);
queued_retval = ERROR_FAIL;
goto skip;
}
queued_retval = ERROR_FAIL;
goto skip;
}
- uint8_t ack = buffer[2] & 0x07;
- LOG_DEBUG("SWD ack not OK @ %d %s", buffer[1],
+ LOG_DEBUG("SWD ack not OK @ %d %s", transfer_count,
ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK");
queued_retval = ack == SWD_ACK_WAIT ? ERROR_WAIT : ERROR_FAIL;
goto skip;
}
ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK");
queued_retval = ack == SWD_ACK_WAIT ? ERROR_WAIT : ERROR_FAIL;
goto skip;
}
- if (block->transfer_count != buffer[1])
+ if (block->transfer_count != transfer_count)
LOG_ERROR("CMSIS-DAP transfer count mismatch: expected %d, got %d",
LOG_ERROR("CMSIS-DAP transfer count mismatch: expected %d, got %d",
- block->transfer_count, buffer[1]);
+ block->transfer_count, transfer_count);
- LOG_DEBUG_IO("Received results of %d queued transactions FIFO index %d", buffer[1], pending_fifo_get_idx);
+ LOG_DEBUG_IO("Received results of %d queued transactions FIFO index %d",
+ transfer_count, pending_fifo_get_idx);
- for (int i = 0; i < buffer[1]; i++) {
+ for (int i = 0; i < transfer_count; i++) {
struct pending_transfer_result *transfer = &(block->transfers[i]);
if (transfer->cmd & SWD_CMD_RnW) {
static uint32_t last_read;
struct pending_transfer_result *transfer = &(block->transfers[i]);
if (transfer->cmd & SWD_CMD_RnW) {
static uint32_t last_read;
- uint32_t data = le_to_h_u32(&buffer[idx]);
+ uint32_t data = le_to_h_u32(&resp[idx]);
uint32_t tmp = data;
idx += 4;
uint32_t tmp = data;
idx += 4;
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);
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 */
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
- buffer[0] = 0; /* report number */
- buffer[1] = CMD_DAP_JTAG_SEQ;
- buffer[2] = queued_seq_count;
- memcpy(buffer + 3, queued_seq_buf, queued_seq_buf_end);
+ /* prepare CMSIS-DAP packet */
+ uint8_t *command = cmsis_dap_handle->command;
+ command[0] = CMD_DAP_JTAG_SEQ;
+ command[1] = queued_seq_count;
+ memcpy(&command[2], queued_seq_buf, queued_seq_buf_end);
#ifdef CMSIS_DAP_JTAG_DEBUG
#ifdef CMSIS_DAP_JTAG_DEBUG
- debug_parse_cmsis_buf(buffer, queued_seq_buf_end + 3);
+ debug_parse_cmsis_buf(command, queued_seq_buf_end + 2);
#endif
/* send command to USB device */
#endif
/* send command to USB device */
- int retval = cmsis_dap_xfer(cmsis_dap_handle, queued_seq_buf_end + 3);
- if (retval != ERROR_OK || buffer[1] != DAP_OK) {
+ int retval = cmsis_dap_xfer(cmsis_dap_handle, queued_seq_buf_end + 2);
+
+ uint8_t *resp = cmsis_dap_handle->response;
+ if (retval != ERROR_OK || resp[1] != DAP_OK) {
LOG_ERROR("CMSIS-DAP command CMD_DAP_JTAG_SEQ failed.");
exit(-1);
}
LOG_ERROR("CMSIS-DAP command CMD_DAP_JTAG_SEQ failed.");
exit(-1);
}
#ifdef CMSIS_DAP_JTAG_DEBUG
LOG_DEBUG_IO("USB response buf:");
for (int c = 0; c < queued_seq_buf_end + 3; ++c)
#ifdef CMSIS_DAP_JTAG_DEBUG
LOG_DEBUG_IO("USB response buf:");
for (int c = 0; c < queued_seq_buf_end + 3; ++c)
- printf("%02X ", buffer[c]);
+ printf("%02X ", resp[c]);
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)
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)
- printf("%02X ", buffer[2+scan->first+b]);
+ printf("%02X ", resp[2+scan->first+b]);
- bit_copy(scan->buffer, scan->buffer_offset, buffer + 2 + scan->first, 0, scan->length);
+ bit_copy(scan->buffer, scan->buffer_offset, &resp[2 + scan->first], 0, scan->length);
{
int retval;
unsigned i;
{
int retval;
unsigned i;
- uint8_t *buffer = cmsis_dap_handle->packet_buffer;
-
- buffer[0] = 0; /* report number */
+ uint8_t *command = cmsis_dap_handle->command;
for (i = 0; i < CMD_ARGC; i++)
for (i = 0; i < CMD_ARGC; i++)
- buffer[i + 1] = strtoul(CMD_ARGV[i], NULL, 16);
+ command[i] = strtoul(CMD_ARGV[i], NULL, 16);
- retval = cmsis_dap_xfer(cmsis_dap_handle, CMD_ARGC + 1);
+ retval = cmsis_dap_xfer(cmsis_dap_handle, CMD_ARGC);
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
if (retval != ERROR_OK) {
LOG_ERROR("CMSIS-DAP command failed.");
return ERROR_JTAG_DEVICE_ERROR;
}
+ uint8_t *resp = cmsis_dap_handle->response;
LOG_INFO("Returned data %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8,
LOG_INFO("Returned data %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8,
- buffer[1], buffer[2], buffer[3], buffer[4]);
+ resp[1], resp[2], resp[3], resp[4]);
int packet_count;
uint8_t *packet_buffer;
uint16_t packet_buffer_size;
int packet_count;
uint8_t *packet_buffer;
uint16_t packet_buffer_size;
+ uint8_t *command;
+ uint8_t *response;
uint8_t caps;
uint8_t mode;
};
uint8_t caps;
uint8_t mode;
};
}
dap->packet_size = packet_size;
}
dap->packet_size = packet_size;
- dap->packet_buffer_size = packet_size + REPORT_ID_SIZE;
+ dap->packet_buffer_size = packet_size;
dap->bdata->usb_ctx = ctx;
dap->bdata->dev_handle = dev_handle;
dap->bdata->ep_out = ep_out;
dap->bdata->usb_ctx = ctx;
dap->bdata->dev_handle = dev_handle;
dap->bdata->ep_out = ep_out;
+ dap->command = dap->packet_buffer;
+ dap->response = dap->packet_buffer;
+
/* skip the first byte that is only used by the HID backend */
err = libusb_bulk_transfer(dap->bdata->dev_handle, dap->bdata->ep_out,
/* skip the first byte that is only used by the HID backend */
err = libusb_bulk_transfer(dap->bdata->dev_handle, dap->bdata->ep_out,
- dap->packet_buffer + REPORT_ID_SIZE, txlen - REPORT_ID_SIZE, &transferred, timeout_ms);
+ dap->packet_buffer, txlen, &transferred, timeout_ms);
if (err) {
if (err == LIBUSB_ERROR_TIMEOUT) {
return ERROR_TIMEOUT_REACHED;
if (err) {
if (err == LIBUSB_ERROR_TIMEOUT) {
return ERROR_TIMEOUT_REACHED;
static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
{
static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
{
- unsigned int packet_buffer_size = pkt_sz + REPORT_ID_SIZE;
- uint8_t *buf = malloc(packet_buffer_size);
+ uint8_t *buf = malloc(pkt_sz);
if (buf == NULL) {
LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
return ERROR_FAIL;
if (buf == NULL) {
LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
return ERROR_FAIL;
dap->packet_buffer = buf;
dap->packet_size = pkt_sz;
dap->packet_buffer = buf;
dap->packet_size = pkt_sz;
- dap->packet_buffer_size = packet_buffer_size;
+ dap->packet_buffer_size = pkt_sz;
+
+ dap->command = dap->packet_buffer;
+ dap->response = dap->packet_buffer;
+ dap->command = dap->packet_buffer + REPORT_ID_SIZE;
+ dap->response = dap->packet_buffer;
+ dap->packet_buffer[0] = 0; /* HID report number */
+
/* Pad the rest of the TX buffer with 0's */
/* Pad the rest of the TX buffer with 0's */
- memset(dap->packet_buffer + txlen, 0, dap->packet_buffer_size - txlen);
+ memset(dap->command + txlen, 0, dap->packet_size - txlen);
/* write data to device */
int retval = hid_write(dap->bdata->dev_handle, dap->packet_buffer, dap->packet_buffer_size);
/* write data to device */
int retval = hid_write(dap->bdata->dev_handle, dap->packet_buffer, dap->packet_buffer_size);
dap->packet_size = pkt_sz;
dap->packet_buffer_size = packet_buffer_size;
dap->packet_size = pkt_sz;
dap->packet_buffer_size = packet_buffer_size;
+ dap->command = dap->packet_buffer + REPORT_ID_SIZE;
+ dap->response = dap->packet_buffer;
+
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)