Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
openocd
Commits
88950d69
Commit
88950d69
authored
Aug 20, 2019
by
Wolfgang Draxinger
Browse files
added CMSID-DAP command to select interface by path
parent
90d82818
Changes
1
Show whitespace changes
Inline
Side-by-side
src/jtag/drivers/cmsis_dap_usb.c
View file @
88950d69
...
...
@@ -62,6 +62,7 @@
static
uint16_t
cmsis_dap_vid
[
MAX_USB_IDS
+
1
]
=
{
0
};
static
uint16_t
cmsis_dap_pid
[
MAX_USB_IDS
+
1
]
=
{
0
};
static
wchar_t
*
cmsis_dap_serial
;
static
char
*
cmsis_dap_path
;
static
bool
swd_mode
;
#define PACKET_SIZE (64 + 1)
/* 64 bytes plus report id */
...
...
@@ -230,8 +231,10 @@ static int cmsis_dap_usb_open(void)
struct
hid_device_info
*
devs
,
*
cur_dev
;
unsigned
short
target_vid
,
target_pid
;
wchar_t
*
target_serial
=
NULL
;
char
*
target_path
=
NULL
;
bool
found
=
false
;
bool
path_found
=
false
;
bool
serial_found
=
false
;
target_vid
=
0
;
...
...
@@ -269,9 +272,19 @@ static int cmsis_dap_usb_open(void)
}
if
(
found
)
{
if
(
cmsis_dap_path
){
if
(
cur_dev
->
path
&&
!
strcmp
(
cur_dev
->
path
,
cmsis_dap_path
)
){
LOG_INFO
(
"Using CMSIS-DAP device with path '%s'"
,
cmsis_dap_path
);
path_found
=
true
;
break
;
}
}
else
/* we have found an adapter, so exit further checks */
/* check serial number matches if given */
if
(
cmsis_dap_serial
!=
NULL
)
{
if
(
cmsis_dap_serial
){
LOG_INFO
(
">>> Considering CMSIS-DAP device with path '%s' <<<"
,
cur_dev
->
path
);
if
((
cur_dev
->
serial_number
!=
NULL
)
&&
wcscmp
(
cmsis_dap_serial
,
cur_dev
->
serial_number
)
==
0
)
{
serial_found
=
true
;
break
;
...
...
@@ -288,9 +301,13 @@ static int cmsis_dap_usb_open(void)
if
(
NULL
!=
cur_dev
)
{
target_vid
=
cur_dev
->
vendor_id
;
target_pid
=
cur_dev
->
product_id
;
if
(
serial_found
)
if
(
serial_found
){
target_serial
=
cmsis_dap_serial
;
}
if
(
path_found
){
target_path
=
cmsis_dap_path
;
}
}
hid_free_enumeration
(
devs
);
...
...
@@ -304,7 +321,11 @@ static int cmsis_dap_usb_open(void)
return
ERROR_FAIL
;
}
if
(
target_path
){
dev
=
hid_open_path
(
target_path
);
}
else
{
dev
=
hid_open
(
target_vid
,
target_pid
,
target_serial
);
}
if
(
dev
==
NULL
)
{
LOG_ERROR
(
"unable to open CMSIS-DAP device 0x%x:0x%x"
,
target_vid
,
target_pid
);
...
...
@@ -1745,6 +1766,20 @@ COMMAND_HANDLER(cmsis_dap_handle_serial_command)
return
ERROR_OK
;
}
COMMAND_HANDLER
(
cmsis_dap_handle_path_command
)
{
if
(
CMD_ARGC
==
1
)
{
cmsis_dap_path
=
strdup
(
CMD_ARGV
[
0
]);
if
(
!
cmsis_dap_path
){
LOG_ERROR
(
"unable to allocate memory"
);
return
ERROR_OK
;
}
}
else
{
LOG_ERROR
(
"expected exactly one argument to cmsis_dap_path <usb-path>"
);
}
return
ERROR_OK
;
}
static
const
struct
command_registration
cmsis_dap_subcommand_handlers
[]
=
{
{
.
name
=
"info"
,
...
...
@@ -1785,6 +1820,13 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
.
help
=
"set the serial number of the adapter"
,
.
usage
=
"serial_string"
,
},
{
.
name
=
"cmsis_dap_path"
,
.
handler
=
&
cmsis_dap_handle_path_command
,
.
mode
=
COMMAND_CONFIG
,
.
help
=
"set the path of the adapter"
,
.
usage
=
"path_string"
,
},
COMMAND_REGISTRATION_DONE
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment