Rust on embedded – running your code

All tooled up, raring to go? The next step for the embryonic Rustacian is the blinky….

The setup

Both the code and the tools used, largely depends on the choice of development board you have available. This page is using the following boards which are cheap, functional and very available:

  • as a loading and debugging tool: a STM32f103c8 with the Black Magic Debug Probe software loaded (Instructions for putting BMP firmware onto boards are in the readme in that git repository)
  • as a target board: the same type of STM32f103c8.

The STM32F103c8 comes on a variety of carrier boards, we’re using the Blue Pill board which is available from the usual online purveyors of tat.  If you start using the BMP debugger on a regular basis then you should consider buying one from the primary vendor, both to support the project and ‘cos it’ll be a hell of a lot more reliable than a bluepill board of dubious pedigree.

Anyway, once you’ve got through that bit, the bobbin tool takes away most, but not all, of the pain when dealing with embedded development in Rust.

Let’s get blinky up and running

The embedded version of “Hello, World” is blinky. Just blink a LED to show that your code runs.

Clone the repo

Using your favourite tool, clone or download the following repo:

git clone
Override the default compiler

Enter the stm32f103xx directory and enter: rustup override set nightly to make this directory use the nightly compiler.

Override the default scan method used by bobbin

By default bobbin selects JTAG as the default way to communicate with the development board. My setup uses the [tt]swdp_scan[/tt] method.

Switch to the ‘config-for-stm32-blackmagic-setup’ branch:

git checkout config-for-stm32-blackmagic-setup

Or  a file .bobbin/config with the following content:


And then run bobbin run --bin stm32f103xx to compile, link, load and run the program.

 Compiling stm32f103xx v0.1.0 (file:///home/erwin/dev/github/bobbin-blinky/stm32f103xx)
 Finished dev [optimized + debuginfo] target(s) in 0.13 secs
 text data bss dec hex filename
 162 0 4 166 a6 target/thumbv7m-none-eabi/debug/stm32f103xx
 Loading target/thumbv7m-none-eabi/debug/stm32f103xx
 Complete Successfully flashed device
 Loader Load Complete
 Console Opening Console

To debug use bobbin gdb --bin stm32f103xx.

Smile, and bask in the reflected glory of your red flashing LED (or possibly green, consistency doesn’t seem to be a strong point on these Bluepill boards).

Leave a Reply

Be the First to Comment!

Notify of