forked from firesim/firesim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-setup-nolog.sh
109 lines (97 loc) · 3.77 KB
/
build-setup-nolog.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# FireSim initial setup script. This script will:
# 1) Initalize submodules (only the required ones, minimizing duplicates
# 2) Install RISC-V tools, including linux tools
# 3) Installs python requirements for firesim manager
# TODO: build FireSim linux distro here?
# exit script if any command fails
set -e
set -o pipefail
unamestr=$(uname)
RISCV=$(pwd)/riscv-tools-install
RDIR=$(pwd)
# ignore riscv-tools for submodule init recursive
# you must do this globally (otherwise riscv-tools deep
# in the submodule tree will get pulled anyway
git config --global submodule.riscv-tools.update none
git config --global submodule.experimental-blocks.update none
git submodule update --init --recursive #--jobs 8
# unignore riscv-tools,catapult-shell2 globally
git config --global --unset submodule.riscv-tools.update
git config --global --unset submodule.experimental-blocks.update
FASTINSTALL=false
# A lazy way to get fast riscv-tools installs for most users:
# 1) If user runs ./build-setup.sh fast :
# a) shallow clone, depth 1 the prebuilt risc-v tools repo
# b) check if HASH in that repo matches the hash of target-design/firechip/riscv-tools
# c) if so, just copy it into riscv-tools-install, otherwise go to 2
# 2) if no riscv-tools installed because either fast was not specified, or
# the hash doesn't match, install as usual (from source)
if [ $# -eq 0 ]; then
# handle case where no args passed. default to FASTINSTALL false
FASTINSTALL=false
elif [ "$1" = "fast" ]; then
git clone https://github.com/firesim/firesim-riscv-tools-prebuilt.git
cd firesim-riscv-tools-prebuilt
PREBUILTHASH="$(cat HASH)"
cd ../target-design/firechip
git submodule update --init riscv-tools
cd riscv-tools
GITHASH="$(git rev-parse HEAD)"
echo "prebuilt hash: $PREBUILTHASH"
echo "git hash: $GITHASH"
cd $RDIR
if [ "$PREBUILTHASH" = "$GITHASH" ]; then
echo "using fast install for riscv-tools"
FASTINSTALL=true
fi
fi
if [ "$FASTINSTALL" = true ]; then
cd firesim-riscv-tools-prebuilt
./installrelease.sh
mv distrib ../riscv-tools-install
# copy HASH in case user wants it later
cp HASH ../riscv-tools-install/
cd $RDIR
rm -rf firesim-riscv-tools-prebuilt
else
# install risc-v tools
mkdir -p riscv-tools-install
export RISCV="$RISCV"
cd target-design/firechip
git submodule update --init --recursive riscv-tools #--jobs 8
cd riscv-tools
export MAKEFLAGS="-j16"
./build.sh
# build static libfesvr library for linking into driver
cd riscv-fesvr/build
$RDIR/scripts/build-static-libfesvr.sh
# update linux headers
cd $RDIR
cd sw/firesim-software/riscv-linux
# TODO: why is this here?
cp ../linux-config-firesim .config
# build linux toolchain
cd $RDIR
cd target-design/firechip/riscv-tools/riscv-gnu-toolchain/build
make -j16 linux
cd $RDIR
fi
echo "export RISCV=$RISCV" > env.sh
echo "export PATH=$RISCV/bin:$RDIR/$DTCversion:\$PATH" >> env.sh
echo "export LD_LIBRARY_PATH=$RISCV/lib" >> env.sh
cd "$RDIR/platforms/f1/aws-fpga/sdk/linux_kernel_drivers/edma"
make
# commands to run only on EC2
# see if the instance info page exists. if not, we are not on ec2.
# this is one of the few methods that works without sudo
if wget -T 1 -t 3 -O /dev/null http://169.254.169.254/; then
# run sourceme-f1-full.sh once on this machine to build aws libraries and
# pull down some IP, so we don't have to waste time doing it each time on
# worker instances
cd $RDIR
bash sourceme-f1-full.sh
fi
echo "Setup complete!"
echo "To use the manager to deploy builds/simulations, source sourceme-f1-manager.sh to setup your environment."
echo "To run builds/simulations manually on this machine, source sourceme-f1-full.sh to setup your environment."