Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

This guide uses a STM32 Nucleo development board to flash to an STM32 series microcontroller. The Nucleo acts as a SWD (Serial Wire Debug) programmer for the main microcontroller, which should be some STM32 series MCU on your PCB.

SWD Interface

(resources: Introduction to JTAG and the Test Access Port (TAP), SWD – ARM’S ALTERNATIVE TO JTAG, STM Nucleo-64 UM1724 User Manual)

SWD is a two-wire protocol that is an alternative to JTAG. JTAG is the most common interface for debugging/accessing MCU registers, but it requires four pins to communicate while SWD only requires two, so many ARM microcontrollers will use SWD to ease pin requirements.

On the STM32 Nucleo development board (see STM Nucleo-64 UM1724 User Manual), there exists both an STM32 MCU as well as a portion reserved for the Embedded ST-LINK programming and debugging tool.

Red: ST-Link Portion for Debugging and Development

Blue: STM32 MCU and Peripherals

On most of the Solar boards, we will have a SWD interface that looks like the following:

And the Nucleo has pins that look like the following:

Pin CN4 Designation
1VDD_TARGETVDD from application
2SWCLKSWD clock
3GNDground
4SWDIO

SWD data I/O

5NRST

RESET of target STM32

6SWO

Reserved


Important Note about CN2 Jumpers

As defined in the documentation, the CN2 jumpers need to be off when trying to use SWD to interface with an external application (in this case, our circuit board's STM32).

If the CN2 jumpers are on, you will be programming the internal STM32 (the one on the Nucleo itself).

Software Tooling

The openocd and stlink packages are some software tools we use to flash and debug code on our board. They are two different options for doing the same thing (flashing and debugging via JTAG/SWD).

  • stlink (software package) is a tool developed by STMicroelectronics to interface with an ST-LINK device (see the STLink repository for more information) for programming and debugging purposes.
  • OpenOCD runs a GDB server, which allows us to debug remote targets via GDB. It also lets us write to flash with some extra configuration (see https://pfeerick.github.io/InfiniTime/doc/openOCD.html)


Step-by-step guide

  1. Connect the SWD interface on the Nucleo to your circuit board via jumper wires. Specifically, connect 3.3V, GND, SWDIO, and SWCLK.
  2. Ensure that the CN2 jumpers are removed from the Nucleo board.
  3. Plug in a USB A to USB mini-B connector into the Nucleo. This should provide power to the Nucleo and you should be able to see a green light.



  • No labels