Giter VIP home page Giter VIP logo

rust-build's Introduction

rust-build

This repository contains:

  • workflows for building Rust fork esp-rs/rust with Xtensa support
  • binary artifacts in Releases

Table of Contents

Xtensa Installation

Linux and macOS

Following instructions are specific for ESP32 and ESP32-S series based on Xtensa architecture.

Instructions for ESP-C series based on RISC-V architecture are described in RiscV section.

Prerequisites

  • Linux:
    • dependencies (command for Ubuntu/Debian):
      apt-get install -y git curl gcc ninja-build cmake libudev-dev \
        python3 python3-pip libusb-1.0-0 libssl-dev pkg-config libtinfo5

No prerequisites are needed for macOS

Installation commands

./install-rust-toolchain.sh

Run ./install-rust-toolchain.sh --help for more information about arguments.

Export variables are displayed at the end of the script.

Windows x64

Following instructions are specific for ESP32 and ESP32-S series based on Xtensa architecture.

Instructions for ESP-C series based on RISC-V architecture are described in RiscV section.

Prerequisites

  • Visual Studio - installed with option Desktop development with C++ - components: MSVCv142 - VS2019 C++ x86/64 build tools, Windows 10 SDK

Visual Studio Installer - configuration

Installation of prerequisites with Chocolatey (run PowerShell as Administrator):

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco install cmake git ninja visualstudio2022-workload-vctools windows-sdk-10.0

Installation commands for PowerShell

./Install-RustToolchain.ps1

Export variables are displayed at the end of the output from the script.

Installation of different version of toolchain:

./Install-RustToolchain.sh --toolchain-version 1.60.0.1 --export-file Export-EspRust.ps1
source ./Export-EspRust.ps1

RiscV Installation

Following instructions are specific for ESP32-C based on RiscV architecture.

Install the RISCV target for Rust:

rustup target add riscv32i-unknown-none-elf

Building projects

Cargo first approach

  1. Get example source code

    git clone https://github.com/ivmarkov/rust-esp32-std-demo.git
    cd rust-esp32-std-demo/
  2. Build and flash:

    cargo espflash --target <TARGET> <SERIAL>

    Where TARGET can be:

    • xtensa-esp32-espidf for the ESP32(Xtensa architecture). [Default]
    • xtensa-esp32s2-espidf for the ESP32-S2(Xtensa architecture).
    • xtensa-esp32s3-espidf for the ESP32-S3(Xtensa architecture).
    • riscv32imc-esp-espidf for the ESP32-C3(RiscV architecture).

    And SERIAL is the serial port connected to the target device.

    cargo-espflash also allows opening a serial monitor after flashing with --monitor option, see Usage section for more information about arguments.

Idf first approach

  1. Get example source code
    git clone https://github.com/espressif/rust-esp32-example.git
    cd rust-esp32-example-main
  2. Select architecture for the build
    idf.py set-target <TARGET>
    Where TARGET can be:
    • esp32 for the ESP32(Xtensa architecture). [Default]
    • esp32s2 for the ESP32-S2(Xtensa architecture).
    • esp32s3 for the ESP32-S3(Xtensa architecture).
  3. Build and flash
    idf.py build flash

Podman/Docker Rust ESP environment

Alternatively, some container images, with pre-installed Rust and ESP-IDF, are published to Dockerhub and can be used to build Rust projects for ESP boards:

Podman example with mapping multiple /dev/ttyUSB from host computer to the container:

podman run --device /dev/ttyUSB0 --device /dev/ttyUSB1 -it docker.io/espressif/idf-rust-examples

Docker (does not support flashing from container):

docker run -it espressif/idf-rust-examples

If you are using the idf-rust-examples image, instructions will be displayed on the screen.

Devcontainers

There is also the option to integrate with Visual Studio Code using remote containers. With this method, we would have a fully working environment to build projects in Rust for ESP boards in VScode alongside useful settings and extensions, for more information, please, refer to esp-rs-devcontainer.

rust-build's People

Contributors

georgik avatar jenspfeifle avatar kevin-june avatar nicholas-l avatar sergiogasquez avatar stappersg avatar svenstaro avatar

Watchers

 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.