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

Go to the source code of this file.

Data Structures

struct  dap_queue
 
struct  speed_map
 
struct  stlink_backend_s
 
struct  stlink_tcp_priv_s
 
struct  stlink_tcp_version
 
struct  stlink_usb_handle_s
 
struct  stlink_usb_priv_s
 
struct  stlink_usb_version
 

Macros

#define BYTES_PER_LINE   16
 
#define CMD_MEM_AP_2_SIZE(cmd)   ((cmd) & 7)
 
#define ENDPOINT_IN   0x80
 
#define ENDPOINT_OUT   0x00
 
#define MAX_QUEUE_DEPTH   (4096)
 
#define MAX_WAIT_RETRIES   8
 
#define OPENOCD_STLINK_TCP_API_VERSION   1
 
#define REQUEST_SENSE   0x03
 
#define REQUEST_SENSE_LENGTH   18
 
#define RW_MISC_CMD_ADDRESS   1
 
#define RW_MISC_CMD_APNUM   5
 
#define RW_MISC_CMD_READ   3
 
#define RW_MISC_CMD_WRITE   2
 
#define STLINK_APIV3_GET_COM_FREQ   0x62
 
#define STLINK_APIV3_GET_VERSION_EX   0xFB
 
#define STLINK_APIV3_SET_COM_FREQ   0x61
 
#define STLINK_BAD_AP_ERROR   0x1d
 
#define STLINK_CMD_SIZE_V1   (10)
 
#define STLINK_CMD_SIZE_V2   (16)
 
#define STLINK_CORE_HALTED   0x81
 
#define STLINK_CORE_RUNNING   0x80
 
#define STLINK_CORE_STAT_UNKNOWN   -1
 
#define STLINK_DATA_SIZE   (6144)
 
#define STLINK_DEBUG_APIV1_CLEARFP   0x0e
 
#define STLINK_DEBUG_APIV1_ENTER   0x20
 
#define STLINK_DEBUG_APIV1_READALLREGS   0x04
 
#define STLINK_DEBUG_APIV1_READREG   0x05
 
#define STLINK_DEBUG_APIV1_RESETSYS   0x03
 
#define STLINK_DEBUG_APIV1_SETFP   0x0b
 
#define STLINK_DEBUG_APIV1_SETWATCHPOINT   0x10
 
#define STLINK_DEBUG_APIV1_WRITEDEBUGREG   0x0f
 
#define STLINK_DEBUG_APIV1_WRITEREG   0x06
 
#define STLINK_DEBUG_APIV2_CLOSE_AP_DBG   0x4C
 
#define STLINK_DEBUG_APIV2_DRIVE_NRST   0x3C
 
#define STLINK_DEBUG_APIV2_DRIVE_NRST_HIGH   0x01
 
#define STLINK_DEBUG_APIV2_DRIVE_NRST_LOW   0x00
 
#define STLINK_DEBUG_APIV2_DRIVE_NRST_PULSE   0x02
 
#define STLINK_DEBUG_APIV2_ENTER   0x30
 
#define STLINK_DEBUG_APIV2_GET_TRACE_NB   0x42
 
#define STLINK_DEBUG_APIV2_GETLASTRWSTATUS   0x3B
 
#define STLINK_DEBUG_APIV2_GETLASTRWSTATUS2   0x3E
 
#define STLINK_DEBUG_APIV2_INIT_AP   0x4B
 
#define STLINK_DEBUG_APIV2_JTAG_SET_FREQ   0x44
 
#define STLINK_DEBUG_APIV2_READ_DAP_REG   0x45
 
#define STLINK_DEBUG_APIV2_READ_IDCODES   0x31
 
#define STLINK_DEBUG_APIV2_READALLREGS   0x3A
 
#define STLINK_DEBUG_APIV2_READDEBUGREG   0x36
 
#define STLINK_DEBUG_APIV2_READMEM_16BIT   0x47
 
#define STLINK_DEBUG_APIV2_READREG   0x33
 
#define STLINK_DEBUG_APIV2_RESETSYS   0x32
 
#define STLINK_DEBUG_APIV2_RW_MISC_IN   0x52
 
#define STLINK_DEBUG_APIV2_RW_MISC_OUT   0x51
 
#define STLINK_DEBUG_APIV2_START_TRACE_RX   0x40
 
#define STLINK_DEBUG_APIV2_STOP_TRACE_RX   0x41
 
#define STLINK_DEBUG_APIV2_SWD_SET_FREQ   0x43
 
#define STLINK_DEBUG_APIV2_WRITE_DAP_REG   0x46
 
#define STLINK_DEBUG_APIV2_WRITEDEBUGREG   0x35
 
#define STLINK_DEBUG_APIV2_WRITEMEM_16BIT   0x48
 
#define STLINK_DEBUG_APIV2_WRITEREG   0x34
 
#define STLINK_DEBUG_COMMAND   0xF2
 
#define STLINK_DEBUG_ENTER_JTAG_NO_RESET   0xa4
 
#define STLINK_DEBUG_ENTER_JTAG_RESET   0x00
 
#define STLINK_DEBUG_ENTER_SWD_NO_RESET   0xa3
 
#define STLINK_DEBUG_ERR_FAULT   0x81
 
#define STLINK_DEBUG_ERR_OK   0x80
 
#define STLINK_DEBUG_EXIT   0x21
 
#define STLINK_DEBUG_FORCEDEBUG   0x02
 
#define STLINK_DEBUG_GETSTATUS   0x01
 
#define STLINK_DEBUG_PORT_ACCESS   0xffff
 
#define STLINK_DEBUG_READCOREID   0x22
 
#define STLINK_DEBUG_READMEM_32BIT   0x07
 
#define STLINK_DEBUG_READMEM_32BIT_NO_ADDR_INC   0x54
 
#define STLINK_DEBUG_READMEM_8BIT   0x0c
 
#define STLINK_DEBUG_RUNCORE   0x09
 
#define STLINK_DEBUG_STEPCORE   0x0a
 
#define STLINK_DEBUG_WRITEMEM_32BIT   0x08
 
#define STLINK_DEBUG_WRITEMEM_32BIT_NO_ADDR_INC   0x50
 
#define STLINK_DEBUG_WRITEMEM_8BIT   0x0d
 
#define STLINK_DEV_BOOTLOADER_MODE   0x04
 
#define STLINK_DEV_DEBUG_MODE   0x02
 
#define STLINK_DEV_DFU_MODE   0x00
 
#define STLINK_DEV_MASS_MODE   0x01
 
#define STLINK_DEV_SWIM_MODE   0x03
 
#define STLINK_DEV_UNKNOWN_MODE   -1
 
#define STLINK_DFU_COMMAND   0xF3
 
#define STLINK_DFU_EXIT   0x07
 
#define STLINK_F_FIX_CLOSE_AP   BIT(8) /* v2>=j29 || v3 */
 
#define STLINK_F_HAS_AP_INIT   BIT(7) /* v2>=j28 || v3 */
 
#define STLINK_F_HAS_CSW   STLINK_F_HAS_DPBANKSEL
 
#define STLINK_F_HAS_DAP_REG   BIT(5) /* v2>=j24 || v3 */
 
#define STLINK_F_HAS_DPBANKSEL   BIT(9) /* v2>=j32 || v3>=j2 */
 
#define STLINK_F_HAS_FPU_REG   STLINK_F_HAS_GETLASTRWSTATUS2
 
#define STLINK_F_HAS_GETLASTRWSTATUS2   BIT(1) /* v2>=j15 || v3 */
 
#define STLINK_F_HAS_JTAG_SET_FREQ   BIT(3) /* v2>=j24 */
 
#define STLINK_F_HAS_MEM_16BIT   BIT(6) /* v2>=j26 || v3 */
 
#define STLINK_F_HAS_MEM_RD_NO_INC   STLINK_F_HAS_DPBANKSEL
 
#define STLINK_F_HAS_MEM_WR_NO_INC   STLINK_F_HAS_MEM_16BIT
 
#define STLINK_F_HAS_RW8_512BYTES   BIT(10) /* v3>=j6 */
 
#define STLINK_F_HAS_RW_MISC   STLINK_F_HAS_DPBANKSEL
 
#define STLINK_F_HAS_SWD_SET_FREQ   BIT(2) /* v2>=j22 */
 
#define STLINK_F_HAS_TARGET_VOLT   STLINK_F_HAS_TRACE
 
#define STLINK_F_HAS_TRACE   BIT(0) /* v2>=j13 || v3 */
 
#define STLINK_F_QUIRK_JTAG_DP_READ   BIT(4) /* v2>=j24 && v2<j32 */
 
#define STLINK_GET_CURRENT_MODE   0xF5
 
#define STLINK_GET_TARGET_VOLTAGE   0xF7
 
#define STLINK_GET_VERSION   0xF1
 
#define STLINK_HLA_AP_NUM   0
 
#define STLINK_HLA_CSW   0
 
#define STLINK_JTAG_GET_IDCODE_ERROR   0x09
 
#define STLINK_JTAG_WRITE_ERROR   0x0c
 
#define STLINK_JTAG_WRITE_VERIF_ERROR   0x0d
 
#define STLINK_MAX_RW16_32   STLINK_DATA_SIZE
 
#define STLINK_MAX_RW8   (64)
 
#define STLINK_READ_TIMEOUT   (LIBUSB_TIMEOUT_MS)
 
#define STLINK_REGSEL_IS_FPU(x)   ((x) > 0x1F)
 
#define STLINK_RX_EP   (1|ENDPOINT_IN)
 
#define STLINK_SERIAL_LEN   24
 
#define STLINK_SG_SIZE   (31)
 
#define STLINK_SWD_AP_ERROR   0x12
 
#define STLINK_SWD_AP_FAULT   0x11
 
#define STLINK_SWD_AP_PARITY_ERROR   0x13
 
#define STLINK_SWD_AP_STICKY_ERROR   0x19
 
#define STLINK_SWD_AP_STICKYORUN_ERROR   0x1a
 
#define STLINK_SWD_AP_WAIT   0x10
 
#define STLINK_SWD_AP_WDATA_ERROR   0x18
 
#define STLINK_SWD_DP_ERROR   0x16
 
#define STLINK_SWD_DP_FAULT   0x15
 
#define STLINK_SWD_DP_PARITY_ERROR   0x17
 
#define STLINK_SWD_DP_WAIT   0x14
 
#define STLINK_SWIM_ASSERT_RESET   0x07
 
#define STLINK_SWIM_BUSY   0x01
 
#define STLINK_SWIM_COMMAND   0xF4
 
