forked from keystone-enclave/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfast-setup.sh
More file actions
executable file
·76 lines (64 loc) · 2.09 KB
/
fast-setup.sh
File metadata and controls
executable file
·76 lines (64 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -e
echo "Starting..."
if ( $(command -v riscv64-unknown-linux-gnu-gcc > /dev/null) &&
$(command -v riscv64-unknown-elf-gcc > /dev/null) )
then
echo "RISCV tools are already installed"
else
echo "Downloading Prebuilt RISC-V Toolchain... "
# The 1.0 version expected libmpfr.so.4, modern Ubuntu has .6
TOOL_VER=1.0
if [[ $(ldconfig -p | grep "libmpfr.so.6") ]]; then
echo "Downloading tools v2.0 (support for libmpfr.so.6)"
TOOL_VER=2.0
fi
export RISCV=$(pwd)/riscv
export PATH=$PATH:$RISCV/bin
wget https://keystone-enclave.eecs.berkeley.edu/files/${TOOL_VER}.tar.gz
# Check tool integrity
echo "Verifying prebuilt toolchain integrity..."
sha256sum -c .prebuilt_tools_shasums --status --ignore-missing
if [[ $? != 0 ]]
then
echo "Toolchain binary download incomplete or corrupted. You can build the toolchain locally or try again."
exit 1
fi
tar -xzvf ${TOOL_VER}.tar.gz
cd firesim-riscv-tools-prebuilt-${TOOL_VER}
./installrelease.sh > riscv-tools-install.log
mv distrib riscv
cp -R riscv ../
cd ..
echo "Toolchain has been installed in $RISCV"
fi
echo "Updating and cloning submodules, this may take a long time"
git config submodule.riscv-gnu-toolchain.update none
# shallow clone submodules ahead of time (Git must be > 2.11)
if [ ! -d linux ]; then
git clone --shallow-since=2019-09-14 https://github.com/torvalds/linux.git linux
fi
if [ ! -d buildroot ]; then
git clone --shallow-since=2019-08-29 https://github.com/buildroot/buildroot.git buildroot
fi
if [ ! -d qemu ]; then
git clone --shallow-since=2018-08-14 https://github.com/qemu/qemu.git qemu
fi
git submodule sync --recursive
git submodule update --init --recursive
# build SDK if not present
if [ -z $KEYSTONE_SDK_DIR ]
then
echo "KEYSTONE_SDK_DIR is not set. Installing from $(pwd)/sdk"
export KEYSTONE_SDK_DIR=$(pwd)/sdk/build
cd sdk
mkdir -p build
cd build
cmake ..
make
make install
cd ../..
fi
# update source.sh
sed "s|KEYSTONE_SDK_DIR=.*|KEYSTONE_SDK_DIR=$KEYSTONE_SDK_DIR|" -i source.sh
echo "RISC-V toolchain and Keystone SDK have been fully setup"