Development Environment Setup

Overview

Building the Rust SDK requires two toolchains:

Toolchain

Source

Purpose

Rust toolchain

Rust official

Compile Rust code and link the ELF firmware

ARM bare-metal toolchain

Realtek

Provides arm-none-eabi-nm / arm-none-eabi-objcopy for post-build firmware packaging

Install the Rust Toolchain

Linux / WSL:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none --profile minimal
$ source ~/.cargo/env

Note

Users in mainland China may set the following mirrors before installing:

$ export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
$ export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup

Install the Nightly Toolchain

rust-toolchain.toml at the repository root pins the required nightly version, components, and cross-compilation target. rustup installs everything automatically the first time rustc is run inside the repository.

Run the following from the Rust SDK root:

Linux / WSL:
$ cd <workdir>/rust
$ rustc --version

The first run triggers an automatic download and installation (may take a few minutes).

Install the ARM Bare-Metal Toolchain

Refer to the following guide to install the Realtek ASDK toolchain:

CLI-Based Build and Flash

Verify Installation

Linux / WSL:
$ rustup show active-toolchain
nightly-x86_64-unknown-linux-gnu (overridden by '.../rust/rust-toolchain.toml')

$ rustup target list --installed | grep thumbv8m.main-none-eabi
thumbv8m.main-none-eabi
thumbv8m.main-none-eabihf

$ arm-none-eabi-nm --version
GNU nm (Realtek ASDK-12.x.x ...) 2.xx.x