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

Can we get SWD support? #69

Closed
ghost opened this issue Oct 25, 2018 · 29 comments
Closed

Can we get SWD support? #69

ghost opened this issue Oct 25, 2018 · 29 comments
Labels
applet Component: applet debug-arm-swd Applet: debug-swd feature-request Meta: feature request

Comments

@ghost
Copy link

ghost commented Oct 25, 2018

Is that possible while only using FOSS?

@whitequark whitequark added the applet Component: applet label Oct 25, 2018
@whitequark
Copy link
Member

There is already a (preview quality) SWD applet! There's no actual gdbserver (or flasher) support right now mostly because I was going to integrate with @azonenberg's jtaghal, and jtaghal isn't evolving quite quickly enough. There will likely be native gdbserver support, the same as for MIPS EJTAG applet.

@whitequark whitequark added the debug-arm-swd Applet: debug-swd label Oct 25, 2018
@esden
Copy link
Member

esden commented Oct 25, 2018

You might be able to plug it into https://github.com/orbcode/orbuculum

@whitequark
Copy link
Member

That's mostly pointless, it's just more C code I cannot actually distribute with Glasgow itself... Really, the protocol is not very complex.

@whitequark whitequark added the feature-request Meta: feature request label Jul 27, 2019
@whitequark
Copy link
Member

Update: I will not even try to rely on jtaghal, Glasgow-native gdbserver is superior in every way.

@JustAnother1
Copy link

I have done some work on SWD. Please let me know how I can help realize the SWD support.

@whitequark
Copy link
Member

There's a prototype of an SWD applet. What's missing is the actual debugger code. Currently the bottleneck is maintainer time / review bandwidth so there is little you can do to make things faster.

@samlittlewood
Copy link

I have been picking at SWIM+stm8, programming only so far.

@whitequark
Copy link
Member

We should probably have a different issue for SWIM, as far as I remember it's a completely different protocol.

@samlittlewood
Copy link

Certainly! I have a couple more branches from master for other protocols, but they are pretty gross atm. I'll create merge rqs when that have at least some utility.

@wrongbaud
Copy link

Is it worth trying to write a driver for support with openocd? That's something I've done in the past and would be willing to work on.

@whitequark
Copy link
Member

Does openocd have something like the JTAG bitbang interface but for SWD? Anything that works through a socket rather than through libusb would work.

@wrongbaud
Copy link

I believe so - I can start experimenting with this and report back if I find something.

@whitequark
Copy link
Member

We can quite easily add a swd-openocd applet like the existing jtag-openocd one, yep.

@perigoso
Copy link

i never realized there was a jtag-openocd bridge, what are the limitations of it? how fast can the clock go? one of the things i wanted from the glasgow was to use it as a debugger programmer

@whitequark
Copy link
Member

As fast as the native JTAG applet allows, which is currently 6 MHz due to a temporary limitation while we're migrating from Migen to nMigen.

@perigoso
Copy link

in that case that swd-openocd applet could prove real usefull to me, how far away in the horizon do you see that coming? not asking for a timeline, just a ballpark.

@whitequark
Copy link
Member

No idea if OpenOCD can even do the equivalent of that. @wrongbaud may be investigating that; you could take a look too if you want things earlier.

@perigoso
Copy link

I have every intention of helping, especially on matters that are especially useful to me; I will look into it, though i am not very familiar with the inner workings of openocd. Also my glasgow is just a parts bin waiting to be assembled so i can't test anything.

@perigoso
Copy link

So, i looked around the OpenOCD code.
Apparently, as it is right now, the remote_bitbang driver that is used with the jtag-openocd applet only supports JTAG, though i found two unmerged patches that added SWD support, i have no idea why they were left open, but they were trivial changes and if they actually worked it shouldn't be to hard to convince them to push them upstream, i have already opened a ticket asking about it.
That being said, if the remote_bitbang supported SWD, not much would be needed in the glasgow applet side in order for it to work, am i correct?

@whitequark
Copy link
Member

That being said, if the remote_bitbang supported SWD, not much would be needed in the glasgow applet side in order for it to work, am i correct?

Correct.

@perigoso
Copy link

So, after opening the ticket there was some progress, one of the patches was rebased, but it needs to be tested, i cant do it myself, because my glasgow isn't ready, and i don't know how i could do it any other way.

If someone could look into this it would be great, i believe it should work.

Here's the ticket:
https://sourceforge.net/p/openocd/tickets/269/

@electroniceel
Copy link
Member

If someone could look into this it would be great, i believe it should work.

I have a working Glasgow revC1 and would like to help, but I haven't used OpenOCD for some time. So what exactly should I do to test?

Take a recent OpenOCD and apply http://openocd.zylin.com/#/c/4205/
But what would be the next steps to get it running?

I have for example a STM32F072 and would hook up it's SWCLK and SWDIO to the Glasgow.

@FFY00
Copy link
Contributor

FFY00 commented Jul 7, 2020

I think you just need to add the new commands to JTAGOpenOCDSubtarget and then you should be able to get glasgow to open a server, as shown in

class JTAGOpenOCDApplet(GlasgowApplet, name="jtag-openocd"):
, and invoke openocd with the stm32f0x config.

Should look something like this:

openocd -c 'interface remote_bitbang; remote_bitbang_port 2222' -f /usr/share/openocd/scripts/target/stm32f0x.cfg

@whitequark
Copy link
Member

I don't think that would work, JTAGOpenOCDApplet can't electrically do SWD if I remember correctly.

@FFY00
Copy link
Contributor

FFY00 commented Jul 7, 2020

Hum, okay. Then we can just copy it to a new applet and apply the required modifications.

@perigoso
Copy link

perigoso commented Jul 8, 2020

I believe connecting to a target using SWD and that driver should be enough to approve the changes.

I don't think we actually need to change anything in the applet.

@FFY00
Copy link
Contributor

FFY00 commented Jul 8, 2020

Well, you should need to test if the new commands actually work, no?

@perigoso
Copy link

perigoso commented Jul 8, 2020

hm, i don't think i understood quite right how the applet worked, i guess you're right

@whitequark whitequark changed the title Can we get SWIM/SWD support? Can we get SWD support? Nov 4, 2020
@whitequark
Copy link
Member

We now have swd-openocd. I'm going to close this issue since it does enable SWD debugging and it'll likely be quite a while before I have bandwidth to either implement or review support for ADIv5 (including internal architecture changes needed to make it maintainable).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
applet Component: applet debug-arm-swd Applet: debug-swd feature-request Meta: feature request
Projects
None yet
Development

No branches or pull requests

8 participants