diff --git a/README.md b/README.md index bb52dda..5909c01 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ First, install the ESP-IDF SDK as shown in the [Get Started](https://docs.espres ### 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](RustOnXtensa.md) guide. +To support the Xtensa instruction set, build and install custom LLVM and Rust toolchains as shown in the [Rust On Xtensa](docs/rust-on-xtensa.md) guide. ### ESP32-C3 diff --git a/docs/rust-on-xtensa-installation-aarch64-apple-darwin.md b/docs/rust-on-xtensa-installation-aarch64-apple-darwin.md new file mode 100644 index 0000000..21d5982 --- /dev/null +++ b/docs/rust-on-xtensa-installation-aarch64-apple-darwin.md @@ -0,0 +1,41 @@ +# Rust on Xtensa Installation for macOS M1 + +Tested OS: macOS Big Sur M1 + +## Prerequisites + +- rustup - https://rustup.rs/ + +## Commands + +``` +rustup toolchain install nightly + +mkdir -p ~/.rustup/toolchains/xtensa + +wget --continue https://dl.espressif.com/dl/idf-rust/dist/aarch64-apple-darwin/rust-1.50.0-dev-aarch64-apple-darwin.tar.xz +tar xvf rust-1.50.0-dev-aarch64-apple-darwin.tar.xz +pushd rust-1.50.0-dev-aarch64-apple-darwin +./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs +popd + +wget --continue https://dl.espressif.com/dl/idf-rust/dist/aarch64-apple-darwin/rust-src-1.50.0-dev.tar.xz +tar xvf rust-src-1.50.0-dev.tar.xz +pushd rust-src-1.50.0-dev +./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" +popd + +rustup default xtensa + +wget --continue https://dl.espressif.com/dl/idf-rust/dist/aarch64-apple-darwin/xtensa-esp32-elf-llvm11_0_0-aarch64-apple-darwin.tar.xz +tar xf xtensa-esp32-elf-llvm11_0_0-aarch64-apple-darwin.tar.xz +export PATH="`pwd`/xtensa-esp32-elf-clang/bin/:$PATH" + +wget --continue https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip +unzip main.zip +cd rust-esp32-example-main/rustlib +cargo build --release +cd .. +idf.py build +``` + diff --git a/docs/rust-on-xtensa-installation-x86_64-apple-darwin.md b/docs/rust-on-xtensa-installation-x86_64-apple-darwin.md new file mode 100644 index 0000000..7b1a695 --- /dev/null +++ b/docs/rust-on-xtensa-installation-x86_64-apple-darwin.md @@ -0,0 +1,41 @@ +# Rust on Xtensa Installation for macOS x64 + +Tested OS: macOS Big Sur x64 + +## Prerequisites + +- rustup - installed with nightly toolchain - https://rustup.rs/ + +## Commands + +``` +rustup toolchain install nightly + +mkdir -p ~/.rustup/toolchains/xtensa + +wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-apple-darwin/rust-1.50.0-dev-x86_64-apple-darwin.tar.xz +tar xvf rust-1.50.0-dev-x86_64-apple-darwin.tar.xz +pushd rust-1.50.0-dev-x86_64-apple-darwin +./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs +popd + +wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-apple-darwin/rust-src-1.50.0-dev.tar.xz +tar xvf rust-src-1.50.0-dev.tar.xz +pushd rust-src-1.50.0-dev +./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs +popd + +rustup default xtensa + +wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-apple-darwin/xtensa-esp32-elf-llvm11_0_0-x86_64-apple-darwin.tar.xz +tar xf xtensa-esp32-elf-llvm11_0_0-x86_64-apple-darwin.tar.xz +export PATH="`pwd`/xtensa-esp32-elf-clang/bin/:$PATH" + +wget https://dl.espressif.com/dl/idf-rust/rust-esp32-example-0.2.tar.gz +tar xvzf rust-esp32-example-0.2.tar.gz +cd rust-esp32-example/rustlib +cargo build --release +cd .. +idf.py build +``` + diff --git a/docs/rust-on-xtensa-installation-x86_64-pc-windows-msvc.md b/docs/rust-on-xtensa-installation-x86_64-pc-windows-msvc.md new file mode 100644 index 0000000..dd813fc --- /dev/null +++ b/docs/rust-on-xtensa-installation-x86_64-pc-windows-msvc.md @@ -0,0 +1,55 @@ +# Rust on Xtensa Installation for Windows x64 + +Tested OS: Windows 10 x64 + +## Prerequisites + +- Visual Studio - installed with option Desktop development with C++ +- rustup - installed with nightly toolchain - https://rustup.rs/ +- Chocolatey - https://chocolatey.org/ + +## Commands for PowerShell + +``` +choco install 7zip + +rustup toolchain install nightly + +mkdir -p ~/.rustup/toolchains/xtensa + +Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/rust-1.50.0-dev-x86_64-pc-windows-msvc.tar.xz -OutFile rust-1.50.0-dev-x86_64-pc-windows-msvc.tar.xz +7z e .\rust-1.50.0-dev-x86_64-pc-windows-msvc.tar.xz +7z x .\rust-1.50.0-dev-x86_64-pc-windows-msvc.tar +pushd rust-1.50.0-dev-x86_64-pc-windows-msvc +cp -Recurse .\rustc\bin ~\.rustup\toolchains\xtensa\ +cp -Recurse .\rustc\lib ~\.rustup\toolchains\xtensa\ +cp -Recurse .\rustc\share ~\.rustup\toolchains\xtensa\ +cp -Recurse .\rust-std-x86_64-pc-windows-msvc\lib\* ~\.rustup\toolchains\xtensa\lib\ +popd + +Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/rust-src-1.50.0-dev.tar.xz -OutFile rust-src-1.50.0-dev.tar.xz +7z e .\rust-src-1.50.0-dev.tar.xz +7z x .\rust-src-1.50.0-dev.tar +pushd rust-src-1.50.0-dev +cp -Recurse .\rust-src\lib\* ~\.rustup\toolchains\xtensa\lib\ +popd + +rustup default xtensa + +Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-win64.zip -OutFile xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-win64.zip +7z x xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-win64.zip +$ClangPath=Join-Path -Path (Get-Location) -ChildPath xtensa-esp32-elf-clang\bin +$env:PATH="${ClangPath};$env:PATH" + +Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/llvm-patch-0.1.x86_64-pc-windows-msvc.tar.gz -OutFile llvm-patch-0.1.x86_64-pc-windows-msvc.tar.gz +tar xzf llvm-patch-0.1.x86_64-pc-windows-msvc.tar.gz +$ClangPatchPath=Join-Path -Path (Get-Location) -ChildPath llvm-patch\bin +$env:PATH="${ClangPatchPath};$env:PATH" + +Invoke-WebRequest https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip -OutFile rust-esp32-example.zip +7z x rust-esp32-example.zip +cd rust-esp32-example-main/rustlib +cargo build --release +cd .. +idf.py build +``` diff --git a/docs/rust-on-xtensa-installation-x86_64-unknown-linux-gnu.md b/docs/rust-on-xtensa-installation-x86_64-unknown-linux-gnu.md new file mode 100644 index 0000000..b2fed55 --- /dev/null +++ b/docs/rust-on-xtensa-installation-x86_64-unknown-linux-gnu.md @@ -0,0 +1,49 @@ +# Rust on Xtensa Installation for Linux x64 + +Tested OS: Ubuntu 20 x64, Mint x64 + +Limitation: Does not work with Ubuntu 18 Bionic - GLIBC problem in cargo: `/lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found.` + +## Prerequisites + +- rustup - installed with nightly toolchain - https://rustup.rs/ + +## Commands + +``` +sudo apt install gcc wget xz-utils + +rustup toolchain install nightly + +mkdir -p ~/.rustup/toolchains/xtensa + +wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-1.50.0-dev-x86_64-unknown-linux-gnu.tar.xz +tar xvf rust-1.50.0-dev-x86_64-unknown-linux-gnu.tar.xz +pushd rust-1.50.0-dev-x86_64-unknown-linux-gnu +./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs +popd + +wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-src-1.50.0-dev.tar.xz +tar xvf rust-src-1.50.0-dev.tar.xz +pushd rust-src-1.50.0-dev +./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs +popd + +rustup default xtensa + +wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz +tar xf xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz +export PATH="`pwd`/xtensa-esp32-elf-clang/bin/:$PATH" + +wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/llvm-patch-0.1.x86_64-unknown-linux-gnu.tar.gz +tar xzf llvm-patch-0.1.x86_64-unknown-linux-gnu.tar.gz +export PATH="`pwd`/llvm-patch/bin/:$PATH" + +wget https://dl.espressif.com/dl/idf-rust/rust-esp32-example-0.2.tar.gz +tar xvzf rust-esp32-example-0.2.tar.gz +cd rust-esp32-example/rustlib +cargo build --release +cd .. +idf.py build +``` + diff --git a/RustOnXtensa.md b/docs/rust-on-xtensa.md similarity index 90% rename from RustOnXtensa.md rename to docs/rust-on-xtensa.md index 0f3c73f..93a586a 100644 --- a/RustOnXtensa.md +++ b/docs/rust-on-xtensa.md @@ -2,7 +2,25 @@ ## Quick start -The installation process of ready to use custom build of Rust and LLVM is described here: https://dl.espressif.com/dl/idf-rust/ +The installation process of ready to use custom build of Rust and LLVM is described here: + +* [Linux Ubuntu x64/Mint x64](rust-on-xtensa-installation-x86_64-unknown-linux-gnu.md) +* [macOS Big Sur x64](rust-on-xtensa-installation-x86_64-apple-darwin.md) +* [macOS Big Sur arm64](rust-on-xtensa-installation-aarch64-apple-darwin.md) +* [Windows 10 x64](rust-on-xtensa-installation-x86_64-pc-windows-msvc.md) + +Make sure to install Rust toolchain nightly: + +`rustup toolchain install nightly` + +Missing nightly toolchain might result in following error: + +``` +error[E0463]: can't find crate for `std` + | + = note: the `xtensa-esp32-none-elf` target may not be installed +``` + Following text describes the build process when building LLVM and Rust from the scratch.