OpenOCD
esp_usb_jtag.c File Reference
Include dependency graph for esp_usb_jtag.c:

Go to the source code of this file.

Data Structures

struct  esp_usb_jtag
 
struct  jtag_gen_hdr
 
struct  jtag_proto_caps_hdr
 
struct  jtag_proto_caps_speed_apb
 

Macros

#define CMD_CLK(cap, tdi, tms)   ((cap ? BIT(2) : 0) | (tms ? BIT(1) : 0) | (tdi ? BIT(0) : 0))
 
#define CMD_FLUSH   0xA
 
#define CMD_REP(r)   (0xC + ((r) & 3))
 
#define CMD_REP_MAX_REPS   1024
 
#define CMD_RST(srst)   (0x8 | (srst ? BIT(0) : 0))
 
#define CMD_RSVD   0xB
 
#define ESP_USB_INTERFACE   1
 
#define IN_BUF_CT   8
 
#define IN_BUF_SZ   64
 
#define JTAG_BUILTIN_DESCR_START_OFF   0 /* Devices with builtin usb jtag */
 
#define JTAG_EUB_DESCR_START_OFF   2 /* ESP USB Bridge */
 
#define JTAG_PROTO_CAPS_DATA_LEN   255
 
#define JTAG_PROTO_CAPS_SPEED_APB_TYPE   1
 
#define JTAG_PROTO_CAPS_VER   1 /* Version field. At the moment, only version 1 is defined. */
 
#define OUT_BUF_SZ   (OUT_EP_SZ * 32)
 
#define OUT_EP_SZ   64
 
#define USB_CONFIGURATION   0
 
#define VEND_DESCR_BUILTIN_JTAG_CAPS   0x2000
 
#define VEND_JTAG_GETTDO   2
 
#define VEND_JTAG_SET_CHIPID   3
 
#define VEND_JTAG_SETDIV   0
 
#define VEND_JTAG_SETIO   1
 
#define VEND_JTAG_SETIO_SRST   BIT(4)
 
#define VEND_JTAG_SETIO_TCK   BIT(2)
 
#define VEND_JTAG_SETIO_TDI   BIT(0)
 
#define VEND_JTAG_SETIO_TMS   BIT(1)
 
#define VEND_JTAG_SETIO_TRST   BIT(3)
 

Functions

struct jtag_proto_caps_hdr __attribute__ ((packed))
 
 COMMAND_HANDLER (esp_usb_jtag_caps_descriptor)
 
 COMMAND_HANDLER (esp_usb_jtag_chip_id)
 
 COMMAND_HANDLER (esp_usb_jtag_setio_cmd)
 
 COMMAND_HANDLER (esp_usb_jtag_tdo_cmd)
 
 COMMAND_HANDLER (esp_usb_jtag_vid_pid)
 
static int esp_usb_jtag_command_add (unsigned int cmd)
 
static int esp_usb_jtag_command_add_raw (unsigned int cmd)
 
static int esp_usb_jtag_flush (void)
 
static int esp_usb_jtag_in (void)
 
static int esp_usb_jtag_in_rdy (void)
 
static int esp_usb_jtag_init (void)
 
static int esp_usb_jtag_khz (int khz, int *divisor)
 
static int esp_usb_jtag_out (int tms, int tdi, int tdo_req)
 
static int esp_usb_jtag_quit (void)
 
static int esp_usb_jtag_recv_buf (void)
 
static int esp_usb_jtag_reset (int trst, int srst)
 
static int esp_usb_jtag_send_buf (void)
 
static int esp_usb_jtag_sleep (unsigned long us)
 
static int esp_usb_jtag_speed (int divisor)
 
static int esp_usb_jtag_speed_div (int divisor, int *khz)
 
static int esp_usb_jtag_write_rlestream (unsigned int cmd, int ct)
 

Variables

struct esp_usb_jtag __attribute__
 
uint8_t apb_speed_10khz [2]
 
uint8_t div_max [2]
 
uint8_t div_min [2]
 
struct adapter_driver esp_usb_adapter_driver
 
static int esp_usb_jtag_caps
 
static const struct command_registration esp_usb_jtag_commands []
 
static struct jtag_interface esp_usb_jtag_interface
 
static struct esp_usb_jtag esp_usb_jtag_priv
 
static const struct command_registration esp_usb_jtag_subcommands []
 
static int esp_usb_pid
 
static int esp_usb_target_chip_id
 
static int esp_usb_vid
 
uint8_t length
 
static struct esp_usb_jtagpriv = &esp_usb_jtag_priv
 
uint8_t proto_ver
 
uint8_t type
 