#define STLINK_SWIM_DATA_SIZE   STLINK_DATA_SIZE
 
#define STLINK_SWIM_DEASSERT_RESET   0x08
 
#define STLINK_SWIM_ENTER   0x00
 
#define STLINK_SWIM_ENTER_SEQ   0x04
 
#define STLINK_SWIM_ERR_OK   0x00
 
#define STLINK_SWIM_EXIT   0x01
 
#define STLINK_SWIM_GEN_RST   0x05
 
#define STLINK_SWIM_READ_CAP   0x02
 
#define STLINK_SWIM_READBUF   0x0c
 
#define STLINK_SWIM_READMEM   0x0b
 
#define STLINK_SWIM_READSTATUS   0x09
 
#define STLINK_SWIM_RESET   0x06
 
#define STLINK_SWIM_SPEED   0x03
 
#define STLINK_SWIM_WRITEMEM   0x0a
 
#define STLINK_TCP_CMD_CLOSE_DEV   0x04
 
#define STLINK_TCP_CMD_GET_DEV_INFO   0x02
 
#define STLINK_TCP_CMD_GET_NB_DEV   0x01
 
#define STLINK_TCP_CMD_GET_NB_OF_DEV_CLIENTS   0x07
 
#define STLINK_TCP_CMD_GET_SERVER_VERSION   0x06
 
#define STLINK_TCP_CMD_OPEN_DEV   0x03
 
#define STLINK_TCP_CMD_REFRESH_DEVICE_LIST   0x00
 
#define STLINK_TCP_CMD_SEND_USB_CMD   0x05
 
#define STLINK_TCP_RECV_BUFFER_SIZE   10240
 
#define STLINK_TCP_REQUEST_READ   1
 
#define STLINK_TCP_REQUEST_READ_SWO   3
 
#define STLINK_TCP_REQUEST_WRITE   0
 
#define STLINK_TCP_SEND_BUFFER_SIZE   10240
 
#define STLINK_TCP_SERIAL_SIZE   32
 
#define STLINK_TCP_SS_BAD_PARAMETER   0x00001002
 
#define STLINK_TCP_SS_CMD_NOT_AVAILABLE   0x00001053
 
#define STLINK_TCP_SS_MEMORY_PROBLEM   0x00001000
 
#define STLINK_TCP_SS_OK   0x00000001
 
#define STLINK_TCP_SS_OPEN_ERR   0x00001003
 
#define STLINK_TCP_SS_SIZE   4
 
#define STLINK_TCP_SS_TCP_BUSY   0x00002004
 
#define STLINK_TCP_SS_TCP_CANT_CONNECT   0x00002002
 
#define STLINK_TCP_SS_TCP_CLOSE_ERROR   0x00002003
 
#define STLINK_TCP_SS_TCP_ERROR   0x00002001
 
#define STLINK_TCP_SS_TIMEOUT   0x00001001
 
#define STLINK_TCP_SS_TRUNCATED_DATA   0x00001052
 
#define STLINK_TCP_SS_WIN32_ERROR   0x00010000
 
#define STLINK_TCP_USB_CMD_SIZE   32
 
#define STLINK_TRACE_EP   (3|ENDPOINT_IN)
 
#define STLINK_TRACE_MAX_HZ   2000000
 
#define STLINK_TRACE_SIZE   4096
 
#define STLINK_TX_EP   (2|ENDPOINT_OUT)
 
#define STLINK_V1_PID   (0x3744)
 
#define STLINK_V2_1_NO_MSD_PID   (0x3752)
 
#define STLINK_V2_1_PID   (0x374B)
 
#define STLINK_V2_1_TRACE_EP   (2|ENDPOINT_IN)
 
#define STLINK_V2_1_TX_EP   (1|ENDPOINT_OUT)
 
#define STLINK_V2_PID   (0x3748)
 
#define STLINK_V2_RW_MISC_SIZE   (64)
 
#define STLINK_V3_2VCP_PID   (0x3753)
 
#define STLINK_V3_MAX_FREQ_NB   10
 
#define STLINK_V3_RW_MISC_SIZE   (1227)
 
#define STLINK_V3_TRACE_MAX_HZ   24000000
 
#define STLINK_V3_USBLOADER_PID   (0x374D)
 
#define STLINK_V3E_NO_MSD_PID   (0x3754)
 
#define STLINK_V3E_PID   (0x374E)
 
#define STLINK_V3S_PID   (0x374F)
 
#define STLINK_WRITE_TIMEOUT   (LIBUSB_TIMEOUT_MS)
 
#define STLINKV3_MAX_RW8   (512)
 

Enumerations

enum  queue_cmd {
  CMD_DP_READ = 1 , CMD_DP_WRITE , CMD_AP_READ , CMD_AP_WRITE ,
  CMD_MEM_AP_READ8 = 0x10 + 1 , CMD_MEM_AP_READ16 = 0x10 + 2 , CMD_MEM_AP_READ32 = 0x10 + 4 , CMD_MEM_AP_WRITE8 = 0x20 + 1 ,
  CMD_MEM_AP_WRITE16 = 0x20 + 2 , CMD_MEM_AP_WRITE32 = 0x20 + 4
}
 
enum  stlink_jtag_api_version { STLINK_JTAG_API_V1 = 1 , STLINK_JTAG_API_V2 , STLINK_JTAG_API_V3 }
 
enum  stlink_mode {
  STLINK_MODE_UNKNOWN = 0 , STLINK_MODE_DFU , STLINK_MODE_MASS , STLINK_MODE_DEBUG_JTAG ,
  STLINK_MODE_DEBUG_SWD , STLINK_MODE_DEBUG_SWIM
}
 

Functions

 __attribute__ ((unused))
 
 COMMAND_HANDLER (stlink_dap_backend_command)
 
 COMMAND_HANDLER (stlink_dap_cmd_command)
 
 COMMAND_HANDLER (stlink_dap_vid_pid)
 
static DECLARE_BITMAP (opened_ap, DP_APSEL_MAX+1)
 
static int stlink_close (void *handle)
 
static int stlink_cmd_allow_retry (void *handle, const uint8_t *buf, int size)
 Issue an STLINK command via USB transfer, with retries on any wait status responses. More...
 
static int stlink_config_trace (void *handle, bool enabled, enum tpiu_pin_protocol pin_protocol, uint32_t port_size, unsigned int *trace_freq, unsigned int traceclkin_freq, uint16_t *prescaler)
 
