2
\$\begingroup\$

I've been learning programming on STM32 MCUs and I've been using nucleo boards, which directly come with a programmer and debugger, that connect directly to the USB port of my PC.

Let's say I want to make my own PCB with a STM32 on it. What are the different methods to load the code into the MCU? Do I need to purchase a specific device? I heard about Segger, Jlink, SWD.. but I'm confused.

Thanks!

\$\endgroup\$
1
  • \$\begingroup\$ The nucleo boards can be used as standalone programmers with some modifications - I have done this a lot with TI launchpad parts and had great success. jeelabs.org/book/1547a/index.html \$\endgroup\$
    – Bryan
    Aug 18, 2022 at 18:19

3 Answers 3

7
\$\begingroup\$

STM32 chips support several interfaces to load code. See https://www.st.com/resource/en/application_note/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf for more details.

The most common approach is to add a SWD (serial wire debugging) connector. It can be implemented with as few as 4 pins: SWCLK, SWDIO, GND and VCC. Optionally, a full 10-pin connector can be fitted, which also includes SWO and RESET.

The advantage of SWD is that it can be used for both loading code and debugging, while the other options only support loading code.

SWD is supported by ST-Link, Segger J-Link and other debug adapaters.

\$\endgroup\$
4
  • \$\begingroup\$ Can you share a tutorial for that, i cant understand where to connect Vcc. There are so many vcc on a stm32f401 chip. \$\endgroup\$
    – mehmet
    Sep 28, 2023 at 17:24
  • 1
    \$\begingroup\$ Any PCB design with an STM32 chip will need to consider many aspects such as power supply, decoupling capacitors, clocks, boot pins etc. There are guides for all STM32 chip families, e.g. Application Note AN4488 Getting started with STM32F4xxxx hardware development for STM32F1xxx chips. Most likely, all Vcc pins need to be connected, all need to have a capacitor plus one additional big capacitor. \$\endgroup\$
    – Codo
    Sep 28, 2023 at 17:47
  • \$\begingroup\$ Thanks for help, while even just testing chip and making a blink example, should we need connect all ground, all vcc and capacitors? \$\endgroup\$
    – mehmet
    Sep 30, 2023 at 19:20
  • \$\begingroup\$ I don’t know if the chip works if not all GNDs and VCCs are connected. You can try it. But you might also waste a lot of time wondering why your code isn‘t working when it fact it is the poorly connected hardware. \$\endgroup\$
    – Codo
    Oct 1, 2023 at 8:41
1
\$\begingroup\$

You need to buy ST-LINK and connect it through SWD interface to your MCU. You can create hex file and load that file to your MCU using STM32CubeProgrammer or an old version of it which is STM32 ST-Link Utility.

\$\endgroup\$
1
\$\begingroup\$

Do I need to purchase a specific device? I heard about Segger, Jlink, SWD.. but I'm confused.

SWD is the name of the standardized interface. It is a flavour of another such well-known interface called JTAG. All Cortex M support SWD.

SWD comes with standardized signals and connectors, the 2x5 1.27mm "box header" connector being by far the most common one. (Which is a horrible one btw, using a 1.27mm ribbon cable for contacting something repeatedly is not a good idea.)

To program a MCU over SWD you will need an in-circuit debugger adapter, which could also be called "flash programmer" or similar.

Segger is a company which makes the Jlink product family of in-circuit debuggers. ST-Link would be another product, provided by ST, though I wouldn't trust that one to handle anything but STM32. Microchip/Atmel has a similar one called ATMEL-ICE which I wouldn't trust beyond Microchip SAM parts either. And so on.

I personally have some nice experience from using Segger JLink across multiple different Cortex Ms from several different manufacturers.

Keep in mind that in circuit debuggers are mainly what they say: debuggers, meant to be used for development. For production programming consider other options such as buying pre-flashed IC or buy an adapter which can do batch programming, depending on your volumes.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.