Getting Started with OPENOCD Using FT2232H Adapter for SWD Debugging

Adapter for SWD Debugging

Old MCUs from vendors like ATMEL and MICROCHIP, like the PIC16F and Atmega family, tend to have a special programming interface to program internal flash. For example, Atmega used SPI pins (MISO, MOSI, SCK) and PIC used two pins (PGC, PGD)— one as a clock and another as a bi-directional data line.

New MCUs, especially with an ARM core, use JTAG/SWD as a programming/debugging interface.

What is the difference between Joint Test Action Group (JTAG) and Serial Wire Debug (SWD)? The answer is that SWD was created as an alternative to JTAG to save pins in the MCU package: SWD replaces the 5-pin JTAG interface with one that's only 2-pin.

To communicate with our target chip, we need a program on the host and hardware as a bridge between the host and the chip. In this tutorial, we will use OpenOCD as the program on the host to send commands and communicate using SWD. We'll use an FT2232H as the bridge to translate signals from the USB port to the SWD interface.

Overview of OpenOCD

Open On-Chip Debugger (OpenOCD) is a free, open-source project that aims to provide debugging, in-system programming, and boundary scan using a debug adapter. The adapter is a hardware module that provides the right signals for the target to understand.

OpenOCD debugger supports a lot of debugging adapters, which can be viewed on the OpenOCD website.

To make OpenOCD work, you should configure it using commands or by using configuration files. When configuration is done and a connection with the target is established, OpenOCD will start running as daemon. Daemon is a background process that answers requests for services. OpenOCD will now wait for connections from GDB, Telnet, or whatever other channel and process given commands.

Overview of FT2232H

FT2232H is dual high-speed USB to multipurpose UART/FIFO IC. This means it is a single-chip USB with dual ports.

Every port is equipped with an engine called a Multi-Protocol Synchronous Serial Engine (MPSSE) to simplify a synchronous serial protocol (USB to JTAG, I2C, SPI, or bit-bang) design. This allows users to configure the channel with the desired protocol. MPSSEs are available on channel A and channel B and can be configured to allow any synchronous serial protocol.


Be Aware Before Selecting OpenOCD

Selecting OpenOCD as your debugging tool with an adapter like FT2232H is a very good choice when you don’t have much budget to work with.

In addition to being free and open source, OpenOCD also has a good support community. BUT, as with any other open-source tool, you could face bugs you may need to fix by yourself.

It took me some time to understand how to make OpenOCD work and flash my MCU, and I hope this tutorial will be a good and complete reference.

Also, I advise anyone searching for debugging tools to choose wisely. For example, if you need a simple tool, I think OpenOCD might not be the best choice for you!

Other good alternative debugging tools are:

  • Segger J-Link
  • Default debuggers embedded into evaluation boards (like STM32, EFM32, and other MCU families) by silicon vendors

In conclusion, if you don’t have much budget, time, or patience, OpenOCD with FT2232H will be a great choice for you.

For more detail: Getting Started with OPENOCD Using FT2232H Adapter for SWD Debugging

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Follow Us:
Scroll to Top