-
Notifications
You must be signed in to change notification settings - Fork 328
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
target/riscv: support multiple DMs #875
Conversation
There is an issue about multiple DMs: #377 This patch need to add some checks mentioned in that issue:
I sent this patch out because I had some questions and want to see if anyone could give me some advice:
|
8650c73
to
b2948d3
Compare
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 looks like it's heading in the right direction.
|
How are you testing these changes? |
I see, my hardware happens to have globally unique coreid, so it doesn't bother me here, but it would be better to add some protection |
I test it on an fpga. With this patch, I can debug the cores on 2 different DMs |
7073a36
to
36c47a6
Compare
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.
Hi @zqb-all,
thank you for taking the time to prepare this change. I believe there are some items to fix - please, take a look at my comments.
Thank you for your detailed review suggestions, which are very helpful. I will add them to this patch tomorrow |
What do you mean by coreid? In the hardware there are 2 numbers that are relevant AFAIK:
|
It seems that I misunderstood something, I thought you meant that the hart on different DMs might have same hartid. Let me clarify my usage. I mean the number which config as
this config file works with the code |
So that then means that to select the first hart on cluster 1 (DM 1), you write 4 to dmcontrol.hartsel. If that works, then your implementation is not compliant with the debug spec. The first hart in a DM must be selected by dmcontrol.hartsel=0, the second by dmcontrol.hartsel=1, and so on. (This is so that it's possible for a debugger to automatically detect every hart on the DM. The fact that OpenOCD still requires you to manually list them is a problem with OpenOCD, but other debuggers exist.) |
Yes
This DM implementation only handle dmcontrol.hartsel=0/1/2/3 now,so when I write 4/5 to dmcontrol.hartsel, the high bits are ignored, just like write 0/1 to dmcontrol.hartsel So it's a coincidence that it just works, I get the point now and will fix it. when config with |
0d008ae
to
3211a2c
Compare
Iterate over all harts (contain those not examine yet) and read the mhartid CSR, that doesn't sounds like a good idea, |
That's a clever trick to make this work for your implementation. :)
I don't think so. It's conceivable that OpenOCD is debugging 2 completely separate RISC-V chips (on different scan chains, or even merely different DMs). Since they're completely separate, they could have conflicting hart ids. So we shouldn't force OpenOCD coreid to be the same as RISC-V hartid. At the same time, if it is possible then we do want them to be the same. It just makes everything much easier for users. For the purposes of this pull request, I don't think you need to do anything special regarding hartids. It is a separate issue, that can be solved separately some day.
I don't think it's as bad as you think. examine() already halts each hart and reads misa. Reading mhartid in addition is not a big change. Some day there will be a unified discovery mechanism, but that group is only just starting up again. But I don't think we need to worry about hartids right now. We do need to worry about debug index and OpenOCD coreid no longer being equal. |
Make sense, ignore hartid for now would make things easier. config |
4be233d
to
7191871
Compare
7191871
to
a36acdb
Compare
I will be able to re-review this change in the week of July 10. |
a36acdb
to
deb5b35
Compare
6e970e9
to
1f9dd23
Compare
27b2297
to
20ada6c
Compare
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 looks fine! I have only few last suggestions regarding the documentation, comments and prints.
@zqb-all Thanks for bearing with all the review comments.
src/target/riscv/riscv-013.c
Outdated
LOG_TARGET_DEBUG(target, "dm @ 0x%x --> nextdm=0x%x", current_dm, next_dm); | ||
/* Check if it's last one in the chain. */ | ||
if (next_dm == 0) { | ||
LOG_TARGET_ERROR(target, "Reach end of DM chain"); |
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 believe you can change this error print to debug. There is already a good and easy-to-understand error message in the function that calls check_dbgbase_exists()
.
If someone needs to dig deeper and troubleshoot the situation, they will most likely enable the verbose log (-d
) and will be able to easily find out what happened.
LOG_TARGET_DEBUG(target, "Reach end of DM chain");
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 disagree. Both of these should be LOG_TARGET_ERROR. These errors will be very rare, so there's no risk of clutter. When the error in the caller does get printed, the user will always want to know immediately which of the two cases were hit. If you only want a single error message (which is not important to me in this case), then the correct way is to remove the error message in the calling function and add more details to these ones here.
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 don't mind both of those being LOG_TARGET_ERROR. It is a detail.
(Still, the message about reaching the end of the DM chain feels redundant: If the search failed, it implicitly means we went through the list and reached the end without finding the item. On the other hand, if it is the very rare case hitting of maximum number of DMs on the DMI bus, then that second error print is justified.)
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.
Let's just use LOG_TARGET_ERROR.
And to make it slightly more useful, I add count of DMs
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.
Sounds good :)
752b288
to
198e0ee
Compare
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.
Two last details, otherwise I consider the review complete from my side.
Thanks!
198e0ee
to
ed393e6
Compare
Thank you for your detailed and helpful review |
prepare for support multiple DMs Change-Id: Ia313006376e4fa762449343e5522b59d3bfd068a Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Support assign DMI address of the debug module by pass -dbgbase to the target create command Change-Id: I774c3746567f6e6d77c43a62dea5e9e67bb25770 Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
5cc1a43
to
b98698a
Compare
Change-Id: I0d65bf9b33fb6d10c33f4f038045832594579e58 Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
b98698a
to
a9f28da
Compare
Support assign DMI address of the debug module by pass -dbgbase to the target create command
Change-Id: I774c3746567f6e6d77c43a62dea5e9e67bb25770