Proposal to Extend RISC-V DMI Transport in OpenOCD #1175
Replies: 12 comments 31 replies
-
It might be a good idea to also run your proposal by the upstream OpenOCD community in case they have any views on it or anybody there might be undertaking similar work? |
Beta Was this translation helpful? Give feedback.
-
Thanks for this proposal! I believe it will be a great improvement. First of all, I'd like to support @TommyMurphyTM1234's suggestion to post this in the mainline's mailing list. I think you will be able to get a lot of valuable feedback there.
I'd like to disagree.
I'm a bit concerned with this part. OpenOCD benefits a whole lot from bundling a bunch of RISC-V DMI transactions into a single USB packet. This is possible thanks to sticky error state of RISC-V JTAG DTM. What I'm trying to say is: efficient communication over USB or TCP/IP will require a more complex interface then the pair of I'd suggest you to look into target/riscv/batch.h. This is the interface currently used to access DMI over JTAG. Though it is a bit JTAG-specific and there are parts that are done separately (e.g. the |
Beta Was this translation helpful? Give feedback.
-
Just to clarify, my reasoning is that the suggested changes sound broad enough that that will most likely require changes beyond the RISC-V target specific parts of OpenOCD and, as such, will benefit from input from, and require acceptance by, the wider OpenOCD community and developers. If the changes were restricted to OpenOCD's RISC-V target specific support then this would be less critical, albeit still a good idea and good manners. 🙂 |
Beta Was this translation helpful? Give feedback.
-
Actually we were thinking, this proposal might be restricted to RISC V
implementation since we were gonna make DMI as the transport module API
interface. Since other Arch dont directly support DMI, we might need to
provide a different abstraction if we want to extend this beyond RISC V
support.
Below is a graphical overview of what we are thinking in terms of how the
newly proposed Transport layer would interface with RISCV specific
implementation.
[image: Screenshot 2024-11-26 at 11.25.56 AM.png]
Pls let us know your thoughts. Thank you
WR
~S
…On Tue, Nov 26, 2024 at 10:01 AM Tommy Murphy ***@***.***> wrote:
First of all, I'd like to support @TommyMurphyTM1234
<https://github.com/TommyMurphyTM1234>'s suggestion to post this in the
mainline's mailing list. I think you will be able to get a lot of valuable
feedback there.
Just to clarify, my reasoning is that the suggested changes sound broad
enough that that will most likely require changes beyond the RISC-V target
specific parts of OpenOCD and, as such, will benefit from input and require
acceptance by the wider OpenOCD community and developers. If the changes
were restricted to OpenOCD's RISC-V target specific support then this would
be less critical, albeit still a good idea.
—
Reply to this email directly, view it on GitHub
<#1175 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APHNMDUCIQL6IOZLDMH35RT2CSZN5AVCNFSM6AAAAABSQZV64WVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMZYGY3DKNI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
.com>
|
Beta Was this translation helpful? Give feedback.
-
This new diagram (#1175 (reply in thread)) makes much more sense, though it may still require some adjustments.
If it comes to RISC-V implementation - we'll have the concern raised by @en-sc (#1175 (comment)):
Regarding this point:
There are at least two issues known to me :
SWD had DAP (debug access point), JTAG has TAP (test access point). If you introduce, say PCIe interface - it does not make sense to configure jtag scan-chain that consists of TAPs (and each TAP requires certain transport-specific characteristics like IRLEN to be set). To me it looks like the presence of these new transports may require introduction of "access points" types - and this is the change that should be definitely discussed with upstream OpenOCD folks. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer Anatoly. Ideally, we want to limit all of the changes in this proposal to remain within the RISCV port. Here are a few proposals:
Example of config file:
What do you think about this proposal? |
Beta Was this translation helpful? Give feedback.
-
Hi @anicic-nikola and all, General comments Overall, I like this proposal of having a higher-level RISC-V debug transport in OpenOCD very much. In fact, we have developed something similar in Codasip internally. It would be beneficial for the whole community to have a unified solution. Also thank you for describing the proposal in a very clear and understandable manner. Where to make the change - riscv-openocd vs. vanilla openocd.org Since there would be target-independent changes (in the transports), I am slightly more inclined to suggest the vanilla openocd.org upstream. I don't feel strongly, though. I will be happy to provide code reviews in either place. Comments to the concrete proposal I have posted my recommendation in a separate comment. Thanks and regards |
Beta Was this translation helpful? Give feedback.
-
Hi @JanMatCodasip @TommyMurphyTM1234 @en-sc @aap-sc Firstly thank you so much for reviewing this proposal. This is very helpful for us. Meantime we made some comments Pls take a look and let us know what you think Regards, Shankar/Nikola |
Beta Was this translation helpful? Give feedback.
-
Thanks for the proposal! If we consider running OpenOCD on a RISC-V hart, debug other RISC-V harts on the same chip. Assume the hardware is implemented in the most direct way, allowing hart to access the DMI bus, then OpenOCD can directly read and write the specified physical memory address equivalent to reading and writing the registers of the DMs. |
Beta Was this translation helpful? Give feedback.
-
Hi, guys, @TommyMurphyTM1234 @en-sc @JanMatCodasip @aap-sc @zqb-all We appreciate a lot your proposals. Here is the structure of the files added for this prototype:
and of course Makefiles updated. The interface of the dtm.h looks like this: // Defines the abstract interface for the Debug Transport Module (DTM)
#ifndef RISCV_TRANSPORT_DTM_H
#define RISCV_TRANSPORT_DTM_H
#include <stdint.h>
#include <stdbool.h>
typedef struct dtm_driver {
const char *name; // e.g., "jtag", "pcie", "socket"
int (*init)(struct dtm_driver *driver);
int (*deinit)(struct dtm_driver *driver);
int (*read_dmi)(struct dtm_driver *driver, uint32_t *data, uint32_t address);
int (*write_dmi)(struct dtm_driver *driver, uint32_t address, uint32_t data);
void *priv; // Private data for the driver
} dtm_driver_t;
int register_dtm_driver(dtm_driver_t *driver);
dtm_driver_t *get_dtm_driver(const char *name);
int select_dtm_driver(const char *name);
dtm_driver_t *get_active_dtm_driver(void);
#endif /* RISCV_TRANSPORT_DTM_H */ And then in
static const char * const riscv_dtm_transports[] = { "jtag", "socket", "pcie", NULL };
static dtm_driver_t socket_driver = {
.name = "socket",
.init = socket_dmi_init,
.deinit = socket_dmi_deinit,
.read_dmi = socket_dmi_read_dmi,
.write_dmi = socket_dmi_write_dmi,
.priv = NULL
}; to be compatible to this driver, so all these methods to create a socket, or send/receive dmi commands are registered to the driver itself. |
Beta Was this translation helpful? Give feedback.
-
Hi, guys @TommyMurphyTM1234 @JanMatCodasip @en-sc @aap-sc @zqb-all |
Beta Was this translation helpful? Give feedback.
-
Hi, guys @TommyMurphyTM1234 @zqb-all @aap-sc @en-sc @JanMatCodasip As you can see from this commit from my forked repo (that had some previous commits to it, too) I went around it in some hacky way to just see what needs to be changed and to later examine all of the necessary changes.
To halt a RISC-V core via DMI, we typically need to write to the Instead of just hacking around the JTAG dependencies, I'm exploring how we can extend OpenOCD to better support non-JTAG transports like our socket-based DMI communication. One idea is to introduce somehow a more abstract interface for target operations (halt, resume, etc.) that isn't tied to JTAG specifics. This would allow us to implement these operations in our custom transport driver. What are your thoughts on it? In the end, the idea is to bypass the JTAG if it is not needed, like it is logically not needed for the socket DMI communication with some server that accepts DMI commands, it does not make sense to have JTAG interface here in our case. |
Beta Was this translation helpful? Give feedback.
-
Why?
Our company, Esperanto Technologies, is actively working with RISC-V hardware and identified a need to support alternative transport methods for Debug Module Interface (DMI) communication beyond JTAG. While JTAG serves many use cases, expanding the supported transport layers to PCIe and Socket would enable:
Flexibility for developers with varying hardware setups.
Networking capabilities through socket-based communication.
Easier integration for RISC-V devices using PCIe for debugging.
These additions would not only meet our internal needs but also benefit the broader OpenOCD and RISC-V communities by demonstrating how to extend transport layers and enabling similar contributions from others.
What?
We propose introducing PCIe and Socket as new transport layers for OpenOCD in the riscv-openocd repository.
Key changes include:
transport select socket
. For the socket layer, additional configuration options like host and port will be added.dmi_read
anddmi_write
functions for RISC-V will dynamically route to the appropriate transport implementation (JTAG, PCIe, or socket) based on user configuration.The selected transport implementation will be injected into the RISCV_INFO structure, ensuring seamless functionality during debugging.
How?
Implementation: We plan on introducing modular transport layers, starting with PCIe and socket, under
src/transport
. Then to modify RISC-V-specificdmi_read
anddmi_write
to invoke the correct transport function dynamically.Extending the OpenOCD configuration parser to allow transport selection (jtag, pcie, socket) will be done if needed, but we believe the transport selection function should follow OpenOCD transport infrastructure pattern. and additional parameters for the socket transport will be done.
Our goal is also to engage the OpenOCD community early, seeking feedback on design and implementation to align with the project's goals and to maintain high code quality.
We believe these changes will make OpenOCD more flexible and powerful for RISC-V developers, both inside and outside of our organization.
Does this proposal align with the community's goals?
Are there additional considerations we should address before proceeding?
Looking forward to your thoughts and suggestions!
Best regards,
Nikola Anicic and Shankar Jayaratnam @NinjaDev108
Esperanto Technologies
Beta Was this translation helpful? Give feedback.
All reactions