43 #if BUILD_CMSIS_DAP_USB == 0
49 #if BUILD_CMSIS_DAP_HID == 0
81 #define CMD_DAP_INFO 0x00
82 #define CMD_DAP_LED 0x01
83 #define CMD_DAP_CONNECT 0x02
84 #define CMD_DAP_DISCONNECT 0x03
85 #define CMD_DAP_WRITE_ABORT 0x08
86 #define CMD_DAP_DELAY 0x09
87 #define CMD_DAP_RESET_TARGET 0x0A
90 #define INFO_ID_VENDOR 0x01
91 #define INFO_ID_PRODUCT 0x02
92 #define INFO_ID_SERNUM 0x03
93 #define INFO_ID_FW_VER 0x04
94 #define INFO_ID_TD_VEND 0x05
95 #define INFO_ID_TD_NAME 0x06
96 #define INFO_ID_CAPS 0xf0
97 #define INFO_ID_PKT_CNT 0xfe
98 #define INFO_ID_PKT_SZ 0xff
99 #define INFO_ID_SWO_BUF_SZ 0xfd
101 #define INFO_CAPS_SWD BIT(0)
102 #define INFO_CAPS_JTAG BIT(1)
103 #define INFO_CAPS_SWO_UART BIT(2)
104 #define INFO_CAPS_SWO_MANCHESTER BIT(3)
105 #define INFO_CAPS_ATOMIC_CMDS BIT(4)
106 #define INFO_CAPS_TEST_DOMAIN_TIMER BIT(5)
107 #define INFO_CAPS_SWO_STREAMING_TRACE BIT(6)
108 #define INFO_CAPS_UART_PORT BIT(7)
109 #define INFO_CAPS_USB_COM_PORT BIT(8)
110 #define INFO_CAPS__NUM_CAPS 9
113 #define LED_ID_CONNECT 0x00
114 #define LED_ID_RUN 0x01
120 #define CONNECT_DEFAULT 0x00
121 #define CONNECT_SWD 0x01
122 #define CONNECT_JTAG 0x02
125 #define CMD_DAP_DELAY 0x09
126 #define CMD_DAP_SWJ_PINS 0x10
127 #define CMD_DAP_SWJ_CLOCK 0x11
128 #define CMD_DAP_SWJ_SEQ 0x12
140 #define SWJ_PIN_TCK (1<<0)
141 #define SWJ_PIN_TMS (1<<1)
142 #define SWJ_PIN_TDI (1<<2)
143 #define SWJ_PIN_TDO (1<<3)
144 #define SWJ_PIN_TRST (1<<5)
145 #define SWJ_PIN_SRST (1<<7)
148 #define CMD_DAP_SWD_CONFIGURE 0x13
149 #define CMD_DAP_SWD_SEQUENCE 0x1D
152 #define CMD_DAP_JTAG_SEQ 0x14
153 #define CMD_DAP_JTAG_CONFIGURE 0x15
154 #define CMD_DAP_JTAG_IDCODE 0x16
158 #define DAP_JTAG_SEQ_TCK 0x3F
160 #define DAP_JTAG_SEQ_TMS 0x40
162 #define DAP_JTAG_SEQ_TDO 0x80
166 #define CMD_DAP_TFER_CONFIGURE 0x04
167 #define CMD_DAP_TFER 0x05
168 #define CMD_DAP_TFER_BLOCK 0x06
169 #define CMD_DAP_TFER_ABORT 0x07
174 #define CMD_DAP_TFER_BLOCK_MIN_OPS 4
178 #define DAP_ERROR 0xFF
181 #define CMD_DAP_SWO_TRANSPORT 0x17
182 #define CMD_DAP_SWO_MODE 0x18
183 #define CMD_DAP_SWO_BAUDRATE 0x19
184 #define CMD_DAP_SWO_CONTROL 0x1A
185 #define CMD_DAP_SWO_STATUS 0x1B
186 #define CMD_DAP_SWO_DATA 0x1C
187 #define CMD_DAP_SWO_EX_STATUS 0x1E
190 #define DAP_SWO_TRANSPORT_NONE 0
191 #define DAP_SWO_TRANSPORT_DATA 1
192 #define DAP_SWO_TRANSPORT_WINUSB 2
195 #define DAP_SWO_MODE_OFF 0
196 #define DAP_SWO_MODE_UART 1
197 #define DAP_SWO_MODE_MANCHESTER 2
200 #define DAP_SWO_CONTROL_STOP 0
201 #define DAP_SWO_CONTROL_START 1
204 #define DAP_SWO_STATUS_CAPTURE_INACTIVE 0
205 #define DAP_SWO_STATUS_CAPTURE_ACTIVE 1
206 #define DAP_SWO_STATUS_CAPTURE_MASK BIT(0)
207 #define DAP_SWO_STATUS_STREAM_ERROR_MASK BIT(6)
208 #define DAP_SWO_STATUS_BUFFER_OVERRUN_MASK BIT(7)
216 "SWO-UART supported",
217 "SWO-MANCHESTER supported",
218 "Atomic commands supported",
219 "Test domain timer supported",
220 "SWO streaming trace supported",
221 "UART communication port supported",
222 "UART via USB COM port supported",
242 #define MAX_PENDING_SCAN_RESULTS 256
247 #define QUEUED_SEQ_BUF_LEN (cmsis_dap_handle->packet_usable_size - 3)
279 LOG_ERROR(
"Requested CMSIS-DAP backend is disabled by configure");
295 LOG_ERROR(
"unable to find a matching CMSIS-DAP device");
332 for (i = 0; i < 64; i++) {
345 LOG_ERROR(
"internal: queue not empty before xfer");
357 uint8_t current_cmd = dap->
command[0];
369 LOG_ERROR(
"CMSIS-DAP command 0x%" PRIx8
" not implemented", current_cmd);
373 if (resp[0] != current_cmd) {
374 LOG_ERROR(
"CMSIS-DAP command mismatch. Sent 0x%" PRIx8
375 " received 0x%" PRIx8, current_cmd, resp[0]);
396 LOG_ERROR(
"CMSIS-DAP command CMD_DAP_SWJ_PINS failed.");
418 LOG_ERROR(
"CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.");
430 #ifdef CMSIS_DAP_JTAG_DEBUG
431 LOG_DEBUG(
"cmsis-dap TMS sequence: len=%d", s_len);
432 for (
unsigned int i = 0; i <
DIV_ROUND_UP(s_len, 8); ++i)
458 LOG_ERROR(
"CMSIS-DAP command CMD_INFO failed.");
477 LOG_ERROR(
"CMSIS-DAP command CMD_LED failed.");
493 LOG_ERROR(
"CMSIS-DAP command CMD_CONNECT failed.");
513 LOG_ERROR(
"CMSIS-DAP command CMD_DISCONNECT failed.");
531 LOG_ERROR(
"CMSIS-DAP command CMD_TFER_Configure failed.");
547 LOG_ERROR(
"CMSIS-DAP command CMD_SWD_Configure failed.");
555 static int cmsis_dap_cmd_dap_delay(uint16_t
delay_us)
564 LOG_ERROR(
"CMSIS-DAP command CMD_Delay failed.");
575 const uint32_t seq_rd = 0x80, seq_wr = 0x00;
584 LOG_DEBUG_IO(
"DP write reg TARGETSEL %" PRIx32, instance_id);
598 command[idx++] = seq_wr | (32 + 1);
605 LOG_ERROR(
"CMSIS-DAP command SWD_Sequence failed.");
646 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Mode(%d) failed.",
mode);
663 uint32_t in_baudrate,
664 uint32_t *dev_baudrate)
673 if (retval !=
ERROR_OK || rvbr == 0) {
674 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Baudrate(%u) -> %u failed.", in_baudrate, rvbr);
681 *dev_baudrate = rvbr;
701 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Control(%d) failed.", control);
726 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Status failed.");
746 size_t max_trace_count,
758 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Data failed.");
765 if (*trace_count > 0)
799 LOG_DEBUG_IO(
"Executing %d queued transactions from FIFO index %u%s",
809 LOG_ERROR(
"internal: write an empty queue?!");
831 uint8_t
cmd = transfer->
cmd;
854 LOG_DEBUG(
"refusing to enable sticky overrun detection");
858 if (!block_cmd || i == 0)
891 LOG_ERROR(
"internal: no pending write when reading?!");
914 LOG_DEBUG(
"error reading adapter response");
926 if (resp[0] != block->
command) {
927 LOG_ERROR(
"CMSIS-DAP command mismatch. Expected 0x%x received 0x%" PRIx8,
943 if (resp[idx] & 0x08) {
948 uint8_t ack = resp[idx++] & 0x07;
958 LOG_ERROR(
"CMSIS-DAP transfer count mismatch: expected %d, got %d",
965 LOG_DEBUG_IO(
"Received results of %d queued transactions FIFO index %u, %s mode",
967 blocking ?
"blocking" :
"nonblocking");
972 static uint32_t last_read;
987 *(uint32_t *)(transfer->
buffer) = tmp;
1020 unsigned int read_count,
bool block_tfer)
1025 size += write_count * 4;
1028 size += write_count * (1 + 4);
1035 unsigned int read_count,
bool block_tfer)
1043 size += read_count * 4;
1077 unsigned int max_transfer_count = block_cmd ? 65535 : 255;
1082 || write_count + read_count > max_transfer_count) {
1170 if (
data[0] == 1 ||
data[0] == 2) {
1200 LOG_INFO(
"CMSIS-DAP: SWO Trace Buffer Size = %u bytes", *swo_buf_sz);
1212 LOG_INFO(
"SWCLK/TCK = %d SWDIO/TMS = %d TDI = %d TDO = %d nTRST = %d nRESET = %d",
1287 LOG_ERROR(
"Sequence %d not supported", seq);
1303 LOG_ERROR(
"CMSIS-DAP: SWD not supported");
1313 LOG_INFO(
"CMSIS-DAP: Interface Initialised (SWD)");
1346 LOG_ERROR(
"CMSIS-DAP: JTAG not supported");
1354 LOG_INFO(
"CMSIS-DAP: Interface Initialised (JTAG)");
1367 uint16_t pkt_sz =
data[1] + (
data[2] << 8);
1374 LOG_DEBUG(
"CMSIS-DAP: Packet Size = %" PRIu16, pkt_sz);
1394 unsigned int pkt_cnt =
data[1];
1398 LOG_DEBUG(
"CMSIS-DAP: Packet Count = %u", pkt_cnt);
1406 LOG_ERROR(
"Unable to allocate memory for CMSIS-DAP queue");
1450 LOG_INFO(
"Connecting under reset");
1453 LOG_INFO(
"CMSIS-DAP: Interface ready");
1494 LOG_ERROR(
"CMSIS-DAP: Interface reset failed");
1501 int retval = cmsis_dap_cmd_dap_delay(
cmd->cmd.sleep->us);
1510 LOG_INFO(
"cmsis-dap JTAG TLR_RESET");
1530 #ifdef SPRINT_BINARY
1531 static void sprint_binary(
char *s,
const uint8_t *buf,
unsigned int offset,
unsigned int len)
1543 uint8_t c = buf[i / 8],
mask = 1 << (i % 8);
1544 if ((i !=
offset) && !(i % 8))
1546 *s++ = (c &
mask) ?
'1' :
'0';
1552 #ifdef CMSIS_DAP_JTAG_DEBUG
1553 static void debug_parse_cmsis_buf(
const uint8_t *
cmd,
int cmdlen)
1556 printf(
"cmsis-dap buffer (%d b): ", cmdlen);
1557 for (
int i = 0; i < cmdlen; ++i)
1558 printf(
" %02x",
cmd[i]);
1562 printf(
"cmsis-dap jtag sequence command %02x (n=%d)\n",
cmd[0],
cmd[1]);
1571 for (
int seq = 0; seq <
cmd[1]; ++seq) {
1576 printf(
" sequence %d starting %d: info %02x (len=%d tms=%d read_tdo=%d): ",
1579 printf(
" %02x",
cmd[pos+i]);
1583 if (pos != cmdlen) {
1584 printf(
"BUFFER LENGTH MISMATCH looks like %d but %d specified", pos, cmdlen);
1602 LOG_DEBUG_IO(
"Flushing %d queued sequences (%d bytes) with %d pending scan results to capture",
1611 #ifdef CMSIS_DAP_JTAG_DEBUG
1620 LOG_ERROR(
"CMSIS-DAP command CMD_DAP_JTAG_SEQ failed.");
1624 #ifdef CMSIS_DAP_JTAG_DEBUG
1627 printf(
"%02X ", resp[c]);
1634 LOG_DEBUG_IO(
"Copying pending_scan_result %d/%d: %d bits from byte %d -> buffer + %d bits",
1636 #ifdef CMSIS_DAP_JTAG_DEBUG
1638 printf(
"%02X ", resp[2+
scan->first+b]);
1657 unsigned int s_offset,
bool tms,
1658 uint8_t *
tdo_buffer,
unsigned int tdo_buffer_offset)
1660 LOG_DEBUG_IO(
"[at %d] %u bits, tms %s, seq offset %u, tdo buf %p, tdo offset %u",
1662 s_len, tms ?
"HIGH" :
"LOW", s_offset,
tdo_buffer, tdo_buffer_offset);
1670 unsigned int len = s_len -
offset;
1673 LOG_DEBUG_IO(
"Splitting long jtag sequence: %u-bit chunk starting at offset %u", len,
offset);
1698 (s_len == 64 ? 0 : s_len);
1711 scan->length = s_len;
1713 scan->buffer_offset = tdo_buffer_offset;
1726 for (
int i = 0; i < s_len; ++i) {
1727 bool bit = (
sequence[i / 8] & (1 << (i % 8))) != 0;
1738 LOG_DEBUG_IO(
"state move from %s to %s: %d clocks, %02X on tms",
1740 tms_scan_bits, tms_scan);
1750 LOG_DEBUG_IO(
"%s type:%d",
cmd->cmd.scan->ir_scan ?
"IRSCAN" :
"DRSCAN",
1754 while (
cmd->cmd.scan->num_fields > 0
1755 &&
cmd->cmd.scan->fields[
cmd->cmd.scan->num_fields - 1].num_bits == 0) {
1756 cmd->cmd.scan->num_fields--;
1757 LOG_DEBUG(
"discarding trailing empty field");
1760 if (!
cmd->cmd.scan->num_fields) {
1765 if (
cmd->cmd.scan->ir_scan) {
1780 unsigned int scan_size = 0;
1782 for (
unsigned int i = 0; i <
cmd->cmd.scan->num_fields; i++, field++) {
1788 cmd->cmd.scan->num_fields,
1792 LOG_DEBUG_IO(
"Last field and have to move out of SHIFT state");
1804 uint8_t last_bit = 0;
1826 LOG_DEBUG_IO(
"Internal field, staying in SHIFT state afterwards");
1845 (
cmd->cmd.scan->ir_scan) ?
"IR" :
"DR", scan_size,
1851 uint8_t tms0 = 0x00;
1852 uint8_t tms1 = 0xff;
1854 for (
int i = 0; i < num_states; i++) {
1860 LOG_ERROR(
"BUG: %s -> %s isn't a valid TAP transition.",
1874 cmd->cmd.pathmove->num_states,
1875 cmd->cmd.pathmove->path[
cmd->cmd.pathmove->num_states - 1]);
1885 for (
unsigned int i = 0; i < num_cycles; i++)
1909 LOG_DEBUG_IO(
"runtest %u cycles, end in %i",
cmd->cmd.runtest->num_cycles,
1910 cmd->cmd.runtest->end_state);
1932 switch (
cmd->type) {
1957 LOG_ERROR(
"BUG: unknown JTAG command type 0x%X encountered",
cmd->type);
1979 LOG_ERROR(
"RTCK not supported. Set nonzero \"adapter speed\".");
1999 uint32_t trace_freq, uint16_t *prescaler)
2001 unsigned int presc = (traceclkin_freq + trace_freq / 2) / trace_freq;
2006 unsigned int max_deviation = (traceclkin_freq * 3) / 100;
2007 if (presc * trace_freq < traceclkin_freq - max_deviation ||
2008 presc * trace_freq > traceclkin_freq + max_deviation)
2023 unsigned int *swo_freq,
2024 unsigned int traceclkin_hz,
2025 uint16_t *swo_prescaler)
2033 LOG_ERROR(
"Failed to disable the SWO-trace.");
2044 LOG_ERROR(
"SWO-trace is not supported by the device.");
2056 LOG_ERROR(
"Selected pin protocol is not supported.");
2060 if (*swo_freq == 0) {
2061 LOG_INFO(
"SWO-trace frequency autodetection not implemented.");
2089 LOG_ERROR(
"SWO frequency is not suitable. Please choose a "
2090 "different frequency or use auto-detection.");
2094 LOG_INFO(
"SWO frequency: %u Hz.", *swo_freq);
2095 LOG_INFO(
"SWO prescaler: %u.", *swo_prescaler);
2126 size_t read_so_far = 0;
2130 uint32_t remaining = *
size - read_so_far;
2131 if (remaining < packet_size)
2132 packet_size = remaining;
2144 }
while (read_so_far < *
size);
2161 for (
unsigned int i = 0; i <
CMD_ARGC; i++)
2172 LOG_INFO(
"Returned data %02" PRIx8
" %02" PRIx8
" %02" PRIx8
" %02" PRIx8,
2173 resp[1], resp[2], resp[3], resp[4]);
2181 LOG_WARNING(
"ignoring extra IDs in cmsis-dap vid_pid "
2186 LOG_WARNING(
"incomplete cmsis-dap vid_pid configuration directive");
2194 for (i = 0; i <
CMD_ARGC; i += 2) {
2213 if (strcmp(
CMD_ARGV[0],
"auto") == 0) {
2223 command_print(
CMD,
"Requested cmsis-dap backend %s is disabled by configure",
2252 .handler = &cmsis_dap_handle_info_command,
2255 .help =
"show cmsis-dap info",
2259 .handler = &cmsis_dap_handle_cmd_command,
2262 .help =
"issue cmsis-dap command",
2266 .handler = &cmsis_dap_handle_vid_pid_command,
2268 .help =
"the vendor ID and product ID of the CMSIS-DAP device",
2269 .usage =
"(vid pid)*",
2273 .handler = &cmsis_dap_handle_backend_command,
2275 .help =
"set the communication backend to use (USB bulk or HID).",
2276 .usage =
"(auto | usb_bulk | hid)",
2280 .handler = &cmsis_dap_handle_quirk_command,
2282 .help =
"allow expensive workarounds of known adapter quirks.",
2283 .usage =
"[enable | disable]",
2285 #if BUILD_CMSIS_DAP_USB
2290 .help =
"USB bulk backend-specific commands",
2300 .
name =
"cmsis-dap",
2302 .help =
"perform CMSIS-DAP management",
2325 .
name =
"cmsis-dap",
const char * adapter_get_required_serial(void)
Retrieves the serial number set with command 'adapter serial'.
unsigned int adapter_get_speed_khz(void)
Retrieves the clock speed of the adapter in kHz.
static uint8_t tdo_buffer[ARMJTAGEW_TAP_BUFFER_SIZE]
@ TPIU_PIN_PROTOCOL_ASYNC_MANCHESTER
asynchronous output with Manchester coding
@ TPIU_PIN_PROTOCOL_ASYNC_UART
asynchronous output with NRZ coding
static void bit_copy(uint8_t *dst, unsigned int dst_offset, const uint8_t *src, unsigned int src_offset, unsigned int bit_count)
static int cmsis_dap_init(void)
static int cmsis_dap_cmd_dap_swo_status(uint8_t *trace_status, size_t *trace_count)
Reads the SWO trace status.
static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, enum cmsis_dap_blocking blocking)
static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap)
static int cmsis_dap_cmd_dap_swo_data(size_t max_trace_count, uint8_t *trace_status, size_t *trace_count, uint8_t *data)
Reads the captured SWO trace data from Trace Buffer.
#define DAP_SWO_MODE_MANCHESTER
#define MAX_PENDING_SCAN_RESULTS
static int cmsis_dap_get_status(void)
static int cmsis_dap_reset(int trst, int srst)
static int cmsis_dap_get_caps_info(void)
static void cmsis_dap_stableclocks(unsigned int num_cycles)
#define INFO_CAPS__NUM_CAPS
static int cmsis_dap_swd_switch_seq(enum swd_special_seq seq)
static uint16_t cmsis_dap_vid[MAX_USB_IDS+1]
static void cmsis_dap_execute_runtest(struct jtag_command *cmd)
static struct jtag_interface cmsis_dap_interface
static int cmsis_dap_swd_open(void)
#define DAP_SWO_STATUS_CAPTURE_MASK
static int cmsis_dap_cmd_dap_swo_control(uint8_t control)
Controls the SWO trace data capture.
static struct cmsis_dap * cmsis_dap_handle
static int cmsis_dap_cmd_dap_info(uint8_t info, uint8_t **data)
static struct pending_scan_result pending_scan_results[MAX_PENDING_SCAN_RESULTS]
static int cmsis_dap_cmd_dap_swj_pins(uint8_t pins, uint8_t mask, uint32_t delay, uint8_t *input)
static unsigned int cmsis_dap_tfer_cmd_size(unsigned int write_count, unsigned int read_count, bool block_tfer)
static int cmsis_dap_cmd_dap_swo_baudrate(uint32_t in_baudrate, uint32_t *dev_baudrate)
Sets the baudrate for capturing SWO trace data.
const struct cmsis_dap_backend cmsis_dap_usb_backend
static unsigned int tfer_max_response_size
static void cmsis_dap_end_state(enum tap_state state)
static int cmsis_dap_speed_div(int speed, int *khz)
#define CMD_DAP_SWJ_CLOCK
static int cmsis_dap_cmd_dap_swd_configure(uint8_t cfg)
static bool calculate_swo_prescaler(unsigned int traceclkin_freq, uint32_t trace_freq, uint16_t *prescaler)
#define INFO_ID_SWO_BUF_SZ
static int queued_seq_buf_end
#define DAP_SWO_STATUS_CAPTURE_ACTIVE
static int queued_seq_count
static void cmsis_dap_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk)
struct adapter_driver cmsis_dap_adapter_driver
static int cmsis_dap_cmd_dap_swj_clock(uint32_t swj_clock)
static void cmsis_dap_swd_discard_all_pending(struct cmsis_dap *dap)
static void cmsis_dap_flush(void)
static int cmsis_dap_execute_queue(struct jtag_command *cmd_queue)
#define CMD_DAP_TFER_CONFIGURE
#define INFO_CAPS_SWO_UART
#define CMD_DAP_SWO_STATUS
#define CMD_DAP_SWD_CONFIGURE
static int cmsis_dap_quit(void)
static const struct swd_driver cmsis_dap_swd_driver
#define DAP_SWO_TRANSPORT_DATA
#define CMD_DAP_DISCONNECT
static void cmsis_dap_swd_cancel_transfers(struct cmsis_dap *dap)
static int cmsis_dap_cmd_dap_disconnect(void)
static const char *const cmsis_dap_transport[]
static int cmsis_dap_cmd_dap_tfer_configure(uint8_t idle, uint16_t retry_count, uint16_t match_retry)
static void cmsis_dap_execute_stableclocks(struct jtag_command *cmd)
static uint8_t queued_seq_buf[1024]
static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen)
static int cmsis_dap_get_serial_info(void)
static void cmsis_dap_flush_read(struct cmsis_dap *dap)
static int pending_scan_result_count
#define CMD_DAP_TFER_BLOCK
static void cmsis_dap_execute_scan(struct jtag_command *cmd)
static void cmsis_dap_execute_command(struct jtag_command *cmd)
#define CMD_DAP_SWO_CONTROL
static int cmsis_dap_swd_run_queue(void)
static int cmsis_dap_cmd_dap_connect(uint8_t mode)
static unsigned int tfer_max_command_size
#define CMD_DAP_SWO_TRANSPORT
static void cmsis_dap_runtest(unsigned int num_cycles)
#define CMD_DAP_TFER_BLOCK_MIN_OPS
static void cmsis_dap_execute_tms(struct jtag_command *cmd)
static unsigned int pending_queue_len
static const struct cmsis_dap_backend *const cmsis_dap_backends[]
#define INFO_CAPS_SWO_MANCHESTER
static int queued_seq_tdo_ptr
static const char *const info_caps_str[INFO_CAPS__NUM_CAPS]
static const struct command_registration cmsis_dap_subcommand_handlers[]
static void cmsis_dap_state_move(void)
static int cmsis_dap_cmd_dap_swo_mode(uint8_t mode)
Sets the SWO trace capture mode.
static void cmsis_dap_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data)
static uint8_t output_pins
#define CMD_DAP_SWD_SEQUENCE
static int cmsis_dap_cmd_dap_swj_sequence(uint8_t s_len, const uint8_t *sequence)
static int cmsis_dap_khz(int khz, int *jtag_speed)
static int cmsis_dap_metacmd_targetsel(uint32_t instance_id)
const struct cmsis_dap_backend cmsis_dap_hid_backend
static int cmsis_dap_backend
static void cmsis_dap_close(struct cmsis_dap *dap)
static int cmsis_dap_poll_trace(uint8_t *buf, size_t *size)
#define CMD_DAP_SWO_BAUDRATE
static int cmsis_dap_swd_init(void)
static void cmsis_dap_execute_sleep(struct jtag_command *cmd)
static int cmsis_dap_open(void)
COMMAND_HANDLER(cmsis_dap_handle_info_command)
static int cmsis_dap_speed(int speed)
#define QUEUED_SEQ_BUF_LEN
static int cmsis_dap_cmd_dap_led(uint8_t led, uint8_t state)
static void cmsis_dap_pathmove(int num_states, enum tap_state *path)
static unsigned int cmsis_dap_tfer_resp_size(unsigned int write_count, unsigned int read_count, bool block_tfer)
static int cmsis_dap_cmd_dap_swo_transport(uint8_t transport)
Sets the SWO transport mode.
#define DAP_SWO_CONTROL_STOP
static void cmsis_dap_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk)
static void cmsis_dap_execute_pathmove(struct jtag_command *cmd)
static const struct command_registration cmsis_dap_command_handlers[]
#define DAP_SWO_CONTROL_START
static int cmsis_dap_execute_tlr_reset(struct jtag_command *cmd)
static int cmsis_dap_get_swo_buf_sz(uint32_t *swo_buf_sz)
static int cmsis_dap_config_trace(bool trace_enabled, enum tpiu_pin_protocol pin_protocol, uint32_t port_size, unsigned int *swo_freq, unsigned int traceclkin_hz, uint16_t *swo_prescaler)
#define DAP_SWO_MODE_UART
static void cmsis_dap_add_jtag_sequence(unsigned int s_len, const uint8_t *sequence, unsigned int s_offset, bool tms, uint8_t *tdo_buffer, unsigned int tdo_buffer_offset)
static void cmsis_dap_add_tms_sequence(const uint8_t *sequence, int s_len)
static uint16_t cmsis_dap_pid[MAX_USB_IDS+1]
static int cmsis_dap_get_version_info(void)
#define MAX_PENDING_REQUESTS
const struct command_registration cmsis_dap_usb_subcommand_handlers[]
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_ENABLE(in, out)
parses an enable/disable command argument
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_ARGUMENT_INVALID
enum scan_type jtag_scan_type(const struct scan_command *cmd)
#define TPIU_ACPR_MAX_SWOSCALER
void delay_us(uint16_t delay)
uint32_t size
Size of dw_spi_transaction::buffer.
enum tap_state tap_get_end_state(void)
For more information,.
enum tap_state tap_state_transition(enum tap_state cur_state, bool tms)
Function tap_state_transition takes a current TAP state and returns the next state according to the t...
const char * tap_state_name(enum tap_state state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
int tap_get_tms_path_len(enum tap_state from, enum tap_state to)
Function int tap_get_tms_path_len returns the total number of bits that represents a TMS path transit...
void tap_set_end_state(enum tap_state new_end_state)
This function sets the state of an "end state follower" which tracks the state that any cable driver ...
enum tap_state tap_get_state(void)
This function gets the state of the "state follower" which tracks the state of the TAPs connected to ...
bool tap_is_state_stable(enum tap_state astate)
Function tap_is_state_stable returns true if the astate is stable.
int tap_get_tms_path(enum tap_state from, enum tap_state to)
This function provides a "bit sequence" indicating what has to be done with TMS during a sequence of ...
#define DEBUG_CAP_TMS_SEQ
#define tap_set_state(new_state)
This function sets the state of a "state follower" which tracks the state of the TAPs connected to th...
static uint8_t caps[JAYLINK_DEV_EXT_CAPS_SIZE]
static bool trace_enabled
static enum reset_types jtag_reset_config
void jtag_sleep(uint32_t us)
enum reset_types jtag_get_reset_config(void)
#define ERROR_JTAG_DEVICE_ERROR
tap_state
Defines JTAG Test Access Port states.
#define ERROR_JTAG_NOT_IMPLEMENTED
static struct scan_blk scan
#define LIBUSB_TIMEOUT_MS
#define ERROR_NOT_IMPLEMENTED
#define LOG_DEBUG_IO(expr ...)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define ERROR_TIMEOUT_REACHED
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
static uint32_t bit(uint32_t value, unsigned int b)
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
int(* read)(struct cmsis_dap *dap, int transfer_timeout_ms, enum cmsis_dap_blocking blocking)
void(* cancel_all)(struct cmsis_dap *dap)
int(* packet_buffer_alloc)(struct cmsis_dap *dap, unsigned int pkt_sz)
void(* close)(struct cmsis_dap *dap)
void(* packet_buffer_free)(struct cmsis_dap *dap)
int(* open)(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], const char *serial)
int(* write)(struct cmsis_dap *dap, int len, int timeout_ms)
unsigned int packet_usable_size
struct pending_request_block pending_fifo[MAX_PENDING_REQUESTS]
unsigned int pending_fifo_put_idx
unsigned int pending_fifo_block_count
unsigned int packet_count
const struct cmsis_dap_backend * backend
unsigned int pending_fifo_get_idx
Represents a driver for a debugging interface.
unsigned int supported
Bit vector listing capabilities exposed by this driver.
struct pending_transfer_result * transfers
unsigned int transfer_count
unsigned int buffer_offset
Offset in the destination buffer.
unsigned int first
Offset in bytes in the CMD_DAP_JTAG_SEQ response buffer.
unsigned int length
Number of bits to read.
uint8_t * buffer
Location to store the result.
This structure defines a single scan field in the scan.
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
const uint8_t * out_value
A pointer to value to be scanned into the device.
unsigned int num_bits
The number of bits this field specifies.
int(* init)(void)
Initialize the debug link so it can perform SWD operations.
Wrapper for transport lifecycle operations.
static const unsigned int swd_seq_dormant_to_swd_len
static const uint8_t swd_seq_dormant_to_jtag[]
Dormant-to-JTAG sequence.
static const uint8_t swd_seq_dormant_to_swd[]
Dormant-to-SWD sequence.
static const uint8_t swd_seq_jtag_to_dormant[]
JTAG-to-dormant sequence.
static int swd_ack_to_error_code(uint8_t ack)
Convert SWD ACK value returned from DP to OpenOCD error code.
static uint8_t swd_cmd(bool is_read, bool is_ap, uint8_t regnum)
Construct a "cmd" byte, in lSB bit order, which swd_driver.read_reg() and swd_driver....
static const unsigned int swd_seq_jtag_to_swd_len
static const unsigned int swd_seq_line_reset_len
static const unsigned int swd_seq_dormant_to_jtag_len
static const unsigned int swd_seq_swd_to_dormant_len
static const uint8_t swd_seq_line_reset[]
SWD Line reset.
static const uint8_t swd_seq_jtag_to_swd[]
JTAG-to-SWD sequence.
static const uint8_t swd_seq_swd_to_jtag[]
SWD-to-JTAG sequence.
static const unsigned int swd_seq_swd_to_jtag_len
static const unsigned int swd_seq_jtag_to_dormant_len
static const uint8_t swd_seq_swd_to_dormant[]
SWD-to-dormant sequence.
static uint16_t le_to_h_u16(const uint8_t *buf)
static void h_u32_to_le(uint8_t *buf, uint32_t val)
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static void h_u16_to_le(uint8_t *buf, uint16_t val)
static uint32_t le_to_h_u32(const uint8_t *buf)
static int parity_u32(uint32_t x)
Calculate the (even) parity of a 32-bit datum.
static struct ublast_lowlevel_priv info