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

Go to the source code of this file.

Data Structures

struct  dtc_reply_queue_entry
 

Macros

#define DTC_LOAD_BUFFER   ST7_USB_BUF_EP2UIDO
 
#define DTC_STATUS_POLL_BYTE   (ST7_USB_BUF_EP0OUT + 0xff)
 
#define DTCLOAD_COMMENT   (0)
 
#define DTCLOAD_ENTRY   (1)
 
#define DTCLOAD_LOAD   (2)
 
#define DTCLOAD_LUT   (5)
 
#define DTCLOAD_LUT_START   (4)
 
#define DTCLOAD_RUN   (3)
 
#define INTERFACE_NAME   "RLink"
 
#define ST7_PA_DBGACK   ST7_PA_IO10
 
#define ST7_PA_DBGRQ   ST7_PA_IO4
 
#define ST7_PA_IO1   ST7_PA1
 
#define ST7_PA_IO10   ST7_PA7
 
#define ST7_PA_IO2   ST7_PA2
 
#define ST7_PA_IO4   ST7_PA4
 
#define ST7_PA_IO8   ST7_PA6
 
#define ST7_PA_NTRST   ST7_PA_IO1
 
#define ST7_PA_RTCK   ST7_PA_IO0
 
#define ST7_PB_IO5   ST7_PB5
 
#define ST7_PB_NSRST   ST7_PB_IO5
 
#define ST7_PC_IO3   ST7_PC2
 
#define ST7_PC_IO7   ST7_PC3
 
#define ST7_PC_IO9   ST7_PC1
 
#define ST7_PC_TCK   ST7_PC_IO7
 
#define ST7_PC_TDI   ST7_PC_IO3
 
#define ST7_PC_TDO   ST7_PC_IO9
 
#define ST7_PD_NBUSY_LED   ST7_PD0
 
#define ST7_PD_NRUN_LED   ST7_PD1
 
#define ST7_PD_VPP_SEL   ST7_PD6
 
#define ST7_PD_VPP_SHDN   ST7_PD7
 
#define ST7_PE_ADAPTER_SENSE_IN   ST7_PE3
 
#define ST7_PE_ADAPTER_SENSE_OUT   ST7_PE4
 
#define ST7_PE_IO6   ST7_PE5
 
#define ST7_PE_TMS   ST7_PE_IO6
 
#define USB_EP1IN_ADDR   (USB_EP1OUT_ADDR | 0x80)
 
#define USB_EP1IN_SIZE   (USB_EP1OUT_SIZE)
 
#define USB_EP1OUT_ADDR   (0x01)
 
#define USB_EP1OUT_SIZE   (16)
 
#define USB_EP2BANK_SIZE   (512)
 
#define USB_EP2IN_ADDR   (USB_EP2OUT_ADDR | 0x80)
 
#define USB_EP2IN_SIZE   (USB_EP2OUT_SIZE)
 
#define USB_EP2OUT_ADDR   (0x02)
 
#define USB_EP2OUT_SIZE   (64)
 
#define USB_IDPRODUCT   (0x9000)
 
#define USB_IDVENDOR   (0x138e)
 

Functions

static int dtc_load_from_buffer (struct libusb_device_handle *hdev_param, const uint8_t *buffer, size_t length)
 
static struct dtc_reply_queue_entrydtc_queue_enqueue_reply (enum scan_type type, uint8_t *buffer, int size, int offset, int length, struct jtag_command *cmd)
 
static int dtc_queue_init (void)
 
static int dtc_queue_run (void)
 
static int dtc_queue_run_if_full (int reserved_cmd, int reserved_reply)
 
static int dtc_run_download (struct libusb_device_handle *hdev_param, uint8_t *command_buffer, int command_buffer_size, uint8_t *reply_buffer, int reply_buffer_size)
 
static int dtc_start_download (void)
 
static int ep1_generic_commandl (struct libusb_device_handle *hdev_param, size_t length,...)
 
static ssize_t ep1_memory_write (struct libusb_device_handle *hdev_param, uint16_t addr, size_t length, uint8_t const *buffer)
 
static void rlink_end_state (enum tap_state state)
 
static int rlink_execute_queue (struct jtag_command *cmd_queue)
 
static int rlink_init (void)
 
static int rlink_khz (int khz, int *speed)
 
