The first step to learning how to program in a new language or on a new platform is "Hello, World!". In the case of embedded systems, the traditional string printing is replaced with sending the string over USB from the SoC to your computer and/or blinking an LED.

In this lab, all of the code has been written for you, and all you have to do is load it onto your SoC. However, while it may sound simple, this is arguably as difficult a task as coding the embedded system itself. Part of this is because there are so many different platforms, programming languages, targets, and programs involved, which makes troubleshooting by searching the internet more difficult than for coding. That being said, if you're programming on Linux in Rust for the STM32, everything should go pretty smoothly.

Procedure

edit
  1. Install Rust, openocd, and gdb
  2. Create a new crate using the git template: cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart
    Note: For the purposes of this lab, 'crate' is synonymous with 'Rust project'. A crate name is generally kebab-cased.
  3. Open a new terminal and run openocd from the git repo directory
  4. Run cargo run --example hello in your terminal

Hopefully, everything ran fine and you now have a terminal window that says "Hello, World!" and a board with a blinking LED.

Activity

edit

Now that you can upload code to your board, try modifying the code. The "Hello" example is outlined by the file examples/hello.rs. Try changing the string so that it says something else, or write a small program that lets you count down from 10.

See also

edit