There are two approaches: cross-compiling and direct use. Everybody does the first but Ray is trying the second because the cross-compiler barfs on some HAL libraries and dammit if we were not going to use the OS we would just have a microcontroller.
Have more than a GB of free space. I put /root on an SD.
Install Rust using https://rustup.rs .
Create a crate:
mkdir -p rust/bustarust
cd rust/bustarust
cargo init
Incorporate libraries I think will help later:
cat 'linux-embedded-hal = "0.3"' >> Cargo.toml'
Build to get the deps prebuilt:
cargo build
Slow, maybe 45 minutes.. But maybe only one-time.
root@bela:~/rust/hal# cargo build
Compiling nrf52840-pac v0.9.0
error: could not compile `nrf52840-pac`
Caused by:
process didn't exit successfully: `rustc --crate-name nrf52840_pac --edition=2018 /root/.cargo/registry/src/github.com-1285ae84e5963aae/nrf52840-pac-0.9.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="cortex-m-rt"' --cfg 'feature="rt"' -C metadata=3cb66f7c0a3c9ccf -C extra-filename=-3cb66f7c0a3c9ccf --out-dir /mnt/sd/root/rust/hal/target/debug/deps -L dependency=/mnt/sd/root/rust/hal/target/debug/deps --extern bare_metal=/mnt/sd/root/rust/hal/target/debug/deps/libbare_metal-272be3cc207ce608.rmeta --extern cortex_m=/mnt/sd/root/rust/hal/target/debug/deps/libcortex_m-3489dabd314c126f.rmeta --extern cortex_m_rt=/mnt/sd/root/rust/hal/target/debug/deps/libcortex_m_rt-28b165ece2c2d8af.rmeta --extern vcell=/mnt/sd/root/rust/hal/target/debug/deps/libvcell-ecc883366d2ce56a.rmeta --cap-lints allow -L /mnt/sd/root/rust/hal/target/debug/build/nrf52840-pac-001162bd156b3368/out -L /mnt/sd/root/rust/hal/target/debug/build/cortex-m-rt-5c66c1610ccc13b8/out` (signal: 9, SIGKILL: kill)
B OOM.