static int stlink_dap_ap_read (struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
 
static int stlink_dap_ap_write (struct adiv5_ap *ap, unsigned int reg, uint32_t data)
 
static int stlink_dap_check_reconnect (struct adiv5_dap *dap)
 
static int stlink_dap_closeall_ap (void)
 
static int stlink_dap_config_trace (bool enabled, enum tpiu_pin_protocol pin_protocol, uint32_t port_size, unsigned int *trace_freq, unsigned int traceclkin_freq, uint16_t *prescaler)
 
static int stlink_dap_dp_read (struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
 
static int stlink_dap_dp_write (struct adiv5_dap *dap, unsigned int reg, uint32_t data)
 
static int stlink_dap_get_and_clear_error (void)
 
static int stlink_dap_get_error (void)
 
static int stlink_dap_init (void)
 
static int stlink_dap_khz (int khz, int *jtag_speed)
 
static int stlink_dap_op_connect (struct adiv5_dap *dap)
 
static int stlink_dap_op_queue_ap_abort (struct adiv5_dap *dap, uint8_t *ack)
 
static int stlink_dap_op_queue_ap_read (struct adiv5_ap *ap, unsigned int reg, uint32_t *data)
 
static int stlink_dap_op_queue_ap_write (struct adiv5_ap *ap, unsigned int reg, uint32_t data)
 
static int stlink_dap_op_queue_dp_read (struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
 
static int stlink_dap_op_queue_dp_write (struct adiv5_dap *dap, unsigned int reg, uint32_t data)
 
static int stlink_dap_op_queue_run (struct adiv5_dap *dap)
 
static void stlink_dap_op_quit (struct adiv5_dap *dap)
 
static int stlink_dap_op_send_sequence (struct adiv5_dap *dap, enum swd_special_seq seq)
 
static int stlink_dap_open_ap (unsigned short apsel)
 
static int stlink_dap_quit (void)
 
static int stlink_dap_record_error (int error)
 
static int stlink_dap_reinit_interface (void)
 
static int stlink_dap_reset (int req_trst, int req_srst)
 
static int stlink_dap_run_finalize (struct adiv5_dap *dap)
 
static void stlink_dap_run_internal (struct adiv5_dap *dap)
 
static int stlink_dap_speed (int speed)
 
static int stlink_dap_speed_div (int speed, int *khz)
 
static int stlink_dap_trace_read (uint8_t *buf, size_t *size)
 
static void stlink_dump_speed_map (const struct speed_map *map, unsigned int map_size)
 
static int stlink_get_com_freq (void *handle, bool is_jtag, struct speed_map *map)
 
static enum stlink_mode stlink_get_mode (enum hl_transports t)
 
static int stlink_match_speed_map (const struct speed_map *map, unsigned int map_size, int khz, bool query)
 
static uint32_t stlink_max_block_size (uint32_t tar_autoincr_block, uint32_t address)
 
static int stlink_open (struct hl_interface_param_s *param, enum stlink_mode mode, void **fd)
 
static int stlink_read_dap_register (void *handle, unsigned short dap_port, unsigned short addr, uint32_t *val)
 
static int stlink_set_com_freq (void *handle, bool is_jtag, unsigned int frequency)
 
static int stlink_speed (void *handle, int khz, bool query)
 
static int stlink_speed_jtag (void *handle, int khz, bool query)
 
static int stlink_speed_swd (void *handle, int khz, bool query)
 
static int stlink_speed_swim (void *handle, int khz, bool query)
 
static int stlink_speed_v3 (void *handle, bool is_jtag, int khz, bool query)
 
static int stlink_swim_assert_reset (void *handle, int reset)
 
static int stlink_swim_enter (void *handle)
 
static int stlink_swim_generate_rst (void *handle)
 
static int stlink_swim_op_read_mem (uint32_t addr, uint32_t size, uint32_t count, uint8_t *buffer)
 
static int stlink_swim_op_reconnect (void)
 
static int stlink_swim_op_srst (void)
 
static int stlink_swim_op_write_mem (uint32_t addr, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int stlink_swim_readbytes (void *handle, uint32_t addr, uint32_t len, uint8_t *data)
 
static int stlink_swim_resync (void *handle)
 
static int stlink_swim_speed (void *handle, int speed)
 
static int stlink_swim_status (void *handle)
 
static int stlink_swim_writebytes (void *handle, uint32_t addr, uint32_t len, const uint8_t *data)
 
static int stlink_tcp_close (void *handle)
 
static int stlink_tcp_open (void *handle, struct hl_interface_param_s *param)
 
static int stlink_tcp_read_trace (void *handle, const uint8_t *buf, int size)
 
static int stlink_tcp_send_cmd (void *handle, int send_size, int recv_size, bool check_tcp_status)
 
static int stlink_tcp_xfer_noerrcheck (void *handle, const uint8_t *buf, int size)
 
static int stlink_usb_assert_srst (void *handle, int srst)
 
static unsigned int stlink_usb_block (void *handle)
 
static int stlink_usb_buf_rw_segment (void *handle, const struct dap_queue *q, unsigned int count)
 
static int stlink_usb_check_voltage (void *handle, float *target_voltage)
 
static int stlink_usb_close (void *handle)
 
static int stlink_usb_close_access_port (void *handle, unsigned char ap_num)
 
static int stlink_usb_count_buf_rw_queue (const struct dap_queue *q, unsigned int len)
 
static int stlink_usb_count_misc_rw_queue (void *handle, const struct dap_queue *q, unsigned int len, unsigned int *pkt_items)
 
static int stlink_usb_current_mode (void *handle, uint8_t *mode)
 
static int stlink_usb_error_check (void *handle)
 Converts an STLINK status code held in the first byte of a response to an openocd error, logs any error/wait status as debug output. More...
 
static int stlink_usb_exit_mode (void *handle)
 
static char * stlink_usb_get_alternate_serial (struct libusb_device_handle *device, struct libusb_device_descriptor *dev_desc)
 
static int stlink_usb_get_rw_status (void *handle)
 
static int stlink_usb_halt (void *handle)
 
static int stlink_usb_hl_open (struct hl_interface_param_s *param, void **fd)
 
static int stlink_usb_idcode (void *handle, uint32_t *idcode)
 
static int stlink_usb_init_access_port (void *handle, unsigned char ap_num)
 
static void stlink_usb_init_buffer (void *handle, uint8_t direction, uint32_t size)
 
static int stlink_usb_init_mode (void *handle, bool connect_under_reset, int initial_interface_speed)
 
static int stlink_usb_mem_rw_queue (void *handle, const struct dap_queue *q, unsigned int len, unsigned int *skip)
 
static int stlink_usb_misc_rw_segment (void *handle, const struct dap_queue *q, unsigned int len, unsigned int items)
 
static int stlink_usb_mode_enter (void *handle, enum stlink_mode type)
 
static int stlink_usb_mode_leave (void *handle, enum stlink_mode type)
 
static int stlink_usb_open (void *handle, struct hl_interface_param_s *param)
 
static int stlink_usb_open_ap (void *handle, unsigned short apsel)
 
static int stlink_usb_override_target (const char *targetname)
 
static int stlink_usb_read_ap_mem (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint32_t size, uint32_t count, uint8_t *buffer)
 
static int stlink_usb_read_mem (void *handle, uint32_t addr, uint32_t size, uint32_t count, uint8_t *buffer)
 
static int stlink_usb_read_mem16 (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, uint8_t *buffer)
 
static int stlink_usb_read_mem32 (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, uint8_t *buffer)
 
static int stlink_usb_read_mem32_noaddrinc (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, uint8_t *buffer)
 
static int stlink_usb_read_mem8 (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, uint8_t *buffer)
 
static int stlink_usb_read_reg (void *handle, unsigned int regsel, uint32_t *val)
 
static int stlink_usb_read_regs (void *handle)
 
static int stlink_usb_read_trace (void *handle, const uint8_t *buf, int size)
 
static int stlink_usb_reset (void *handle)
 
static int stlink_usb_run (void *handle)
 
static int stlink_usb_rw_misc_in (void *handle, uint32_t items, uint8_t *buffer)
 
static int stlink_usb_rw_misc_out (void *handle, uint32_t items, const uint8_t *buffer)
 
static void stlink_usb_set_cbw_transfer_datalength (void *handle, uint32_t size)
 
static int stlink_usb_set_jtagclk (void *handle, uint16_t clk_divisor)
 
static int stlink_usb_set_swdclk (void *handle, uint16_t clk_divisor)
 
static enum target_state stlink_usb_state (void *handle)
 
static int stlink_usb_step (void *handle)
 
static void stlink_usb_trace_disable (void *handle)
 
static int stlink_usb_trace_enable (void *handle)
 
static int stlink_usb_trace_read (void *handle, uint8_t *buf, size_t *size)
 
static int stlink_usb_usb_close (void *handle)
 
static int stlink_usb_usb_open (void *handle, struct hl_interface_param_s *param)
 
static int stlink_usb_usb_read_trace (void *handle, const uint8_t *buf, int size)
 
static int stlink_usb_usb_xfer_noerrcheck (void *handle, const uint8_t *buf, int size)
 
static enum target_state stlink_usb_v2_get_status (void *handle)
 
static int stlink_usb_v2_read_debug_reg (void *handle, uint32_t addr, uint32_t *val)
 
static int stlink_usb_version (void *handle)
 
static int stlink_usb_write_ap_mem (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int stlink_usb_write_debug_reg (void *handle, uint32_t addr, uint32_t val)
 
static int stlink_usb_write_mem (void *handle, uint32_t addr, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int stlink_usb_write_mem16 (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, const uint8_t *buffer)
 
static int stlink_usb_write_mem32 (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, const uint8_t *buffer)
 
static int stlink_usb_write_mem32_noaddrinc (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, const uint8_t *buffer)
 
static int stlink_usb_write_mem8 (void *handle, uint8_t ap_num, uint32_t csw, uint32_t addr, uint16_t len, const uint8_t *buffer)
 
static int stlink_usb_write_reg (void *handle, unsigned int regsel, uint32_t val)
 
static int stlink_usb_xfer_errcheck (void *handle, const uint8_t *buf, int size)
 
static int stlink_usb_xfer_noerrcheck (void *handle, const uint8_t *buf, int size)
 
static int stlink_usb_xfer_rw (void *handle, int cmdsize, const uint8_t *buf, int size)
 
static void stlink_usb_xfer_v1_create_cmd (void *handle, uint8_t direction, uint32_t size)
 
static int stlink_usb_xfer_v1_get_sense (void *handle)
 
static int stlink_usb_xfer_v1_get_status (void *handle)
 
static int stlink_write_dap_register (void *handle, unsigned short dap_port, unsigned short addr, uint32_t val)
 

Variables

static uint32_t last_csw_default [DP_APSEL_MAX+1]
 
struct adapter_driver stlink_dap_adapter_driver
 
static const struct command_registration stlink_dap_command_handlers []
 
static int stlink_dap_error = ERROR_OK
 
static struct stlink_usb_handle_sstlink_dap_handle
 
static const struct dap_ops stlink_dap_ops
 
static struct hl_interface_param_s stlink_dap_param
 
static const struct command_registration stlink_dap_subcommand_handlers []
 
static const char *const stlink_dap_transport [] = { "dapdirect_swd", "dapdirect_jtag", "swim", NULL }
 
static const struct speed_map stlink_khz_to_speed_map_jtag []
 
static const struct speed_map stlink_khz_to_speed_map_swd []
 
static const struct swim_driver stlink_swim_ops
 
static struct stlink_backend_s stlink_tcp_backend
 
static struct stlink_backend_s stlink_usb_backend
 
struct hl_layout_api_s stlink_usb_layout_api
 

Macro Definition Documentation

◆ BYTES_PER_LINE

#define BYTES_PER_LINE   16

Definition at line 4999 of file stlink_usb.c.

◆ CMD_MEM_AP_2_SIZE

#define CMD_MEM_AP_2_SIZE (   cmd)    ((cmd) & 7)

Definition at line 207 of file stlink_usb.c.

◆ ENDPOINT_IN

#define ENDPOINT_IN   0x80

Definition at line 60 of file stlink_usb.c.

◆ ENDPOINT_OUT

#define ENDPOINT_OUT   0x00

Definition at line 61 of file stlink_usb.c.

◆ MAX_QUEUE_DEPTH

#define MAX_QUEUE_DEPTH   (4096)

Definition at line 185 of file stlink_usb.c.

◆ MAX_WAIT_RETRIES

#define MAX_WAIT_RETRIES   8

Definition at line 106 of file stlink_usb.c.

◆ OPENOCD_STLINK_TCP_API_VERSION

#define OPENOCD_STLINK_TCP_API_VERSION   1

Definition at line 476 of file stlink_usb.c.

◆ REQUEST_SENSE

#define REQUEST_SENSE   0x03

Definition at line 462 of file stlink_usb.c.

◆ REQUEST_SENSE_LENGTH

#define REQUEST_SENSE_LENGTH   18

Definition at line 463 of file stlink_usb.c.

◆ RW_MISC_CMD_ADDRESS

#define RW_MISC_CMD_ADDRESS   1

Definition at line 4329 of file stlink_usb.c.

◆ RW_MISC_CMD_APNUM

#define RW_MISC_CMD_APNUM   5

Definition at line 4332 of file stlink_usb.c.

◆ RW_MISC_CMD_READ

#define RW_MISC_CMD_READ   3

Definition at line 4331 of file stlink_usb.c.

◆ RW_MISC_CMD_WRITE

#define RW_MISC_CMD_WRITE   2

Definition at line 4330 of file stlink_usb.c.

◆ STLINK_APIV3_GET_COM_FREQ

#define STLINK_APIV3_GET_COM_FREQ   0x62

Definition at line 446 of file stlink_usb.c.

◆ STLINK_APIV3_GET_VERSION_EX

#define STLINK_APIV3_GET_VERSION_EX   0xFB

Definition at line 448 of file stlink_usb.c.

◆ STLINK_APIV3_SET_COM_FREQ

#define STLINK_APIV3_SET_COM_FREQ   0x61

Definition at line 445 of file stlink_usb.c.

◆ STLINK_BAD_AP_ERROR

#define STLINK_BAD_AP_ERROR   0x1d

Definition at line 334 of file stlink_usb.c.

◆ STLINK_CMD_SIZE_V1

#define STLINK_CMD_SIZE_V1   (10)

Definition at line 76 of file stlink_usb.c.

◆ STLINK_CMD_SIZE_V2

#define STLINK_CMD_SIZE_V2   (16)

Definition at line 75 of file stlink_usb.c.

◆ STLINK_CORE_HALTED

#define STLINK_CORE_HALTED   0x81

Definition at line 337 of file stlink_usb.c.

◆ STLINK_CORE_RUNNING

#define STLINK_CORE_RUNNING   0x80

Definition at line 336 of file stlink_usb.c.

◆ STLINK_CORE_STAT_UNKNOWN

#define STLINK_CORE_STAT_UNKNOWN   -1

Definition at line 338 of file stlink_usb.c.

◆ STLINK_DATA_SIZE

#define STLINK_DATA_SIZE   (6144)

Definition at line 74 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_CLEARFP

#define STLINK_DEBUG_APIV1_CLEARFP   0x0e

Definition at line 400 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_ENTER

#define STLINK_DEBUG_APIV1_ENTER   0x20

Definition at line 408 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_READALLREGS

#define STLINK_DEBUG_APIV1_READALLREGS   0x04

Definition at line 390 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_READREG

#define STLINK_DEBUG_APIV1_READREG   0x05

Definition at line 391 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_RESETSYS

#define STLINK_DEBUG_APIV1_RESETSYS   0x03

Definition at line 389 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_SETFP

#define STLINK_DEBUG_APIV1_SETFP   0x0b

Definition at line 397 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_SETWATCHPOINT

#define STLINK_DEBUG_APIV1_SETWATCHPOINT   0x10

Definition at line 402 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_WRITEDEBUGREG

#define STLINK_DEBUG_APIV1_WRITEDEBUGREG   0x0f

Definition at line 401 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV1_WRITEREG

#define STLINK_DEBUG_APIV1_WRITEREG   0x06

Definition at line 392 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_CLOSE_AP_DBG

#define STLINK_DEBUG_APIV2_CLOSE_AP_DBG   0x4C

Definition at line 437 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_DRIVE_NRST

#define STLINK_DEBUG_APIV2_DRIVE_NRST   0x3C

Definition at line 422 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_DRIVE_NRST_HIGH

#define STLINK_DEBUG_APIV2_DRIVE_NRST_HIGH   0x01

Definition at line 451 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_DRIVE_NRST_LOW

#define STLINK_DEBUG_APIV2_DRIVE_NRST_LOW   0x00

Definition at line 450 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_DRIVE_NRST_PULSE

#define STLINK_DEBUG_APIV2_DRIVE_NRST_PULSE   0x02

Definition at line 452 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_ENTER

#define STLINK_DEBUG_APIV2_ENTER   0x30

Definition at line 412 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_GET_TRACE_NB

#define STLINK_DEBUG_APIV2_GET_TRACE_NB   0x42

Definition at line 428 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_GETLASTRWSTATUS

#define STLINK_DEBUG_APIV2_GETLASTRWSTATUS   0x3B

Definition at line 421 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_GETLASTRWSTATUS2

#define STLINK_DEBUG_APIV2_GETLASTRWSTATUS2   0x3E

Definition at line 424 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_INIT_AP

#define STLINK_DEBUG_APIV2_INIT_AP   0x4B

Definition at line 436 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_JTAG_SET_FREQ

#define STLINK_DEBUG_APIV2_JTAG_SET_FREQ   0x44

Definition at line 430 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_READ_DAP_REG

#define STLINK_DEBUG_APIV2_READ_DAP_REG   0x45

Definition at line 431 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_READ_IDCODES

#define STLINK_DEBUG_APIV2_READ_IDCODES   0x31

Definition at line 413 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_READALLREGS

#define STLINK_DEBUG_APIV2_READALLREGS   0x3A

Definition at line 420 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_READDEBUGREG

#define STLINK_DEBUG_APIV2_READDEBUGREG   0x36

Definition at line 418 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_READMEM_16BIT

#define STLINK_DEBUG_APIV2_READMEM_16BIT   0x47

Definition at line 433 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_READREG

#define STLINK_DEBUG_APIV2_READREG   0x33

Definition at line 415 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_RESETSYS

#define STLINK_DEBUG_APIV2_RESETSYS   0x32

Definition at line 414 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_RW_MISC_IN

#define STLINK_DEBUG_APIV2_RW_MISC_IN   0x52

Definition at line 441 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_RW_MISC_OUT

#define STLINK_DEBUG_APIV2_RW_MISC_OUT   0x51

Definition at line 440 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_START_TRACE_RX

#define STLINK_DEBUG_APIV2_START_TRACE_RX   0x40

Definition at line 426 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_STOP_TRACE_RX

#define STLINK_DEBUG_APIV2_STOP_TRACE_RX   0x41

Definition at line 427 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_SWD_SET_FREQ

#define STLINK_DEBUG_APIV2_SWD_SET_FREQ   0x43

Definition at line 429 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_WRITE_DAP_REG

#define STLINK_DEBUG_APIV2_WRITE_DAP_REG   0x46

Definition at line 432 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_WRITEDEBUGREG

#define STLINK_DEBUG_APIV2_WRITEDEBUGREG   0x35

Definition at line 417 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_WRITEMEM_16BIT

#define STLINK_DEBUG_APIV2_WRITEMEM_16BIT   0x48

Definition at line 434 of file stlink_usb.c.

◆ STLINK_DEBUG_APIV2_WRITEREG

#define STLINK_DEBUG_APIV2_WRITEREG   0x34

Definition at line 416 of file stlink_usb.c.

◆ STLINK_DEBUG_COMMAND

#define STLINK_DEBUG_COMMAND   0xF2

Definition at line 341 of file stlink_usb.c.

◆ STLINK_DEBUG_ENTER_JTAG_NO_RESET

#define STLINK_DEBUG_ENTER_JTAG_NO_RESET   0xa4

Definition at line 406 of file stlink_usb.c.

◆ STLINK_DEBUG_ENTER_JTAG_RESET

#define STLINK_DEBUG_ENTER_JTAG_RESET   0x00

Definition at line 404 of file stlink_usb.c.

◆ STLINK_DEBUG_ENTER_SWD_NO_RESET

#define STLINK_DEBUG_ENTER_SWD_NO_RESET   0xa3

Definition at line 405 of file stlink_usb.c.

◆ STLINK_DEBUG_ERR_FAULT

#define STLINK_DEBUG_ERR_FAULT   0x81

Definition at line 317 of file stlink_usb.c.

◆ STLINK_DEBUG_ERR_OK

#define STLINK_DEBUG_ERR_OK   0x80

Definition at line 316 of file stlink_usb.c.

◆ STLINK_DEBUG_EXIT

#define STLINK_DEBUG_EXIT   0x21

Definition at line 409 of file stlink_usb.c.

◆ STLINK_DEBUG_FORCEDEBUG

#define STLINK_DEBUG_FORCEDEBUG   0x02

Definition at line 388 of file stlink_usb.c.

◆ STLINK_DEBUG_GETSTATUS

#define STLINK_DEBUG_GETSTATUS   0x01

Definition at line 387 of file stlink_usb.c.

◆ STLINK_DEBUG_PORT_ACCESS

#define STLINK_DEBUG_PORT_ACCESS   0xffff

Definition at line 454 of file stlink_usb.c.

◆ STLINK_DEBUG_READCOREID

#define STLINK_DEBUG_READCOREID   0x22

Definition at line 410 of file stlink_usb.c.

◆ STLINK_DEBUG_READMEM_32BIT

#define STLINK_DEBUG_READMEM_32BIT   0x07

Definition at line 393 of file stlink_usb.c.

◆ STLINK_DEBUG_READMEM_32BIT_NO_ADDR_INC

#define STLINK_DEBUG_READMEM_32BIT_NO_ADDR_INC   0x54

Definition at line 443 of file stlink_usb.c.

◆ STLINK_DEBUG_READMEM_8BIT

#define STLINK_DEBUG_READMEM_8BIT   0x0c

Definition at line 398 of file stlink_usb.c.

◆ STLINK_DEBUG_RUNCORE

#define STLINK_DEBUG_RUNCORE   0x09

Definition at line 395 of file stlink_usb.c.

◆ STLINK_DEBUG_STEPCORE

#define STLINK_DEBUG_STEPCORE   0x0a

Definition at line 396 of file stlink_usb.c.

◆ STLINK_DEBUG_WRITEMEM_32BIT

#define STLINK_DEBUG_WRITEMEM_32BIT   0x08

Definition at line 394 of file stlink_usb.c.

◆ STLINK_DEBUG_WRITEMEM_32BIT_NO_ADDR_INC

#define STLINK_DEBUG_WRITEMEM_32BIT_NO_ADDR_INC   0x50

Definition at line 439 of file stlink_usb.c.

◆ STLINK_DEBUG_WRITEMEM_8BIT

#define STLINK_DEBUG_WRITEMEM_8BIT   0x0d

Definition at line 399 of file stlink_usb.c.

◆ STLINK_DEV_BOOTLOADER_MODE

#define STLINK_DEV_BOOTLOADER_MODE   0x04

Definition at line 351 of file stlink_usb.c.

◆ STLINK_DEV_DEBUG_MODE

#define STLINK_DEV_DEBUG_MODE   0x02

Definition at line 349 of file stlink_usb.c.

◆ STLINK_DEV_DFU_MODE

#define STLINK_DEV_DFU_MODE   0x00

Definition at line 347 of file stlink_usb.c.

◆ STLINK_DEV_MASS_MODE

#define STLINK_DEV_MASS_MODE   0x01

Definition at line 348 of file stlink_usb.c.

◆ STLINK_DEV_SWIM_MODE

#define STLINK_DEV_SWIM_MODE   0x03

Definition at line 350 of file stlink_usb.c.

◆ STLINK_DEV_UNKNOWN_MODE

#define STLINK_DEV_UNKNOWN_MODE   -1

Definition at line 352 of file stlink_usb.c.

◆ STLINK_DFU_COMMAND

#define STLINK_DFU_COMMAND   0xF3

Definition at line 342 of file stlink_usb.c.

◆ STLINK_DFU_EXIT

#define STLINK_DFU_EXIT   0x07

Definition at line 354 of file stlink_usb.c.

◆ STLINK_F_FIX_CLOSE_AP

#define STLINK_F_FIX_CLOSE_AP   BIT(8) /* v2>=j29 || v3 */

Definition at line 512 of file stlink_usb.c.

◆ STLINK_F_HAS_AP_INIT

#define STLINK_F_HAS_AP_INIT   BIT(7) /* v2>=j28 || v3 */

Definition at line 511 of file stlink_usb.c.

◆ STLINK_F_HAS_CSW

#define STLINK_F_HAS_CSW   STLINK_F_HAS_DPBANKSEL

Definition at line 522 of file stlink_usb.c.

◆ STLINK_F_HAS_DAP_REG

#define STLINK_F_HAS_DAP_REG   BIT(5) /* v2>=j24 || v3 */

Definition at line 509 of file stlink_usb.c.

◆ STLINK_F_HAS_DPBANKSEL

#define STLINK_F_HAS_DPBANKSEL   BIT(9) /* v2>=j32 || v3>=j2 */

Definition at line 513 of file stlink_usb.c.

◆ STLINK_F_HAS_FPU_REG

#define STLINK_F_HAS_FPU_REG   STLINK_F_HAS_GETLASTRWSTATUS2

Definition at line 518 of file stlink_usb.c.

◆ STLINK_F_HAS_GETLASTRWSTATUS2

#define STLINK_F_HAS_GETLASTRWSTATUS2   BIT(1) /* v2>=j15 || v3 */

Definition at line 505 of file stlink_usb.c.

◆ STLINK_F_HAS_JTAG_SET_FREQ

#define STLINK_F_HAS_JTAG_SET_FREQ   BIT(3) /* v2>=j24 */

Definition at line 507 of file stlink_usb.c.

◆ STLINK_F_HAS_MEM_16BIT

#define STLINK_F_HAS_MEM_16BIT   BIT(6) /* v2>=j26 || v3 */

Definition at line 510 of file stlink_usb.c.

◆ STLINK_F_HAS_MEM_RD_NO_INC

#define STLINK_F_HAS_MEM_RD_NO_INC   STLINK_F_HAS_DPBANKSEL

Definition at line 520 of file stlink_usb.c.

◆ STLINK_F_HAS_MEM_WR_NO_INC

#define STLINK_F_HAS_MEM_WR_NO_INC   STLINK_F_HAS_MEM_16BIT

Definition at line 519 of file stlink_usb.c.

◆ STLINK_F_HAS_RW8_512BYTES

#define STLINK_F_HAS_RW8_512BYTES   BIT(10) /* v3>=j6 */

Definition at line 514 of file stlink_usb.c.

◆ STLINK_F_HAS_RW_MISC

#define STLINK_F_HAS_RW_MISC   STLINK_F_HAS_DPBANKSEL

Definition at line 521 of file stlink_usb.c.

◆ STLINK_F_HAS_SWD_SET_FREQ

#define STLINK_F_HAS_SWD_SET_FREQ   BIT(2) /* v2>=j22 */

Definition at line 506 of file stlink_usb.c.

◆ STLINK_F_HAS_TARGET_VOLT

#define STLINK_F_HAS_TARGET_VOLT   STLINK_F_HAS_TRACE

Definition at line 517 of file stlink_usb.c.

◆ STLINK_F_HAS_TRACE

#define STLINK_F_HAS_TRACE   BIT(0) /* v2>=j13 || v3 */

Definition at line 504 of file stlink_usb.c.

◆ STLINK_F_QUIRK_JTAG_DP_READ

#define STLINK_F_QUIRK_JTAG_DP_READ   BIT(4) /* v2>=j24 && v2<j32 */

Definition at line 508 of file stlink_usb.c.

◆ STLINK_GET_CURRENT_MODE

#define STLINK_GET_CURRENT_MODE   0xF5

Definition at line 344 of file stlink_usb.c.

◆ STLINK_GET_TARGET_VOLTAGE

#define STLINK_GET_TARGET_VOLTAGE   0xF7

Definition at line 345 of file stlink_usb.c.

◆ STLINK_GET_VERSION

#define STLINK_GET_VERSION   0xF1

Definition at line 340 of file stlink_usb.c.

◆ STLINK_HLA_AP_NUM

#define STLINK_HLA_AP_NUM   0

Definition at line 109 of file stlink_usb.c.

◆ STLINK_HLA_CSW

#define STLINK_HLA_CSW   0

Definition at line 110 of file stlink_usb.c.

◆ STLINK_JTAG_GET_IDCODE_ERROR

#define STLINK_JTAG_GET_IDCODE_ERROR   0x09

Definition at line 322 of file stlink_usb.c.

◆ STLINK_JTAG_WRITE_ERROR

#define STLINK_JTAG_WRITE_ERROR   0x0c

Definition at line 323 of file stlink_usb.c.

◆ STLINK_JTAG_WRITE_VERIF_ERROR

#define STLINK_JTAG_WRITE_VERIF_ERROR   0x0d

Definition at line 324 of file stlink_usb.c.

◆ STLINK_MAX_RW16_32

#define STLINK_MAX_RW16_32   STLINK_DATA_SIZE

Definition at line 100 of file stlink_usb.c.

◆ STLINK_MAX_RW8

#define STLINK_MAX_RW8   (64)

Definition at line 98 of file stlink_usb.c.

◆ STLINK_READ_TIMEOUT

#define STLINK_READ_TIMEOUT   (LIBUSB_TIMEOUT_MS)

Definition at line 64 of file stlink_usb.c.

◆ STLINK_REGSEL_IS_FPU

#define STLINK_REGSEL_IS_FPU (   x)    ((x) > 0x1F)

Definition at line 524 of file stlink_usb.c.

◆ STLINK_RX_EP

#define STLINK_RX_EP   (1|ENDPOINT_IN)

Definition at line 66 of file stlink_usb.c.

◆ STLINK_SERIAL_LEN

#define STLINK_SERIAL_LEN   24

Definition at line 58 of file stlink_usb.c.

◆ STLINK_SG_SIZE

#define STLINK_SG_SIZE   (31)

Definition at line 73 of file stlink_usb.c.

◆ STLINK_SWD_AP_ERROR

#define STLINK_SWD_AP_ERROR   0x12

Definition at line 320 of file stlink_usb.c.

◆ STLINK_SWD_AP_FAULT

#define STLINK_SWD_AP_FAULT   0x11

Definition at line 319 of file stlink_usb.c.

◆ STLINK_SWD_AP_PARITY_ERROR

#define STLINK_SWD_AP_PARITY_ERROR   0x13

Definition at line 321 of file stlink_usb.c.

◆ STLINK_SWD_AP_STICKY_ERROR

#define STLINK_SWD_AP_STICKY_ERROR   0x19

Definition at line 331 of file stlink_usb.c.

◆ STLINK_SWD_AP_STICKYORUN_ERROR

#define STLINK_SWD_AP_STICKYORUN_ERROR   0x1a

Definition at line 332 of file stlink_usb.c.

◆ STLINK_SWD_AP_WAIT

#define STLINK_SWD_AP_WAIT   0x10

Definition at line 318 of file stlink_usb.c.

◆ STLINK_SWD_AP_WDATA_ERROR

#define STLINK_SWD_AP_WDATA_ERROR   0x18

Definition at line 330 of file stlink_usb.c.

◆ STLINK_SWD_DP_ERROR

#define STLINK_SWD_DP_ERROR   0x16

Definition at line 327 of file stlink_usb.c.

◆ STLINK_SWD_DP_FAULT

#define STLINK_SWD_DP_FAULT   0x15

Definition at line 326 of file stlink_usb.c.

◆ STLINK_SWD_DP_PARITY_ERROR

#define STLINK_SWD_DP_PARITY_ERROR   0x17

Definition at line 328 of file stlink_usb.c.

◆ STLINK_SWD_DP_WAIT

#define STLINK_SWD_DP_WAIT   0x14

Definition at line 325 of file stlink_usb.c.

◆ STLINK_SWIM_ASSERT_RESET

#define STLINK_SWIM_ASSERT_RESET   0x07

Definition at line 380 of file stlink_usb.c.

◆ STLINK_SWIM_BUSY

#define STLINK_SWIM_BUSY   0x01

Definition at line 315 of file stlink_usb.c.

◆ STLINK_SWIM_COMMAND

#define STLINK_SWIM_COMMAND   0xF4

Definition at line 343 of file stlink_usb.c.

◆ STLINK_SWIM_DATA_SIZE

#define STLINK_SWIM_DATA_SIZE   STLINK_DATA_SIZE

Definition at line 101 of file stlink_usb.c.

◆ STLINK_SWIM_DEASSERT_RESET

#define STLINK_SWIM_DEASSERT_RESET   0x08

Definition at line 381 of file stlink_usb.c.

◆ STLINK_SWIM_ENTER

#define STLINK_SWIM_ENTER   0x00

Definition at line 373 of file stlink_usb.c.

◆ STLINK_SWIM_ENTER_SEQ

#define STLINK_SWIM_ENTER_SEQ   0x04

Definition at line 377 of file stlink_usb.c.

◆ STLINK_SWIM_ERR_OK

#define STLINK_SWIM_ERR_OK   0x00

Definition at line 314 of file stlink_usb.c.

◆ STLINK_SWIM_EXIT

#define STLINK_SWIM_EXIT   0x01

Definition at line 374 of file stlink_usb.c.

◆ STLINK_SWIM_GEN_RST

#define STLINK_SWIM_GEN_RST   0x05

Definition at line 378 of file stlink_usb.c.

◆ STLINK_SWIM_READ_CAP

#define STLINK_SWIM_READ_CAP   0x02

Definition at line 375 of file stlink_usb.c.

◆ STLINK_SWIM_READBUF

#define STLINK_SWIM_READBUF   0x0c

Definition at line 385 of file stlink_usb.c.

◆ STLINK_SWIM_READMEM

#define STLINK_SWIM_READMEM   0x0b

Definition at line 384 of file stlink_usb.c.

◆ STLINK_SWIM_READSTATUS

#define STLINK_SWIM_READSTATUS   0x09

Definition at line 382 of file stlink_usb.c.

◆ STLINK_SWIM_RESET

#define STLINK_SWIM_RESET   0x06

Definition at line 379 of file stlink_usb.c.

◆ STLINK_SWIM_SPEED

#define STLINK_SWIM_SPEED   0x03

Definition at line 376 of file stlink_usb.c.

◆ STLINK_SWIM_WRITEMEM

#define STLINK_SWIM_WRITEMEM   0x0a

Definition at line 383 of file stlink_usb.c.

◆ STLINK_TCP_CMD_CLOSE_DEV

#define STLINK_TCP_CMD_CLOSE_DEV   0x04

Definition at line 470 of file stlink_usb.c.

◆ STLINK_TCP_CMD_GET_DEV_INFO

#define STLINK_TCP_CMD_GET_DEV_INFO   0x02

Definition at line 468 of file stlink_usb.c.

◆ STLINK_TCP_CMD_GET_NB_DEV

#define STLINK_TCP_CMD_GET_NB_DEV   0x01

Definition at line 467 of file stlink_usb.c.

◆ STLINK_TCP_CMD_GET_NB_OF_DEV_CLIENTS

#define STLINK_TCP_CMD_GET_NB_OF_DEV_CLIENTS   0x07

Definition at line 473 of file stlink_usb.c.

◆ STLINK_TCP_CMD_GET_SERVER_VERSION

#define STLINK_TCP_CMD_GET_SERVER_VERSION   0x06

Definition at line 472 of file stlink_usb.c.

◆ STLINK_TCP_CMD_OPEN_DEV

#define STLINK_TCP_CMD_OPEN_DEV   0x03

Definition at line 469 of file stlink_usb.c.

◆ STLINK_TCP_CMD_REFRESH_DEVICE_LIST

#define STLINK_TCP_CMD_REFRESH_DEVICE_LIST   0x00

Definition at line 466 of file stlink_usb.c.

◆ STLINK_TCP_CMD_SEND_USB_CMD

#define STLINK_TCP_CMD_SEND_USB_CMD   0x05

Definition at line 471 of file stlink_usb.c.

◆ STLINK_TCP_RECV_BUFFER_SIZE

#define STLINK_TCP_RECV_BUFFER_SIZE   10240

Definition at line 484 of file stlink_usb.c.

◆ STLINK_TCP_REQUEST_READ

#define STLINK_TCP_REQUEST_READ   1

Definition at line 478 of file stlink_usb.c.

◆ STLINK_TCP_REQUEST_READ_SWO

#define STLINK_TCP_REQUEST_READ_SWO   3

Definition at line 479 of file stlink_usb.c.

◆ STLINK_TCP_REQUEST_WRITE

#define STLINK_TCP_REQUEST_WRITE   0

Definition at line 477 of file stlink_usb.c.

◆ STLINK_TCP_SEND_BUFFER_SIZE

#define STLINK_TCP_SEND_BUFFER_SIZE   10240

Definition at line 483 of file stlink_usb.c.

◆ STLINK_TCP_SERIAL_SIZE

#define STLINK_TCP_SERIAL_SIZE   32

Definition at line 482 of file stlink_usb.c.

◆ STLINK_TCP_SS_BAD_PARAMETER

#define STLINK_TCP_SS_BAD_PARAMETER   0x00001002

Definition at line 490 of file stlink_usb.c.

◆ STLINK_TCP_SS_CMD_NOT_AVAILABLE

#define STLINK_TCP_SS_CMD_NOT_AVAILABLE   0x00001053

Definition at line 493 of file stlink_usb.c.

◆ STLINK_TCP_SS_MEMORY_PROBLEM

#define STLINK_TCP_SS_MEMORY_PROBLEM   0x00001000

Definition at line 488 of file stlink_usb.c.

◆ STLINK_TCP_SS_OK

#define STLINK_TCP_SS_OK   0x00000001

Definition at line 487 of file stlink_usb.c.

◆ STLINK_TCP_SS_OPEN_ERR

#define STLINK_TCP_SS_OPEN_ERR   0x00001003

Definition at line 491 of file stlink_usb.c.

◆ STLINK_TCP_SS_SIZE

#define STLINK_TCP_SS_SIZE   4

Definition at line 480 of file stlink_usb.c.

◆ STLINK_TCP_SS_TCP_BUSY

#define STLINK_TCP_SS_TCP_BUSY   0x00002004

Definition at line 497 of file stlink_usb.c.

◆ STLINK_TCP_SS_TCP_CANT_CONNECT

#define STLINK_TCP_SS_TCP_CANT_CONNECT   0x00002002

Definition at line 495 of file stlink_usb.c.

◆ STLINK_TCP_SS_TCP_CLOSE_ERROR

#define STLINK_TCP_SS_TCP_CLOSE_ERROR   0x00002003

Definition at line 496 of file stlink_usb.c.

◆ STLINK_TCP_SS_TCP_ERROR

#define STLINK_TCP_SS_TCP_ERROR   0x00002001

Definition at line 494 of file stlink_usb.c.

◆ STLINK_TCP_SS_TIMEOUT

#define STLINK_TCP_SS_TIMEOUT   0x00001001

Definition at line 489 of file stlink_usb.c.

◆ STLINK_TCP_SS_TRUNCATED_DATA

#define STLINK_TCP_SS_TRUNCATED_DATA   0x00001052

Definition at line 492 of file stlink_usb.c.

◆ STLINK_TCP_SS_WIN32_ERROR

#define STLINK_TCP_SS_WIN32_ERROR   0x00010000

Definition at line 498 of file stlink_usb.c.

◆ STLINK_TCP_USB_CMD_SIZE

#define STLINK_TCP_USB_CMD_SIZE   32

Definition at line 481 of file stlink_usb.c.

◆ STLINK_TRACE_EP

#define STLINK_TRACE_EP   (3|ENDPOINT_IN)

Definition at line 68 of file stlink_usb.c.

◆ STLINK_TRACE_MAX_HZ

#define STLINK_TRACE_MAX_HZ   2000000

Definition at line 457 of file stlink_usb.c.

◆ STLINK_TRACE_SIZE

#define STLINK_TRACE_SIZE   4096

Definition at line 456 of file stlink_usb.c.

◆ STLINK_TX_EP

#define STLINK_TX_EP   (2|ENDPOINT_OUT)

Definition at line 67 of file stlink_usb.c.

◆ STLINK_V1_PID

#define STLINK_V1_PID   (0x3744)

Definition at line 78 of file stlink_usb.c.

◆ STLINK_V2_1_NO_MSD_PID

#define STLINK_V2_1_NO_MSD_PID   (0x3752)

Definition at line 81 of file stlink_usb.c.

◆ STLINK_V2_1_PID

#define STLINK_V2_1_PID   (0x374B)

Definition at line 80 of file stlink_usb.c.

◆ STLINK_V2_1_TRACE_EP

#define STLINK_V2_1_TRACE_EP   (2|ENDPOINT_IN)

Definition at line 71 of file stlink_usb.c.

◆ STLINK_V2_1_TX_EP

#define STLINK_V2_1_TX_EP   (1|ENDPOINT_OUT)

Definition at line 70 of file stlink_usb.c.

◆ STLINK_V2_PID

#define STLINK_V2_PID   (0x3748)

Definition at line 79 of file stlink_usb.c.

◆ STLINK_V2_RW_MISC_SIZE

#define STLINK_V2_RW_MISC_SIZE   (64)

Definition at line 4481 of file stlink_usb.c.

◆ STLINK_V3_2VCP_PID

#define STLINK_V3_2VCP_PID   (0x3753)

Definition at line 85 of file stlink_usb.c.

◆ STLINK_V3_MAX_FREQ_NB

#define STLINK_V3_MAX_FREQ_NB   10

Definition at line 460 of file stlink_usb.c.

◆ STLINK_V3_RW_MISC_SIZE

#define STLINK_V3_RW_MISC_SIZE   (1227)

Definition at line 4482 of file stlink_usb.c.

◆ STLINK_V3_TRACE_MAX_HZ

#define STLINK_V3_TRACE_MAX_HZ   24000000

Definition at line 458 of file stlink_usb.c.

◆ STLINK_V3_USBLOADER_PID

#define STLINK_V3_USBLOADER_PID   (0x374D)

Definition at line 82 of file stlink_usb.c.

◆ STLINK_V3E_NO_MSD_PID

#define STLINK_V3E_NO_MSD_PID   (0x3754)

Definition at line 86 of file stlink_usb.c.

◆ STLINK_V3E_PID

#define STLINK_V3E_PID   (0x374E)

Definition at line 83 of file stlink_usb.c.

◆ STLINK_V3S_PID

#define STLINK_V3S_PID   (0x374F)

Definition at line 84 of file stlink_usb.c.

◆ STLINK_WRITE_TIMEOUT

#define STLINK_WRITE_TIMEOUT   (LIBUSB_TIMEOUT_MS)

Definition at line 63 of file stlink_usb.c.

◆ STLINKV3_MAX_RW8

#define STLINKV3_MAX_RW8   (512)

Definition at line 99 of file stlink_usb.c.

Enumeration Type Documentation

◆ queue_cmd

enum queue_cmd
Enumerator
CMD_DP_READ 
CMD_DP_WRITE 
CMD_AP_READ 
CMD_AP_WRITE 
CMD_MEM_AP_READ8 
CMD_MEM_AP_READ16 
CMD_MEM_AP_READ32 
CMD_MEM_AP_WRITE8 
CMD_MEM_AP_WRITE16 
CMD_MEM_AP_WRITE32 

Definition at line 187 of file stlink_usb.c.

◆ stlink_jtag_api_version

Enumerator
STLINK_JTAG_API_V1 
STLINK_JTAG_API_V2 
STLINK_JTAG_API_V3 

Definition at line 112 of file stlink_usb.c.

◆ stlink_mode

Enumerator
STLINK_MODE_UNKNOWN 
STLINK_MODE_DFU 
STLINK_MODE_MASS 
STLINK_MODE_DEBUG_JTAG 
STLINK_MODE_DEBUG_SWD 
STLINK_MODE_DEBUG_SWIM 

Definition at line 118 of file stlink_usb.c.

Function Documentation

◆ __attribute__()

◆ COMMAND_HANDLER() [1/3]

◆ COMMAND_HANDLER() [2/3]

◆ COMMAND_HANDLER() [3/3]

◆ DECLARE_BITMAP()

static DECLARE_BITMAP ( opened_ap  ,
DP_APSEL_MAX 1 
)
static

◆ stlink_close()

static int stlink_close ( void *  handle)
static

Definition at line 3258 of file stlink_usb.c.

References ERROR_OK, and stlink_usb_close().

Referenced by stlink_dap_quit(), and stlink_open().

◆ stlink_cmd_allow_retry()

static int stlink_cmd_allow_retry ( void *  handle,
const uint8_t *  buf,
int  size 
)
static

◆ stlink_config_trace()

static int stlink_config_trace ( void *  handle,
bool  enabled,
enum tpiu_pin_protocol  pin_protocol,
uint32_t  port_size,
unsigned int *  trace_freq,
unsigned int  traceclkin_freq,
uint16_t *  prescaler 
)
static

◆ stlink_dap_ap_read()

static int stlink_dap_ap_read ( struct adiv5_ap ap,
unsigned int  reg,
uint32_t *  data 
)
static

◆ stlink_dap_ap_write()

static int stlink_dap_ap_write ( struct adiv5_ap ap,
unsigned int  reg,
uint32_t  data 
)
static

◆ stlink_dap_check_reconnect()

static int stlink_dap_check_reconnect ( struct adiv5_dap dap)
static

◆ stlink_dap_closeall_ap()

static int stlink_dap_closeall_ap ( void  )
static

◆ stlink_dap_config_trace()

static int stlink_dap_config_trace ( bool  enabled,
enum tpiu_pin_protocol  pin_protocol,
uint32_t  port_size,
unsigned int *  trace_freq,
unsigned int  traceclkin_freq,
uint16_t *  prescaler 
)
static

Definition at line 4933 of file stlink_usb.c.

References stlink_config_trace(), and stlink_dap_handle.

◆ stlink_dap_dp_read()

◆ stlink_dap_dp_write()

◆ stlink_dap_get_and_clear_error()

static int stlink_dap_get_and_clear_error ( void  )
static

Definition at line 4057 of file stlink_usb.c.

References ERROR_OK, and stlink_dap_error.

Referenced by stlink_dap_run_finalize().

◆ stlink_dap_get_error()

static int stlink_dap_get_error ( void  )
static

◆ stlink_dap_init()

◆ stlink_dap_khz()

static int stlink_dap_khz ( int  khz,
int *  jtag_speed 
)
static

Definition at line 5144 of file stlink_usb.c.

References ERROR_FAIL, ERROR_OK, LOG_ERROR, stlink_dap_handle, and stlink_speed().

◆ stlink_dap_op_connect()

◆ stlink_dap_op_queue_ap_abort()

static int stlink_dap_op_queue_ap_abort ( struct adiv5_dap dap,
uint8_t *  ack 
)
static

Definition at line 4323 of file stlink_usb.c.

References ERROR_OK, and LOG_WARNING.

◆ stlink_dap_op_queue_ap_read()

◆ stlink_dap_op_queue_ap_write()

◆ stlink_dap_op_queue_dp_read()

static int stlink_dap_op_queue_dp_read ( struct adiv5_dap dap,
unsigned int  reg,
uint32_t *  data 
)
static

◆ stlink_dap_op_queue_dp_write()

static int stlink_dap_op_queue_dp_write ( struct adiv5_dap dap,
unsigned int  reg,
uint32_t  data 
)
static

◆ stlink_dap_op_queue_run()

static int stlink_dap_op_queue_run ( struct adiv5_dap dap)
static

◆ stlink_dap_op_quit()

static void stlink_dap_op_quit ( struct adiv5_dap dap)
static

Definition at line 4685 of file stlink_usb.c.

References ERROR_OK, LOG_ERROR, and stlink_dap_closeall_ap().

◆ stlink_dap_op_send_sequence()

static int stlink_dap_op_send_sequence ( struct adiv5_dap dap,
enum swd_special_seq  seq 
)
static

Definition at line 4210 of file stlink_usb.c.

References ERROR_OK.

◆ stlink_dap_open_ap()

static int stlink_dap_open_ap ( unsigned short  apsel)
static

◆ stlink_dap_quit()

static int stlink_dap_quit ( void  )
static

Definition at line 5114 of file stlink_usb.c.

References LOG_DEBUG, stlink_close(), and stlink_dap_handle.

◆ stlink_dap_record_error()

static int stlink_dap_record_error ( int  error)
static

◆ stlink_dap_reinit_interface()

◆ stlink_dap_reset()

static int stlink_dap_reset ( int  req_trst,
int  req_srst 
)
static

◆ stlink_dap_run_finalize()

◆ stlink_dap_run_internal()

◆ stlink_dap_speed()

static int stlink_dap_speed ( int  speed)
static

◆ stlink_dap_speed_div()

static int stlink_dap_speed_div ( int  speed,
int *  khz 
)
static

Definition at line 5156 of file stlink_usb.c.

◆ stlink_dap_trace_read()

static int stlink_dap_trace_read ( uint8_t *  buf,
size_t *  size 
)
static

Definition at line 4943 of file stlink_usb.c.

References size, stlink_dap_handle, and stlink_usb_trace_read().

◆ stlink_dump_speed_map()

static void stlink_dump_speed_map ( const struct speed_map map,
unsigned int  map_size 
)
static

Definition at line 3089 of file stlink_usb.c.

References LOG_DEBUG.

Referenced by stlink_usb_init_mode().

◆ stlink_get_com_freq()

◆ stlink_get_mode()

static enum stlink_mode stlink_get_mode ( enum hl_transports  t)
static

Definition at line 1631 of file stlink_usb.c.

Referenced by stlink_usb_hl_open().

◆ stlink_match_speed_map()

static int stlink_match_speed_map ( const struct speed_map map,
unsigned int  map_size,
int  khz,
bool  query 
)
static

Definition at line 3001 of file stlink_usb.c.

References LOG_INFO, and speed_map::speed.

Referenced by stlink_speed_jtag(), stlink_speed_swd(), and stlink_speed_v3().

◆ stlink_max_block_size()

static uint32_t stlink_max_block_size ( uint32_t  tar_autoincr_block,
uint32_t  address 
)
static

Definition at line 2797 of file stlink_usb.c.

Referenced by stlink_usb_read_ap_mem(), and stlink_usb_write_ap_mem().

◆ stlink_open()

◆ stlink_read_dap_register()

◆ stlink_set_com_freq()

◆ stlink_speed()

◆ stlink_speed_jtag()

static int stlink_speed_jtag ( void *  handle,
int  khz,
bool  query 
)
static

◆ stlink_speed_swd()

static int stlink_speed_swd ( void *  handle,
int  khz,
bool  query 
)
static

◆ stlink_speed_swim()

static int stlink_speed_swim ( void *  handle,
int  khz,
bool  query 
)
static

Definition at line 2983 of file stlink_usb.c.

References ERROR_OK, LOG_ERROR, stlink_swim_speed(), SWIM_FREQ_HIGH, and SWIM_FREQ_LOW.

Referenced by stlink_speed().

◆ stlink_speed_v3()

static int stlink_speed_v3 ( void *  handle,
bool  is_jtag,
int  khz,
bool  query 
)
static

◆ stlink_swim_assert_reset()

◆ stlink_swim_enter()

◆ stlink_swim_generate_rst()

◆ stlink_swim_op_read_mem()

static int stlink_swim_op_read_mem ( uint32_t  addr,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer 
)
static

◆ stlink_swim_op_reconnect()

static int stlink_swim_op_reconnect ( void  )
static

◆ stlink_swim_op_srst()

static int stlink_swim_op_srst ( void  )
static

Definition at line 4871 of file stlink_usb.c.

References stlink_dap_handle, and stlink_swim_generate_rst().

◆ stlink_swim_op_write_mem()

static int stlink_swim_op_write_mem ( uint32_t  addr,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)
static

◆ stlink_swim_readbytes()

◆ stlink_swim_resync()

◆ stlink_swim_speed()

◆ stlink_swim_status()

◆ stlink_swim_writebytes()

◆ stlink_tcp_close()

◆ stlink_tcp_open()

static int stlink_tcp_open ( void *  handle,
struct hl_interface_param_s param 
)
static

Definition at line 3460 of file stlink_usb.c.

◆ stlink_tcp_read_trace()

static int stlink_tcp_read_trace ( void *  handle,
const uint8_t *  buf,
int  size 
)
static

◆ stlink_tcp_send_cmd()

static int stlink_tcp_send_cmd ( void *  handle,
int  send_size,
int  recv_size,
bool  check_tcp_status 
)
static

◆ stlink_tcp_xfer_noerrcheck()

◆ stlink_usb_assert_srst()

◆ stlink_usb_block()

◆ stlink_usb_buf_rw_segment()

◆ stlink_usb_check_voltage()

◆ stlink_usb_close()

static int stlink_usb_close ( void *  handle)
inlinestatic

Definition at line 302 of file stlink_usb.c.

References stlink_usb_handle_s::backend, and stlink_backend_s::close.

Referenced by stlink_close().

◆ stlink_usb_close_access_port()

◆ stlink_usb_count_buf_rw_queue()

static int stlink_usb_count_buf_rw_queue ( const struct dap_queue q,
unsigned int  len 
)
static

◆ stlink_usb_count_misc_rw_queue()

◆ stlink_usb_current_mode()

◆ stlink_usb_error_check()

◆ stlink_usb_exit_mode()

◆ stlink_usb_get_alternate_serial()

static char* stlink_usb_get_alternate_serial ( struct libusb_device_handle *  device,
struct libusb_device_descriptor *  dev_desc 
)
static

Definition at line 3287 of file stlink_usb.c.

References device, LOG_ERROR, NULL, and STLINK_SERIAL_LEN.

Referenced by stlink_usb_usb_open().

◆ stlink_usb_get_rw_status()

◆ stlink_usb_halt()

◆ stlink_usb_hl_open()

static int stlink_usb_hl_open ( struct hl_interface_param_s param,
void **  fd 
)
static

Definition at line 3793 of file stlink_usb.c.

References param, stlink_get_mode(), and stlink_open().

◆ stlink_usb_idcode()

◆ stlink_usb_init_access_port()

◆ stlink_usb_init_buffer()

static void stlink_usb_init_buffer ( void *  handle,
uint8_t  direction,
uint32_t  size 
)
static

Definition at line 1233 of file stlink_usb.c.

References stlink_usb_handle_s::cmdbuf, stlink_usb_handle_s::cmdidx, stlink_usb_handle_s::databuf, direction, stlink_usb_handle_s::direction, size, stlink_usb_version::stlink, STLINK_DATA_SIZE, STLINK_SG_SIZE, stlink_usb_xfer_v1_create_cmd(), and stlink_usb_handle_s::version.

Referenced by __attribute__(), COMMAND_HANDLER(), stlink_get_com_freq(), stlink_read_dap_register(), stlink_set_com_freq(), stlink_swim_assert_reset(), stlink_swim_enter(), stlink_swim_generate_rst(), stlink_swim_readbytes(), stlink_swim_resync(), stlink_swim_speed(), stlink_swim_status(), stlink_swim_writebytes(), stlink_tcp_read_trace(), stlink_usb_assert_srst(), stlink_usb_check_voltage(), stlink_usb_close_access_port(), stlink_usb_current_mode(), stlink_usb_get_rw_status(), stlink_usb_halt(), stlink_usb_idcode(), stlink_usb_init_access_port(), stlink_usb_mode_enter(), stlink_usb_mode_leave(), stlink_usb_read_mem16(), stlink_usb_read_mem32(), stlink_usb_read_mem32_noaddrinc(), stlink_usb_read_mem8(), stlink_usb_read_reg(), stlink_usb_read_regs(), stlink_usb_reset(), stlink_usb_run(), stlink_usb_rw_misc_in(), stlink_usb_rw_misc_out(), stlink_usb_set_jtagclk(), stlink_usb_set_swdclk(), stlink_usb_state(), stlink_usb_step(), stlink_usb_trace_disable(), stlink_usb_trace_enable(), stlink_usb_v2_read_debug_reg(), stlink_usb_version(), stlink_usb_write_debug_reg(), stlink_usb_write_mem16(), stlink_usb_write_mem32(), stlink_usb_write_mem32_noaddrinc(), stlink_usb_write_mem8(), stlink_usb_write_reg(), and stlink_usb_xfer_v1_get_sense().

◆ stlink_usb_init_mode()

◆ stlink_usb_mem_rw_queue()

static int stlink_usb_mem_rw_queue ( void *  handle,
const struct dap_queue q,
unsigned int  len,
unsigned int *  skip 
)
static

◆ stlink_usb_misc_rw_segment()

◆ stlink_usb_mode_enter()

◆ stlink_usb_mode_leave()

◆ stlink_usb_open()

static int stlink_usb_open ( void *  handle,
struct hl_interface_param_s param 
)
inlinestatic

Definition at line 295 of file stlink_usb.c.

References stlink_usb_handle_s::backend, stlink_backend_s::open, and param.

Referenced by stlink_open().

◆ stlink_usb_open_ap()

static int stlink_usb_open_ap ( void *  handle,
unsigned short  apsel 
)
static

◆ stlink_usb_override_target()

static int stlink_usb_override_target ( const char *  targetname)
static

Definition at line 2978 of file stlink_usb.c.

◆ stlink_usb_read_ap_mem()

static int stlink_usb_read_ap_mem ( void *  handle,
uint8_t  ap_num,
uint32_t  csw,
uint32_t  addr,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer 
)
static

◆ stlink_usb_read_mem()

static int stlink_usb_read_mem ( void *  handle,
uint32_t  addr,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer 
)
static

Definition at line 2883 of file stlink_usb.c.

References addr, buffer, count, size, STLINK_HLA_AP_NUM, STLINK_HLA_CSW, and stlink_usb_read_ap_mem().

◆ stlink_usb_read_mem16()

◆ stlink_usb_read_mem32()

◆ stlink_usb_read_mem32_noaddrinc()

◆ stlink_usb_read_mem8()

◆ stlink_usb_read_reg()

◆ stlink_usb_read_regs()

◆ stlink_usb_read_trace()

static int stlink_usb_read_trace ( void *  handle,
const uint8_t *  buf,
int  size 
)
static

◆ stlink_usb_reset()

◆ stlink_usb_run()

◆ stlink_usb_rw_misc_in()

◆ stlink_usb_rw_misc_out()

◆ stlink_usb_set_cbw_transfer_datalength()

static void stlink_usb_set_cbw_transfer_datalength ( void *  handle,
uint32_t  size 
)
static

Definition at line 1205 of file stlink_usb.c.

References buf_set_u32(), stlink_usb_handle_s::cmdbuf, and size.

Referenced by stlink_swim_writebytes().

◆ stlink_usb_set_jtagclk()

◆ stlink_usb_set_swdclk()

◆ stlink_usb_state()

◆ stlink_usb_step()

◆ stlink_usb_trace_disable()

◆ stlink_usb_trace_enable()

◆ stlink_usb_trace_read()

static int stlink_usb_trace_read ( void *  handle,
uint8_t *  buf,
size_t *  size 
)
static

Definition at line 2069 of file stlink_usb.c.

Referenced by stlink_dap_trace_read().

◆ stlink_usb_usb_close()

◆ stlink_usb_usb_open()

◆ stlink_usb_usb_read_trace()

static int stlink_usb_usb_read_trace ( void *  handle,
const uint8_t *  buf,
int  size 
)
static

◆ stlink_usb_usb_xfer_noerrcheck()

static int stlink_usb_usb_xfer_noerrcheck ( void *  handle,
const uint8_t *  buf,
int  size 
)
static

◆ stlink_usb_v2_get_status()

static enum target_state stlink_usb_v2_get_status ( void *  handle)
static

Definition at line 2069 of file stlink_usb.c.

◆ stlink_usb_v2_read_debug_reg()

static int stlink_usb_v2_read_debug_reg ( void *  handle,
uint32_t  addr,
uint32_t *  val 
)
static

◆ stlink_usb_version()

◆ stlink_usb_write_ap_mem()

static int stlink_usb_write_ap_mem ( void *  handle,
uint8_t  ap_num,
uint32_t  csw,
uint32_t  addr,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)
static

◆ stlink_usb_write_debug_reg()

◆ stlink_usb_write_mem()

static int stlink_usb_write_mem ( void *  handle,
uint32_t  addr,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)
static

◆ stlink_usb_write_mem16()

◆ stlink_usb_write_mem32()

◆ stlink_usb_write_mem32_noaddrinc()

◆ stlink_usb_write_mem8()

◆ stlink_usb_write_reg()

◆ stlink_usb_xfer_errcheck()

◆ stlink_usb_xfer_noerrcheck()

◆ stlink_usb_xfer_rw()

◆ stlink_usb_xfer_v1_create_cmd()

static void stlink_usb_xfer_v1_create_cmd ( void *  handle,
uint8_t  direction,
uint32_t  size 
)
static

◆ stlink_usb_xfer_v1_get_sense()

◆ stlink_usb_xfer_v1_get_status()

◆ stlink_write_dap_register()

static int stlink_write_dap_register ( void *  handle,
unsigned short  dap_port,
unsigned short  addr,
uint32_t  val 
)
static

Definition at line 3976 of file stlink_usb.c.

Referenced by stlink_dap_ap_write(), and stlink_dap_dp_write().

Variable Documentation

◆ last_csw_default

uint32_t last_csw_default[DP_APSEL_MAX+1]
static

◆ stlink_dap_adapter_driver

struct adapter_driver stlink_dap_adapter_driver
Initial value:
= {
.name = "st-link",
.transports = stlink_dap_transport,
.init = stlink_dap_init,
.quit = stlink_dap_quit,
.reset = stlink_dap_reset,
.speed = stlink_dap_speed,
.speed_div = stlink_dap_speed_div,
.config_trace = stlink_dap_config_trace,
.poll_trace = stlink_dap_trace_read,
.dap_jtag_ops = &stlink_dap_ops,
.dap_swd_ops = &stlink_dap_ops,
.swim_ops = &stlink_swim_ops,
}

Definition at line 5182 of file stlink_usb.c.

◆ stlink_dap_command_handlers

const struct command_registration stlink_dap_command_handlers[]
static
Initial value:
= {
{
.name = "st-link",
.mode = COMMAND_ANY,
.help = "perform st-link management",
.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
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:235

Definition at line 5000 of file stlink_usb.c.

◆ stlink_dap_error

int stlink_dap_error = ERROR_OK
static

◆ stlink_dap_handle

◆ stlink_dap_ops

const struct dap_ops stlink_dap_ops
static
Initial value:
= {
.send_sequence = stlink_dap_op_send_sequence,
.queue_dp_read = stlink_dap_op_queue_dp_read,
.queue_dp_write = stlink_dap_op_queue_dp_write,
.queue_ap_read = stlink_dap_op_queue_ap_read,
.queue_ap_write = stlink_dap_op_queue_ap_write,
.queue_ap_abort = stlink_dap_op_queue_ap_abort,
.sync = NULL,
}
#define NULL
Definition: usb.h:16

Definition at line 5156 of file stlink_usb.c.

◆ stlink_dap_param

struct hl_interface_param_s stlink_dap_param
static

Definition at line 4042 of file stlink_usb.c.

Referenced by COMMAND_HANDLER(), stlink_dap_init(), and stlink_dap_speed().

◆ stlink_dap_subcommand_handlers

const struct command_registration stlink_dap_subcommand_handlers[]
static
Initial value:
= {
{
.name = "vid_pid",
.handler = stlink_dap_vid_pid,
.mode = COMMAND_CONFIG,
.help = "USB VID and PID of the adapter",
.usage = "(vid pid)+",
},
{
.name = "backend",
.handler = &stlink_dap_backend_command,
.mode = COMMAND_CONFIG,
.help = "select which ST-Link backend to use",
.usage = "usb | tcp [port]",
},
{
.name = "cmd",
.handler = stlink_dap_cmd_command,
.mode = COMMAND_EXEC,
.help = "send arbitrary command",
.usage = "rx_n (tx_byte)+",
},
}
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 5000 of file stlink_usb.c.

◆ stlink_dap_transport

const char* const stlink_dap_transport[] = { "dapdirect_swd", "dapdirect_jtag", "swim", NULL }
static

Definition at line 5182 of file stlink_usb.c.

◆ stlink_khz_to_speed_map_jtag

const struct speed_map stlink_khz_to_speed_map_jtag[]
static
Initial value:
= {
{9000, 4},
{4500, 8},
{2250, 16},
{1125, 32},
{562, 64},
{281, 128},
{140, 256}
}

Definition at line 308 of file stlink_usb.c.

Referenced by stlink_speed_jtag(), and stlink_usb_init_mode().

◆ stlink_khz_to_speed_map_swd

const struct speed_map stlink_khz_to_speed_map_swd[]
static
Initial value:
= {
{4000, 0},
{1800, 1},
{1200, 2},
{950, 3},
{480, 7},
{240, 15},
{125, 31},
{100, 40},
{50, 79},
{25, 158},
{15, 265},
{5, 798}
}

Definition at line 308 of file stlink_usb.c.

Referenced by stlink_speed_swd(), and stlink_usb_init_mode().

◆ stlink_swim_ops

const struct swim_driver stlink_swim_ops
static
Initial value:
= {
}

Definition at line 5156 of file stlink_usb.c.

◆ stlink_tcp_backend

struct stlink_backend_s stlink_tcp_backend
static
Initial value:
= {
.open = stlink_tcp_open,
.close = stlink_tcp_close,
.xfer_noerrcheck = stlink_tcp_xfer_noerrcheck,
.read_trace = stlink_tcp_read_trace,
}

Definition at line 3460 of file stlink_usb.c.

Referenced by stlink_open(), and stlink_usb_count_misc_rw_queue().

◆ stlink_usb_backend

struct stlink_backend_s stlink_usb_backend
static
Initial value:
= {
.xfer_noerrcheck = stlink_usb_usb_xfer_noerrcheck,
}

Definition at line 3460 of file stlink_usb.c.

Referenced by stlink_open().

◆ stlink_usb_layout_api

struct hl_layout_api_s stlink_usb_layout_api

Definition at line 3976 of file stlink_usb.c.