static void rlink_path_move (struct pathmove_command *cmd)
 
static int rlink_quit (void)
 
static void rlink_reset (int trst, int srst)
 
static void rlink_runtest (unsigned int num_cycles)
 
static int rlink_scan (struct jtag_command *cmd, enum scan_type type, uint8_t *buffer, int scan_size)
 
static int rlink_speed (int speed)
 
static int rlink_speed_div (int speed, int *khz)
 
static void rlink_state_move (void)
 
static int tap_state_queue_append (uint8_t tms)
 
static int tap_state_queue_init (void)
 
static int tap_state_queue_run (void)
 

Variables

static uint8_t dtc_entry_download
 
struct {
   uint8_t   cmd_buffer [USB_EP2BANK_SIZE]
 
   uint32_t   cmd_index
 
   uint32_t   reply_index
 
   struct dtc_reply_queue_entry *   rq_head
 
   struct dtc_reply_queue_entry *   rq_tail
 
dtc_queue
 
static struct libusb_device_handle * hdev
 
struct adapter_driver rlink_adapter_driver
 
static struct jtag_interface rlink_interface
 
struct {
   uint32_t   buffer
 
   uint32_t   length
 
tap_state_queue
 

Macro Definition Documentation

◆ DTC_LOAD_BUFFER

#define DTC_LOAD_BUFFER   ST7_USB_BUF_EP2UIDO

Definition at line 280 of file rlink.c.

◆ DTC_STATUS_POLL_BYTE

#define DTC_STATUS_POLL_BYTE   (ST7_USB_BUF_EP0OUT + 0xff)

Definition at line 51 of file rlink.c.

◆ DTCLOAD_COMMENT

#define DTCLOAD_COMMENT   (0)

Definition at line 273 of file rlink.c.

◆ DTCLOAD_ENTRY

#define DTCLOAD_ENTRY   (1)

Definition at line 274 of file rlink.c.

◆ DTCLOAD_LOAD

#define DTCLOAD_LOAD   (2)

Definition at line 275 of file rlink.c.

◆ DTCLOAD_LUT

#define DTCLOAD_LUT   (5)

Definition at line 278 of file rlink.c.

◆ DTCLOAD_LUT_START

#define DTCLOAD_LUT_START   (4)

Definition at line 277 of file rlink.c.

◆ DTCLOAD_RUN

#define DTCLOAD_RUN   (3)

Definition at line 276 of file rlink.c.

◆ INTERFACE_NAME

#define INTERFACE_NAME   "RLink"

Definition at line 35 of file rlink.c.

◆ ST7_PA_DBGACK

#define ST7_PA_DBGACK   ST7_PA_IO10

Definition at line 85 of file rlink.c.

◆ ST7_PA_DBGRQ

#define ST7_PA_DBGRQ   ST7_PA_IO4

Definition at line 80 of file rlink.c.

◆ ST7_PA_IO1

#define ST7_PA_IO1   ST7_PA1

Definition at line 65 of file rlink.c.

◆ ST7_PA_IO10

#define ST7_PA_IO10   ST7_PA7

Definition at line 69 of file rlink.c.

◆ ST7_PA_IO2

#define ST7_PA_IO2   ST7_PA2

Definition at line 66 of file rlink.c.

◆ ST7_PA_IO4

#define ST7_PA_IO4   ST7_PA4

Definition at line 67 of file rlink.c.

◆ ST7_PA_IO8

#define ST7_PA_IO8   ST7_PA6

Definition at line 68 of file rlink.c.

◆ ST7_PA_NTRST

#define ST7_PA_NTRST   ST7_PA_IO1

Definition at line 78 of file rlink.c.

◆ ST7_PA_RTCK

#define ST7_PA_RTCK   ST7_PA_IO0

Definition at line 77 of file rlink.c.

◆ ST7_PB_IO5

#define ST7_PB_IO5   ST7_PB5

Definition at line 70 of file rlink.c.

◆ ST7_PB_NSRST

#define ST7_PB_NSRST   ST7_PB_IO5

Definition at line 81 of file rlink.c.

◆ ST7_PC_IO3

#define ST7_PC_IO3   ST7_PC2

Definition at line 72 of file rlink.c.

◆ ST7_PC_IO7

#define ST7_PC_IO7   ST7_PC3

Definition at line 73 of file rlink.c.

◆ ST7_PC_IO9

#define ST7_PC_IO9   ST7_PC1

Definition at line 71 of file rlink.c.

◆ ST7_PC_TCK

#define ST7_PC_TCK   ST7_PC_IO7

Definition at line 83 of file rlink.c.

◆ ST7_PC_TDI

#define ST7_PC_TDI   ST7_PC_IO3

Definition at line 79 of file rlink.c.

◆ ST7_PC_TDO

#define ST7_PC_TDO   ST7_PC_IO9

Definition at line 84 of file rlink.c.

◆ ST7_PD_NBUSY_LED

#define ST7_PD_NBUSY_LED   ST7_PD0

Definition at line 53 of file rlink.c.

◆ ST7_PD_NRUN_LED

#define ST7_PD_NRUN_LED   ST7_PD1

Definition at line 54 of file rlink.c.

◆ ST7_PD_VPP_SEL

#define ST7_PD_VPP_SEL   ST7_PD6

Definition at line 56 of file rlink.c.

◆ ST7_PD_VPP_SHDN

#define ST7_PD_VPP_SHDN   ST7_PD7

Definition at line 58 of file rlink.c.

◆ ST7_PE_ADAPTER_SENSE_IN

#define ST7_PE_ADAPTER_SENSE_IN   ST7_PE3

Definition at line 61 of file rlink.c.

◆ ST7_PE_ADAPTER_SENSE_OUT

#define ST7_PE_ADAPTER_SENSE_OUT   ST7_PE4

Definition at line 62 of file rlink.c.

◆ ST7_PE_IO6

#define ST7_PE_IO6   ST7_PE5

Definition at line 74 of file rlink.c.

◆ ST7_PE_TMS

#define ST7_PE_TMS   ST7_PE_IO6

Definition at line 82 of file rlink.c.

◆ USB_EP1IN_ADDR

#define USB_EP1IN_ADDR   (USB_EP1OUT_ADDR | 0x80)

Definition at line 42 of file rlink.c.

◆ USB_EP1IN_SIZE

#define USB_EP1IN_SIZE   (USB_EP1OUT_SIZE)

Definition at line 43 of file rlink.c.

◆ USB_EP1OUT_ADDR

#define USB_EP1OUT_ADDR   (0x01)

Definition at line 40 of file rlink.c.

◆ USB_EP1OUT_SIZE

#define USB_EP1OUT_SIZE   (16)

Definition at line 41 of file rlink.c.

◆ USB_EP2BANK_SIZE

#define USB_EP2BANK_SIZE   (512)

Definition at line 49 of file rlink.c.

◆ USB_EP2IN_ADDR

#define USB_EP2IN_ADDR   (USB_EP2OUT_ADDR | 0x80)

Definition at line 47 of file rlink.c.

◆ USB_EP2IN_SIZE

#define USB_EP2IN_SIZE   (USB_EP2OUT_SIZE)

Definition at line 48 of file rlink.c.

◆ USB_EP2OUT_ADDR

#define USB_EP2OUT_ADDR   (0x02)

Definition at line 45 of file rlink.c.

◆ USB_EP2OUT_SIZE

#define USB_EP2OUT_SIZE   (64)

Definition at line 46 of file rlink.c.

◆ USB_IDPRODUCT

#define USB_IDPRODUCT   (0x9000)

Definition at line 38 of file rlink.c.

◆ USB_IDVENDOR

#define USB_IDVENDOR   (0x138e)

Definition at line 37 of file rlink.c.

Function Documentation

◆ dtc_load_from_buffer()

static int dtc_load_from_buffer ( struct libusb_device_handle *  hdev_param,
const uint8_t *  buffer,
size_t  length 
)
static

◆ dtc_queue_enqueue_reply()

static struct dtc_reply_queue_entry* dtc_queue_enqueue_reply ( enum scan_type  type,
uint8_t *  buffer,
int  size,
int  offset,
int  length,
struct jtag_command cmd 
)
inlinestatic

◆ dtc_queue_init()

static int dtc_queue_init ( void  )
static

Definition at line 582 of file rlink.c.

References dtc_queue, and NULL.

Referenced by rlink_init().

◆ dtc_queue_run()

◆ dtc_queue_run_if_full()

static int dtc_queue_run_if_full ( int  reserved_cmd,
int  reserved_reply 
)
static

Definition at line 760 of file rlink.c.

References dtc_queue, dtc_queue_run(), ERROR_OK, USB_EP2BANK_SIZE, and USB_EP2IN_SIZE.

Referenced by rlink_scan(), and tap_state_queue_run().

◆ dtc_run_download()

static int dtc_run_download ( struct libusb_device_handle *  hdev_param,
uint8_t *  command_buffer,
int  command_buffer_size,
uint8_t *  reply_buffer,
int  reply_buffer_size 
)
static

◆ dtc_start_download()

◆ ep1_generic_commandl()

static int ep1_generic_commandl ( struct libusb_device_handle *  hdev_param,
size_t  length,
  ... 
)
static

◆ ep1_memory_write()

static ssize_t ep1_memory_write ( struct libusb_device_handle *  hdev_param,
uint16_t  addr,
size_t  length,
uint8_t const *  buffer 
)
static

◆ rlink_end_state()

static void rlink_end_state ( enum tap_state  state)
static

Definition at line 845 of file rlink.c.

References LOG_ERROR, state, tap_is_state_stable(), and tap_set_end_state().

Referenced by rlink_execute_queue(), rlink_runtest(), and rlink_scan().

◆ rlink_execute_queue()

◆ rlink_init()

◆ rlink_khz()

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

◆ rlink_path_move()

static void rlink_path_move ( struct pathmove_command cmd)
static

◆ rlink_quit()

static int rlink_quit ( void  )
static

Definition at line 1653 of file rlink.c.

◆ rlink_reset()

◆ rlink_runtest()

static void rlink_runtest ( unsigned int  num_cycles)
static

◆ rlink_scan()

◆ rlink_speed()

static int rlink_speed ( int  speed)
static

◆ rlink_speed_div()

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

Definition at line 1405 of file rlink.c.

References ERROR_FAIL, ERROR_OK, rlink_speed_table::khz, LOG_ERROR, and rlink_speed_table_size.

◆ rlink_state_move()

static void rlink_state_move ( void  )
static

◆ tap_state_queue_append()

static int tap_state_queue_append ( uint8_t  tms)
static

Definition at line 828 of file rlink.c.

References tap_state_queue, and tap_state_queue_run().

Referenced by rlink_path_move(), rlink_runtest(), rlink_scan(), and rlink_state_move().

◆ tap_state_queue_init()

static int tap_state_queue_init ( void  )
static

Definition at line 772 of file rlink.c.

References tap_state_queue.

Referenced by rlink_init(), and tap_state_queue_run().

◆ tap_state_queue_run()

static int tap_state_queue_run ( void  )
static

Variable Documentation

◆ buffer

uint32_t buffer

◆ cmd_buffer

uint8_t cmd_buffer[USB_EP2BANK_SIZE]

Definition at line 568 of file rlink.c.

◆ cmd_index

uint32_t cmd_index

Definition at line 566 of file rlink.c.

Referenced by stlink_usb_misc_rw_segment().

◆ dtc_entry_download

uint8_t dtc_entry_download
static

Definition at line 283 of file rlink.c.

Referenced by dtc_load_from_buffer(), and dtc_start_download().

◆ 

◆ hdev

struct libusb_device_handle* hdev
static

◆ length

uint32_t length

◆ reply_index

uint32_t reply_index

Definition at line 567 of file rlink.c.

◆ rlink_adapter_driver

struct adapter_driver rlink_adapter_driver
Initial value:
= {
.name = "rlink",
.transports = jtag_only,
.init = rlink_init,
.quit = rlink_quit,
.speed = rlink_speed,
.khz = rlink_khz,
.speed_div = rlink_speed_div,
.jtag_ops = &rlink_interface,
}
const char *const jtag_only[]
Definition: adapter.c:27

Definition at line 1653 of file rlink.c.

◆ rlink_interface

struct jtag_interface rlink_interface
static
Initial value:
= {
.execute_queue = rlink_execute_queue,
}

Definition at line 1653 of file rlink.c.

◆ rq_head

struct dtc_reply_queue_entry* rq_head

Definition at line 564 of file rlink.c.

◆ rq_tail

struct dtc_reply_queue_entry* rq_tail

Definition at line 565 of file rlink.c.

◆ 

struct { ... } tap_state_queue