Home

Awesome

Rust on the xtensa architecture

⚠️ NOTE: This repo is now obsolete, there is now a quickstart repo for bare-metal and a template for using the standard library.

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

Supported chips

namearchrust-targetcustom compiler required
esp32Xtensaxtensa-esp32-none-elfyes
esp8266Xtensaxtensa-esp8266-none-elfyes

Installing the compiler

For Xtensa targets a forked compiler must be installed, follow the instructions from the book.

Installing tools

Currently the xtensa targets do not have LLD support. Therefore the GCC toolchain is required for linking.

xtensa-esp32-elf toolchain for esp32 development

Instructions can be found on Espressif's web site and the latest tool toolchain can be downloaded from here.

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-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz -C ~/esp
$ PATH="$PATH:$HOME/esp/xtensa-esp32-elf/bin"

Old instructions can be found on Espressif's web site.

xtensa-lx106-elf toolchain for esp8266 development

Install the xtensa-lx106-elf toolchain from the espressif web site.

$ mkdir ~/esp
$ tar -xzf ~/Downloads/xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz -C ~/esp
$ PATH="$PATH:$HOME/esp/xtensa-lx106-elf/bin"

Cargo Build

Since the introduction of the build-std feature of cargo, it is possible to build core without any additional tools.

Flashing

Install espflash:

$ cargo install cargo-espflash

Example for the ESP32, remember to use target = xtensa-esp32-none-elf inside .cargo/config:

$ cargo espflash --chip esp32 --example esp32 --speed 460800 --features="xtensa-lx-rt/lx6,xtensa-lx/lx6,esp32-hal" /dev/ttyUSB0

Example for the ESP8266, remember to use target = xtensa-esp8266-none-elf inside .cargo/config:

$ cargo espflash --chip esp8266 --example esp8266 --features="xtensa-lx-rt/lx106 xtensa-lx/lx106 esp8266-hal" /dev/ttyUSB0

esptool

The preferred method of flashing is to use cargo-espflash, but you can use Espressif's esptool.py to flash the binaries manually. Esptool is python-based command line tool for flashing Espressif's chips. Full installation instructions are available on the website.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.