How to boot stm32 Blue Pill?

 On the STM32 “Blue Pill”, “booting” basically means:

  1. Power the board correctly

  2. Put it in the right boot mode (BOOT0/BOOT1)

  3. 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 5V pin, GND to GND.

  • Direct 3.3 V

    • Feed 3.3 V into 3.3V pin, GND to 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:

BOOT0BOOT1Boot sourceUse case
00Main flashNormal: run your program
10System memory (ROM)Built-in serial bootloader
01SRAMRarely 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:

    • SWDIOSWDIO on Blue Pill

    • SWCLKSWCLK on Blue Pill

    • GND → GND

    • 3.3V (optional, if you want ST-LINK to power the board)

Steps

  1. Wire ST-LINK to Blue Pill as above.

  2. Power the board (via USB or via ST-LINK 3.3 V).

  3. Make sure BOOT0 jumper = 0 (LOW).

  4. Open STM32CubeProgrammer or ST-LINK Utility on your PC.

  5. Connect to the target, load your .hex or .bin file.

  6. Click Program.

  7. 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 TXPA10 (RX1)

    • Adapter RXPA9 (TX1)

    • GND → GND

    • Optionally 5V5V if the adapter can power the board

To enter the bootloader:

  1. Set BOOT0 jumper = 1 (HIGH).

  2. Power the board.

  3. Press RESET.
    → Now it’s in the ROM bootloader and listens on USART1.

Then program it

Use one of:

  • STM32CubeProgrammer (select UART mode)

  • stm32flash from command line

  • Arduino IDE with STM32 core (select “Serial” upload method)

After programming:

  1. Set BOOT0 back to 0 (LOW).

  2. 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:

  1. Power LED on?

    • If no, check power wiring or USB cable.

  2. BOOT0 = 0?

    • If BOOT0 is accidentally HIGH, it will sit in the ROM bootloader and not run flash.

  3. 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).

  4. 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.

  5. 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:

  1. Wire ST-LINK (SWDIO, SWCLK, GND, 3.3V).

  2. Set BOOT0 = 0.

  3. Flash a simple example:

// pseudo code outline int main(void) { // enable GPIOC clock // configure PC13 as push-pull output // loop: toggle PC13, delay }

(Or use any example project called “Blinky” for STM32F103 and PC13.)

  1. Press RESET → LED near PC13 should blink → board is booting correctly from flash.

评论

此博客中的热门博文

Detailed Explanation of STM32 HAL Library Clock System

How To Connect Stm32 To PC?

How do you set up ADC (Analog-to-Digital Converter) in STM32?