Macro Definition Documentation

◆ CMD_CLK

#define CMD_CLK (   cap,
  tdi,
  tms 
)    ((cap ? BIT(2) : 0) | (tms ? BIT(1) : 0) | (tdi ? BIT(0) : 0))

Definition at line 160 of file esp_usb_jtag.c.

◆ CMD_FLUSH

#define CMD_FLUSH   0xA

Definition at line 162 of file esp_usb_jtag.c.

◆ CMD_REP

#define CMD_REP (   r)    (0xC + ((r) & 3))

Definition at line 164 of file esp_usb_jtag.c.

◆ CMD_REP_MAX_REPS

#define CMD_REP_MAX_REPS   1024

Definition at line 168 of file esp_usb_jtag.c.

◆ CMD_RST

#define CMD_RST (   srst)    (0x8 | (srst ? BIT(0) : 0))

Definition at line 161 of file esp_usb_jtag.c.

◆ CMD_RSVD

#define CMD_RSVD   0xB

Definition at line 163 of file esp_usb_jtag.c.

◆ ESP_USB_INTERFACE

#define ESP_USB_INTERFACE   1

Definition at line 186 of file esp_usb_jtag.c.

◆ IN_BUF_CT

#define IN_BUF_CT   8

Definition at line 184 of file esp_usb_jtag.c.

◆ IN_BUF_SZ

#define IN_BUF_SZ   64

Definition at line 180 of file esp_usb_jtag.c.

◆ JTAG_BUILTIN_DESCR_START_OFF

#define JTAG_BUILTIN_DESCR_START_OFF   0 /* Devices with builtin usb jtag */

Definition at line 114 of file esp_usb_jtag.c.

◆ JTAG_EUB_DESCR_START_OFF

#define JTAG_EUB_DESCR_START_OFF   2 /* ESP USB Bridge */

Definition at line 119 of file esp_usb_jtag.c.

◆ JTAG_PROTO_CAPS_DATA_LEN

#define JTAG_PROTO_CAPS_DATA_LEN   255

Definition at line 144 of file esp_usb_jtag.c.

◆ JTAG_PROTO_CAPS_SPEED_APB_TYPE

#define JTAG_PROTO_CAPS_SPEED_APB_TYPE   1

Definition at line 145 of file esp_usb_jtag.c.

◆ JTAG_PROTO_CAPS_VER

#define JTAG_PROTO_CAPS_VER   1 /* Version field. At the moment, only version 1 is defined. */

Definition at line 107 of file esp_usb_jtag.c.

◆ OUT_BUF_SZ

#define OUT_BUF_SZ   (OUT_EP_SZ * 32)

Definition at line 178 of file esp_usb_jtag.c.

◆ OUT_EP_SZ

#define OUT_EP_SZ   64

Definition at line 175 of file esp_usb_jtag.c.

◆ USB_CONFIGURATION

#define USB_CONFIGURATION   0

Definition at line 171 of file esp_usb_jtag.c.

◆ VEND_DESCR_BUILTIN_JTAG_CAPS

#define VEND_DESCR_BUILTIN_JTAG_CAPS   0x2000

Definition at line 147 of file esp_usb_jtag.c.

◆ VEND_JTAG_GETTDO

#define VEND_JTAG_GETTDO   2

Definition at line 151 of file esp_usb_jtag.c.

◆ VEND_JTAG_SET_CHIPID

#define VEND_JTAG_SET_CHIPID   3

Definition at line 152 of file esp_usb_jtag.c.

◆ VEND_JTAG_SETDIV

#define VEND_JTAG_SETDIV   0

Definition at line 149 of file esp_usb_jtag.c.

◆ VEND_JTAG_SETIO

#define VEND_JTAG_SETIO   1

Definition at line 150 of file esp_usb_jtag.c.

◆ VEND_JTAG_SETIO_SRST

#define VEND_JTAG_SETIO_SRST   BIT(4)

Definition at line 158 of file esp_usb_jtag.c.

◆ VEND_JTAG_SETIO_TCK

#define VEND_JTAG_SETIO_TCK   BIT(2)

Definition at line 156 of file esp_usb_jtag.c.

◆ VEND_JTAG_SETIO_TDI

#define VEND_JTAG_SETIO_TDI   BIT(0)

Definition at line 154 of file esp_usb_jtag.c.

◆ VEND_JTAG_SETIO_TMS

#define VEND_JTAG_SETIO_TMS   BIT(1)

Definition at line 155 of file esp_usb_jtag.c.

◆ VEND_JTAG_SETIO_TRST

#define VEND_JTAG_SETIO_TRST   BIT(3)

