9 years, 11 months ago.

How does stlink program mcu on nucleo board?

Hello all,

I am working on making my own board for an stm32f411 and am trying to figure out how the stlink on the nucleo board programs the chip.

Looking at the schematics, if I am correct, it looks like the only signals that cross from the stlink side of the nucleo board to the mcu side are: nrst, tck, tms, swo, usart_tx, usart_rx, and mco. So it looks like boot0 doesn't go across? So I'm wondering how the stlink programs the mcu then? Normally I thought boot0 is pulled low and then data sent to the uart. Can someone explain this to me? Thanks!

Also, I'm wondering what stlink uses those pins for: tck, tms, swo, and mco? I couldn't find a good pin description for those pins. Thanks!

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F401RET6 microcontroller.

1 Answer

9 years, 11 months ago.

You should only need three connections (and supply, 0v and +3.3v) These will be SWDIO, SWCLK and RESET. The other connections would normally be for Debug functions through the STLink.

Don't forget to disconnect the Nucleo MCU, normally removing its +V is enough otherwise you will have to disconnect SWDIO and / or SWCLK.

I have not tried this on ST but works on the Freescale platforms.

Give it a try and report back here :)

Accepted Answer

What about boot0 though? Don't you need to set it to boot from system memory, and then set it back to boot program?

posted by Josh Grauman 14 Dec 2014

I don't know that one, best bet is to follow all the ST Nucleo web links, download as much info as you can, you may find the answer and more info on SWD download to your Target. However don't worry if it works with just three connections.

posted by Paul Staron 14 Dec 2014

Boot0 pin is used to start from mcu rom bootloader, which handles few commands to be able to flash it using uart, i2c, spi, usb DFU. Mbed does not use bootloader at all. STlink uses SWD (sort of 2wire serialized jtag protocol), take a look at your cpu reference manual, it tells: By default, the JTAG-Debug Port is active. If the debugger host wants to switch to the SW-DP, it must provide a dedicated JTAG sequence on TMS/TCK (respectively mapped to SWDIO and SWCLK) which disables the JTAG-DP and enables the SW-DP. This way it is possible to activate the SWDP using only the SWCLK and SWDIO pins. This sequence is: 1. Send more than 50 TCK cycles with TMS (SWDIO) =1 2. Send the 16-bit sequence on TMS (SWDIO) = 0111100111100111 (MSB transmitted first) 3. Send more than 50 TCK cycles with TMS (SWDIO) =1

The uart tx/rx that goed to stlink, if i'm not wrong, should be there only because stlink acts like "usb-to-uart adapter" (no semihosting stuff)

posted by Geremia G 14 Dec 2014

That is super helpful. Where can I find more info about programming via TMS/TCK, etc.? Thanks!

posted by Josh Grauman 15 Dec 2014

I've not digged inside stm32 debug port, but i would suggest to take a look here: stm32F411 reference manual http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00119316.pdf arm cortex M4 tech ref manual http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0439d/index.html arm debug interface v5 http://www.pjrc.com/arm/pdf/doc/ARM_debug.pdf

posted by Geremia G 15 Dec 2014