Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 1.48 KB

File metadata and controls

53 lines (45 loc) · 1.48 KB

Rust Low-Level Example

This project's sole purpose is to understand and explore how Rust can be used in the same way as was done in the led-ext.s assembly language example. This example intentionally does not use any external crates so that it is as close as possible to the original example.

Like we needed with the assembly examples we have to specify a linker script:

$ cargo rustc -- -C link-arg=-Tlinker-script.ld

This has been added to config.toml so we don't have to type this every time we build. We also have to set up the vector table which is done by the script and also we have code in main.rs to handle this.

Setup

The board I'm using is STM32F0 which uses Cortex-M0 so we need to add this target to be able to cross compile:

$ rustup target add thumbv6m-none-eabi

Building

$ cargo build -v

Flashing and Running

Start openocd:

$ openocd -f board/stm32f0discovery.cfg

Start a telnet session:

$ telnet localhost 4444

Flash the program:

> reset halt
> flash write_image erase target/thumbv6m-none-eabi/debug/rust-low-level
> reset run

Running should turn on the led:

Rust LED example

Debug:

$ arm-none-eabi-gdb target/thumbv6m-none-eabi/debug/rust-low-level