43 #if BUILD_CMSIS_DAP_USB == 1
47 #if BUILD_CMSIS_DAP_HID == 1
73 #define CMD_DAP_INFO 0x00
74 #define CMD_DAP_LED 0x01
75 #define CMD_DAP_CONNECT 0x02
76 #define CMD_DAP_DISCONNECT 0x03
77 #define CMD_DAP_WRITE_ABORT 0x08
78 #define CMD_DAP_DELAY 0x09
79 #define CMD_DAP_RESET_TARGET 0x0A
82 #define INFO_ID_VENDOR 0x01
83 #define INFO_ID_PRODUCT 0x02
84 #define INFO_ID_SERNUM 0x03
85 #define INFO_ID_FW_VER 0x04
86 #define INFO_ID_TD_VEND 0x05
87 #define INFO_ID_TD_NAME 0x06
88 #define INFO_ID_CAPS 0xf0
89 #define INFO_ID_PKT_CNT 0xfe
90 #define INFO_ID_PKT_SZ 0xff
91 #define INFO_ID_SWO_BUF_SZ 0xfd
93 #define INFO_CAPS_SWD BIT(0)
94 #define INFO_CAPS_JTAG BIT(1)
95 #define INFO_CAPS_SWO_UART BIT(2)
96 #define INFO_CAPS_SWO_MANCHESTER BIT(3)
97 #define INFO_CAPS_ATOMIC_CMDS BIT(4)
98 #define INFO_CAPS_TEST_DOMAIN_TIMER BIT(5)
99 #define INFO_CAPS_SWO_STREAMING_TRACE BIT(6)
100 #define INFO_CAPS_UART_PORT BIT(7)
101 #define INFO_CAPS_USB_COM_PORT BIT(8)
102 #define INFO_CAPS__NUM_CAPS 9
105 #define LED_ID_CONNECT 0x00
106 #define LED_ID_RUN 0x01
112 #define CONNECT_DEFAULT 0x00
113 #define CONNECT_SWD 0x01
114 #define CONNECT_JTAG 0x02
117 #define CMD_DAP_DELAY 0x09
118 #define CMD_DAP_SWJ_PINS 0x10
119 #define CMD_DAP_SWJ_CLOCK 0x11
120 #define CMD_DAP_SWJ_SEQ 0x12
132 #define SWJ_PIN_TCK (1<<0)
133 #define SWJ_PIN_TMS (1<<1)
134 #define SWJ_PIN_TDI (1<<2)
135 #define SWJ_PIN_TDO (1<<3)
136 #define SWJ_PIN_TRST (1<<5)
137 #define SWJ_PIN_SRST (1<<7)
140 #define CMD_DAP_SWD_CONFIGURE 0x13
141 #define CMD_DAP_SWD_SEQUENCE 0x1D
144 #define CMD_DAP_JTAG_SEQ 0x14
145 #define CMD_DAP_JTAG_CONFIGURE 0x15
146 #define CMD_DAP_JTAG_IDCODE 0x16
150 #define DAP_JTAG_SEQ_TCK 0x3F
152 #define DAP_JTAG_SEQ_TMS 0x40
154 #define DAP_JTAG_SEQ_TDO 0x80
158 #define CMD_DAP_TFER_CONFIGURE 0x04
159 #define CMD_DAP_TFER 0x05
160 #define CMD_DAP_TFER_BLOCK 0x06
161 #define CMD_DAP_TFER_ABORT 0x07
165 #define DAP_ERROR 0xFF
168 #define CMD_DAP_SWO_TRANSPORT 0x17
169 #define CMD_DAP_SWO_MODE 0x18
170 #define CMD_DAP_SWO_BAUDRATE 0x19
171 #define CMD_DAP_SWO_CONTROL 0x1A
172 #define CMD_DAP_SWO_STATUS 0x1B
173 #define CMD_DAP_SWO_DATA 0x1C
174 #define CMD_DAP_SWO_EX_STATUS 0x1E
177 #define DAP_SWO_TRANSPORT_NONE 0
178 #define DAP_SWO_TRANSPORT_DATA 1
179 #define DAP_SWO_TRANSPORT_WINUSB 2
182 #define DAP_SWO_MODE_OFF 0
183 #define DAP_SWO_MODE_UART 1
184 #define DAP_SWO_MODE_MANCHESTER 2
187 #define DAP_SWO_CONTROL_STOP 0
188 #define DAP_SWO_CONTROL_START 1
191 #define DAP_SWO_STATUS_CAPTURE_INACTIVE 0
192 #define DAP_SWO_STATUS_CAPTURE_ACTIVE 1
193 #define DAP_SWO_STATUS_CAPTURE_MASK BIT(0)
194 #define DAP_SWO_STATUS_STREAM_ERROR_MASK BIT(6)
195 #define DAP_SWO_STATUS_BUFFER_OVERRUN_MASK BIT(7)
203 "SWO-UART supported",
204 "SWO-MANCHESTER supported",
205 "Atomic commands supported",
206 "Test domain timer supported",
207 "SWO streaming trace supported",
208 "UART communication port supported",
209 "UART via USB COM port supported",
236 #define MAX_PENDING_REQUESTS 3
246 #define MAX_PENDING_SCAN_RESULTS 256
251 #define QUEUED_SEQ_BUF_LEN (cmsis_dap_handle->packet_size - 3)
293 LOG_ERROR(
"unable to find a matching CMSIS-DAP device");
328 for (i = 0; i < 64; i++) {
362 LOG_ERROR(
"CMSIS-DAP command 0x%" PRIx8
" not implemented", current_cmd);
366 if (resp[0] != current_cmd) {
367 LOG_ERROR(
"CMSIS-DAP command mismatch. Sent 0x%" PRIx8
368 " received 0x%" PRIx8, current_cmd, resp[0]);
388 LOG_ERROR(
"CMSIS-DAP command CMD_DAP_SWJ_PINS failed.");
410 LOG_ERROR(
"CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.");
422 #ifdef CMSIS_DAP_JTAG_DEBUG
423 LOG_DEBUG(
"cmsis-dap TMS sequence: len=%d", s_len);
450 LOG_ERROR(
"CMSIS-DAP command CMD_INFO failed.");
469 LOG_ERROR(
"CMSIS-DAP command CMD_LED failed.");
485 LOG_ERROR(
"CMSIS-DAP command CMD_CONNECT failed.");
505 LOG_ERROR(
"CMSIS-DAP command CMD_DISCONNECT failed.");
523 LOG_ERROR(
"CMSIS-DAP command CMD_TFER_Configure failed.");
539 LOG_ERROR(
"CMSIS-DAP command CMD_SWD_Configure failed.");
547 static int cmsis_dap_cmd_dap_delay(uint16_t
delay_us)
556 LOG_ERROR(
"CMSIS-DAP command CMD_Delay failed.");
567 const uint32_t SEQ_RD = 0x80, SEQ_WR = 0x00;
576 LOG_DEBUG_IO(
"DP write reg TARGETSEL %" PRIx32, instance_id);
590 command[idx++] = SEQ_WR | (32 + 1);
597 LOG_ERROR(
"CMSIS-DAP command SWD_Sequence failed.");
638 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Mode(%d) failed.",
mode);
655 uint32_t in_baudrate,
656 uint32_t *dev_baudrate)
665 if (retval !=
ERROR_OK || rvbr == 0) {
666 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Baudrate(%u) -> %u failed.", in_baudrate, rvbr);
673 *dev_baudrate = rvbr;
693 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Control(%d) failed.", control);
718 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Status failed.");
738 size_t max_trace_count,
750 LOG_ERROR(
"CMSIS-DAP: command CMD_SWO_Data failed.");
757 if (*trace_count > 0)
785 uint8_t
cmd = transfer->
cmd;
808 LOG_DEBUG(
"refusing to enable sticky overrun detection");
858 LOG_ERROR(
"CMSIS-DAP command mismatch. Expected 0x%x received 0x%" PRIx8,
865 uint8_t ack = resp[2] & 0x07;
866 if (resp[2] & 0x08) {
880 LOG_ERROR(
"CMSIS-DAP transfer count mismatch: expected %d, got %d",
883 LOG_DEBUG_IO(
"Received results of %d queued transactions FIFO index %d",
889 static uint32_t last_read;
904 *(uint32_t *)(transfer->
buffer) = tmp;
1018 if (
data[0] == 1 ||
data[0] == 2) {
1048 LOG_INFO(
"CMSIS-DAP: SWO Trace Buffer Size = %u bytes", *swo_buf_sz);
1060 LOG_INFO(
"SWCLK/TCK = %d SWDIO/TMS = %d TDI = %d TDO = %d nTRST = %d nRESET = %d",
1130 LOG_ERROR(
"Sequence %d not supported", seq);
1146 LOG_ERROR(
"CMSIS-DAP: SWD not supported");
1156 LOG_INFO(
"CMSIS-DAP: Interface Initialised (SWD)");
1189 LOG_ERROR(
"CMSIS-DAP: JTAG not supported");
1197 LOG_INFO(
"CMSIS-DAP: Interface Initialised (JTAG)");
1211 uint16_t pkt_sz =
data[1] + (
data[2] << 8);
1224 LOG_DEBUG(
"CMSIS-DAP: Packet Size = %" PRIu16, pkt_sz);
1234 int pkt_cnt =
data[1];
1238 LOG_DEBUG(
"CMSIS-DAP: Packet Count = %d", pkt_cnt);
1245 LOG_ERROR(
"Unable to allocate memory for CMSIS-DAP queue");
1289 LOG_INFO(
"Connecting under reset");
1292 LOG_INFO(
"CMSIS-DAP: Interface ready");
1333 LOG_ERROR(
"CMSIS-DAP: Interface reset failed");
1340 int retval = cmsis_dap_cmd_dap_delay(
cmd->cmd.sleep->us);
1349 LOG_INFO(
"cmsis-dap JTAG TLR_RESET");
1369 #ifdef SPRINT_BINARY
1370 static void sprint_binary(
char *s,
const uint8_t *buf,
int offset,
int len)
1382 uint8_t c = buf[i / 8],
mask = 1 << (i % 8);
1383 if ((i !=
offset) && !(i % 8))
1385 *s++ = (c &
mask) ?
'1' :
'0';
1391 #ifdef CMSIS_DAP_JTAG_DEBUG
1392 static void debug_parse_cmsis_buf(
const uint8_t *
cmd,
int cmdlen)
1395 printf(
"cmsis-dap buffer (%d b): ", cmdlen);
1396 for (
int i = 0; i < cmdlen; ++i)
1397 printf(
" %02x",
cmd[i]);
1401 printf(
"cmsis-dap jtag sequence command %02x (n=%d)\n",
cmd[0],
cmd[1]);
1410 for (
int seq = 0; seq <
cmd[1]; ++seq) {
1415 printf(
" sequence %d starting %d: info %02x (len=%d tms=%d read_tdo=%d): ",
1418 printf(
" %02x",
cmd[pos+i]);
1422 if (pos != cmdlen) {
1423 printf(
"BUFFER LENGTH MISMATCH looks like %d but %d specified", pos, cmdlen);
1441 LOG_DEBUG_IO(
"Flushing %d queued sequences (%d bytes) with %d pending scan results to capture",
1450 #ifdef CMSIS_DAP_JTAG_DEBUG
1459 LOG_ERROR(
"CMSIS-DAP command CMD_DAP_JTAG_SEQ failed.");
1463 #ifdef CMSIS_DAP_JTAG_DEBUG
1466 printf(
"%02X ", resp[c]);
1473 LOG_DEBUG_IO(
"Copying pending_scan_result %d/%d: %d bits from byte %d -> buffer + %d bits",
1475 #ifdef CMSIS_DAP_JTAG_DEBUG
1477 printf(
"%02X ", resp[2+
scan->first+b]);
1496 bool tms, uint8_t *
tdo_buffer,
int tdo_buffer_offset)
1498 LOG_DEBUG_IO(
"[at %d] %d bits, tms %s, seq offset %d, tdo buf %p, tdo offset %d",
1500 s_len, tms ?
"HIGH" :
"LOW", s_offset,
tdo_buffer, tdo_buffer_offset);
1508 int len = s_len -
offset;
1511 LOG_DEBUG_IO(
"Splitting long jtag sequence: %d-bit chunk starting at offset %d", len,
offset);
1536 (s_len == 64 ? 0 : s_len);
1549 scan->length = s_len;
1551 scan->buffer_offset = tdo_buffer_offset;
1564 for (
int i = 0; i < s_len; ++i) {
1565 bool bit = (
sequence[i / 8] & (1 << (i % 8))) != 0;
1576 LOG_DEBUG_IO(
"state move from %s to %s: %d clocks, %02X on tms",
1578 tms_scan_bits, tms_scan);
1588 LOG_DEBUG_IO(
"%s type:%d",
cmd->cmd.scan->ir_scan ?
"IRSCAN" :
"DRSCAN",
1592 while (
cmd->cmd.scan->num_fields > 0
1593 &&
cmd->cmd.scan->fields[
cmd->cmd.scan->num_fields - 1].num_bits == 0) {
1594 cmd->cmd.scan->num_fields--;
1595 LOG_DEBUG(
"discarding trailing empty field");
1598 if (
cmd->cmd.scan->num_fields == 0) {
1603 if (
cmd->cmd.scan->ir_scan) {
1618 unsigned scan_size = 0;
1620 for (
int i = 0; i <
cmd->cmd.scan->num_fields; i++, field++) {
1626 cmd->cmd.scan->num_fields,
1630 LOG_DEBUG_IO(
"Last field and have to move out of SHIFT state");
1642 uint8_t last_bit = 0;
1664 LOG_DEBUG_IO(
"Internal field, staying in SHIFT state afterwards");
1683 (
cmd->cmd.scan->ir_scan) ?
"IR" :
"DR", scan_size,
1689 uint8_t tms0 = 0x00;
1690 uint8_t tms1 = 0xff;
1692 for (
int i = 0; i < num_states; i++) {
1698 LOG_ERROR(
"BUG: %s -> %s isn't a valid TAP transition.",
1712 cmd->cmd.pathmove->num_states,
1713 cmd->cmd.pathmove->path[
cmd->cmd.pathmove->num_states - 1]);
1723 for (
int i = 0; i < num_cycles; i++)
1747 LOG_DEBUG_IO(
"runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles,
1748 cmd->cmd.runtest->end_state);
1770 switch (
cmd->type) {
1795 LOG_ERROR(
"BUG: unknown JTAG command type 0x%X encountered",
cmd->type);
1817 LOG_ERROR(
"RTCK not supported. Set nonzero \"adapter speed\".");
1837 uint32_t trace_freq, uint16_t *prescaler)
1839 unsigned int presc = (traceclkin_freq + trace_freq / 2) / trace_freq;
1844 unsigned int max_deviation = (traceclkin_freq * 3) / 100;
1845 if (presc * trace_freq < traceclkin_freq - max_deviation ||
1846 presc * trace_freq > traceclkin_freq + max_deviation)
1861 unsigned int *swo_freq,
1862 unsigned int traceclkin_hz,
1863 uint16_t *swo_prescaler)
1871 LOG_ERROR(
"Failed to disable the SWO-trace.");
1882 LOG_ERROR(
"SWO-trace is not supported by the device.");
1894 LOG_ERROR(
"Selected pin protocol is not supported.");
1898 if (*swo_freq == 0) {
1899 LOG_INFO(
"SWO-trace frequency autodetection not implemented.");
1927 LOG_ERROR(
"SWO frequency is not suitable. Please choose a "
1928 "different frequency or use auto-detection.");
1932 LOG_INFO(
"SWO frequency: %u Hz.", *swo_freq);
1933 LOG_INFO(
"SWO prescaler: %u.", *swo_prescaler);
1964 size_t read_so_far = 0;
1968 uint32_t remaining = *
size - read_so_far;
1969 if (remaining < packet_size)
1970 packet_size = remaining;
1982 }
while (read_so_far < *
size);
1999 for (
unsigned i = 0; i <
CMD_ARGC; i++)
2010 LOG_INFO(
"Returned data %02" PRIx8
" %02" PRIx8
" %02" PRIx8
" %02" PRIx8,
2011 resp[1], resp[2], resp[3], resp[4]);
2019 LOG_WARNING(
"ignoring extra IDs in cmsis_dap_vid_pid "
2024 LOG_WARNING(
"incomplete cmsis_dap_vid_pid configuration directive");
2032 for (i = 0; i <
CMD_ARGC; i += 2) {
2049 if (strcmp(
CMD_ARGV[0],
"auto") == 0) {
2059 LOG_ERROR(
"invalid backend argument to cmsis_dap_backend <backend>");
2062 LOG_ERROR(
"expected exactly one argument to cmsis_dap_backend <backend>");
2071 .handler = &cmsis_dap_handle_info_command,
2074 .help =
"show cmsis-dap info",
2078 .handler = &cmsis_dap_handle_cmd_command,
2081 .help =
"issue cmsis-dap command",
2089 .
name =
"cmsis-dap",
2091 .help =
"perform CMSIS-DAP management",
2096 .
name =
"cmsis_dap_vid_pid",
2097 .handler = &cmsis_dap_handle_vid_pid_command,
2099 .help =
"the vendor ID and product ID of the CMSIS-DAP device",
2100 .usage =
"(vid pid)*",
2103 .name =
"cmsis_dap_backend",
2104 .handler = &cmsis_dap_handle_backend_command,
2106 .help =
"set the communication backend to use (USB bulk or HID).",
2107 .usage =
"(auto | usb_bulk | hid)",
2109 #if BUILD_CMSIS_DAP_USB
2111 .name =
"cmsis_dap_usb",
2114 .help =
"USB bulk backend-specific commands",
2137 .
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 dst_offset, const uint8_t *src, unsigned src_offset, unsigned 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_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)
#define MAX_PENDING_REQUESTS
#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 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)
static int cmsis_dap_cmd_dap_swj_pins(uint8_t pins, uint8_t mask, uint32_t delay, uint8_t *input)
static int cmsis_dap_cmd_dap_swo_baudrate(uint32_t in_baudrate, uint32_t *dev_baudrate)
Sets the baudrate for capturing SWO trace data.
static int cmsis_dap_speed_div(int speed, int *khz)
#define CMD_DAP_SWJ_CLOCK
static int pending_fifo_block_count
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)
static struct pending_request_block pending_fifo[MAX_PENDING_REQUESTS]
#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_flush(void)
#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 int cmsis_dap_cmd_dap_disconnect(void)
static const char *const cmsis_dap_transport[]
static void cmsis_dap_runtest(int num_cycles)
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 void cmsis_dap_swd_read_process(struct cmsis_dap *dap, int timeout_ms)
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 int pending_fifo_put_idx
static void cmsis_dap_flush_read(struct cmsis_dap *dap)
static int pending_scan_result_count
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 void cmsis_dap_end_state(tap_state_t state)
static int cmsis_dap_swd_run_queue(void)
static int cmsis_dap_cmd_dap_connect(uint8_t mode)
#define CMD_DAP_SWO_TRANSPORT
static void cmsis_dap_execute_tms(struct jtag_command *cmd)
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 int cmsis_dap_execute_queue(void)
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 pending_queue_len
static int cmsis_dap_metacmd_targetsel(uint32_t instance_id)
static void cmsis_dap_stableclocks(int num_cycles)
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 void cmsis_dap_pathmove(int num_states, tap_state_t *path)
static int pending_fifo_get_idx
static int cmsis_dap_cmd_dap_led(uint8_t led, uint8_t state)
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_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)
const struct cmsis_dap_backend cmsis_dap_usb_backend
const struct command_registration cmsis_dap_usb_subcommand_handlers[]
const struct cmsis_dap_backend cmsis_dap_hid_backend
#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_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.
struct jtag_command * jtag_command_queue
The current queue of jtag_command_s structures.
enum scan_type jtag_scan_type(const struct scan_command *cmd)
#define TPIU_ACPR_MAX_SWOSCALER
void delay_us(uint16_t delay)
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
tap_state_t tap_state_transition(tap_state_t 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(tap_state_t state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
void tap_set_end_state(tap_state_t new_end_state)
This function sets the state of an "end state follower" which tracks the state that any cable driver ...
tap_state_t tap_get_end_state(void)
For more information,.
int tap_get_tms_path(tap_state_t from, tap_state_t to)
This function provides a "bit sequence" indicating what has to be done with TMS during a sequence of ...
int tap_get_tms_path_len(tap_state_t from, tap_state_t to)
Function int tap_get_tms_path_len returns the total number of bits that represents a TMS path transit...
tap_state_t tap_get_state(void)
This function gets the state of the "state follower" which tracks the state of the TAPs connected to ...
#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
enum tap_state tap_state_t
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)
size_t size
Size of the control block search area.
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
int(* read)(struct cmsis_dap *dap, int timeout_ms)
int(* packet_buffer_alloc)(struct cmsis_dap *dap, unsigned int pkt_sz)
void(* close)(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)
const struct cmsis_dap_backend * backend
Represents a driver for a debugging interface.
unsigned supported
Bit vector listing capabilities exposed by this driver.
struct pending_transfer_result * transfers
unsigned first
Offset in bytes in the CMD_DAP_JTAG_SEQ response buffer.
uint8_t * buffer
Location to store the result.
unsigned length
Number of bits to read.
unsigned buffer_offset
Offset in the destination buffer.
This structure defines a single scan field in the scan.
int num_bits
The number of bits this field specifies.
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.
int(* init)(void)
Initialize the debug link so it can perform SWD operations.
Wrapper for transport lifecycle operations.
static const unsigned swd_seq_swd_to_jtag_len
static const unsigned swd_seq_jtag_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 const unsigned swd_seq_dormant_to_swd_len
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 swd_seq_jtag_to_dormant_len
static const unsigned swd_seq_dormant_to_jtag_len
static const uint8_t swd_seq_line_reset[]
SWD Line reset.
static const unsigned swd_seq_line_reset_len
static const unsigned swd_seq_swd_to_dormant_len
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 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