Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
openocd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
openocd
Commits
88950d69
Commit
88950d69
authored
5 years ago
by
Wolfgang Draxinger
Browse files
Options
Downloads
Patches
Plain Diff
added CMSID-DAP command to select interface by path
parent
90d82818
Branches
ch3/leds-api
No related tags found
1 merge request
!1
added CMSID-DAP command to select interface by path
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/jtag/drivers/cmsis_dap_usb.c
+45
-3
45 additions, 3 deletions
src/jtag/drivers/cmsis_dap_usb.c
with
45 additions
and
3 deletions
src/jtag/drivers/cmsis_dap_usb.c
+
45
−
3
View file @
88950d69
...
@@ -62,6 +62,7 @@
...
@@ -62,6 +62,7 @@
static
uint16_t
cmsis_dap_vid
[
MAX_USB_IDS
+
1
]
=
{
0
};
static
uint16_t
cmsis_dap_vid
[
MAX_USB_IDS
+
1
]
=
{
0
};
static
uint16_t
cmsis_dap_pid
[
MAX_USB_IDS
+
1
]
=
{
0
};
static
uint16_t
cmsis_dap_pid
[
MAX_USB_IDS
+
1
]
=
{
0
};
static
wchar_t
*
cmsis_dap_serial
;
static
wchar_t
*
cmsis_dap_serial
;
static
char
*
cmsis_dap_path
;
static
bool
swd_mode
;
static
bool
swd_mode
;
#define PACKET_SIZE (64 + 1)
/* 64 bytes plus report id */
#define PACKET_SIZE (64 + 1)
/* 64 bytes plus report id */
...
@@ -230,8 +231,10 @@ static int cmsis_dap_usb_open(void)
...
@@ -230,8 +231,10 @@ static int cmsis_dap_usb_open(void)
struct
hid_device_info
*
devs
,
*
cur_dev
;
struct
hid_device_info
*
devs
,
*
cur_dev
;
unsigned
short
target_vid
,
target_pid
;
unsigned
short
target_vid
,
target_pid
;
wchar_t
*
target_serial
=
NULL
;
wchar_t
*
target_serial
=
NULL
;
char
*
target_path
=
NULL
;
bool
found
=
false
;
bool
found
=
false
;
bool
path_found
=
false
;
bool
serial_found
=
false
;
bool
serial_found
=
false
;
target_vid
=
0
;
target_vid
=
0
;
...
@@ -269,9 +272,19 @@ static int cmsis_dap_usb_open(void)
...
@@ -269,9 +272,19 @@ static int cmsis_dap_usb_open(void)
}
}
if
(
found
)
{
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 */
/* we have found an adapter, so exit further checks */
/* check serial number matches if given */
/* 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
)
{
if
((
cur_dev
->
serial_number
!=
NULL
)
&&
wcscmp
(
cmsis_dap_serial
,
cur_dev
->
serial_number
)
==
0
)
{
serial_found
=
true
;
serial_found
=
true
;
break
;
break
;
...
@@ -288,9 +301,13 @@ static int cmsis_dap_usb_open(void)
...
@@ -288,9 +301,13 @@ static int cmsis_dap_usb_open(void)
if
(
NULL
!=
cur_dev
)
{
if
(
NULL
!=
cur_dev
)
{
target_vid
=
cur_dev
->
vendor_id
;
target_vid
=
cur_dev
->
vendor_id
;
target_pid
=
cur_dev
->
product_id
;
target_pid
=
cur_dev
->
product_id
;
if
(
serial_found
)
if
(
serial_found
){
target_serial
=
cmsis_dap_serial
;
target_serial
=
cmsis_dap_serial
;
}
}
if
(
path_found
){
target_path
=
cmsis_dap_path
;
}
}
hid_free_enumeration
(
devs
);
hid_free_enumeration
(
devs
);
...
@@ -304,7 +321,11 @@ static int cmsis_dap_usb_open(void)
...
@@ -304,7 +321,11 @@ static int cmsis_dap_usb_open(void)
return
ERROR_FAIL
;
return
ERROR_FAIL
;
}
}
if
(
target_path
){
dev
=
hid_open_path
(
target_path
);
}
else
{
dev
=
hid_open
(
target_vid
,
target_pid
,
target_serial
);
dev
=
hid_open
(
target_vid
,
target_pid
,
target_serial
);
}
if
(
dev
==
NULL
)
{
if
(
dev
==
NULL
)
{
LOG_ERROR
(
"unable to open CMSIS-DAP device 0x%x:0x%x"
,
target_vid
,
target_pid
);
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)
...
@@ -1745,6 +1766,20 @@ COMMAND_HANDLER(cmsis_dap_handle_serial_command)
return
ERROR_OK
;
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
[]
=
{
static
const
struct
command_registration
cmsis_dap_subcommand_handlers
[]
=
{
{
{
.
name
=
"info"
,
.
name
=
"info"
,
...
@@ -1785,6 +1820,13 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
...
@@ -1785,6 +1820,13 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
.
help
=
"set the serial number of the adapter"
,
.
help
=
"set the serial number of the adapter"
,
.
usage
=
"serial_string"
,
.
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
COMMAND_REGISTRATION_DONE
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment