-
-
Notifications
You must be signed in to change notification settings - Fork 785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/wch link support #2061
base: main
Are you sure you want to change the base?
Feature/wch link support #2061
Changes from all commits
7f2a122
4719dd2
4330f7f
f7bcbb0
3ebb928
d355ef4
86ca7e3
d7181f8
49701ab
15a3766
6a427b2
e088f65
dbb40bb
c0e8934
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,9 @@ static bool cmd_help(target_s *target, int argc, const char **argv); | |
|
||
static bool cmd_jtag_scan(target_s *target, int argc, const char **argv); | ||
static bool cmd_swd_scan(target_s *target, int argc, const char **argv); | ||
#if defined(ENABLE_RVSWD) && defined(PLATFORM_HAS_RVSWD) | ||
static bool cmd_rvswd_scan(target_s *target, int argc, const char **argv); | ||
#endif | ||
static bool cmd_auto_scan(target_s *target, int argc, const char **argv); | ||
static bool cmd_frequency(target_s *target, int argc, const char **argv); | ||
static bool cmd_targets(target_s *target, int argc, const char **argv); | ||
|
@@ -94,6 +97,9 @@ const command_s cmd_list[] = { | |
{"jtag_scan", cmd_jtag_scan, "Scan JTAG chain for devices"}, | ||
{"swd_scan", cmd_swd_scan, "Scan SWD interface for devices: [TARGET_ID]"}, | ||
{"swdp_scan", cmd_swd_scan, "Deprecated: use swd_scan instead"}, | ||
#if defined(ENABLE_RVSWD) && defined(PLATFORM_HAS_RVSWD) | ||
{"rvswd_scan", cmd_rvswd_scan, "Scan RVSWD for devices"}, | ||
#endif | ||
{"auto_scan", cmd_auto_scan, "Automatically scan all chain types for devices"}, | ||
{"frequency", cmd_frequency, "set minimum high and low times: [FREQ]"}, | ||
{"targets", cmd_targets, "Display list of available targets"}, | ||
|
@@ -316,6 +322,52 @@ bool cmd_swd_scan(target_s *target, int argc, const char **argv) | |
return true; | ||
} | ||
|
||
#if defined(ENABLE_RVSWD) && defined(PLATFORM_HAS_RVSWD) | ||
bool cmd_rvswd_scan(target_s *target, int argc, const char **argv) | ||
{ | ||
(void)target; | ||
(void)argc; | ||
(void)argv; | ||
|
||
if (platform_target_voltage()) | ||
gdb_outf("Target voltage: %s\n", platform_target_voltage()); | ||
|
||
if (connect_assert_nrst) | ||
platform_nrst_set_val(true); /* will be deasserted after attach */ | ||
|
||
bool scan_result = false; | ||
TRY (EXCEPTION_ALL) { | ||
#if CONFIG_BMDA == 1 | ||
scan_result = bmda_rvswd_scan(); | ||
#else | ||
scan_result = false; | ||
#endif | ||
} | ||
CATCH () { | ||
case EXCEPTION_TIMEOUT: | ||
gdb_outf("Timeout during scan. Is target stuck in WFI?\n"); | ||
break; | ||
case EXCEPTION_ERROR: | ||
gdb_outf("Exception: %s\n", exception_frame.msg); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
if (!scan_result) { | ||
platform_target_clk_output_enable(false); | ||
platform_nrst_set_val(false); | ||
gdb_out("RVSWD scan failed!\n"); | ||
return false; | ||
} | ||
|
||
cmd_targets(NULL, 0, NULL); | ||
platform_target_clk_output_enable(false); | ||
morse(NULL, false); | ||
return true; | ||
} | ||
#endif | ||
|
||
bool cmd_auto_scan(target_s *target, int argc, const char **argv) | ||
{ | ||
(void)target; | ||
|
@@ -342,8 +394,18 @@ bool cmd_auto_scan(target_s *target, int argc, const char **argv) | |
#else | ||
scan_result = adiv5_swd_scan(0); | ||
#endif | ||
if (!scan_result) | ||
if (!scan_result) { | ||
gdb_out("SWD scan found no devices.\n"); | ||
#if defined(ENABLE_RVSWD) && defined(PLATFORM_HAS_RVSWD) | ||
#if CONFIG_BMDA == 1 | ||
scan_result = bmda_rvswd_scan(); | ||
#else | ||
scan_result = false; | ||
#endif | ||
if (!scan_result) | ||
gdb_out("RVSWD scan found no devices.\n"); | ||
#endif | ||
} | ||
Comment on lines
-345
to
+408
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given how nested this is getting, perhaps lets invert this logic by extracting the post-scan actions into their own function (this allows all scan routines to stop duplicating those same actions) so we can check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have some ideas to help with that and make it more future proof too, but for now some minor refactor in that direction wouldn't hurt |
||
} | ||
} | ||
CATCH () { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,13 @@ if rtt_support | |
endif | ||
endif | ||
|
||
# RVSWD support handling | ||
rvswd_support = get_option('rvswd_support') | ||
if rtt_support | ||
libbmd_core_args += ['-DENABLE_RVSWD=1'] | ||
bmd_core_args += ['-DENABLE_RVSWD=1'] | ||
Comment on lines
+85
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We suggest making this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct, I noticed after pushing |
||
endif | ||
|
||
# Advertise QStartNoAckMode | ||
advertise_noackmode = get_option('advertise_noackmode') | ||
if advertise_noackmode | ||
|
@@ -117,6 +124,7 @@ summary( | |
{ | ||
'Debug output': debug_output, | ||
'RTT support': rtt_support, | ||
'RVSWD support': rvswd_support, | ||
'Advertise QStartNoAckMode': advertise_noackmode, | ||
}, | ||
bool_yn: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line and its identical counterpart below can be lifted out together just above the check for the scan result. That reduces repetition.