A bare metal STM32F103C8T6/STM32F103 MCU program written in pure Rust

Overview

MCU STM32F103C8T6 Bare-metal in Rust

EN | 中文

A bare metal (register level) STM32F103C8T6/STM32F103 MCU program written in pure Rust without any IDE, SDK, HAL or library, and no assembly code, the only tool required is the Rust compiler. Implement basic input and output, timer, serial communication, etc. by directly reading and writing registers of hardware.

stm32f103 rust bare-metal

Implemented Features

  • GPIO read and write
  • Set system clock
  • SysTick and interrupt
  • UART read and write
stm32f103-v2.mp4

Demo video

Source Code Structure

  • src/register_*.rs Definition of register structures and values
  • src/startup.rs startup and vector array
  • src/main.rs main program
  • .vscode/launch.json configuration file for VSCode debug
  • svd/ System View Description file for displaying various register names and address values during GDB debugging
  • build.sh script for compiling
  • flash.sh script for compiling and downloading firmware

Wires

  • PC13: builtin LED -
  • PB5: external LED +
  • PA0: button (the another button pin connect to GND)
  • PA9: USART1_TX -> CP2012 RX
  • PA10: USART1_RX -> CP2012 TX

Compile

Install Rust on your platform first, then run:

$ ./build.sh

Flash

Connect the MCU to your computer using the CMSIS_DAP debugger (hardware) and then run:

$ ./flash.sh

Debug

$ ./server-gdb-server.sh

then open another terminal, and run:

$ ./start-gdb-client-with-svd.sh

Reference Documents

Hardware description and register structure and value description documentations:

For those who want to know how it works and who want to go further and implement more features, check out these:

C language version

This project is also implemented in C by the author, for those interested please check out MCU STM32F030C8T6 Bare-metal in C

You might also like...
Pure Rust library for Apache ZooKeeper built on tokio

zookeeper-async Async Zookeeper client written 100% in Rust, based on tokio. This library is intended to be equivalent with the official (low-level) Z

Pure rust implementation of python's random module with compatible generator behaviour.

pyrand Pure rust implementation of (parts of) python's random module with compatible PRNG behaviour: seeding with equivalent values will yield identic

Rust program to monitor Windows 10 Registry keys for changes or modifications.

RegMon This Rust program monitors changes to multiple registry keys in Windows 10 and writes the changes to a text file. It also periodically sends a

Waits until the exit code of a program is zero

Waitz A rust utility to wait that a program exits with 0. You need to wait for something to start up and don't know when it finishes?

✨ Safe, global singletons initialized at program start

✨ magic_static Safe, global singletons initialized at program start. Usage Simply add magic_static as a dependency in your Cargo.toml to get started:

Soufflé is a variant of Datalog for tool designers crafting analyses in Horn clauses. Soufflé synthesizes a native parallel C++ program from a logic specification.

Welcome! This is the official repository for the Soufflé language project. The Soufflé language is similar to Datalog (but has terms known as records)

Noir Pay - Fork of the Light Protocol Program for local testing / optimisation.

Noir Pay v0 Built on Light Protocol Noir Pay will be directly built ontop of the Light Protocol SDK and provide users with a beautifully simple privat

A simple program for handling Ethiopian calendar dates.

Mek’ut’erīya A simple program for handling Ethiopian calendar dates. Installation cargo install --git https://github.com/frectonz/mek-ut-er-ya If you

Token management program (vesting and mining) implemented in Anchor
Token management program (vesting and mining) implemented in Anchor

Deep Dive into Anchor by Implementing Token Management Program Author: @ironaddicteddog, @emersonliuuu [Updated at 2022.5.21] You can find the full co

Owner
Hema Shushu
Hema Shushu
Convert an MCU register description from the EDC format to the SVD format

edc2svd Convert an MCU register description from the EDC format to the SVD format EDC files are used to describe the special function registers of PIC

Stephan 4 Oct 9, 2021
A program written in pure Rust to query music info from mpd and display it in a notification.

musinfo A program written in pure Rust to query music info from mpd and display it in a notification. Note: Cover art is expected to be placed at /tmp

Cpt.Howdy 10 Aug 16, 2022
Wait Service is a pure rust program to test and wait on the availability of a service.

Wait Service Wait Service is a pure rust program to test and wait on the availability of a service.

Magic Len (Ron Li) 3 Jan 18, 2022
Program a Raspberry Pi Pico with pure Rust

pi-pico-rs Program a Raspberry Pi Pico with pure Rust. Get Started Install the latest version of Rust and the thumbv6m-none-eabi target. This is the p

Gerald Nash 5 Jul 29, 2022
Rustymind is a driver and parser for NeuroSky MindWave EEG headset written in pure Rust.

Rustymind is a driver and parser for NeuroSky MindWave EEG headset written in pure Rust. You can use it to connect, interact, and plot real time data from the headset.

Junjun Dong 34 Sep 13, 2022
A program written in Rust, that allows the user to find the current location of the International Space Station and see it on a map.

ISS Location ViewFinder A program written in Rust, that allows the user to find the current location of the International Space Station and see it on

Suvaditya Mukherjee 2 Nov 8, 2021
Pure rust implementation of jq

XQ JQ reimplemented purely in Rust. Caution This program is under development. You probably want to use the original implementation of jq, or pure Go

null 181 Jan 4, 2023
A pure Rust PLONK implementation using arkworks as a backend.

PLONK This is a pure Rust implementation of the PLONK zk proving system Usage use ark_plonk::prelude::*; use ark_ec::bls12::Bls12; use rand_core::OsRn

rust-zkp 201 Dec 31, 2022
mollusc is a collection of pure-Rust libraries for parsing, interpreting, and analyzing LLVM.

mollusc is a collection of pure-Rust libraries for parsing, interpreting, and analyzing LLVM.

William Woodruff 50 Dec 2, 2022
Svix - A pure Rust and fully tested KSUID implementation

Svix - Webhooks as a service Svix-KSUID (Rust) A pure Rust and fully tested KSUID implementation This library is fully compatible with Segment's KSUID

Svix 48 Jan 3, 2023