- Grab the following:
- https://github.com/kelnos/rust-xtensa (branch xtensa-update-12-02-2021) OR download https://files.spurint.org/rust/rust-1.50.0-nightly-xtensa.tar.bz2
- https://github.com/kelnos/esp32-hal (branch rust-1.50)
- https://github.com/kelnos/esp32-wifi (branch experiments)
- If you've downloaded the Rust tarball, unpack to /opt/xtensa. If you are building from source, use the script provided in this gist (
rust-xtensa-build
) to build it. - Install form:
cargo install form
- Install svdtools (requires python 3.6 or above):
pip3 install --upgrade --user svdtools
- Install an old-ish version of svd2rust using:
cargo install --git https://github.com/rust-embedded/svd2rust --rev 29129c0e4e261bf4c38057f7585e7ddfc05fafd0 -- svd2rust
- Fetch version 4.2 of ESP-IDF (https://github.com/espressif/esp-idf/archive/v4.2.tar.gz), and unpack it somewhere. Set the
IDF_PATH
env var to its location (actually I don't think you need this unless you are regenerating the rust bindings in esp32-wifi). - Fetch the latest ESP32 toolchain/binutils (https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-tools.html#xtensa-esp32-elf) and unpack in /opt/xtensa.
- Grab the provided
rust-xtensa
script andsource
it into your shell session. - In the
esp32
crate source, runmake
. - In the
esp32-wifi
checkout, create a file calledrust-toolchain
that just contains the wordnightly
, and runcargo xbuild --example test
.
Last active
February 22, 2021 08:05
-
-
Save kelnos/e1db69cfda9e1a60feb46488e02a70a3 to your computer and use it in GitHub Desktop.
Building esp32-wifi against Rust 1.50.0 using ESP-IDF 4.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root=/opt/xtensa | |
rust=$root/rust | |
export RUST_BACKTRACE=full | |
export XARGO_RUST_SRC=$rust/lib/rustlib/src/rust/library | |
export RUST_SRC_PATH=$XARGO_RUST_SRC | |
export RUSTC=$rust/bin/rustc | |
export RUSTDOC=$rust/bin/rustdoc | |
export PATH=$rust/bin:$PATH:$root/xtensa-esp32-elf/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
prefix=/opt/xtensa/rust | |
channel=nightly | |
base_debug_args="--enable-debug --disable-optimize --disable-optimize-llvm --enable-llvm-release-debuginfo" | |
jobs=$(($(nproc)-2)) | |
clean=true | |
build=true | |
install=true | |
hostmach=unknown | |
hostabi=gnu | |
checkarg() { | |
[ "$2" ] || { | |
echo "'$1' requires an argument" >&2 | |
exit 1 | |
} | |
} | |
while [ "$1" ]; do | |
case "$1" in | |
--prefix) | |
checkarg "$1" "2" | |
prefix=$2 | |
shift | |
;; | |
--channel) | |
checkarg "$1" "$2" | |
channel=$2 | |
shift | |
;; | |
--debug) | |
extra_configure_args="$base_debug_args" | |
;; | |
--debug-assert) | |
extra_configure_args="$base_debug_args --enable-llvm-assertions --enable-debug-assertions" | |
;; | |
--jobs|-j) | |
checkarg "$1" "$2" | |
jobs=$2 | |
shift | |
;; | |
--host-mach) | |
checkarg "$1" "$2" | |
hostmach=$2 | |
shift | |
;; | |
--host-abi) | |
checkarg "$1" "$2" | |
hostabi=$2 | |
shift | |
;; | |
--no-clean) | |
clean=false | |
;; | |
--no-build) | |
build=false | |
;; | |
--no-install) | |
install=false | |
;; | |
*) | |
echo "Unknown option '$1'" >&2 | |
exit 1 | |
;; | |
esac | |
shift | |
done | |
hostarch=$(uname -m)-$hostmach-$(uname -s | tr '[A-Z]' '[a-z]')-$hostabi | |
if [ "$clean" = "true" ]; then | |
git clean -xfd | |
fi | |
if [ "$build" = "true" ]; then | |
./configure \ | |
--prefix=$prefix \ | |
--release-channel=$channel \ | |
--experimental-targets=Xtensa \ | |
--disable-docs \ | |
--disable-compiler-docs \ | |
$extra_configure_args | |
./x.py build --stage 2 --jobs $jobs | |
fi | |
if [ "$install" = "true" ]; then | |
rm -rf $prefix/* || true | |
./x.py install | |
mkdir -p $prefix/lib/rustlib/src/rust | |
cp -av Cargo.lock library $prefix/lib/rustlib/src/rust | |
mkdir -p $prefix/lib/rustlib/$hostarch | |
cp -av build/$hostarch/llvm/bin $prefix/lib/rustlib/$hostarch/ | |
cp -av build/$hostarch/stage2/lib/rustlib/$hostarch/ $prefix/lib/rustlib/$hostarch/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment