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
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.
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:
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.
Read more: http://www.micromouseonline.com/2009/12/29/arm-stm32-jtag/#ixzz1k8HndcKE
2. Flashing with OpenOCD
E. g. to flash the firmware “fancyblink.elf”:
1. STM32VL Discovery
openocd -f interface/flyswatter.cfg -f board/stm32100b_eval.cfg \ -c init -c targets -c "halt" \ -c "flash write_image erase fancyblink.elf" \ -c "verify_image firmware.elf" \ -c "reset run" -c shutdown
openocd -f interface/flyswatter.cfg -f board/olimex_stm32_h103.cfg \ -c init -c targets -c "halt" -c "flash write_image erase fancyblink.elf" \ -c "verify_image fancyblink.elf" \ -c "reset run" -c shutdown