Skip to content

gdamjan/rust-embedded-intro

Repository files navigation

Rust Embedded Intro

Using the nrf8340-dk board based on Cortex-M33 with the thumbv8m.main-none-eabihf ISA, with 1MB Flash and 256K RAM.

nRF5340-DK

Preparation

  • rustup - is recommended to install rust and its components
  • cargo install cargo-binutils - for cargo size and cargo objdump -- --disassemble, etc…
  • cargo install probe-rs-tools - flash and debug using the probe-rs project

Examples

  • cargo embed --example rtt - build, flash and open the rtt debugger/monitor
  • cargo embed --example embassy - embassy demo with 2 concurent tasks, blinking 2 LEDs

VS Code settings

The repo will also suggest common extensions for VS Code:

and some settings to instruct rust-analyzer to only run for the thumbv8m.main-none-eabihf target.

Infrastructure files

Apart from the rust source code files, the following files are involved in the build and debug process:

  • Cargo.toml, Cargo.lock - Cargo is the Rust package manager. Dependencies are specified here.
  • rust-toolchain.toml - rustup overrides. Make sure we use stable rust, and have the thumbv8m.main-none-eabihf target, and the llvm-tools component.
  • memory.x - the memory layout of the nRF5340/Cortex-M33 core.
  • .cargo/config.toml - this sets the default build target (thumbv8m.main-none-eabihf).
  • build.rs - linker flags, track changes to memory.x.
  • Embed.toml - cargo-embed config file. Specifies the chip, and enables rtt.

About

My Playground for the nrf5340-dk devkit and Rust

Topics

Resources

License

Stars

Watchers

Forks