9

I have a STM32F4 Discovery board and a ST-Link/V2 programmer.

I want to use my own ST-Link (not the embedded one) for programming and debugging the board.

How should I connect the external ST-Link to the board ?

maddouri
  • 211
  • 1
  • 2
  • 8
  • 1
    What does the documentation say? – Leon Heller Aug 01 '15 at 11:15
  • To use the embedded ST-Link. However, I prefer to use a standalone programmer (a little bit like what the author of [this article](http://e.pavlin.si/2011/10/24/stm32f4-discovery-and-ulink2/) did with their uLink2) – maddouri Aug 01 '15 at 11:23
  • 1
    @865719 That article explains exactly what you need. What is your question? – Passerby Aug 07 '15 at 07:45
  • Related: https://electronics.stackexchange.com/questions/230036/problems-connecting-st-link-v2-and-stm32f4-discovery-board – phoenix Dec 05 '18 at 19:04

2 Answers2

16

You'll need to isolate the microcontroller from the st-link portion of the board. To do this just remove the jumpers on the CN3 pins.

CN3 location 'CN3'

Then, to use your external st-link, make the following connections to the microconroller pin headers:

  • SWDIO -> PA13
  • SWCLK -> PA14
  • GND -> GND
  • VAPP -> 3V/VDD

  • Do not connect the USB cable

Program it in SW mode.

Not sure why you'd want to do this, unless you wanted to use JTAG to program it instead. If that's the case let me know and I'll update the answer.

Sensors
  • 1,295
  • 14
  • 29
  • You also need to still power the board externally, as the programmer does not provide power. You could do this by connecting the USB cable to a USB wall charger. – phoenix Dec 05 '18 at 19:40
0

Instructions for STM32F407G-DISC1 (updated STM32F4DISCOVERY)

Update ST-Link/v2 Firmware

As explained in this answer, some recent versions of the STM32F407G-DISC1 contain firmware in their onboard ST-Link/v2 that pull the F4 into reset unless they are connected to a USB device.

  1. Download and install ST-LINK Utility onto a Windows PC.

  2. Select ST-LINK | Firmware Update | Device Connect | Yes >>>>

Version V2.J32.M22 is known to work.

Supply External Power

Next, power the board from an external power source (such as an AC to USB power adapter). The external ST-Link/v2 does not supply power. Don't plug it into the PC you are programming from or you might accidentally try to use the onboard version to program from.

Remove CN3 Jumpers

As shown in @Sensor's answer, remove the two CN3 jumpers to isolate the F4 chip from the onboard ST-Link/v2.

Connect External ST-Link/v2

Wire the following connections between the external ST-Link/v2 and the DISCOVERY board according to the ST-Link/v2 manual.

PIN1  (VAPP)      -> VDD
PIN7  (TMS_SWDIO) -> PA13
PIN9  (TCK_SWCLK) -> PA14
PIN15 (NRST)      -> NRST
PIN20 (GND)       -> GND

PIN15 isn't strictly needed when programming from Windows, but it was required when programming from openocd using the default stm32f4discovery.cfg configuration.

Program

The following command can be used to program using the latest master branch of openocd installed with brew install --HEAD openocd on macOS.

$ openocd -f board/stm32f4discovery.cfg -c "program app.elf" -c reset -c shutdown
phoenix
  • 153
  • 5
  • If you'd like to program the [`pyboard`](https://docs.micropython.org/en/latest/pyboard/quickref.html) in this way, see [this page](https://github.com/micropython/micropython/wiki/Programming-Debugging-the-pyboard-using-ST-Link-v2). – phoenix Mar 05 '19 at 16:04