2
\$\begingroup\$

I am new to STM32 and recently trying to make a custom board with STM32F103RB. But I am a bit confused by the available methods to program the chip. Let's say I use ST-Link via SWD, does it mean that I do not need to burn bootloader to the chip on my own? That is, does it mean that I can program the brand new chip directly with ST-Link without any other additional procedure?

If yes, then does it mean that I do not need to use BOOT0 and BOOT1 pins?

What about using USB via USBDP and USBDM pins on STM32?

Thank you all very much!

\$\endgroup\$
7
\$\begingroup\$

The bootloader is in ROM, it is not user-modifiable (ie: you can't "burn" a new bootloader). This appnote describes the bootloader features for different STM32 parts.

On the all the STM32 parts that I've used, you pull BOOT0 to ground to bypass the bootloader and boot from flash (address 0x0800000 on most STM32s). With BOOT0 pulled low, the pin state of BOOT1 doesn't matter. I normally pull BOOT0 down with a 100 kOhm resistor on the boards I design at work. Don't leave it floating, it is not pulled down internally so funny stuff will happen if you don't pull it down.

You can use ST-Link SWD to flash your firmware to the chip and debug running code. Any IDE that supports the STM32 should know how to do this out of the box, I personally use Ac6 because it's free. As a minimum, you need to connect the SWDIO, SWCLK, and GND lines to the programmer, but you should also bring out NRST wherever possible because debugging without a hardware reset line can be a real pain.

As for your last question - the bootloader for the F103 series does not support USB, although some other parts (like the F105 series) do. I would not recommend programming via USB unless you have a specific reason to: SWD will let you program and debug, and is vastly simpler to get working.

\$\endgroup\$
  • \$\begingroup\$ Thank you very much! I got the impression that I need to burn the bootloader because Atmega requires that. So just a short follow up question: if I do not bring out the NRST what would happen or what is the potential risk? \$\endgroup\$ – Penthrite Sep 19 '17 at 4:25
  • \$\begingroup\$ It will still work, but when flashing the chip the ST-Link won't be able to force a reset by flashing the NRST line so it's forced to resort to a software reset. This works, and I've done boards this way when I was really strapped for conductors, but debugging is much more reliable when you have a hardware reset. \$\endgroup\$ – Peter Sep 19 '17 at 4:31
  • \$\begingroup\$ Vcc has to be connected too, otherwise ST-Link would refuse to access the controler \$\endgroup\$ – berendi Sep 19 '17 at 6:08
  • \$\begingroup\$ @berendi: preferentially, yes, but I have faked out an ST-Link before by connecting another 3.3V supply to the VCC pin. I've made some really space-constrained boards :). \$\endgroup\$ – Peter Sep 19 '17 at 7:32
  • \$\begingroup\$ Thank you both :) One last thing, since BOOT1 doesn't matter, can I leave it floating? I am trying to save every bit of space since I am making a space-constrained board as well. \$\endgroup\$ – Penthrite Sep 19 '17 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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