Practice Mcu Bare Metal Rust Save

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.

Project README

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. Implemented the 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

Demo video

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

Open Source Agenda is not affiliated with "Practice Mcu Bare Metal Rust" Project. README Source: hemashushu/practice-mcu-bare-metal-rust
Stars
115
Open Issues
0
Last Commit
1 year ago

Open Source Agenda Badge

Open Source Agenda Rating