Skip to content
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

CMSIS-DAP trace commands proposal #3

Open
flit opened this issue Oct 12, 2021 · 12 comments
Open

CMSIS-DAP trace commands proposal #3

flit opened this issue Oct 12, 2021 · 12 comments

Comments

@flit
Copy link

flit commented Oct 12, 2021

Hi there! 👋🏽

You should know about the proposal to add trace command support to CMSIS-DAP. The proposal is from @gzied of Trande UG and was first proposed and is documented in ARMmbed/DAPLink#781. There is also a gdb extension that has been proposed on the Linaro mailing list. The CMSIS team are aware of this proposal.

The proposals are attached:
DAP_TPIU_proposal.pdf
gdb_remote_protocol_extensions_etm_btrace.pdf

Other links:
Detailed memo to Linaro CoreSight mailing list
Announcement on Linaro CoreSight mailing list

The gdb extension code is in gzied/binutils-gdb.

I'd very much like to see a standard come out of this collection of works, and not have multiple incompatible trace extensions arise. I don't know what your plans are for the host protocol, but hopefully we can pull together and produce a common interface that builds on the wide reach and compatibility of CMSIS-DAP. 🚀

Fyi, I'm not associated with Trande UG. I'm just a maintainer of DAPLink and pyOCD, and an employee of Arm. I often represent open source community interests with the CMSIS team at Arm. (I'm not a member of the CMSIS team; I'm a systems researcher in Arm Research).

If you'd like, feel free to send me an email (check my GH account info) and we can talk offline, too.

cc @mbrossard

@flit
Copy link
Author

flit commented Oct 12, 2021

(After reading your docs site a bit…)

I should mention that I have been planning a proposal to add power and voltage controls to CMSIS-DAP. I'll keep you informed.

@mubes
Copy link
Contributor

mubes commented Oct 12, 2021 via email

@flit
Copy link
Author

flit commented Oct 13, 2021

That's great you're already talking with Zied.

I certainly understand focusing on getting a first stable release. Looking forward to seeing the end result!

Regarding the trace endpoint and interface, that makes sense and is the kind of feedback we need.

We may want to support both cases of TPIU framing included and not. As you probably know, Zied wants to completely avoid software intervention and data massaging on the probe side, so the FPGA fabric can directly perform USB DMA transfers. While you could do that in hardware, it would add complexity, gate count, and perhaps latency. Whereas the host generally has plenty of spare cycles for that kind of thing even at USB3 speeds. It might be easier and more flexible to have a host-side process that receives the raw data, de-frames and serves separate streams over TCP.

Btw, I'm keen to add support for trace to pyocd as soon as feasible and time permits.

Cheers
-c

@mubes
Copy link
Contributor

mubes commented Oct 13, 2021 via email

@gzied
Copy link

gzied commented Oct 14, 2021

Hi Dave, Chris,
the proposals brought to the community, either to extend CMSIS-dap interface, OpenOcd, gdb and eclipse are considering different use cases/implementations and are meant to be a starting point for an industry standard.

@dave please start checking the proposal pointed out by Chris, it is there to be reviewed, discussed and amended.

Port size, trace buffer etc... are already part of the proposal. Other aspects like frame sync timeout, power level etc.. can be added.
Power level is usually buried down in hardware/firmware either using active sensing or delegating it to components that does this automatically. It is for example not part of the cmsis dap interface for debugging, probably for such reasons. It is not tracing specific and should be done at the upper level.

It is very attractive to do the deframing in hardware, and as we discussed it, I did not consider it only because it may be in a grey zone of some existing patents.
If you do the deframing in hardware, you have to report the correct parameters to the consumer of trace data. This info comes from the registers of TPIU, and openOcd/pyOcd, needs to collect and report them. You will need then to change the content of values retrieved from those registers by the debugger driver to let the consumer of the data know the actual formatting in place.

/Zied

@flit
Copy link
Author

flit commented Oct 14, 2021

Our current implementation is completely gateware (including
CMSIS-DAP), there is no CPU intervention at all....there is a VexRISCV
optionally in the build, but we don't actually use that at the moment.

That's really cool!!

python isn't the best environment for handling 40MByte/sec streams :-)

It depends on what you're actually doing and how much is done in native (C/Rust/etc) extensions. For the major use case of passing trace data to gdb or a tool like Orbuculum, very little would be done in Python so performance should be ok (remains to be proven of course), or processing directly with the Python API and commands. The latter would likely be processing smaller chunks of trace data, and could be built on native extensions if performance isn't acceptable, while still providing a convenient and simple Python API.

@mubes
Copy link
Contributor

mubes commented Oct 14, 2021 via email

@flit
Copy link
Author

flit commented Oct 18, 2021

I'm not going to get into the discussion about when python is appropriate and when it isn't.

Sorry, didn't mean to pry open that can of worms! 😄

the orb decoding stack is built to be lib-rified

Good to hear, that's just what I was hoping for.

for way too long the silicon has been able to do things that no reasonably priced tool has been able to access

Right on the mark!

That's part of my interest is expanding CMSIS-DAP in this regard. The availability of CMSIS-DAP and its wide support in tools has made possible the extensive ecosystem of open source debug probes. Stepping that up to support trace can only benefit the whole embedded developer community.

lot of additional cool things that can be done

Completely agreed. That is one of the ideas behind pyocd, too.

Overall, it sounds like all of our projects fundamentally have the same motivation and goals.

@zyp
Copy link
Collaborator

zyp commented Oct 18, 2021

The Orbtrace gateware is designed to be modular and flexible, so I see no reason we wouldn't support a CMSIS-DAP trace extension. On the other hand, we naturally also want to keep the current interface, and the gateware architecture makes it easy to build it with support for either or both.

For perspective: CMSIS-DAP support for debug is also an optional feature of the gateware. I'm personally a big fan of having a gdbserver running on the debug unit itself so that gdb can connect directly rather than requiring additional middleware on the host. We've got the modularity to support either, although the latter is not implemented yet.

@flit
Copy link
Author

flit commented Oct 18, 2021

Sounds good!

From my experience, having the gdbserver on the debug unit makes for greater complexity and more difficulty for managing target support (especially flash algos and "special" debug logic). It also means the debug unit firmware can be more stable and simple. (Although DAPLink has USB MSD flash programming, which adds most of that complexity back in…) But that's just a personal view. 😉

@mubes
Copy link
Contributor

mubes commented Oct 18, 2021 via email

@zyp
Copy link
Collaborator

zyp commented Oct 18, 2021

From my experience, having the gdbserver on the debug unit makes for greater complexity and more difficulty for managing target support (especially flash algos and "special" debug logic).

Yeah, I agree it's a two edged sword, which is why I'd like to have both the gdbserver option that'll cover 90% of my use cases and the CMSIS-DAP option that's able to be used with whatever host middleware that's able to provide the remaining 10%. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants