[mbedmicro/pyOCD] Are there any examples for using pyOCD with JTAG only devices (#592)

4 views
Skip to first unread message

Jie Zhang

unread,
Mar 25, 2019, 4:33:17 PM3/25/19
to mbedmicro/pyOCD, Subscribed

Hi, I'm looking for some examples for using pyOCD with JTAG only devices. I have a target with Cortex-M core which only supports JTAG. I tried to use pyOCD and a CMSIS-DAP adapter to connect to it, but not successful. I'm wondering maybe I should manually select JTAG mode. Is there an example for manually select JTAG mode? Thanks.

The CMSIS-DAP adapter I'm using does support both JTAG and SWD modes. I can use OpenOCD to connect to the target successfully.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Chris Reed

unread,
Mar 25, 2019, 5:02:42 PM3/25/19
to mbedmicro/pyOCD, Subscribed

Hi! No, I'm sorry but pyOCD doesn't truly support JTAG at the moment. We've never encountered a device that only supports JTAG and not SWD, and SWD is more efficient than JTAG. So there really has not been a reason. This is the first time it's been requested (I think).

You probably can get it to work with a few small changes.

  • Add a user option to select between SWD or JTAG.
  • Probably need user options to set the JTAG device count and IR length. Then the DAP_JTAG_Configure CMSIS-DAP command needs to be sent with these option values. The command is already implemented in CMSISDAPProtocol but would need to be exposed at higher levels.
  • Ideally would also support scan-chain auto-detection using DAP_JTAG_Sequence, but this not strictly necessary. (STLink also supports JTAG but only supports auto-detect.)
  • At pyocd/coresight/dap.py:92 it should check that SWD is selected before executing self.link.swj_sequence().

That might be all! 😄

If you make progress, we would love to see a pull request to enable JTAG! I'll also put JTAG support on the roadmap.

Jie Zhang

unread,
Mar 25, 2019, 6:15:07 PM3/25/19
to mbedmicro/pyOCD, Subscribed

Thanks. I saw #110 has been merged in 2015. I thought pyOCD might have already supported JTAG only devices.

Chris Reed

unread,
Mar 25, 2019, 6:44:01 PM3/25/19
to mbedmicro/pyOCD, Subscribed

Interesting! I wasn't aware of that PR. Unfortunately it was a long time ago and it seems parts of the JTAG support introduced by that PR were broken and/or dropped along the way. I'll create a new issue to fix that regression, and to get JTAG testing integrated into our CI system.

Chris Reed

unread,
Mar 25, 2019, 7:23:24 PM3/25/19
to mbedmicro/pyOCD, Subscribed

Actually, I was mostly wrong. It looks like JTAG support wasn't dropped, I was just looking at the wrong location. DAPAccessCMSISDAP.swj_sequence() has the logic to init JTAG. So all that's missing are the user options and STLink JTAG support. I created #593 to track this.

You could hack in JTAG support by changing pyocd/coresight/dap.py:91 to pass DebugProbe.Protocol.JTAG. However, this has not been tested in quite some time, probably since #110 was introduced. So no telling if there are other issues that will prevent it from working. If you do encounter other problems, please create GitHub issues so we can get them fixed.

Sorry for my incorrect first response!

Jie Zhang

unread,
Mar 25, 2019, 7:34:56 PM3/25/19
to mbedmicro/pyOCD, Subscribed

It's OK. Thanks for you detailed replies. I have further questions. Instead of hack, what's the proper way to add a JTAG only target? Does pyOCD already support multiple JTAG devices on the same scan chain now?

Chris Reed

unread,
Mar 25, 2019, 7:45:26 PM3/25/19
to mbedmicro/pyOCD, Subscribed

It looks like right now it's hard coded for a single device with an IR length = 4. This is in the DAPAccessCMSISDAP.swj_sequence() function where it calls self._protocol.jtag_configue(4). If you changed this call you can adjust IR length and number of devices (device count is the second optional param).

The proper way to implement this is detailed in #593. Basically it needs new user options to control JTAG vs SWD, IR length, and device count.

The actual support for multiple devices on the scan chain is handled entirely in the CMSIS-DAP firmware. The DAP_JTAG_Configure command just tells it the number.

Chris Reed

unread,
Apr 13, 2019, 6:25:52 PM4/13/19
to mbedmicro/pyOCD, Subscribed

Is it ok to close this issue now that #593 has been added to track implementing the rest of the features required to properly support JTAG? Thanks.

Jie Zhang

unread,
Apr 24, 2019, 9:45:38 PM4/24/19
to mbedmicro/pyOCD, Subscribed

Closed #592.

Reply all
Reply to author
Forward
0 new messages