Flashing a STM32F103


I am trying to get blink working on my bluepill which I bought off AliExpress.

I can get the example blink.ino code to work on arduino IDE using "Generic STM32F103C6" using the stlink upload option

However I am unable to flash the equivalent code it using

cargo flash --release --chip stm32F103C8

The output looks good but no flashing LED

Here is my code (I have tried several)

//! Blinks an LED
//! This assumes that a LED is connected to pc13 as is the case on the blue pill board.
//! Note: Without additional hardware, PC13 should not be used to drive an LED, see page 5.1.2 of
//! the reference manual for an explanation. This is not an issue on the blue pill.


use panic_halt as _;

use nb::block;

use cortex_m_rt::entry;
use stm32f1xx_hal::{pac, prelude::*, timer::Timer};

fn main() -> ! {
    // Get access to the core peripherals from the cortex-m crate
    let cp = cortex_m::Peripherals::take().unwrap();
    // Get access to the device specific peripherals from the peripheral access crate
    let dp = pac::Peripherals::take().unwrap();

    // Take ownership over the raw flash and rcc devices and convert them into the corresponding
    // HAL structs
    let mut flash = dp.FLASH.constrain();
    let rcc = dp.RCC.constrain();

    // Freeze the configuration of all the clocks in the system and store the frozen frequencies in
    // `clocks`
    let clocks = rcc.cfgr.freeze(&mut flash.acr);

    // Acquire the GPIOC peripheral
    let mut gpioc = dp.GPIOC.split();

    // Configure gpio C pin 13 as a push-pull output. The `crh` register is passed to the function
    // in order to configure the port. For pins 0-7, crl should be passed instead.
    let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
    // Configure the syst timer to trigger an update every second
    let mut timer = Timer::syst(cp.SYST, &clocks).counter_hz();

    // Wait for the timer to trigger an update and change the state of the LED
    loop {

And my toml


name = "blink"

version = "0.1.0"

edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


embedded-hal = "1.0.0"

nb = "1"

cortex-m = "0.7.6"

cortex-m-rt = "0.7.1"

# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives

panic-halt = "0.2.0"


version = "0.10.0"

features = ["rt", "stm32f103", "medium"]

I do have a BMP if it is the ST-Link which is the problem but would be keen to understand the problem.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.