Skip to main content
Explorer II
January 7, 2025
Solved

Using SWD pins to flash code

  • January 7, 2025
  • 2 replies
  • 1280 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

     

     

     

    2 replies

    Super User
    January 7, 2025

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

    Explorer II
    January 8, 2025

    Thank you!

    Super User
    January 8, 2025
    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