Is there any chip solution available to do SWD <---> JTAG conversion? - Page 1
Forum section: electronics / general

author: muthukural001
author_rank: Regular Contributor
timestamp: April 07, 2020, 05:00:46 am
content: Hello All,I am looking for a chip that can do SWD <---> JTAG conversion. Is there any chip solution available for this?.If anyone have come across this, please suggest.Thanks and Regards,Muthu

author: ataradov
author_rank: Super Contributor
timestamp: April 07, 2020, 05:10:20 am
content: It is not generally possible. Those interfaces are not identical in functionality.

author: fchk
author_rank: Frequent Contributor
timestamp: April 07, 2020, 05:26:01 am
content: It also doesn't make any sense. There are enough USB Debug cables that can do both, so you simply don't use the other ones. Problem solved.

author: muthukural001
author_rank: Regular Contributor
timestamp: April 07, 2020, 05:37:08 am
content: Hi Ataradov,Thanks.I have FT2232H and it supports to interface only JTAG signals...Since the SoC is having only SWD signals, I need an Interface adapter to convert SWD to JTAG and vice versa. I have found something in online, there they have connected signal as in the attached picture. I have no idea that it is a generic one that can work for me as well.

author: ataradov
author_rank: Super Contributor
timestamp: April 07, 2020, 05:41:04 am
content: FT2232H supports SWD in a normal bit-bang mode, it just depends on the driver. What software you are planning to use with that FT2232H?The circuit is just a generic map from a usual JTAG pinout to SWD pinout. You still can't use JTAG driver to talk SWD.

author: muthukural001
author_rank: Regular Contributor
timestamp: April 07, 2020, 05:56:47 am
content: Hi Ataradov,Thanks.FT2232H has dual ports, we are fixing one for UART and other for SWD/JTAG use.Nowhere in FT2232H datasheet, it is saying that it supports SWD explicitly.Also, it seems that there is no driver support for FT2232H for SWD. Regarding software to be used with FT2232H, I have no idea what is customer going to use.

author: ataradov
author_rank: Super Contributor
timestamp: April 07, 2020, 06:01:17 am
content: Well, that's important. It does not just magically support JTAG either. Yes, it has hardware that implements JTAG, but without the driver and the software that uses it, it is useless anyway.It does not need to say that. FT2232H supports arbitrary pin manipulation, this is sufficient to implement SWD interface.OpenOCD, for example supports it in that mode. And that's where your picture is coming from. But this is not a generic thing. This is something OpenOCD authors coded in their tool.

author: muthukural001
author_rank: Regular Contributor
timestamp: April 07, 2020, 07:25:51 am
content: Hi Ataradov,Thanks.It means that we need to develop SWD driver ourselves, which will be programmed into FT2232H. With the SWD driver programmed on FT2232H, can we use the circuit in the picture that I shared previously, to interface FT2232H with our SoC?

author: ataradov
author_rank: Super Contributor
timestamp: April 07, 2020, 07:29:54 am
content: You don't need to program anything into FT2232H. It already comes with the OS drivers that let you do anything you want with any of the pins (set, clear, read). Whatever software you are using must know how to talk to those drivers and how SWD interface works.Again, it all depends on the actual debugger/programmer software you will be using. If it does not support FT2232H already, there is not much you can do. If it does, then you don't need to do anything.For example, if you want to debug using GDB over OpenOCD, then you don't need to do anything at all.But if you want to debug using IAR or something like this, and there is no already supported FT2232H-based debugger, then you will have to create IAR-specific driver. And that I have no idea how to do, you would have to figure that out for each vendor individually. It is really much easier to take any general purpose MCU and implement CMSIS-DAP interface. You will automatically gain support by all the tools.

author: muthukural001
author_rank: Regular Contributor
timestamp: April 07, 2020, 08:53:48 am
content: Hi Ataradov,Thanks for the detailed explanation. Still, I have one question. Provided my Software supports SWD, can I connect my SOC's SWD pins to the respective pins of FT2232H directly?Thanks and Regards,Muthu

author: fchk
author_rank: Frequent Contributor
timestamp: April 07, 2020, 11:57:56 am
content: Quote from: muthukural001 on April 07, 2020, 08:53:48 amNo. The FT2232 needs additional hardware for this.A TI XDS100v2 uses a CPLD for this.http://software-dl.ti.com/sdo/sdo_apps_public_sw/XDS/XDS100v2Schematic(rev2)-Setup.zipOlimex does it with gates. (non-switchable)https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-SWD/You may want to use this instead of FT2232H:https://github.com/majbthrd/DapperMiser

author: ataradov
author_rank: Super Contributor
timestamp: April 07, 2020, 03:49:03 pm
content: Quote from: muthukural001 on April 07, 2020, 08:53:48 amYour software must support SWD over FT2232H specifically, like OpenOCD does. In that case you don't need any additional adapters.

