Skip to main content
Associate II
January 7, 2025
Solved

Using SWD pins to flash code

  • January 7, 2025
  • 5 replies
  • 1403 views

Hi,

 

I am using STM32H503 controller and wanted to understand if SWDIO pin can be used to flash the code.

This topic has been closed for replies.
Best answer by Andrew Neil

Not on its own.

The SWD interface consists of two pins:

  1. SWDIO is the (bidirectional) data pin;
  2. SWCLK is the clock pin.

You need both plus, of course, GND.

https://developer.arm.com/documentation/101636/0100/Debug-and-Trace/JTAG-SWD-Interface

https://learn.sparkfun.com/tutorials/arm-programming/jtag-and-swd

https://kb.segger.com/Target_Interface_SWD

Although not always strictly necessary, you should also include NRST in your debugger/programmer connection - it can get you out of some "bricked" states.

In addition, most debug/programming probes (eg, ST-Link) also want a connection to the target's VDD line.

See the documentation for your debug/programming probe.

See Application note AN5711Getting started with STM32H5 MCU hardware development:
https://www.st.com/resource/en/application_note/an5711-getting-started-with-stm32h5-mcu-hardware-development-stmicroelectronics.pdf#page=27

 

 

 

5 replies

TDK
January 7, 2025

Yes, the SWD connection is the typical way code is flashed using STM32CubeProgrammer and an ST-Link programmer.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate II
January 8, 2025

Thank you!

Andrew Neil
Super User
January 8, 2025
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Andrew NeilBest answer
Super User
January 7, 2025

Not on its own.

The SWD interface consists of two pins:

  1. SWDIO is the (bidirectional) data pin;
  2. SWCLK is the clock pin.

You need both plus, of course, GND.

https://developer.arm.com/documentation/101636/0100/Debug-and-Trace/JTAG-SWD-Interface

https://learn.sparkfun.com/tutorials/arm-programming/jtag-and-swd

https://kb.segger.com/Target_Interface_SWD

Although not always strictly necessary, you should also include NRST in your debugger/programmer connection - it can get you out of some "bricked" states.

In addition, most debug/programming probes (eg, ST-Link) also want a connection to the target's VDD line.

See the documentation for your debug/programming probe.

See Application note AN5711Getting started with STM32H5 MCU hardware development:
https://www.st.com/resource/en/application_note/an5711-getting-started-with-stm32h5-mcu-hardware-development-stmicroelectronics.pdf#page=27

 

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.