37 #define MAX_PENDING_SCAN_RESULTS 256
96 "-------------------------------------");
102 cmd->cmd.runtest->num_cycles,
119 cmd->cmd.pathmove->num_states,
133 if (
cmd->cmd.scan->ir_scan)
135 "JTAG Scan write IR(%d bits), "
142 "JTAG Scan write DR(%d bits), "
165 cmd->cmd.stableclocks->num_cycles);
185 "in non-stable state \"%s\"",
195 cmd->cmd.tms->num_bits);
201 LOG_ERROR(
"BUG: unknown JTAG command type "
202 "encountered: %d",
cmd->type);
282 LOG_ERROR(
"Can't find USB JTAG Interface!"
283 "Please check connection and permissions.");
368 for (i = 0; i < tms_scan_bits; i++)
376 for (
unsigned int i = 0; i < num_states; i++) {
382 LOG_ERROR(
"BUG: %s -> %s isn't a valid TAP transition",
396 for (
int i = 0; i < num_bits; i++)
402 while (num_cycles > 0) {
456 LOG_DEBUG(
"trst: %i, srst: %i", trst, srst);
540 int available_scans =
543 if (scans > available_scans)
552 uint8_t
bit = 1 << bit_index;
574 int len_tmp, len_all, i;
577 while (len_all <
length) {
589 len_tmp =
length - len_all;
599 for (i = 0; i < len_tmp; i++) {
603 >> ((len_all + i)%8)) & 1);
639 "JTAG scan read(%d bits, from src %d bits to dest %d bits):",
640 length, src_first, dest_first);
655 LOG_ERROR(
"vsllink_jtag_execute failure");
674 LOG_INFO(
"VSLLink SWD mode enabled");
682 const int_least32_t delay2hz[] = {
683 1850000, 235000, 130000, 102000, 85000, 72000
687 uint16_t delay = UINT16_MAX;
689 for (uint16_t i = 0; i <
ARRAY_SIZE(delay2hz); i++) {
690 if (hz >= delay2hz[i]) {
697 if (delay == UINT16_MAX)
698 delay = (500000 / hz) - 1;
703 uint16_t retry_count = 250 * hz / 1000 / 54;
705 LOG_DEBUG(
"SWD delay: %d, retry count: %d", delay, retry_count);
732 LOG_ERROR(
"Sequence %d not supported", seq);
758 struct libusb_device_handle *usb_device_handle,
759 struct libusb_device_descriptor *usb_desc)
761 char desc_string[256];
765 retval = libusb_get_string_descriptor_ascii(usb_device_handle,
766 usb_desc->iSerialNumber, (
unsigned char *)desc_string,
767 sizeof(desc_string));
772 sizeof(desc_string)))
776 retval = libusb_get_string_descriptor_ascii(usb_device_handle,
777 usb_desc->iProduct, (
unsigned char *)desc_string,
778 sizeof(desc_string));
782 if (!strstr(desc_string,
"Versaloon"))
790 ssize_t num_devices, i;
791 struct libusb_device **usb_devices;
792 struct libusb_device_descriptor usb_desc;
793 struct libusb_device_handle *usb_device_handle;
798 if (num_devices <= 0)
801 for (i = 0; i < num_devices; i++) {
802 struct libusb_device *
device = usb_devices[i];
804 retval = libusb_get_device_descriptor(
device, &usb_desc);
812 retval = libusb_open(
device, &usb_device_handle);
820 libusb_close(usb_device_handle);
823 libusb_free_device_list(usb_devices, 1);
825 if (i == num_devices)
828 retval = libusb_claim_interface(usb_device_handle,
832 libusb_close(usb_device_handle);
847 #define BYTES_PER_LINE 16
857 snprintf(line, 5,
"%04x", i & 0xffff);
859 snprintf(s, 4,
" %02x",
buffer[j]);
869 .handler = &vsllink_handle_usb_vid_command,
871 .help =
"Set USB VID",
876 .handler = &vsllink_handle_usb_pid_command,
878 .help =
"Set USB PID",
882 .name =
"usb_bulkin",
883 .handler = &vsllink_handle_usb_bulkin_command,
885 .help =
"Set USB input endpoint",
889 .name =
"usb_bulkout",
890 .handler = &vsllink_handle_usb_bulkout_command,
892 .help =
"Set USB output endpoint",
896 .name =
"usb_interface",
897 .handler = &vsllink_handle_usb_interface_command,
899 .help =
"Set USB output interface",
900 .usage =
"<interface>",
909 .help =
"perform vsllink management",
const char * adapter_get_required_serial(void)
Retrieves the serial number set with command 'adapter serial'.
unsigned int adapter_get_speed_khz(void)
Retrieves the clock speed of the adapter in kHz.
static const struct device_t * device
void * buf_set_buf(const void *_src, unsigned int src_start, void *_dst, unsigned int dst_start, unsigned int len)
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
enum scan_type jtag_scan_type(const struct scan_command *cmd)
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
scan_type
The inferred type of a scan_command structure, indicating whether the command has the host scan in fr...
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
tap_state_t tap_state_transition(tap_state_t cur_state, bool tms)
Function tap_state_transition takes a current TAP state and returns the next state according to the t...
const char * tap_state_name(tap_state_t state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
void tap_set_end_state(tap_state_t new_end_state)
This function sets the state of an "end state follower" which tracks the state that any cable driver ...
tap_state_t tap_get_end_state(void)
For more information,.
int tap_get_tms_path(tap_state_t from, tap_state_t to)
This function provides a "bit sequence" indicating what has to be done with TMS during a sequence of ...
int tap_get_tms_path_len(tap_state_t from, tap_state_t to)
Function int tap_get_tms_path_len returns the total number of bits that represents a TMS path transit...
tap_state_t tap_get_state(void)
This function gets the state of the "state follower" which tracks the state of the TAPs connected to ...
#define DEBUG_CAP_TMS_SEQ
#define tap_set_state(new_state)
This function sets the state of a "state follower" which tracks the state of the TAPs connected to th...
void jtag_sleep(uint32_t us)
#define ERROR_JTAG_QUEUE_FAILED
#define ERROR_JTAG_INIT_FAILED
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
#define LOG_DEBUG_IO(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_LEVEL_IS(FOO)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
static uint32_t bit(uint32_t value, unsigned int b)
uint8_t bits[QN908X_FLASH_MAX_BLOCKS *QN908X_FLASH_PAGES_PER_BLOCK/8]
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
const char * usage
a string listing the options and arguments, required or optional
RESULT(* delayms)(uint16_t ms)
RESULT(* fini)(uint8_t interface_index)
RESULT(* init)(uint8_t interface_index)
RESULT(* out)(uint8_t interface_index, uint32_t pin_mask, uint32_t value)
RESULT(* config)(uint8_t interface_index, uint32_t pin_mask, uint32_t io, uint32_t pull_en_mask, uint32_t input_pull_mask)
RESULT(* init)(uint8_t interface_index)
RESULT(* execute)(uint8_t interface_index, uint8_t *tdi, uint8_t *tms, uint8_t *tdo, uint32_t bitlen)
RESULT(* config)(uint8_t interface_index, uint32_t khz)
RESULT(* fini)(uint8_t interface_index)
RESULT(* seqout)(uint8_t interface_index, const uint8_t *data, uint16_t bitlen)
RESULT(* init)(uint8_t interface_index)
RESULT(* transact)(uint8_t interface_index, uint8_t request, uint32_t *data, uint8_t *ack)
RESULT(* config)(uint8_t interface_index, uint8_t trn, uint16_t retry, uint16_t dly)
RESULT(* fini)(uint8_t interface_index)
Represents a driver for a debugging interface.
unsigned int supported
Bit vector listing capabilities exposed by this driver.
int length
Number of bits to read.
uint8_t * buffer
Location to store the result.
struct scan_command * command
The scan_command provide a means of encapsulating a set of scan_field structures that should be scann...
int(* init)(void)
Initialize the debug link so it can perform SWD operations.
struct interface_swd_t swd
struct interface_gpio_t gpio
RESULT(* peripheral_commit)(void)
struct interface_delay_t delay
struct interface_jtag_raw_t jtag_raw
struct versaloon_adaptors_t adaptors
struct versaloon_usb_setting_t usb_setting
struct libusb_device_handle * usb_device_handle
struct libusb_context * libusb_ctx
static const unsigned int swd_seq_jtag_to_swd_len
static const unsigned int swd_seq_line_reset_len
static const uint8_t swd_seq_line_reset[]
SWD Line reset.
static const uint8_t swd_seq_jtag_to_swd[]
JTAG-to-SWD sequence.
static const uint8_t swd_seq_swd_to_jtag[]
SWD-to-JTAG sequence.
static const unsigned int swd_seq_swd_to_jtag_len
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
struct libusb_device_handle * versaloon_usb_device_handle
struct versaloon_interface_t versaloon_interface
static void vsllink_path_move(unsigned int num_states, tap_state_t *path)
static void vsllink_state_move(void)
static int vsllink_tms_offset
#define MAX_PENDING_SCAN_RESULTS
static int tap_buffer_size
static int vsllink_khz(int khz, int *jtag_speed)
static int vsllink_jtag_execute(void)
static void vsllink_stableclocks(unsigned int num_cycles, int tms)
static void vsllink_debug_buffer(uint8_t *buffer, int length)
static void vsllink_usb_close(struct vsllink *vsllink)
static int vsllink_check_usb_strings(struct libusb_device_handle *usb_device_handle, struct libusb_device_descriptor *usb_desc)
static const struct command_registration vsllink_command_handlers[]
static void vsllink_tap_init(void)
static int vsllink_swd_run_queue(void)
static int vsllink_reset(int trst, int srst)
static void vsllink_tms(int num_bits, const uint8_t *bits)
static const struct command_registration vsllink_subcommand_handlers[]
static int vsllink_usb_open(struct vsllink *vsllink)
static struct pending_scan_result pending_scan_results_buffer[MAX_PENDING_SCAN_RESULTS]
static int vsllink_init(void)
static uint8_t * tdi_buffer
static void vsllink_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size, struct scan_command *command)
static int_least32_t vsllink_swd_frequency(int_least32_t hz)
static uint8_t * tdo_buffer
static struct vsllink * vsllink_handle
static const char *const vsllink_transports[]
struct adapter_driver vsllink_adapter_driver
static int vsllink_speed(int speed)
static void vsllink_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk)
static int vsllink_execute_queue(struct jtag_command *cmd_queue)
static void vsllink_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk)
static void vsllink_tap_ensure_pending(int scans)
static int vsllink_swd_init(void)
static int vsllink_speed_div(int jtag_speed, int *khz)
static int vsllink_swd_switch_seq(enum swd_special_seq seq)
static void vsllink_end_state(tap_state_t state)
static void vsllink_runtest(unsigned int num_cycles)
static int vsllink_quit(void)
static int vsllink_tap_execute(void)
static const struct swd_driver vsllink_swd_driver
static void vsllink_tap_append_scan(int length, uint8_t *buffer, struct scan_command *command)
static uint8_t * tms_buffer
static int pending_scan_results_length
static struct jtag_interface vsllink_interface
static int vsllink_interface_init(void)
static void vsllink_tap_append_step(int tms, int tdi)
COMMAND_HANDLER(vsllink_handle_usb_vid_command)
static void vsllink_free_buffer(void)