diff options
author | Paul Fertser <fercerpav@gmail.com> | 2017-01-26 23:41:40 +0300 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2017-12-12 21:13:55 +0000 |
commit | 31c58c139d85c35cc8ebce4196edb2c5eb157c7a (patch) | |
tree | 91e43c935709234d69da7e3986de90b3dc127346 /src/jtag/hla | |
parent | eb26a884e0ff0fb6568aeda65fe21eec1e5b6557 (diff) | |
download | riscv-openocd-31c58c139d85c35cc8ebce4196edb2c5eb157c7a.zip riscv-openocd-31c58c139d85c35cc8ebce4196edb2c5eb157c7a.tar.gz riscv-openocd-31c58c139d85c35cc8ebce4196edb2c5eb157c7a.tar.bz2 |
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>
Diffstat (limited to 'src/jtag/hla')
-rw-r--r-- | src/jtag/hla/hla_interface.c | 26 | ||||
-rw-r--r-- | src/jtag/hla/hla_interface.h | 10 |
2 files changed, 25 insertions, 11 deletions
diff --git a/src/jtag/hla/hla_interface.c b/src/jtag/hla/hla_interface.c index 9217631..62a8f59 100644 --- a/src/jtag/hla/hla_interface.c +++ b/src/jtag/hla/hla_interface.c @@ -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; } diff --git a/src/jtag/hla/hla_interface.h b/src/jtag/hla/hla_interface.h index 0992d1c..262025e 100644 --- a/src/jtag/hla/hla_interface.h +++ b/src/jtag/hla/hla_interface.h @@ -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; /** */ |