ESP32 Bit Pirate home
  • JTAG/SWD
  • Advanced
  • 5 min
  • Serial CLI

Recipe · Advanced · JTAG/SWD

How to use an OpenOCD JTAG/SWD adapter

After SWD/JTAG pins are known, the firmware can switch into an OpenOCD adapter workflow. This recipe is the bridge between discovery and a real debug session.

OpenOCD debug adapter connection.
Do discovery first; adapter mode expects a known pinout and a supported host workflow.

Wiring View

Target BP SWD/JTAGBP GPIOsGNDBP GNDVREFcheck only
Connect the confirmed target debug signals to the GPIOs selected in adapter setup.
Step 1

Start the Bit Pirate adapter

In the Bit Pirate terminal, enter JTAG mode and start the OpenOCD adapter setup:

mode jtag
openocd

Confirm, select the GPIOs and let the board reboot into USB CDC adapter mode. Close the serial terminal before starting OpenOCD.

Step 2

Run OpenOCD on your computer

Run the command matching your wiring on the computer. Replace /dev/ttyACM0 with the adapter's USB port and target/stm32f1x.cfg with your target configuration.

SWD target example

openocd -f interface/buspirate.cfg -c "buspirate port /dev/ttyACM0; transport select swd" -f target/stm32f1x.cfg

JTAG target example

openocd -f interface/buspirate.cfg -c "buspirate port /dev/ttyACM0; transport select jtag" -f target/stm32f1x.cfg

Result

What success looks like

OpenOCD opens the adapter and detects the target through the selected SWD or JTAG transport.

Troubleshooting

  • Port missing or busy: recheck the USB device name and close other serial clients.
  • Missing driver or transport: check OpenOCD Bus Pirate support.
  • Target not detected: verify GPIOs, ground, power and target configuration.
  • Check whether the target is held in reset or low-power mode.

Next steps

  • Use the scan recipes to verify SWD/JTAG pins.
  • Keep a known-good OpenOCD config beside the project.
  • Document target voltage, reset and boot strap requirements.

OpenOCD JTAG/SWD adapter FAQ

Should I scan pins before OpenOCD?

Yes. OpenOCD adapter mode expects a known JTAG or SWD mapping. Use the scan recipes first when the target pads are not labelled or not trusted.

What role does Bit Pirate play in an OpenOCD session?

Bit Pirate acts as the USB-facing transport adapter. OpenOCD still provides the target configuration, reset strategy and debug protocol logic for the MCU or SoC you are investigating.

Is Bit Pirate a replacement for a high-speed debug probe?

No. The USB adapter is useful for bring-up, recovery, experiments and low-speed debug access, but dedicated JTAG/SWD probes are better for production flashing and heavy debug sessions.

Go deeper