Skip to content

kkingsbe/STM32-Rust-Quickstart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository is intended to serve as a template repo for easily getting up & running with writing Rust for STM-32 microprocessors.

Features

  • Flashing & debugging support (with breakpoints) through probe-rs
  • Ready-made tasks & launch scripts
  • A Github CI workflow for automatically building the repo on each commit
  • Detailed instructions for getting the entire toolchain up & running

Debugging:

  1. Install the ST-Link drivers here
  2. Install VSCode
  3. Install cargo-flash with the following command:
    • cargo install cargo-flash
  4. Install probe-rs with the following command:
    • cargo install probe-rs --locked --features cli
  5. Add the neccesary build target with the following command:
    • rustup target install thumbv7m-none-eabi
  6. Add the Debugger for probe-rs extension to vscode
  7. The rest "should" already be setup & work. You can add a new breakpoint by clicking on the left margin next to any line of code.

Setting up debugging for a new project

To set up debugging within a new project, you can use the launch.json and tasks.json files as a template. The main important points to remember are the following:

  • To debug you must be using a build which has no link-time optimizations or compiler optimizations. Easiest way to guarantee this is to just use a non-release build.

Automating the build process:

To automate the build process, you can use vscodes "tasks" feature. It allows you to define different tasks within the tasks.json file, which are just console commands. These tasks can then be invoked from launch scripts within the launch.json file. This repo has 4 tasks defined, for preforming debug & release builds & deployments. The debug build task is then called from the launch.json before it begins the debugging process.

Automated Testing

In order to prevent flawed code from making it onto a flight vehicle, and to make it easier to know when bad code made it into the codebase, I strongly recommend using Github actions to automatically build the codebase on each commit. It is also able to run any tests which are specified in the codebase. You can use the file located at .github/workflows/rust.yml as a starting point for your workflow.

Additional Resources

Rust on an STM32 Microcontroller (Medium.com)

Rust on STM32: Getting Started (jonathanklimt.de)

probe.rs documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages