Skip to main content
Visitor II
November 30, 2020
Question

How to program multiple STM32 MCUs over SWD (or otherwise) using one programming port

  • November 30, 2020
  • 2 replies
  • 5180 views

Hello nice people.

I am supposed to develop a board that will have 2 STM MCUs (STM32F334 and STM32F01).

Is it anyways possible to be able to program both MCUs (simultaneously or individually) using a single SWD port. I know how to do it using JTAG chain (TDI -> TDO .....) but i don't know if it is also possible using SWD. Asking because many new processors don't support JTAG anymore but only SWD. THe aim is to use one programming port for both MCUs because of space restrictions.

Thanks

asrar

    This topic has been closed for replies.

    2 replies

    Super User
    November 30, 2020

    It's not possible using a standard connector. You could use a set of jumpers in addition to the port to select which processor it connects to, but then you may as well just put two connectors if you go that route.

    There are space-saving connectors out there that may be a better option.

    ma.alam9Author
    Visitor II
    December 2, 2020

    Thanks TDK.

    After knowing that protocol wise it was not possible to do two MCUs using same SWD port, I set out to experiment. As it turns out, i don't actually need to have complete two separate ports having SWCLK, SWDIO and nRST, 3V3 and GND each. It is possible to "short" SWCLK, SWDIO and of course 3v3 and GND of both MCUs. THe only pin that needs to be addressed distinctly is the nRST port. So i just added another pin on the same port for 2nd MCU's nRST From a switch in the cable I can then physically select which of the two controllers will be targeted. In order to avoid manual hardware intervention from switch i could also multiplex the nRST line to both MCUs using a tiny SSR with NC to main MCU and NO to secondary MCU. using the main MCU to drive the SSR switch, I can route the nRST from cable to the nRST pin of second MCU. so in short.... problem solved.. though not as perfect as expected...

    Thanks for the help guys.

    BR

    Asrar

    Visitor II
    April 15, 2025

    I am trying to replicate the same thing but I am not having the same success as you. Can you tell if the nRST is pulled low or high using the switch? Also in your software have you selected connect under reset (Hardware reset) or any other options?

    Super User
    April 15, 2025

    @ClumsySpider wrote:

    Can you tell if the nRST is pulled low or high using the switch? 


    See the chip datasheet: when the nRST pin is held low, the chip is held in reset; when the pin is high, the chip is released from reset.

    nRST has an internal pullup.