cancel
Showing results for 
Search instead for 
Did you mean: 

Which pins are needed to program a mcu via swd

ABoya.14
Associate II

hello everyone !

i'm using a nucleo board (NUCLEO-F401RE) to program a MCU STM32F301 placed on newly fabricated pcb; the mcu has never been programmed.

i have disconnected the jumpers to use the CN4 connector. 

i have just connected the SWCLK (clock signal) and the SWDIO (data I/O) and i get an error message (Device not found)

i would like to know if i have to connect the NRST (Resest) pin also or maybe the GND and The VCC.

ps:most of the documents i found on swd were talking about only two pins to be connected: clock and data

thank you all

8 REPLIES 8
Uwe Bonnes
Principal III

Well, not connecting ground is never a good idea. Whether VCC is needed depends on the debugger. If the debugger senses Target voltage, you need to connect VCC too. Reset is needed if you traget remaps SWD pins or does sleep deep for longer times.

thank you for answer.

the thing is the board has its own voltage of 3 volts. should i use the voltage supply of the board or i have to use the vcc of the USB connector (which is 5 volts while the maximum voltage that the mcu can support is 3.6 V)

thank you.

Uwe Bonnes
Principal III

Don't apply USB voltage without double thinking!

The STLINK from a nucleo board has it's own debugger IO supply at 3.3 Volt. So only connect ground and the swd pins. However the target needs to run with 3.3V so voltage levels at the SWD pins match. Perhaps you get connection to a target at 2.5 Volt, but not reliable.

i think the problem stems from voltage level. since as you're saying the nucleo board has its pins at 3v3 while the voltage supply on board is about 3 V even lightly less than 3 v.

thank you for your help

S.Ma
Principal

If you want to flash an STM32 with SWD on a custom designed board you will need:

SWDIO, SWDCLK, GND and the STM32 power supply line connected to STLink.

The supply line is used as input voltage monitoring for the STLink. If it is missing, the debugger will think the STM32 is OFF. This voltage monitoring also tell the STLink if the STM32 is 1.8V, 2.5V, 3.3V etc.... to avoid all the level shifting enjoyable pain.

thank you so much for your answer.

but do you think if i have to re-flash my MCU, the NRST (reset) could be needed ?

The fact is that I use my MCU for an I2C communication with another device and that the clock line for the I2C bus is identical to the clock line of the SWD. Do you think I need a NRST pin for this case; since once my software is implemented on the MCU, I can not intervene on it.

greetings