mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
jtag: drivers: stlink: handle all versions with single config
Extend HLA interface to allow multiple VID/PID pairs and use it to autodetect the connected stlink version. Change-Id: I35cd895b2260e23cf0e8fcb1fc11a78c2b99c69b Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/3961 Tested-by: jenkins Reviewed-by: Karl Palsson <karlp@tweak.net.au> Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
committed by
Spencer Oliver
parent
eb26a884e0
commit
31c58c139d
@@ -2948,8 +2948,8 @@ Specifies the serial number of the adapter.
|
||||
Specifies the adapter layout to use.
|
||||
@end deffn
|
||||
|
||||
@deffn {Config Command} {hla_vid_pid} vid pid
|
||||
The vendor ID and product ID of the device.
|
||||
@deffn {Config Command} {hla_vid_pid} [vid pid]+
|
||||
Pairs of vendor IDs and product IDs of the device.
|
||||
@end deffn
|
||||
|
||||
@deffn {Command} {hla_command} command
|
||||
|
||||
@@ -1650,13 +1650,11 @@ static int stlink_usb_open(struct hl_interface_param_s *param, void **fd)
|
||||
|
||||
h->transport = param->transport;
|
||||
|
||||
const uint16_t vids[] = { param->vid, 0 };
|
||||
const uint16_t pids[] = { param->pid, 0 };
|
||||
const char *serial = param->serial;
|
||||
|
||||
LOG_DEBUG("transport: %d vid: 0x%04x pid: 0x%04x serial: %s",
|
||||
param->transport, param->vid, param->pid,
|
||||
param->serial ? param->serial : "");
|
||||
for (unsigned i = 0; param->vid[i]; i++) {
|
||||
LOG_DEBUG("transport: %d vid: 0x%04x pid: 0x%04x serial: %s",
|
||||
param->transport, param->vid[i], param->pid[i],
|
||||
param->serial ? param->serial : "");
|
||||
}
|
||||
|
||||
/*
|
||||
On certain host USB configurations(e.g. MacBook Air)
|
||||
@@ -1668,7 +1666,7 @@ static int stlink_usb_open(struct hl_interface_param_s *param, void **fd)
|
||||
in order to become operational.
|
||||
*/
|
||||
do {
|
||||
if (jtag_libusb_open(vids, pids, serial, &h->fd) != ERROR_OK) {
|
||||
if (jtag_libusb_open(param->vid, param->pid, param->serial, &h->fd) != ERROR_OK) {
|
||||
LOG_ERROR("open failed");
|
||||
goto error_open;
|
||||
}
|
||||
@@ -1683,8 +1681,14 @@ static int stlink_usb_open(struct hl_interface_param_s *param, void **fd)
|
||||
/* RX EP is common for all versions */
|
||||
h->rx_ep = STLINK_RX_EP;
|
||||
|
||||
uint16_t pid;
|
||||
if (jtag_libusb_get_pid(jtag_libusb_get_device(h->fd), &pid) != ERROR_OK) {
|
||||
LOG_DEBUG("libusb_get_pid failed");
|
||||
goto error_open;
|
||||
}
|
||||
|
||||
/* wrap version for first read */
|
||||
switch (param->pid) {
|
||||
switch (pid) {
|
||||
case STLINK_V1_PID:
|
||||
h->version.stlink = 1;
|
||||
h->tx_ep = STLINK_TX_EP;
|
||||
@@ -1736,12 +1740,6 @@ static int stlink_usb_open(struct hl_interface_param_s *param, void **fd)
|
||||
}
|
||||
} while (1);
|
||||
|
||||
/* compare usb vid/pid */
|
||||
if ((param->vid != h->vid) || (param->pid != h->pid))
|
||||
LOG_INFO("vid/pid are not identical: 0x%04X/0x%04X 0x%04X/0x%04X",
|
||||
param->vid, param->pid,
|
||||
h->vid, h->pid);
|
||||
|
||||
/* check if mode is supported */
|
||||
err = ERROR_OK;
|
||||
|
||||
|
||||
@@ -688,14 +688,18 @@ static int icdi_usb_open(struct hl_interface_param_s *param, void **fd)
|
||||
}
|
||||
|
||||
LOG_DEBUG("transport: %d vid: 0x%04x pid: 0x%04x", param->transport,
|
||||
param->vid, param->pid);
|
||||
param->vid[0], param->pid[0]);
|
||||
|
||||
/* TODO: convert libusb_ calls to jtag_libusb_ */
|
||||
if (param->vid[1])
|
||||
LOG_WARNING("Bad configuration: 'hla_vid_pid' command does not accept more than one VID PID pair on ti-icdi!");
|
||||
|
||||
if (libusb_init(&h->usb_ctx) != 0) {
|
||||
LOG_ERROR("libusb init failed");
|
||||
goto error_open;
|
||||
}
|
||||
|
||||
h->usb_dev = libusb_open_device_with_vid_pid(h->usb_ctx, param->vid, param->pid);
|
||||
h->usb_dev = libusb_open_device_with_vid_pid(h->usb_ctx, param->vid[0], param->pid[0]);
|
||||
if (!h->usb_dev) {
|
||||
LOG_ERROR("open failed");
|
||||
goto error_open;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include <target/target.h>
|
||||
|
||||
static struct hl_interface_s hl_if = { {0, 0, 0, 0, 0, HL_TRANSPORT_UNKNOWN, false, -1}, 0, 0 };
|
||||
static struct hl_interface_s hl_if = { {0, 0, { 0 }, { 0 }, 0, HL_TRANSPORT_UNKNOWN, false, -1}, 0, 0 };
|
||||
|
||||
int hl_interface_open(enum hl_transports tr)
|
||||
{
|
||||
@@ -264,15 +264,27 @@ COMMAND_HANDLER(hl_interface_handle_layout_command)
|
||||
|
||||
COMMAND_HANDLER(hl_interface_handle_vid_pid_command)
|
||||
{
|
||||
LOG_DEBUG("hl_interface_handle_vid_pid_command");
|
||||
|
||||
if (CMD_ARGC != 2) {
|
||||
LOG_WARNING("ignoring extra IDs in hl_vid_pid (maximum is 1 pair)");
|
||||
if (CMD_ARGC > HLA_MAX_USB_IDS * 2) {
|
||||
LOG_WARNING("ignoring extra IDs in hla_vid_pid "
|
||||
"(maximum is %d pairs)", HLA_MAX_USB_IDS);
|
||||
CMD_ARGC = HLA_MAX_USB_IDS * 2;
|
||||
}
|
||||
if (CMD_ARGC < 2 || (CMD_ARGC & 1)) {
|
||||
LOG_WARNING("incomplete hla_vid_pid configuration directive");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], hl_if.param.vid);
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], hl_if.param.pid);
|
||||
unsigned i;
|
||||
for (i = 0; i < CMD_ARGC; i += 2) {
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i], hl_if.param.vid[i / 2]);
|
||||
COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], hl_if.param.pid[i / 2]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Explicitly terminate, in case there are multiple instances of
|
||||
* hla_vid_pid.
|
||||
*/
|
||||
hl_if.param.vid[i / 2] = hl_if.param.pid[i / 2] = 0;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -29,15 +29,17 @@ enum e_hl_transports;
|
||||
/** */
|
||||
extern const char *hl_transports[];
|
||||
|
||||
#define HLA_MAX_USB_IDS 8
|
||||
|
||||
struct hl_interface_param_s {
|
||||
/** */
|
||||
const char *device_desc;
|
||||
/** */
|
||||
const char *serial;
|
||||
/** */
|
||||
uint16_t vid;
|
||||
/** */
|
||||
uint16_t pid;
|
||||
/** List of recognised VIDs */
|
||||
uint16_t vid[HLA_MAX_USB_IDS + 1];
|
||||
/** List of recognised PIDs */
|
||||
uint16_t pid[HLA_MAX_USB_IDS + 1];
|
||||
/** */
|
||||
unsigned api;
|
||||
/** */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# STM32F091RC
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF260944
|
||||
|
||||
source [find interface/stlink-v2-1.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# This is an ST NUCLEO F103RB board with a single STM32F103RBT6 chip.
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF259875
|
||||
|
||||
source [find interface/stlink-v2-1.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# This is an ST NUCLEO F334R8 board with a single STM32F334R8T6 chip.
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF260004
|
||||
|
||||
source [find interface/stlink-v2-1.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# STM32F411RET6
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF260320
|
||||
|
||||
source [find interface/stlink-v2-1.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# This is an ST NUCLEO L152RE board with a single STM32L152RET6 chip.
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF260002
|
||||
|
||||
source [find interface/stlink-v2-1.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# This is a ST NUCLEO L476RG board with a single STM32L476RGT6 chip.
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF261636
|
||||
|
||||
source [find interface/stlink-v2-1.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This is for using the onboard STLINK/V2
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This is for using the onboard STLINK/V2
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This is for using the onboard STLINK/V2
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This is for using the onboard STLINK/V2
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This is for using the onboard STLINK/V2
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# This is an STM32F0 discovery board with a single STM32F051R8T6 chip.
|
||||
# http://www.st.com/internet/evalboard/product/253215.jsp
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# This is an STM32F3 discovery board with a single STM32F303VCT6 chip.
|
||||
# http://www.st.com/internet/evalboard/product/254044.jsp
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF259090
|
||||
#
|
||||
|
||||
source [find interface/stlink-v2-1.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF259090
|
||||
#
|
||||
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user