cancel
Showing results for 
Search instead for 
Did you mean: 

how to programm a L432KC with an external STLink

MSimo.1
Associate II

Hey, iam working with a STM32 L432KC with an ST-Link onboard.

Iam am planning to create a PCB with the same chip and iam wondering how i could programm/debug it.

I read through the Instructions and i think SWD is the right thing for me.

I have a STM L452RE-P laying around. This is Board with a "ST-Link-Section" witch you can break off the PCB. (so you break the PCB in two parts and have the ST-Link part and the microcontroller part )

How can i programm/debug my L432KC with that ST-Link part off the L52RE-P?

ive found the SWD clock and data pins on the ST-Link part but i dont know where to connect them to the L432. Pin PA14/13 (SWCLK/SWDIO) are not routed to any pins of the PCB

Thank you!

13 REPLIES 13

>I connected SWDIO, SWCLK, GND and VDD from the ST-Link(broken off) to the SWD Connector of the Nucleo Board.

Connector CN2? No. As clive1 and I said: this is the SWD interface of the ST-LINK chip on the Nucleo-32 board. Only STM might use that during board production.

Try the following:

  • leave the broken off board parts aside
  • open (remove) SB14 and SB9 on the Nucleo-32 board
  • power the Nucleo-32 board with 3.3V through the 3V3 and GND pins
  • power the on-board (Nucelo-32) ST-LINK through USB connected to your PC

Now, the Nucleo-32 board should be found by STM2CubeIDE debugger or STM32Programmer.

You cannot use an external ST-LINK on a Nucleo-32 without hacking the board.

Later, when you have your board, connect the broken-off ST-LINK to it as show in the link I gave you in the beginning or as shown in the Nucleo-32 board schematics.

hth

KnarfB

okay, thats working.. i thought i cant use the onboard debugger anymore.. Thank you very much!

to make that clear:

On my own PCB design ...

I just need a 4 pin connector to GND, 3.3V, SWCLK(PA13), SWDIO(PA14) to connect to the ST-Link?

What about a reset ? i thought, the debugger has to tell the MCU ro reset ? (after flashing)

should i use a 5 pin header with a reset? would it be correct to route that reset pin to NRST?

what about UART? my USART2_TX pin is PA2.. can i connect that to VCP_RX of the ST-Link?

that would be a 6 pin connector ? am i thinking right?

3.3V supply and GND are needed for your board to work.

For a ST-LINK debug connection

  • GND, SWCLK, and SWDIO are minimum
  • reset (NRST) is optional and useful, see below
  • SWO is optional and maybe useful. SWO is a fast tracing output which can be used for printf tracing (logging) similar to a VCP_TX but using a different protocol and needing a SWO capable debugger/logger
  • VCP_RX and VCP_TX is a useful serial console interface which can be used for printf tracing (logging) as well as for user IO as you like. It can be routed to any USART on your PCB and is not closely related to SWD, just happens to show up on the same USB. Shows up as a COM port on the host PC.

> What about a reset ? i thought, the debugger has to tell the MCU ro reset ? (after flashing)

A MCU reset can also be triggered by some magic SWDIO+SWDCK commands. But this is "soft" and works only when the SWD interface is available, i.e. SWD pins are not reconfigured and MCU not in certain low-power modes. The NRST can give it a "hard" reset anytime, which is more powerful.

Take a look at the broken-off of your Nucleo-64-p board (User manual UM2206). It has GND, SWCLK, SWDIO, NRST, SWO on pin 2-6 of CN3 and VCP_RX and VCP_TX on the connector nearby. You cannot fail if you make those signals available on your board.

CN3 Pin 1 marked VDD_TARGET is a special case. It is an input to SWD for detecting the target (debuggee) VDD voltage which can be evaluated by the debugger. High-end debug probes can use that pin for IO level conversion, galvanic decoupling etc.. Think of it as a 1-channel digital voltmeter input. Maybe useful to connect too, especially to detect low battery... scenarios.

Beware: some low-cost ST-LINK debug clones have a 3.3V pin which acts as an output to power the target, this is not the standard, do not connect.

STM AN4989 Application note "STM32 microcontroller debug toolbox has valuable info on debugging, SWO etc..

thank you man! this information is so useful! I dont want to end up witch a MCU on a selfmade PCB wich i cannot programm/debug :face_with_tears_of_joy: