GithubHelp home page GithubHelp logo

ivancho523 / rust-esp32-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from espressif/rust-esp32-example

0.0 1.0 0.0 25 KB

Example of Rust integration into an ESP-IDF project, for ESP32 series of chips

License: MIT License

CMake 20.52% C 33.66% Makefile 2.50% Rust 43.31%

rust-esp32-example's Introduction

Rust ESP32 Example

An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

This example starts a FreeRTOS task to call a function in Rust and display the results in C.

Setup

First, install the ESP-IDF SDK as shown in the Get Started guides. For best support of the ESP32-C3, install the SDK from the master branch.

ESP32 and ESP32-S series

To support the Xtensa instruction set, build and install custom LLVM and Rust toolchains as shown in the Rust On Xtensa guide.

ESP32-C3

Install the RISCV target for Rust:

rustup target add riscv32i-unknown-none-elf

Build Rust library

This will eventually be folded into the main CMake build, but for now, build the library separately.

ESP32 or ESP32-S2

To build the Rust library, run:

cd rustlib
xargo build --release
cd ..

Build with manual configuration of the target:

export RUSTC=/usr/local/xtensa/rust/bin/rustc
export XARGO_RUST_SRC=/usr/local/xtensa/rust/library
cd rustlib
xargo build --release --target=xtensa-esp32-none-elf
cd ..

ESP32-C3

To build the Rust library, run:

cd rustlib
cargo build --release
cd ..

Build with manual configuration of the target:

unset RUSTC
unset XARGO_RUST_SRC
cd rustlib
cargo build --release --target=riscv32i-unknown-none-elf
cd ..

Configure

First ensure that the environment variables for the ESP32 SDK are properly set up. If you have followed the instructions in the Getting Started guide, activate the environment with the get_idf alias:

get_idf

Next, configure the project for the desired MCU.

For the ESP32:

idf.py set-target esp32
idf.py menuconfig

For the ESP32-S2:

idf.py set-target esp32s2
idf.py menuconfig

For the ESP32-C3:

idf.py set-target esp32c3
idf.py menuconfig

Build

Build the project by running:

idf.py build

Flash

Flash the compiled binary by running:

idf.py -p /dev/cu.SLAB_USBtoUART flash

Monitor

Connect to the UART over USB port to monitor the application console:

idf.py -p /dev/cu.SLABtoUART monitor

To exit the monitor, press Ctrl-].

Debugging on ESP32-WROVER-KIT

openocd -f board/esp32-wrover-kit-3.3v.cfg

rust-esp32-example's People

Contributors

georgik avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.