Skip to content

Rust learning demo for blue pill development board with STM32F103C8 microcontroller

License

Notifications You must be signed in to change notification settings

viktorchvatal/blue-pill-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust blue pill learning demo

My personal walk through learning Rust development on STM32 family of microcontrollers, using:

  • Blue Pill development board with STM32F103C8 microcontroller as target device, featuring 20K RAM and 64K flash
  • STLink v2 as a programming and debugging interface
  • Debian 10/11 bullseye and Visual studio code as development environment
  • Pros: cheap board ($5), small-factor, breadboard-friendly, good Rust support
  • Cons: market is flooded with counterfeit chips, harder to find high quality boards

stlink v2 photo

Motivation

After years spent with hobby project build using Atmel AVR Tiny and Mega microcontrollers using AVR assembler od C programming environments, I wanted to enter the world of ARM microcontroller development. 32-bit ARM devices usually provide better CPU performance (compared to 8-bit AVD devices) as well as order of magnitude of RAM and Flash capacity, but for similar price. As a Rust developer, I wanted a brand with good Rust community support.

I did not want to buy pricey large and well equipped development boards, but as a hobbyist I wanted to find a small breadboard-friendly development board that could be used in both the prototype and the final device itself.

As of 2019, best fit was the $5 Blue Pill board featuring STM32F103C8 CPU with 20K RAM and 64K ROM. Advantages are small size, low price and great Rust support, which made this board one of the best to start with, but low quality and cheap counterfeit chip clones, that flooded the market make this option less appealing, but it is still reasonable option to start with.

Other Boards

After playing with Blue Pill, i also tried its more expensive, but much more capable counter part Black Pill - more demos and examples for Black Pill development board can be found in the black-pill-rust repository

stlink v2 photo

During 2020, another $5 alternative to the Blue Pill emerged - a Raspberry PI Pico board, carrying two computing cores and tons of RAM and 2MB of onboard Flash memory. My experiments with the RPi Pico are in the rpi-pico-rust repository. Rust software ecosystem for RPi Pico is quite young to date, with some features still unimplemented, but considering that RPi Pico has its best years ahead and that it features best value for money compared to other boards, as of 2022 it would be my preferred board to start ARM Rust development.

stlink v2 photo

Most drivers used in all the demos across different boards use platform-agnostic device drivers written on top of embedded_hal crate, so than can be easily transferred across from one board to another.


Userful Resources

Following links contain a lot of useful resources about STM32 platform and Rust

Getting Started

Getting started - learn how to install development tools and flash the first program

stlink v2 photo

Panic Handling and Panic LED via GPIO

Panic handling and panic LED - handling panics using halt, panic LED and semihosting output

Panic LED ON

PWM Channels and colored LEDS

PWM Channels and colored LEDS - changing brightness of multipe LEDS using PWM channels and micromath fast approximation library

PWM LEDs

Connecting TM1637 LED Display

Connecting a TM1637 LED display - connecting a LED display driven by TM1637 circuit using tm1637 crate

LED Display connected

HX1230 Matrix Graphical Display

HX1230 Graphical display demo - communicating with the HX1230 graphical display

HX1230 Display

DHT11 Temperature and humidity sensor [in progress]

DHT11 Temperature and humidity sensor demo - communicating with the HX1230 graphical display

HX1230 Display

BMP280 Pressure and Temperature sensor [in progress]

BMP280 Pressure and Temperature sensor - communicating with the HX1230 graphical display

BMP280 Pressure and Temperature sensor

Using MAX7219 to drive 7-segment 8-character display [in progress]

MAX7219 display

BMP280 Pressure and Temperature sensor

About

Rust learning demo for blue pill development board with STM32F103C8 microcontroller

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published