How to boot stm32 Blue Pill?
On the STM32 “Blue Pill”, “booting” basically means:
-
Power the board correctly
-
Put it in the right boot mode (BOOT0/BOOT1)
-
Have valid firmware in flash
I’ll walk you through the typical ways to boot it.
1. Powering the Blue Pill (don’t skip this)
The board has an STM32F103C8 (or CB) + a 3.3 V regulator.
You can power it in three safe ways:
-
Via USB port (Mini-USB)
-
Plug into USB → board gets 5 V → regulator makes 3.3 V for the MCU.
-
-
Via 5V pin
-
Feed regulated 5 V into the
5Vpin,GNDto GND.
-
-
Direct 3.3 V
-
Feed 3.3 V into
3.3Vpin,GNDto GND (bypasses regulator).
-
⚠️ Never put 5 V on the 3.3 V pin → instant blue smoke risk.
If power is good, the red power LED should light.
2. Boot mode basics: BOOT0 & BOOT1
The STM32 decides where to boot from using BOOT0 and BOOT1 at reset:
-
On the Blue Pill:
-
BOOT0 is broken out with a jumper.
-
BOOT1 (PB2) is usually fixed low (GND) with a resistor.
-
So the useful modes are:
| BOOT0 | BOOT1 | Boot source | Use case |
|---|---|---|---|
| 0 | 0 | Main flash | Normal: run your program |
| 1 | 0 | System memory (ROM) | Built-in serial bootloader |
| 0 | 1 | SRAM | Rarely used |
In practice:
-
BOOT0 jumper LOW → MCU boots from flash (your code).
-
BOOT0 jumper HIGH → MCU boots into ROM bootloader (USART1).
After programming, you almost always want BOOT0 back to LOW.
3. Easiest way to boot & run: with ST-LINK
This is the most “professional” way.
What you need
-
A ST-LINK/V2 (or cheap clone).
-
Four connections:
-
SWDIO→SWDIOon Blue Pill -
SWCLK→SWCLKon Blue Pill -
GND→ GND -
3.3V(optional, if you want ST-LINK to power the board)
-
Steps
-
Wire ST-LINK to Blue Pill as above.
-
Power the board (via USB or via ST-LINK 3.3 V).
-
Make sure BOOT0 jumper = 0 (LOW).
-
Open STM32CubeProgrammer or ST-LINK Utility on your PC.
-
Connect to the target, load your
.hexor.binfile. -
Click Program.
-
Press RESET on the Blue Pill.
Now the board boots every reset from flash, and runs your program automatically (no need to touch BOOT0 again).
4. Booting via the built-in serial bootloader (no ST-LINK)
The F103 has a ROM bootloader on USART1 (PA9/PA10) by default.
You’ll need:
-
A USB–Serial adapter (3.3 V level, not 5 V if you want to be safe)
-
Connections:
-
Adapter TX→PA10 (RX1) -
Adapter RX→PA9 (TX1) -
GND→ GND -
Optionally
5V→5Vif the adapter can power the board
-
To enter the bootloader:
-
Set BOOT0 jumper = 1 (HIGH).
-
Power the board.
-
Press RESET.
→ Now it’s in the ROM bootloader and listens on USART1.
Then program it
Use one of:
-
STM32CubeProgrammer (select UART mode)
-
stm32flashfrom command line -
Arduino IDE with STM32 core (select “Serial” upload method)
After programming:
-
Set BOOT0 back to 0 (LOW).
-
Press RESET again.
→ It now boots from your code in flash.
5. “It doesn’t boot, what should I check?”
If nothing seems to run:
-
Power LED on?
-
If no, check power wiring or USB cable.
-
-
BOOT0 = 0?
-
If BOOT0 is accidentally HIGH, it will sit in the ROM bootloader and not run flash.
-
-
Do you actually have valid code in flash?
-
Use ST-LINK or CubeProgrammer → “Readout” or “Verify” to confirm there’s a program.
-
Try flashing a simple blinky (toggle PC13 LED).
-
-
Clock configuration
-
If you configured the external crystal wrong in code, it may crash early.
-
Start with a simple known-good example from STM32Cube or Arduino core.
-
-
USB confusion
-
A “stock” Blue Pill does not have a USB bootloader in ROM.
-
Plugging USB in won’t make it show up as a programmable device unless you’ve already installed a custom USB bootloader.
-
6. Minimal recipe: “I just want a blink on PC13”
Fast path using ST-LINK:
-
Wire ST-LINK (SWDIO, SWCLK, GND, 3.3V).
-
Set BOOT0 = 0.
-
Flash a simple example:
(Or use any example project called “Blinky” for STM32F103 and PC13.)
-
Press RESET → LED near PC13 should blink → board is booting correctly from flash.
.jpg)
评论
发表评论