Using Flyswatter JTAG to Flash STM32

Content

Earlier I described how to flash the IFLAT32 and the STM32VL board through X-Link JTAG and OpenOCD. Since my X-Link lately stopped working for no reason, I bough the flyswatter JTAG from tincantools. The flyswatter is known to work very well with Linux, and to be supported from OpenOCD. Also it is fairly cheap (well compared to the X-Link, more then twice as expensive, but anyway). Now, the only thing is, the flyswatter comes with an 14 pin JTAG, whereas the X-Link came with a 7 pin mini JTAG. Since I want to flash the IFLAT32, which also comes with a 7 pin mini JTAG, as well as my various STM32VL based projects (which I also equipped with a 7 pin interface), I need an adapter for that. So what will be described in this howto, is how to build that adapter, how to invoke OpenOCD to flash the above mentioned boards. I will not go into details on how to install OpenOCD ore things I already described here and her.

1. 14 to 7 Pin JTAG Adapter

The 14 pin JTAG of the flyswatter has a pinout as described here. The mini JTAG of the IFLAT32 has a layout as shown here. Thus, the adapter schematic looks like this:

Schematic 14 pin flyswatter JTAG to 7 pin mini JTAG

Also I soldered some male header pins onto the flyswatter (there are already wholes for that on the board). Then I can put a jumper on the on header pin J3 between +3.3v and Vtarget. Since Vtarget and Vsupply are connected together on the flyswatter, setting this jumper will result in a 3v3 power supply on pin 1 of the mini JTAG, thus if the jumper is set as show in the picture below, your target board is power supplied by the flyswatter. If you intend to power supply your target from a different source, leaf this jumper out.

Jumper for 3v3 power-supply on JTAG

For information on the JTAG interface, and the interfacing with STM32 MCUs, this page provides some good information.

The following table shows, which pins from the STM32 must be connected to the corresponding pins of the 7 pin mini JTAG:

Pin

Name

Connection

Type

1

VCC

3.3V

Output

2

GND

GND

Output

3

nTRST

PB4

Input

4

TMS

PA13

Input

5

TDO

PB3

Input

6

TDI

PA15

Output

7

TCK

PA14

Input

A note on the “Pull-ups/dows” discussion: you will find adapters using pull-ups/dows for some of the pins (TMS, TDI, TDO, nSRST and nTRST should have pull-ups of 10k normally, TCK, RTCK, DBGRQ and DBGACK should have a pull-down of 10k normally). But as “micromouse” also points out in his post, the STM32 comes with build in pull-ups/downs, so there really is no need to use external pull-ups/downs.