-
-
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
Conversation
Since spec v0.13 there is an explicit version value (15) to identify dm/dmi's that do not conform with any available specs
Identify but allow non-standard DMI versions but only process standard explicitly know DM versions
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.
Do please update all the copyright strings across all the files to include the current year date. Eg 2023-2025
instead of just 2023
.
This is only a preliminary review - we still have two files to go through, but this is looking great so far.
libbmd_core_args += ['-DENABLE_RVSWD=1'] | ||
bmd_core_args += ['-DENABLE_RVSWD=1'] |
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.
We suggest making this CONFIG_RVSWD
to be consistent with the revamped macro naming style. The if
just above needs checking as we think the condition is wrong - think it should be checking rvswd_support
, not rtt_support
.
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.
You are correct, I noticed after pushing
if (dmi->version == RISCV_DEBUG_UNKNOWN) | ||
return; | ||
if (dmi->version == RISCV_DEBUG_0_11) { | ||
DEBUG_INFO("RISC-V debug v0.11 not presently supported\n"); | ||
DEBUG_INFO("RISC-V v0.11 DMI is not presently supported\n"); |
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.
The inclusion of the term "debug" here is very intentional as the specification is the RISC-V Debug specification, not the ISA specification. For this piece of technical clarity in case we wind up needing to specify ISA specification conformance too, we would like to keep including this extra word in all messages involving the DTM, DMI, and DM versioning. Adding this is about the DMI version is good though 👍🏼
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.
Hm, that does make sense, I'll reword it again
@@ -586,18 +613,21 @@ static riscv_debug_version_e riscv_dm_version(const uint32_t status) | |||
case 0: | |||
return RISCV_DEBUG_UNIMPL; | |||
case 1: | |||
DEBUG_INFO("RISC-V debug v0.11 DM\n"); | |||
DEBUG_INFO("RISC-V v0.11 Debug Module\n"); |
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.
Same for these strings as above.
} | ||
|
||
/* Reads the 96 bit unique id */ | ||
static bool ch32vx_uid_cmd(target_s *const target, const int argc, const char **const argv) |
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.
Is this able to use the stm32_common.c stm32_uid()
function? Would be neat if it can.
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.
Maybe, a lot of things can be shared with stm32, that's what #1642 was about, but that's a mess now, I'll look but I might push sharing stuff for later
} | ||
|
||
if (!scan_result) { | ||
platform_target_clk_output_enable(false); |
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.
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 | ||
} |
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.
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 if (scan_result)
and then return via that post-scan routine?
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.
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
Detailed description
This is the first part of #1399 which will be broken up into smaller PR's
This adds support for the WCH-Link debug probe by WCH, it's a naive implementation based on a rough reverse engineer of the protocol, which is not publicly documented
Your checklist for this pull request
Closing issues