Toolchain

Set up a Cortex-M + Rust environment in one minute

Common Rust target installation commands for Cortex-M cores: M0/M0+, M3, M4/M7, M4F/M7F, and M33F.

/toolchain/2 of 41 min read178 words
  • toolchain
  • cortex-m
Contents

Before you start#

This step is simple. After completing the Rust environment setup, copy the commands below into a terminal.


Commands#

Use the commands below to install the targets you need.

# M0/M0+ core; common chips: STM32F0xx, PY32F0xx, ...
rustup target add thumbv6m-none-eabi
# M3 core; common chips: STM32F1xx, ...
rustup target add thumbv7m-none-eabi
# M4 and M7 cores; common chips: STM32F4xx, ...
rustup target add thumbv7em-none-eabi
# M4F and M7F cores; F means hardware floating point. Common chips: STM32F4xx, STM32G4xx, STM32H7xx, ...
rustup target add thumbv7em-none-eabihf
# M33F core; common chips: STM32U5xx, ...
rustup target add thumbv8m.main-none-eabihf

Summary#

Every chip covered by this site uses one of the target values listed above. Installing all of them is convenient.


Troubleshooting#

  • If compilation reports can't find crate for core, the chip's target is usually missing.
  • If you are unsure which core a chip uses, check its datasheet and select the matching target.
  • Prefer an eabihf target for hardware floating-point chips. A mismatch between the project and chip can fail at build or run time.

Discussion

Comments and discussion

Sign in with GitHub to leave a comment, ask a question, or add context.