Setting up the project in VSCode entails two main steps:

  1. Installation of Compile and Debug Tools

    This entails setting up the tools needed to compile and debug and including:

  2. VSCode Environment Configuration

    This entails installing the necessary extensions and then cloning and configuring a standard Rust template for the STM32F4xx

Step number 1 needs only to be done once per system/PC. Other than installing necessary extensions, step 2 needs to be done per project.

1. Compile and Debug Tools Installation Steps

Rust Compile Toolchain

Rustup Installation

Install rustup by following the instructions at https://rustup.rs.

If you already have rustup installed double check that you are on the stable channel and your stable toolchain is up to date. rustc -V should return a date newer than the one shown below:

$ rustc -V
rustc 1.31.0 (abe02cefd 2018-12-04)

Rust is an easy language to cross-compile, but the default installation only supports native compilation of the host machine. Therefore, add a rustuptarget with to add the target cross-compiler. To install a target, the command signature is as follows:

rustup target install [*target name*]

For example, since we are targeting the ARM's Cortex-M4 with a FPU (processor incorporated in the STM32F4) the command is:

$ rustup target add thumbv7em-none-eabihf

This indicates that we are installing the ARM-v7 architecture target which is adopted in the Cotrex-M4 processor. Note that for different ARM processors (Ex. Cotex-M0) a different target might be needed.

If you are unsure of the name of the target architecture and want to obtain a list of the available targets to install then you can retrieve them as follows:

$ rustc --print target-list

cargo-binutils

cargo-binutils is a Cargo subcommand that makes it easy to use LLVM binary utilities. llvm-objdumpAnd llvm-sizeso on can be called from Cargo.

If you have GNU binutils for your target architecture installed and are familiar with the command line, you shouldn't force it. However, when binary hacking with Rust, it is a big advantage that it can be used with the same command regardless of the target architecture.