Definition at line 157 of file esp_usb_jtag.c.

Function Documentation

◆ __attribute__()

struct jtag_proto_caps_hdr __attribute__ ( (packed)  )

◆ COMMAND_HANDLER() [1/5]

COMMAND_HANDLER ( esp_usb_jtag_caps_descriptor  )

◆ COMMAND_HANDLER() [2/5]

COMMAND_HANDLER ( esp_usb_jtag_chip_id  )

◆ COMMAND_HANDLER() [3/5]

◆ COMMAND_HANDLER() [4/5]

COMMAND_HANDLER ( esp_usb_jtag_tdo_cmd  )

◆ COMMAND_HANDLER() [5/5]

COMMAND_HANDLER ( esp_usb_jtag_vid_pid  )

◆ esp_usb_jtag_command_add()

static int esp_usb_jtag_command_add ( unsigned int  cmd)
static

◆ esp_usb_jtag_command_add_raw()

◆ esp_usb_jtag_flush()

◆ esp_usb_jtag_in()

◆ esp_usb_jtag_in_rdy()

static int esp_usb_jtag_in_rdy ( void  )
static

Definition at line 442 of file esp_usb_jtag.c.

Referenced by esp_usb_jtag_in(), and esp_usb_jtag_init().

◆ esp_usb_jtag_init()

◆ esp_usb_jtag_khz()

static int esp_usb_jtag_khz ( int  khz,
int *  divisor 
)
static

◆ esp_usb_jtag_out()

static int esp_usb_jtag_out ( int  tms,
int  tdi,
int  tdo_req 
)
static

◆ esp_usb_jtag_quit()

static int esp_usb_jtag_quit ( void  )
static

◆ esp_usb_jtag_recv_buf()

◆ esp_usb_jtag_reset()

static int esp_usb_jtag_reset ( int  trst,
int  srst 
)
static

Definition at line 434 of file esp_usb_jtag.c.

References CMD_RST, and esp_usb_jtag_command_add().

Referenced by esp_usb_jtag_init().

◆ esp_usb_jtag_send_buf()

◆ esp_usb_jtag_sleep()

static int esp_usb_jtag_sleep ( unsigned long  us)
static

Definition at line 424 of file esp_usb_jtag.c.

References esp_usb_jtag_flush(), and jtag_sleep().

Referenced by esp_usb_jtag_init().

◆ esp_usb_jtag_speed()

static int esp_usb_jtag_speed ( int  divisor)
static

◆ esp_usb_jtag_speed_div()

static int esp_usb_jtag_speed_div ( int  divisor,
int *  khz 
)
static

Definition at line 605 of file esp_usb_jtag.c.

References esp_usb_jtag::base_speed_khz, ERROR_OK, and priv.

◆ esp_usb_jtag_write_rlestream()

static int esp_usb_jtag_write_rlestream ( unsigned int  cmd,
int  ct 
)
static

Variable Documentation

◆ __attribute__

static __attribute__

Definition at line 804 of file armv8.c.

◆ apb_speed_10khz

uint8_t apb_speed_10khz[2]

Definition at line 2 of file esp_usb_jtag.c.

◆ div_max

uint8_t div_max[2]

Definition at line 4 of file esp_usb_jtag.c.

◆ div_min

uint8_t div_min[2]

Definition at line 3 of file esp_usb_jtag.c.

Referenced by esp_usb_jtag_khz().

◆ esp_usb_adapter_driver

struct adapter_driver esp_usb_adapter_driver
Initial value:
= {
.name = "esp_usb_jtag",
.transports = jtag_only,
.commands = esp_usb_jtag_commands,
.speed_div = esp_usb_jtag_speed_div,
.jtag_ops = &esp_usb_jtag_interface,
}
const char *const jtag_only[]
Definition: adapter.c:31
static int esp_usb_jtag_quit(void)
Definition: esp_usb_jtag.c:595
static int esp_usb_jtag_khz(int khz, int *divisor)
Definition: esp_usb_jtag.c:611
static int esp_usb_jtag_init(void)
Definition: esp_usb_jtag.c:475
static int esp_usb_jtag_speed_div(int divisor, int *khz)
Definition: esp_usb_jtag.c:605
static int esp_usb_jtag_speed(int divisor)
Definition: esp_usb_jtag.c:631
static const struct command_registration esp_usb_jtag_commands[]
Definition: esp_usb_jtag.c:766
static struct jtag_interface esp_usb_jtag_interface
Definition: esp_usb_jtag.c:777

Definition at line 716 of file esp_usb_jtag.c.

◆ esp_usb_jtag_caps

int esp_usb_jtag_caps
static

