chapter two

2 Setting up your Rust tool-chain

 

This chapter covers

  • Establishing an embedded Rust environment tailored for microcontroller development.
  • Expanding Cargo’s capabilities for building and inspecting embedded binaries.
  • Using classic GNU utilities for inspecting and manipulating the binaries.
  • Simplifying bare-metal Rust project creation with standardized templates.
  • Flashing, debugging, and testing firmware, including the use of the Knurling tools and emulator environments for a streamlined work-flow.

Embedded Rust development (2.1) introduces unique challenges compared to desktop Rust applications. We have explored Rust’s general advantages for embedded systems. Building on that foundation, this chapter provides practical guidance for setting up and managing your development environment, introducing key tools, processes, and best practices specifically tailored for embedded Rust development.

Figure 2.1 Rust no_std development flow
CH02 F01 Cabanis

2.1 Setting up your embedded Rust environment

This section guides you through setting up an embedded Rust development environment. We will install and configure the Rust toolchain and supporting tools required for embedded targets, ensuring your setup is ready for practical development. We will walk through the process of preparing your Rust tool-chain and editor, ensuring that your environment is ready for embedded Rust work.

2.1.1 A brief word about embedded Rust vs. desktop Rust

2.1.2 Installing and using rustup

2.1.3 Managing embedded targets

2.1.4 Targets and target triples explained

2.1.5 Common pitfalls in target setup

2.1.6 Understanding rustc and compiler alternatives

2.1.7 IDE and editor setup: VSCode

2.2 Expanding cargo: Building, generating, and inspecting binaries

2.2.1 Building embedded binaries with cargo

2.2.2 Installing and using cargo-binutils

2.3 Oldies but goodies: The GNU binary utilities

2.3.1 Overview of key tools

2.4 Streamlining bare-metal Rust development

2.4.1 Installing the cargo-generate sub-command

2.4.2 Using a project template with cargo-generate

2.4.3 Making sense of project’s settings