OpenOCD
|
JTAG adapters based on the FT2232 full and high speed USB parts are popular low cost JTAG debug solutions. More...
Go to the source code of this file.
Data Structures | |
struct | signal |
struct | swd_cmd_queue_entry |
Macros | |
#define | JTAG_MODE (LSB_FIRST | POS_EDGE_IN | NEG_EDGE_OUT) |
#define | JTAG_MODE_ALT (LSB_FIRST | NEG_EDGE_IN | NEG_EDGE_OUT) |
#define | MAX_USB_IDS 8 |
#define | SWD_MODE (LSB_FIRST | POS_EDGE_IN | NEG_EDGE_OUT) |
Functions | |
COMMAND_HANDLER (ftdi_handle_channel_command) | |
COMMAND_HANDLER (ftdi_handle_device_desc_command) | |
COMMAND_HANDLER (ftdi_handle_get_signal_command) | |
COMMAND_HANDLER (ftdi_handle_layout_init_command) | |
COMMAND_HANDLER (ftdi_handle_layout_signal_command) | |
COMMAND_HANDLER (ftdi_handle_set_signal_command) | |
COMMAND_HANDLER (ftdi_handle_tdo_sample_edge_command) | |
COMMAND_HANDLER (ftdi_handle_vid_pid_command) | |
static int | create_default_signal (const char *name, uint16_t data_mask) |
static struct signal * | create_signal (const char *name) |
static int | create_signals (void) |
static struct signal * | find_signal_by_name (const char *name) |
static void | ftdi_end_state (tap_state_t state) |
static void | ftdi_execute_command (struct jtag_command *cmd) |
static void | ftdi_execute_pathmove (struct jtag_command *cmd) |
static int | ftdi_execute_queue (struct jtag_command *cmd_queue) |
static void | ftdi_execute_runtest (struct jtag_command *cmd) |
static void | ftdi_execute_scan (struct jtag_command *cmd) |
static void | ftdi_execute_sleep (struct jtag_command *cmd) |
static void | ftdi_execute_stableclocks (struct jtag_command *cmd) |
static void | ftdi_execute_statemove (struct jtag_command *cmd) |
static void | ftdi_execute_tms (struct jtag_command *cmd) |
Clock a bunch of TMS (or SWDIO) transitions, to change the JTAG (or SWD) state machine. More... | |
static int | ftdi_get_signal (const struct signal *s, uint16_t *value_out) |
static int | ftdi_initialize (void) |
static int | ftdi_khz (int khz, int *jtag_speed) |
static int | ftdi_quit (void) |
static int | ftdi_reset (int trst, int srst) |
static int | ftdi_set_signal (const struct signal *s, char value) |
static int | ftdi_speed (int speed) |
static int | ftdi_speed_div (int speed, int *khz) |
static int | ftdi_swd_init (void) |
static void | ftdi_swd_queue_cmd (uint8_t cmd, uint32_t *dst, uint32_t data, uint32_t ap_delay_clk) |
static void | ftdi_swd_read_reg (uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk) |
static int | ftdi_swd_run_queue (void) |
Flush the MPSSE queue and process the SWD transaction queue. More... | |
static void | ftdi_swd_swdio_en (bool enable) |
static int | ftdi_swd_switch_seq (enum swd_special_seq seq) |
static void | ftdi_swd_write_reg (uint8_t cmd, uint32_t value, uint32_t ap_delay_clk) |
static void | move_to_state (tap_state_t goal_state) |
Function move_to_state moves the TAP controller from the current state to a goal_state through a path given by tap_get_tms_path(). More... | |
Variables | |
static uint16_t | direction |
static int | freq |
struct adapter_driver | ftdi_adapter_driver |
static uint8_t | ftdi_channel |
static const struct command_registration | ftdi_command_handlers [] |
static char * | ftdi_device_desc |
static struct jtag_interface | ftdi_interface |
static uint8_t | ftdi_jtag_mode = JTAG_MODE |
static uint16_t | ftdi_pid [MAX_USB_IDS+1] = { 0 } |
static const struct command_registration | ftdi_subcommand_handlers [] |
static const struct swd_driver | ftdi_swd |
static const char *const | ftdi_transports [] = { "jtag", "swd", NULL } |
static uint16_t | ftdi_vid [MAX_USB_IDS+1] = { 0 } |
static uint16_t | jtag_direction_init |
static uint16_t | jtag_output_init |
static struct mpsse_ctx * | mpsse_ctx |
static uint16_t | output |
static int | queued_retval |
static struct signal * | signals |
static struct swd_cmd_queue_entry * | swd_cmd_queue |
static size_t | swd_cmd_queue_alloced |
static size_t | swd_cmd_queue_length |
static bool | swd_mode |
JTAG adapters based on the FT2232 full and high speed USB parts are popular low cost JTAG debug solutions.
Many FT2232 based JTAG adapters are discrete, but development boards may integrate them as alternatives to more capable (and expensive) third party JTAG pods.
JTAG uses only one of the two communications channels ("MPSSE engines") on these devices. Adapters based on FT4232 parts have four ports/channels (A/B/C/D), instead of just two (A/B).
Especially on development boards integrating one of these chips (as opposed to discrete pods/dongles), the additional channels can be used for a variety of purposes, but OpenOCD only uses one channel at a time.
FT2232 based JTAG adapters are "dumb" not "smart", because most JTAG request/response interactions involve round trips over the USB link. A "smart" JTAG adapter has intelligence close to the scan chain, so it can for example poll quickly for a status change (usually taking on the order of microseconds not milliseconds) before beginning a queued transaction which require the previous one to have completed.
There are dozens of adapters of this type, differing in details which this driver needs to understand. Those "layout" details are required as part of FT2232 driver configuration.
This code uses information contained in the MPSSE specification which was found here: https://www.ftdichip.com/Support/Documents/AppNotes/AN2232C-01_MPSSE_Cmnd.pdf Hereafter this is called the "MPSSE Spec".
The datasheet for the ftdichip.com's FT2232H part is here: https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT2232H.pdf
Also note the issue with code 0x4b (clock data to TMS) noted in http://developer.intra2net.com/mailarchive/html/libftdi/2009/msg00292.html which can affect longer JTAG state paths.
Definition in file ftdi.c.
#define JTAG_MODE (LSB_FIRST | POS_EDGE_IN | NEG_EDGE_OUT) |
#define JTAG_MODE_ALT (LSB_FIRST | NEG_EDGE_IN | NEG_EDGE_OUT) |
#define SWD_MODE (LSB_FIRST | POS_EDGE_IN | NEG_EDGE_OUT) |
COMMAND_HANDLER | ( | ftdi_handle_channel_command | ) |
Definition at line 721 of file ftdi.c.
References CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and ftdi_channel.
COMMAND_HANDLER | ( | ftdi_handle_device_desc_command | ) |
COMMAND_HANDLER | ( | ftdi_handle_get_signal_command | ) |
Definition at line 845 of file ftdi.c.
References CMD, CMD_ARGC, CMD_ARGV, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, find_signal_by_name(), and ftdi_get_signal().
COMMAND_HANDLER | ( | ftdi_handle_layout_init_command | ) |
Definition at line 731 of file ftdi.c.
References CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, jtag_direction_init, and jtag_output_init.
COMMAND_HANDLER | ( | ftdi_handle_layout_signal_command | ) |
Definition at line 742 of file ftdi.c.
References CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, create_signal(), signal::data_mask, ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, find_signal_by_name(), signal::input_mask, signal::invert_data, signal::invert_input, signal::invert_oe, LOG_ERROR, and signal::oe_mask.
COMMAND_HANDLER | ( | ftdi_handle_set_signal_command | ) |
Definition at line 814 of file ftdi.c.
References CMD_ARGC, CMD_ARGV, ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, find_signal_by_name(), ftdi_set_signal(), LOG_ERROR, and mpsse_flush().
COMMAND_HANDLER | ( | ftdi_handle_tdo_sample_edge_command | ) |
Definition at line 897 of file ftdi.c.
References CMD, CMD_ARGC, CMD_ARGV, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ftdi_jtag_mode, JTAG_MODE, JTAG_MODE_ALT, nvp::name, NULL, nvp_name2value(), nvp_value2name(), and nvp::value.
COMMAND_HANDLER | ( | ftdi_handle_vid_pid_command | ) |
Definition at line 867 of file ftdi.c.
References CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ftdi_pid, ftdi_vid, LOG_WARNING, and MAX_USB_IDS.
|
static |
Definition at line 995 of file ftdi.c.
References create_signal(), signal::data_mask, ERROR_FAIL, ERROR_OK, signal::invert_data, signal::invert_oe, LOG_ERROR, name, and signal::oe_mask.
Referenced by create_signals().
|
static |
Definition at line 135 of file ftdi.c.
References name, signal::next, NULL, and signals.
Referenced by COMMAND_HANDLER(), and create_default_signal().
|
static |
Definition at line 1010 of file ftdi.c.
References create_default_signal(), ERROR_FAIL, and ERROR_OK.
Referenced by ftdi_swd_init().
|
static |
Definition at line 126 of file ftdi.c.
References name, signal::next, NULL, and signals.
Referenced by COMMAND_HANDLER(), ftdi_execute_queue(), ftdi_initialize(), ftdi_reset(), ftdi_swd_run_queue(), and ftdi_swd_swdio_en().
|
static |
Definition at line 302 of file ftdi.c.
References LOG_ERROR, state, tap_is_state_stable(), tap_set_end_state(), and tap_state_name().
Referenced by ftdi_execute_runtest(), ftdi_execute_scan(), and ftdi_execute_statemove().
|
static |
Definition at line 597 of file ftdi.c.
References cmd, ftdi_execute_pathmove(), ftdi_execute_runtest(), ftdi_execute_scan(), ftdi_execute_sleep(), ftdi_execute_stableclocks(), ftdi_execute_statemove(), ftdi_execute_tms(), JTAG_PATHMOVE, JTAG_RUNTEST, JTAG_SCAN, JTAG_SLEEP, JTAG_STABLECLOCKS, JTAG_TLR_RESET, JTAG_TMS, and LOG_ERROR.
Referenced by ftdi_execute_queue().
|
static |
Definition at line 371 of file ftdi.c.
References buf_set_u32(), cmd, ftdi_jtag_mode, LOG_DEBUG_IO, LOG_ERROR, mpsse_clock_tms_cs_out(), tap_get_state(), tap_set_end_state(), tap_set_state, tap_state_name(), and tap_state_transition().
Referenced by ftdi_execute_command().
|
static |
Definition at line 627 of file ftdi.c.
References cmd, ERROR_OK, find_signal_by_name(), ftdi_execute_command(), ftdi_set_signal(), LOG_ERROR, and mpsse_flush().
|
static |
Definition at line 312 of file ftdi.c.
References cmd, ftdi_end_state(), ftdi_jtag_mode, LOG_DEBUG_IO, move_to_state(), mpsse_clock_tms_cs_out(), tap_get_end_state(), tap_get_state(), TAP_IDLE, tap_state_name(), and zero.
Referenced by ftdi_execute_command().
|
static |
Definition at line 422 of file ftdi.c.
References bit_copy(), cmd, ftdi_end_state(), ftdi_jtag_mode, scan_field::in_value, jtag_scan_type(), LOG_DEBUG_IO, move_to_state(), mpsse_clock_data(), mpsse_clock_tms_cs(), mpsse_clock_tms_cs_out(), scan_field::num_bits, scan_field::out_value, TAP_DRSHIFT, tap_get_end_state(), tap_get_state(), TAP_IDLE, TAP_IRSHIFT, tap_set_state, tap_state_name(), and tap_state_transition().
Referenced by ftdi_execute_command().
|
static |
Definition at line 562 of file ftdi.c.
References cmd, jtag_sleep(), LOG_DEBUG_IO, mpsse_flush(), tap_get_state(), and tap_state_name().
Referenced by ftdi_execute_command().
|
static |
Definition at line 573 of file ftdi.c.
References cmd, ftdi_jtag_mode, LOG_DEBUG_IO, mpsse_clock_tms_cs_out(), tap_get_state(), TAP_RESET, and tap_state_name().
Referenced by ftdi_execute_command().
|
static |
Definition at line 342 of file ftdi.c.
References cmd, ftdi_end_state(), LOG_DEBUG_IO, move_to_state(), tap_get_end_state(), tap_get_state(), TAP_RESET, and tap_state_name().
Referenced by ftdi_execute_command().
|
static |
Clock a bunch of TMS (or SWDIO) transitions, to change the JTAG (or SWD) state machine.
REVISIT: Not the best method, perhaps.
Definition at line 358 of file ftdi.c.
References cmd, ftdi_jtag_mode, LOG_DEBUG_IO, and mpsse_clock_tms_cs_out().
Referenced by ftdi_execute_command().
|
static |
Definition at line 206 of file ftdi.c.
References ERROR_FAIL, ERROR_OK, signal::input_mask, signal::invert_input, LOG_ERROR, mpsse_flush(), mpsse_read_data_bits_high_byte(), mpsse_read_data_bits_low_byte(), and signal::name.
Referenced by COMMAND_HANDLER().
|
static |
Definition at line 649 of file ftdi.c.
References adapter_get_required_serial(), adapter_get_speed_khz(), adapter_usb_get_location(), signal::data_mask, direction, ERROR_JTAG_INIT_FAILED, find_signal_by_name(), freq, ftdi_channel, ftdi_device_desc, ftdi_pid, ftdi_set_signal(), ftdi_vid, jtag_direction_init, jtag_output_init, LOG_DEBUG, LOG_ERROR, mpsse_flush(), mpsse_loopback_config(), mpsse_open(), mpsse_set_data_bits_high_byte(), mpsse_set_data_bits_low_byte(), mpsse_set_frequency(), output, swd_mode, tap_get_tms_path_len(), and TAP_IRPAUSE.
|
static |
Definition at line 291 of file ftdi.c.
References ERROR_FAIL, ERROR_OK, LOG_DEBUG, and mpsse_is_high_speed().
|
static |
Definition at line 690 of file ftdi.c.
References ERROR_OK, ftdi_device_desc, mpsse_close(), signal::name, signal::next, signals, and swd_cmd_queue.
|
static |
Definition at line 524 of file ftdi.c.
References find_signal_by_name(), ftdi_set_signal(), jtag_get_reset_config(), LOG_DEBUG_IO, LOG_ERROR, mpsse_flush(), RESET_HAS_SRST, RESET_HAS_TRST, RESET_SRST_PUSH_PULL, RESET_TRST_OPEN_DRAIN, and swd_mode.
|
static |
Definition at line 153 of file ftdi.c.
References signal::data_mask, direction, ERROR_FAIL, ERROR_OK, signal::invert_data, signal::invert_oe, LOG_ERROR, mpsse_set_data_bits_high_byte(), mpsse_set_data_bits_low_byte(), signal::name, signal::oe_mask, and output.
Referenced by COMMAND_HANDLER(), ftdi_execute_queue(), ftdi_initialize(), ftdi_reset(), ftdi_swd_run_queue(), and ftdi_swd_swdio_en().
|
static |
Definition at line 269 of file ftdi.c.
References ERROR_OK, ftdi_jtag_mode, JTAG_MODE_ALT, LOG_ERROR, LOG_INFO, mpsse_set_frequency(), and swd_mode.
|
static |
|
static |
Definition at line 1023 of file ftdi.c.
References create_signals(), ERROR_FAIL, ERROR_OK, LOG_INFO, swd_cmd_queue, swd_cmd_queue_alloced, and swd_mode.
|
static |
Definition at line 1131 of file ftdi.c.
References buf_set_u32(), swd_cmd_queue_entry::cmd, cmd, swd_cmd_queue_entry::dst, ERROR_OK, ftdi_swd_run_queue(), ftdi_swd_swdio_en(), LOG_DEBUG, mpsse_clock_data_in(), mpsse_clock_data_out(), NULL, parity_u32(), queued_retval, SWD_CMD_APNDP, SWD_CMD_PARK, swd_cmd_queue, swd_cmd_queue_alloced, swd_cmd_queue_length, SWD_CMD_RNW, SWD_CMD_START, SWD_MODE, and swd_cmd_queue_entry::trn_ack_data_parity_trn.
Referenced by ftdi_swd_read_reg(), and ftdi_swd_write_reg().
|
static |
Definition at line 1184 of file ftdi.c.
References cmd, ftdi_swd_queue_cmd(), and SWD_CMD_RNW.
|
static |
Flush the MPSSE queue and process the SWD transaction queue.
Definition at line 1059 of file ftdi.c.
References buf_get_u32(), cmd, swd_cmd_queue_entry::dst, ERROR_FAIL, ERROR_OK, find_signal_by_name(), ftdi_set_signal(), LOG_CUSTOM_LEVEL, LOG_DEBUG_IO, LOG_ERROR, LOG_LVL_DEBUG, LOG_LVL_DEBUG_IO, mpsse_clock_data_out(), mpsse_flush(), NULL, parity(), parity_u32(), queued_retval, SWD_ACK_FAULT, SWD_ACK_OK, swd_ack_to_error_code(), SWD_ACK_WAIT, SWD_CMD_A32, SWD_CMD_APNDP, swd_cmd_queue, swd_cmd_queue_length, swd_cmd_returns_ack(), SWD_CMD_RNW, and SWD_MODE.
Referenced by ftdi_swd_queue_cmd().
|
static |
Definition at line 1037 of file ftdi.c.
References signal::data_mask, direction, find_signal_by_name(), ftdi_set_signal(), jtag_direction_init, mpsse_set_data_bits_low_byte(), and output.
Referenced by ftdi_swd_queue_cmd().
|
static |
|
static |
Definition at line 1190 of file ftdi.c.
References cmd, ftdi_swd_queue_cmd(), NULL, and SWD_CMD_RNW.
|
static |
Function move_to_state moves the TAP controller from the current state to a goal_state through a path given by tap_get_tms_path().
State transition logging is performed by delegation to clock_tms().
goal_state | is the destination state for the move. |
Definition at line 241 of file ftdi.c.
References ftdi_jtag_mode, LOG_DEBUG_IO, mpsse_clock_tms_cs_out(), tap_get_state(), tap_get_tms_path(), tap_get_tms_path_len(), tap_set_state, tap_state_name(), and tap_state_transition().
Referenced by ftdi_execute_runtest(), ftdi_execute_scan(), and ftdi_execute_statemove().
|
static |
Definition at line 120 of file ftdi.c.
Referenced by adapter_driver_gpios_init(), angie_allocate_payload(), angie_get_queue_size(), armv4_5_run_algorithm_inner(), armv7m_start_algorithm(), armv7m_wait_algorithm(), COMMAND_HELPER(), dsp563xx_run_algorithm(), ftdi_initialize(), ftdi_set_signal(), ftdi_swd_swdio_en(), init_mem_param(), init_reg_param(), mips32_run_algorithm(), riscv_run_algorithm(), stlink_usb_init_buffer(), stlink_usb_xfer_v1_create_cmd(), stm8_run_algorithm(), ulink_allocate_payload(), ulink_get_queue_size(), usbprog_jtag_set_direction(), xtensa_start_algorithm(), and xtensa_wait_algorithm().
|
static |
Definition at line 117 of file ftdi.c.
Referenced by FLASH_BANK_COMMAND_HANDLER(), and ftdi_initialize().
struct adapter_driver ftdi_adapter_driver |
|
static |
Definition at line 83 of file ftdi.c.
Referenced by COMMAND_HANDLER(), and ftdi_initialize().
|
static |
|
static |
Definition at line 82 of file ftdi.c.
Referenced by COMMAND_HANDLER(), ftdi_initialize(), and ftdi_quit().
|
static |
|
static |
Definition at line 84 of file ftdi.c.
Referenced by COMMAND_HANDLER(), ftdi_execute_pathmove(), ftdi_execute_runtest(), ftdi_execute_scan(), ftdi_execute_stableclocks(), ftdi_execute_tms(), ftdi_speed(), and move_to_state().
|
static |
Definition at line 91 of file ftdi.c.
Referenced by COMMAND_HANDLER(), and ftdi_initialize().
|
static |
|
static |
|
static |
|
static |
Definition at line 90 of file ftdi.c.
Referenced by COMMAND_HANDLER(), and ftdi_initialize().
|
static |
Definition at line 122 of file ftdi.c.
Referenced by COMMAND_HANDLER(), ftdi_initialize(), and ftdi_swd_swdio_en().
|
static |
Definition at line 121 of file ftdi.c.
Referenced by COMMAND_HANDLER(), and ftdi_initialize().
|
static |
Definition at line 119 of file ftdi.c.
Referenced by COMMAND_HANDLER(), ftdi_initialize(), ftdi_set_signal(), ftdi_swd_swdio_en(), handle_iod_output(), parport_write_data(), and target_handle_md_output().
|
static |
Definition at line 116 of file ftdi.c.
Referenced by ftdi_swd_queue_cmd(), and ftdi_swd_run_queue().
|
static |
Definition at line 106 of file ftdi.c.
Referenced by create_signal(), find_signal_by_name(), and ftdi_quit().
|
static |
Referenced by ftdi_quit(), ftdi_swd_init(), ftdi_swd_queue_cmd(), and ftdi_swd_run_queue().
|
static |
Definition at line 115 of file ftdi.c.
Referenced by ftdi_swd_init(), and ftdi_swd_queue_cmd().
|
static |
Definition at line 114 of file ftdi.c.
Referenced by ftdi_swd_queue_cmd(), and ftdi_swd_run_queue().
|
static |
Definition at line 86 of file ftdi.c.
Referenced by ftdi_initialize(), ftdi_reset(), ftdi_speed(), and ftdi_swd_init().