In one of my previous articles I described in short, how to flash the IFLAT-32 by using the X-Link JTAG and OpenOCD. Here I will give some hints, on how the X-Link JTAG could be used to flash the STM32VL Descovery (or any other ST32) as well. As a prerequisite, make sure to install OpenOCD as described in the section “Insatalling OpenOCD”. Falshing the STM32 Discovery in general works the same way as flashing the IFLAT-32. There are only two things to take care of:
- A different board configuration has to be used for OpenOCD.
- There is no JTAG connector on the STM32VL Discovery (since you are supposed to use ST-Link for flashing/debugging).
1. Connecting the STM32 Discovery to the X-Link JTAG
The following table shows, which pins from the STM32 must be connected to the corresponding pins of the X-Link (They are labeled on the X-Links back-side):
| 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 |
Note on the 3.3V power supply: you could also use 5V power supply since the X-Link has a switch to select the power supply. Using 5V power supply has the advantage, that the 5V pin on the STM32 Discovery is on the same side as the rest of the needed pins.
2. Check if OpenOCD is Working
For the STM32, which is a STM32100, we use the “board/stm32100b_eval.cfg” which is provided by the default OpenOCD install (mine is version 0.5.0). To check if your board is detected try the following:
openocd -f interface/openocd-usb.cfg -f board/stm32100b_eval.cfg
If everything works, your CPU should be reported (check for “Info : JTAG tap: stm32.cpu …”), and you should be able to telnet to the OpenOCD console on port 4444.
3. Flashing with OpenOCD
E. g. to flash the firmware “firmware.elf”:
openocd -f interface/openocd-usb.cfg -f board/stm32100b_eval.cfg \
-c init -c targets -c "halt" \
-c "flash write_image erase firmware.elf" \
-c "verify_image firmware.elf" \
-c "reset run" -c shutdown
4. Useful Links on OpenOCD Usage
- Basic configuration
- Basic usage pattern
- Exmaples on how to flash different MCUs with OpenOCD. Has a section for STM32 as well …


Hi,
Thanks for this detailed description.
OpenOCD 0.6.0-r2 already supports stm32VLDiscovery board.
If one starts the OpenOCD server with board/stm32vldiscovery.cfg then it will use interface/stlink-v1.cfg and target/stm32f1x_stlink.cfg.
I think it worths to give a try: http://sourceforge.net/projects/openocd/files/openocd/0.6.1/
Cheers,
R
Thanks for that hint!