cancel
Showing results for 
Search instead for 
Did you mean: 

Confused over correct connections for BOOT0, NRST and SWD.

SCook.1
Associate III

Hi, I'm working on a custom board which I've been programming with an ST-LINK V2 using the SWCLK and SWDIO lines. I mistakenly left BOOT0 floating, but I need to order more boards, so I'm going to correct this mistake.

My question: Am I right in thinking that if I tie BOOT0 to GND, the STM32F1 will boot on its own when powered-up (which doesn't currently happen - I have to rely on PlatformIO resetting it after uploading the program), but I'll still be able to program it using just the SWCLK and SWDIO lines? Or will I have to connect NRST as well? (NRST is currently floating but has an 100nf cap tied to GND as per the datasheet.)

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

In general, you can leave the BOOT pins inactive for programming via SWCLK and SWDIO, i.e. BOOT0 to GND and BOOT1 as desired. BOOT0 and BOOT1 only need to be activated if you want to use the built-in bootloader and programme via USART1, for example.

So, to let the STM32F1 work normally and still be able to program it via SWDIO/SWCLK, you only need to connect BOOT0 to GND level (selects main Flash memory as boot space) and connect the debugger with SWDIO, SWCLK and possibly NRST. The debugger can then access the STM32F1 via e.g. soft reset.

By the way, pin BOOT1 can also be used as a GPIO. If you configure this GPIO to input and activate a pull-up, this pull-up is not yet active at reset time. BOOT1 floats during the polling of BOOT0 and BOOT1. The reference manuals mentiones here:

The values on the BOOT pins are latched on the 4th rising edge of SYSCLK after a reset. It is up to the user to set the BOOT1 and BOOT0 pins after Reset to select the required boot mode.

I hope there weren't too many syllables? ;)

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
Peter BENSCH
ST Employee

Leaving BOOT0 floating is not a good idea as the pin is high impedance and can therefore catch external noise, leading to unpredictable behaviour on reset. For this reason, BOOT0 must be fixed at 0 or 1, which can of course also be done using a pull-down/-up resistor.

As described in AN2606, the family of STM32F1 has three different bootloaders with different patterns (1 and 3) for triggering, see section 4.1 there for more details.

It is recommended to connect NRST so that you can use the STM32CubeProgrammer to perform the Connect under Reset function, which is often used for Ultra Low Power STM32 in deepest sleep mode. However, you can also leave NRST open (with only the capacitor connected), which limits the connection capabilities somewhat.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
SCook.1
Associate III

Thank you for your help. I'm afraid I can't make much sense out of AN2606 :) Would it be possible for you to please explain in words with as few syllables as possible what I need to do?

I currently have BOOT0 floating (by mistake), but I can redo the PCB to connect it to 0V or 3V3. BOOT1 I have configured as a digital input with the built-in pullup activated. (Yes, this was another mistake as I didn't realise I had to worry about BOOT1.) What do I need to change in order to have the STM32 run my program when it starts, but still be able to program it from the SWDIO and SWCLK pins while I'm developing it?

PS: I'm not using any kind of low power mode or battery backup, if that's relevant.

You can connect BOOT0 to GND and always enable SWDIO in firmware, 4 wires are enough: 3.3v, GND, SWDIO, SWCLK. In very rare cases reset may be required to unbrick MCU, then use tweezers to short NRST capacitor, press connect button in ST-Link after releasing capacitor.

Peter BENSCH
ST Employee

In general, you can leave the BOOT pins inactive for programming via SWCLK and SWDIO, i.e. BOOT0 to GND and BOOT1 as desired. BOOT0 and BOOT1 only need to be activated if you want to use the built-in bootloader and programme via USART1, for example.

So, to let the STM32F1 work normally and still be able to program it via SWDIO/SWCLK, you only need to connect BOOT0 to GND level (selects main Flash memory as boot space) and connect the debugger with SWDIO, SWCLK and possibly NRST. The debugger can then access the STM32F1 via e.g. soft reset.

By the way, pin BOOT1 can also be used as a GPIO. If you configure this GPIO to input and activate a pull-up, this pull-up is not yet active at reset time. BOOT1 floats during the polling of BOOT0 and BOOT1. The reference manuals mentiones here:

The values on the BOOT pins are latched on the 4th rising edge of SYSCLK after a reset. It is up to the user to set the BOOT1 and BOOT0 pins after Reset to select the required boot mode.

I hope there weren't too many syllables? ;)

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thank you. One of the reasons I'm redoing my design is that the current prototype is bricked and I've been unable to resurrect it. I had the same idea about using tweezers to short the NRST cap, but couldn't get it to work, partly because it's one of those jobs that needs 3 hands. I'll try again as I may have been doing it in the wrong order or something.

Thank you Peter. Just enough syllables! So it seems I can just route BOOT0 to GND and it should then boot correctly, even if BOOT1 is floating. I'll go ahead and order the PCBs.