Skip to content
A demo crate for the xtensa uC's (ESP32, ESP8266)
Rust Shell GDB
Branch: master
Clone or download
Latest commit 326b84f Feb 10, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.cargo Save temps issue fix, use modify instead of write for gpio set and cl… Jan 12, 2020
.vscode Add cortex-m-debug config. This uses the SVD from esp32 to debug appl… Jan 13, 2020
src Save temps issue fix, use modify instead of write for gpio set and cl… Jan 12, 2020
.gitignore Add cortex-m-debug config. This uses the SVD from esp32 to debug appl… Jan 13, 2020
Cargo.toml Bump esp32 Jan 18, 2020
README.md Update build instruction Feb 10, 2020
build.rs Adde memory.x and updated build.rs Aug 29, 2019
flash Adde memory.x and updated build.rs Aug 29, 2019
flash_release Clean up blinky Sep 9, 2019
memory.x
openocd.cfg Add cortex-m-debug config. This uses the SVD from esp32 to debug appl… Jan 13, 2020
openocd_flash.cfg Clean up blinky Sep 9, 2019
setenv Bump esp32 Jan 18, 2020
xtensa.gdb

README.md

Rust on the xtensa architecture

Need help? Join the esp-rs room on matrix, https://matrix.to/#/#esp-rs:matrix.org.

Building

Requirements

llvm-xtensa

Please refer to Espressif's llvm project for authoratative instructions.

$ git clone https://github.com/espressif/llvm-project
$ cd llvm-project/llvm
$ mkdir build
$ cd build
$ cmake .. -DLLVM_TARGETS_TO_BUILD="Xtensa;X86" -DCMAKE_BUILD_TYPE=Release -G "Ninja"
$ cmake --build .

Calling make with an appropriate number of threads will speed the process considerably.

Many use the guideline n + 1, where n is the number of processor cores on your machine. For example, for a processor with 4 logical cores:

$ make -j5

rust-xtensa

Please refer to the rust-xtensa project for authoratative instructions.

Assuming you built llvm in your home directory:

$ git clone https://github.com/MabezDev/rust-xtensa
$ cd rust-xtensa
$ git checkout xtensa-target
$ ./configure --llvm-root=$HOME/llvm-project/llvm/build
$ ./x.py build

xtensa-esp32-elf toolchain

Instructions can be found on Espressif's web site.

Download the archived toolchain file, and extract it to the directory of your choice. Then add the toolchain's bin/ directory to your $PATH. For example:

$ mkdir ~/esp
$ tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz -C ~/esp
$ PATH="$PATH:$HOME/esp/xtensa-esp32-elf/bin"

xargo or cargo xbuild

$ cargo install xargo

or

$ cargo install xbuild

esptool

$ pip install esptool

Starting a new project

$ git clone https://github.com/MabezDev/xtensa-rust-quickstart

Workflow

Update CUSTOM_RUSTC in setenv to point to the version of rust you compiled earlier. Then load the environment variables with source setenv.

If you installed xbuild instead of xargo, you will need to update flash and flash_release accordingly.

You should now be able to call xargo (or cargo xbuild) to build the project. You can also run the flash script to both build the project, and flash it to the ESP32

You will need to change the parameter BLINKY_GPIO to match your board's LED pin. Unfortunately, this may require adjustments to the chip's IO_MUX peripheral, which will mean consulting the ESP32 Technical Reference Manual. See this issue for more information.

Resources

  • The esp-rs organization has been formed to develop runtime, pac and hal crates for the esp32 and eventually esp8266.
  • Checkout @lexxvir's project for an example of using the esp-idf bindings in a Rust application.

FAQ

  • error: intermittent IO error while iterating directory - try creating that directory
  • undefined reference to .L see this issue
You can’t perform that action at this time.