author: muthukural001
author_rank: Regular Contributor
timestamp: May 18, 2020, 02:20:40 pm
content: Hi Ataradov,Our software supports SWD. So, can we follow Openocd's SWD to JTAG wiring diagram as attached, to connect our SoC's SWD signals to FTT2232H's JTAG ?Do you see any issue with it?. Please suggest.Thanks,Muthu

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 18, 2020, 02:30:46 pm
content: The FT2232H absolutely supports SWD. I have actually designed a JTAG/SWD probe that can do both JTAG and SWD from the same chip.Now of course your software must support this too. OpenOCD does.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 18, 2020, 02:46:40 pm
content: Quote from: muthukural001 on May 18, 2020, 02:20:40 pmIt's not just about the wiring though.Your software has to support SWD with the FT2232H. Is that the case? (It requires proper driving of it, including the change of data direction on the fly, etc.)

author: muthukural001
author_rank: Regular Contributor
timestamp: May 19, 2020, 09:52:20 am
content: Hi SiliconWizard,QuoteIf possible, can you share the circuit that you used to interface SWD signals to FT2232H?Thanks,Muthu

author: TK
author_rank: Super Contributor
timestamp: May 19, 2020, 12:47:20 pm
content: What is your target uController that needs SWD? Just get a Segger Jlink Edu mini or some other low cost programmer / debugger.

author: chriva
author_rank: Regular Contributor
timestamp: May 19, 2020, 01:10:56 pm
content: Almost all of STM's controllers with SWD have built-in bootloaders which lets you use UART to program them.There is no such thing as an electrical converter for JTAG <-> SWD since they use completely different protocols. You either get an adapter that knows how to talk the language/is electrically compatible or use the bootloaderIt has been a while so I don't remember the details but I know you can turn a stm32f103 board into a st-link by burning the appropriate firmware to it and get a compatible programmer/debugger that way.Some info about the built-in loader:https://www.st.com/resource/en/application_note/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf

author: TK
author_rank: Super Contributor
timestamp: May 19, 2020, 01:24:41 pm
content: Quote from: chriva on May 19, 2020, 01:10:56 pmstm32F103 nucleo board already has ST-LINK, you can reprogram it with Segger Jlink for free, but it will only work with STM32 cortex-M targets

author: ataradov
author_rank: Super Contributor
timestamp: May 19, 2020, 03:53:02 pm
content: Quote from: muthukural001 on May 19, 2020, 09:52:20 amYou really need to understand that the circuit depends entirely on your software.FT2232H is just a dummy USB-to-GPIO interface in this case. What pins do what is defined purely by the software.So figure out what software wants, and you will know automatically what pins to use and the schematic will be obvious.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 19, 2020, 04:05:22 pm
content: Quote from: ataradov on May 19, 2020, 03:53:02 pmNot quite.It has a not too shabby serial engine (MPSSE), which is also used for SWD (which allows to get pretty high communication speeds you could certainly never get if the serial transfers were just bitbanged.)At least OpenOCD does make use of the MPSSE in SWD mode. You could entirely bit-bang SWD, but that would be pretty slow.So for SWD, two of the signals (CLK and IO) can only go to specific pins of the FT2232H (if you want to make use of the MPSSE.) That's typically ADBUS0-2 (or BDBUS0-2).You can put all other signals of course freely on other IOs of the FT2232H, and of course the software must handle data direction properly, but between direction changes, the serial engine takes care of the communication.As for sharing a schematic, that's actually one project I did entirely with a schematic-less design entry tool I designed like 1 1/2 year ago (you could probably find the thread in the EDA section), so I have no schematic to share for this to speak of unfortunately, and the source file for the design would probably not help you much without extensive explanations. As said above, all that matters is to wire SWDCLK and SWDIO to respectively TCK and TDI/TDO pins of the corresponding channel on the FT2232H as the schematic you posted shows. The other required control pins will all depend on your software as they are just GPIOs, and are configurable if you use OpenOCD. Take a look at some interface config files for OpenOCD to figure it out, and I think it's also documented in OpenOCD's docs.

author: profdc9
author_rank: Frequent Contributor
timestamp: May 22, 2020, 04:52:24 am
content: OpenOCD has CFG files already for the cheaper FT232H in SWD modehttps://github.com/unprovable/FTDI-Oh-My/blob/master/FT232H-openOCD.cfghttps://github.com/ntfreak/openocd/blob/master/tcl/interface/ftdi/ft232h-module-swd.cfgYou could probably buy any FT232H breakout off of ebay/aliexpress and connect it up as shown in the cfg files, and it should talk SWD.If you use OpenOCD, there's very little to do, as it already knows how to talk SWD using the MPSSE engine of the FT232H.