Definition at line 223 of file esp_usb_jtag.c.

Referenced by COMMAND_HANDLER(), and esp_usb_jtag_init().

◆ esp_usb_jtag_commands

const struct command_registration esp_usb_jtag_commands[]
static
Initial value:
= {
{
.name = "espusbjtag",
.mode = COMMAND_ANY,
.help = "ESP-USB-JTAG commands",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration esp_usb_jtag_subcommands[]
Definition: esp_usb_jtag.c:727
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:235

Definition at line 716 of file esp_usb_jtag.c.

◆ esp_usb_jtag_interface

struct jtag_interface esp_usb_jtag_interface
static
Initial value:
= {
.supported = DEBUG_CAP_TMS_SEQ,
.execute_queue = bitq_execute_queue,
}
int bitq_execute_queue(void)
Definition: bitq.c:206
#define DEBUG_CAP_TMS_SEQ
Definition: interface.h:189

Definition at line 716 of file esp_usb_jtag.c.

◆ esp_usb_jtag_priv

struct esp_usb_jtag esp_usb_jtag_priv
static

Definition at line 1 of file esp_usb_jtag.c.

◆ esp_usb_jtag_subcommands

const struct command_registration esp_usb_jtag_subcommands[]
static

Definition at line 716 of file esp_usb_jtag.c.

◆ esp_usb_pid

int esp_usb_pid
static

Definition at line 222 of file esp_usb_jtag.c.

Referenced by COMMAND_HANDLER(), and esp_usb_jtag_init().

◆ esp_usb_target_chip_id

int esp_usb_target_chip_id
static

Definition at line 224 of file esp_usb_jtag.c.

Referenced by COMMAND_HANDLER(), and esp_usb_jtag_init().

◆ esp_usb_vid

int esp_usb_vid
static

Definition at line 221 of file esp_usb_jtag.c.

Referenced by COMMAND_HANDLER(), and esp_usb_jtag_init().

◆ length

uint8_t length

Definition at line 1 of file esp_usb_jtag.c.

Referenced by aarch64_set_watchpoint(), adjust_sink_list(), aice_pipe_read_mem_bulk(), aice_pipe_write_mem_bulk(), aice_read_mem_bulk(), aice_usb_bulk_read_mem(), aice_usb_bulk_write_mem(), aice_write_mem_bulk(), armjtagew_tap_append_scan(), armjtagew_tap_execute(), breakpoint_add(), breakpoint_add_internal(), buspirate_tap_append_scan(), buspirate_tap_execute(), cc26xx_erase(), cc26xx_write(), COMMAND_HANDLER(), command_log_capture_finish(), context_breakpoint_add(), context_breakpoint_add_internal(), dpm_bpwp_setup(), dpmv8_bpwp_setup(), flash_erase_address_range(), flash_iterate_address_range(), flash_iterate_address_range_inner(), flash_unlock_address_range(), gdb_get_target_description_chunk(), gdb_get_thread_list_chunk(), gdb_memory_map(), gdb_query_packet(), gdb_v_packet(), handle_bp_command_set(), hexify(), hybrid_breakpoint_add(), hybrid_breakpoint_add_internal(), jlink_clock_data(), jlink_init(), jlink_swd_run_queue(), mpsse_clock_data(), mpsse_clock_data_in(), mpsse_clock_data_out(), mpsse_clock_tms_cs(), mpsse_clock_tms_cs_out(), nds32_cache_sync(), nds32_extract_field_8u(), nds32_select_memory_mode(), npcx_erase(), opendous_tap_append_scan(), opendous_tap_execute(), openjtag_add_scan(), osbdm_swap(), poll_trace(), read_callback(), read_channel_name(), read_from_channel(), read_section(), riscv_hit_watchpoint(), rp2040_flash_erase(), rtt_input(), rtt_write_channel(), target_asciimsg(), target_hexmsg(), target_jim_get_reg(), target_jim_set_reg(), target_rtt_read_callback(), target_rtt_write_callback(), vsllink_jtag_execute(), vsllink_tap_append_scan(), watchpoint_add(), watchpoint_add_internal(), write_to_channel(), and xlnx_pcie_xvc_swd_sequence().

◆ priv

struct esp_usb_jtag* priv = &esp_usb_jtag_priv
static

Definition at line 219 of file esp_usb_jtag.c.

Referenced by aarch64_handle_target_request(), add_service(), arm7_9_handle_target_request(), arm_jtag_reset_callback(), arm_tpiu_swo_poll_trace(), arm_tpiu_swo_service_connection_closed(), arm_tpiu_swo_service_new_connection(), command_free(), COMMAND_HANDLER(), command_set_output_handler(), cortex_a_handle_target_request(), cortex_m_handle_target_request(), dap_info_ap_header(), dap_info_cs_component(), dap_info_mem_ap_header(), dap_info_rom_table_entry(), dap_lookup_cs_component_cs_component(), desc_bits_to_string(), esp_usb_jtag_command_add(), esp_usb_jtag_command_add_raw(), esp_usb_jtag_flush(), esp_usb_jtag_in(), esp_usb_jtag_init(), esp_usb_jtag_khz(), esp_usb_jtag_out(), esp_usb_jtag_quit(), esp_usb_jtag_recv_buf(), esp_usb_jtag_send_buf(), esp_usb_jtag_speed(), esp_usb_jtag_speed_div(), FLASH_BANK_COMMAND_HANDLER(), gdb_log_callback(), gdb_target_callback_event_handler(), handle_target(), hl_handle_target_request(), ipdbg_polling_callback(), jim_arm_tpiu_swo_enable(), jsp_poll_read(), jtag_enable_callback(), jtag_register_event_callback(), jtag_reset_callback(), jtag_unregister_event_callback(), log_add_callback(), log_remove_callback(), nds32_callback_event_handler(), riscv_mmu(), rp2040_call_rom_func(), rp2040_finalize_stack_free(), rp2040_flash_auto_probe(), rp2040_flash_erase(), rp2040_flash_probe(), rp2040_flash_write(), rp2040_stack_grab_and_prep(), target_register_event_callback(), target_register_reset_callback(), target_register_timer_callback(), target_register_trace_callback(), target_unregister_event_callback(), target_unregister_reset_callback(), target_unregister_timer_callback(), target_unregister_trace_callback(), tcl_target_callback_event_handler(), tcl_target_callback_reset_handler(), tcl_target_callback_trace_handler(), telnet_log_callback(), xcf_auto_probe(), xcf_info(), and xcf_probe().

◆ proto_ver

uint8_t proto_ver

Definition at line 0 of file esp_usb_jtag.c.

◆ type

uint8_t type

Definition at line 0 of file esp_usb_jtag.c.

Referenced by aarch64_set_context_breakpoint(), aarch64_set_hybrid_breakpoint(), add_trigger(), amt_jtagaccel_execute_queue(), amt_jtagaccel_scan(), arc_deinit_target(), arc_jtag_read_registers(), arc_jtag_write_registers(), arc_reg_add(), arm11_examine(), armjtagew_execute_queue(), bitbang_execute_queue(), bitbang_scan(), breakpoint_add(), breakpoint_add_internal(), buspirate_execute_queue(), cmapi_read_dap_reg(), cmapi_write_dap_reg(), COMMAND_HANDLER(), context_breakpoint_add(), context_breakpoint_add_internal(), cortex_a_set_context_breakpoint(), cortex_a_set_hybrid_breakpoint(), cortex_m_step(), dtc_load_from_buffer(), dtc_queue_enqueue_reply(), evaluate_extend(), evaluate_media(), evaluate_p_add_sub(), fileio_open(), gdb_breakpoint_watchpoint_packet(), gdb_generate_reg_type_description(), gdb_get_reg_type_name(), gw16012_execute_queue(), gw16012_scan(), hybrid_breakpoint_add(), hybrid_breakpoint_add_internal(), jim_arc_add_reg_type_flags(), jim_arc_add_reg_type_struct(), jim_arc_read_reg_type_field(), jtag_set_reset_config(), nds32_reg_set(), opendous_execute_queue(), read_flash_id(), read_rtt_channel(), riscv_enumerate_triggers(), rlink_execute_queue(), rlink_scan(), rtos_try_next(), semihosting_common(), stlink_usb_mode_enter(), stlink_usb_mode_leave(), syncbb_scan(), target_init_one(), target_register_timer_callback(), target_rtt_read_channel_info(), ublast_build_out(), ublast_clock_tdi(), ublast_clock_tdi_flip_tms(), ublast_scan(), ulink_calculate_delay(), ulink_calculate_frequency(), ulink_queue_scan(), usbprog_execute_queue(), usbprog_scan(), usbtoxxx_add_command(), usbtoxxx_execute_command(), versaloon_add_pending(), vsllink_execute_queue(), xds110_legacy_read_reg(), xds110_legacy_write_reg(), xds110_swd_queue_cmd(), xlnx_pcie_xvc_execute_scan(), xtensa_build_reg_cache(), xtensa_fetch_all_regs(), xtensa_get_gdb_reg_list(), xtensa_get_mem_config(), and xtensa_write_dirty_registers().