klonyyy / STMViewer

Real-time STM32 variable & trace viewer
GNU General Public License v3.0
556 stars 62 forks source link

Support for J-Link Debug Probes #22

Closed kmeinhar closed 6 months ago

kmeinhar commented 9 months ago

Hey! Just saw your great post on the Interrupt blog and would love to use this tool as well!

Sadly we are not using STM MCUs but processors from Silabs and Nordic. If it is possible to support those the versatility of this tool would greatly be increased. Below I will describe the things I found might be necessary to support those processors.

Development boards by both companies are shipped with a debugger that runs Segger J-Link software. As far as I can tell they would be able to at least support the Variable Viewer feature. Because this debug probe can also view memory at run time.

The biggest problem for implementing support is that there is no open source implementation of Segger J-Link debugger similar to stlink library. But it seems to be possible to access J-Link probes with their dynamic library that they ship with their J-Link tools binary: https://www.segger.com/downloads/jlink (Installs library in /opt/SEGGER/JLink/libjlinkarm.so on Linux) There is a this Python library that does exactly that: https://github.com/square/pylink They do this by wrapping the calls in this library here: https://github.com/square/pylink/blob/master/pylink/library.py An example on how to read memory can be found here: https://github.com/square/pylink/blob/master/pylink/jlink.py#L2889

For STMViewer it would be necessary to create a new JlinkHandler to replace the current StlinkHandler. This JlinkHandler would then use libjlinkarm to open debugger and read memory in the same way.

When I find time I might try to create a draft PR for this support. But already thanks for this great tool!

escherstair commented 9 months ago

Support for J_Link probes would be great. I'm going to test it and to give feedback when the support is available.

kmeinhar commented 9 months ago

@escherstair Created a draft prototype. But much more work required.

klonyyy commented 6 months ago

Hello everyone, first prototype of the JLink support is merged to devel. Feel free to test it out and let me know how it went. I'll close this general issue, if there are any specific problems, please start a new issue. Thanks for your contribution!