-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa3d21b
commit 8505624
Showing
2 changed files
with
77 additions
and
27 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,71 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
set -e | ||
|
||
# From https://unix.stackexchange.com/a/137639 ---------------------- | ||
function fail { | ||
echo $1 >&2 | ||
exit 1 | ||
} | ||
|
||
function retry { | ||
local n=1 | ||
local max=10 | ||
local delay=15 | ||
while true; do | ||
"$@" && break || { | ||
if [[ $n -lt $max ]]; then | ||
((n++)) | ||
echo "Command failed. Attempt $n/$max:" | ||
sleep $delay; | ||
else | ||
fail "The command has failed after $n attempts." | ||
fi | ||
} | ||
done | ||
} | ||
# ------------------------------------------------------------------- | ||
|
||
set +e | ||
echo "Using Google DNS to avoid around DNS resolution issues." | ||
cat /etc/resolv.conf | sudo tee /etc/resolv.conf.bak | ||
sudo chattr -i /etc/resolv.conf | ||
sudo rm /etc/resolv.conf | ||
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf | ||
sudo chattr +i /etc/resolv.conf | ||
set -e | ||
|
||
echo "Provisioning Tock development VM..." | ||
cd /home/tock/ | ||
|
||
echo "Cloning git repos" | ||
git clone https://github.com/tock/tock ./tock | ||
git clone https://github.com/tock/libtock-c ./libtock-c | ||
git clone https://github.com/tock/libtock-rs ./libtock-rs | ||
|
||
echo "Installing rustup" | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
retry git clone https://github.com/tock/tock ./tock | ||
retry git clone https://github.com/tock/libtock-c ./libtock-c | ||
retry git clone https://github.com/tock/libtock-rs ./libtock-rs | ||
|
||
echo "Installing Tockloader" | ||
sudo pip3 install tockloader | ||
retry sudo pip3 install tockloader | ||
|
||
echo "Installing rustup" | ||
curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
|
||
echo "Installing GCC toolchains" | ||
sudo apt install -y gcc-arm-none-eabi gcc-riscv64-unknown-elf | ||
echo "Source the Rust setup" | ||
source /home/tock/.cargo/env | ||
|
||
echo "Building kernel" | ||
pushd ./tock/boards/nordic/nrf52840dk/ && make && popd | ||
pushd ./tock/boards/opentitan/earlgrey-cw310/ && make && popd | ||
echo "Build the libtock-c example app, downloading toolchains and elf2tab" | ||
pushd libtock-c/examples/c_hello | ||
retry make | ||
popd | ||
|
||
echo "Building libtock-c app" | ||
pushd ./libtock-c/examples/c_hello/ && make && popd | ||
pushd ./libtock-c/examples/cxx_hello/ && make && popd | ||
echo "Build the nRF52840DK Tock board, which will download the Rust toolchain" | ||
pushd tock/boards/nordic/nrf52840dk | ||
retry make | ||
popd | ||
|
||
echo "Building libtock-rs app" | ||
pushd ./libtock-rs/ && make nrf52840 EXAMPLE=blink && popd | ||
set +e | ||
echo "Restoring DNS configuration." | ||
sudo chattr -i /etc/resolv.conf | ||
sudo rm /etc/resolv.conf | ||
sudo mv /etc/resolv.conf.bak /etc/resolv.conf | ||
sudo chattr +i /etc/resolv.conf | ||
set -e |
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