-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-setup-nolog.sh
202 lines (173 loc) · 6.33 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/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)
FASTINSTALL=false
IS_LIBRARY=false
SUBMODULES_ONLY=false
function usage
{
echo "usage: build-setup.sh [ fast | --fast] [--submodules-only] [--library]"
echo " fast: if set, pulls in a pre-compiled RISC-V toolchain for an EC2 manager instance"
echo " submodules-only: if set, skips toolchain handling (cloning or building)"
echo " library: if set, initializes submodules assuming FireSim is being used"
echo " as a library submodule"
}
if [ "$1" == "--help" -o "$1" == "-h" -o "$1" == "-H" ]; then
usage
exit 3
fi
while test $# -gt 0
do
case "$1" in
fast | --fast) # I don't want to break this api
FASTINSTALL=true
;;
--library)
IS_LIBRARY=true;
;;
--submodules-only)
SUBMODULES_ONLY=true;
;;
-h | -H | --help)
usage
exit
;;
--*) echo "ERROR: bad option $1"
usage
exit 1
;;
*) echo "ERROR: bad argument $1"
usage
exit 2
;;
esac
shift
done
git config submodule.target-design/chipyard.update none
git submodule update --init --recursive #--jobs 8
if [ "$IS_LIBRARY" = false ]; then
# This checks if firemarshal has already been configured by someone. If
# not, we will provide our own config. This must be checked before calling
# init-submodules-no-riscv-tools.sh because that will configure
# firemarshal.
marshal_cfg=$RDIR/target-design/chipyard/software/firemarshal/marshal-config.yaml
if [ ! -f $marshal_cfg ]; then
first_init=true
else
first_init=false
fi
git config --unset submodule.target-design/chipyard.update
git submodule update --init target-design/chipyard
cd $RDIR/target-design/chipyard
./scripts/init-submodules-no-riscv-tools.sh --no-firesim
cd $RDIR
# Configure firemarshal to know where our firesim installation is.
# If this is a fresh init of chipyard, we can safely overwrite the marshal
# config, otherwise we have to assume the user might have changed it
if [ $first_init = true ]; then
echo "firesim-dir: '../../../../'" > $marshal_cfg
fi
fi
if [ "$SUBMODULES_ONLY" = true ]; then
# Only initialize submodules
exit
fi
# A lazy way to get fast riscv-tools installs for most users:
# 1) If user runs ./build-setup.sh fast :
# a) clone the prebuilt risc-v tools repo
# b) check if HASH in that repo matches the hash of target-design/chipyard/riscv-tools
# c) if so, just copy it into riscv-tools-install, otherwise croak forcing
# the user to rerun this script without --fast
# 2) If fast was not specified, but the toolchain from source
if [ "$IS_LIBRARY" = true ]; then
target_chipyard_dir=$RDIR/../..
# setup marshal symlink
ln -s ../../../software/firemarshal $RDIR/sw/firesim-software
else
target_chipyard_dir=$RDIR/target-design/chipyard
# setup marshal symlink
ln -s ../target-design/chipyard/software/firemarshal $RDIR/sw/firesim-software
fi
# Restrict the devtoolset environment to a subshell
#
# The devtoolset wrapper around sudo does not correctly pass options
# through, which causes an aws-fpga SDK setup script to fail:
# platforms/f1/aws-fpga/sdk/userspace/install_fpga_mgmt_tools.sh
(
# Enable latest Developer Toolset for GNU make 4.x
devtoolset=''
for dir in /opt/rh/devtoolset-* ; do
! [ -x "${dir}/root/usr/bin/make" ] || devtoolset="${dir}"
done
if [ -n "${devtoolset}" ] ; then
echo "Enabling ${devtoolset##*/}"
. "${devtoolset}/enable"
fi
# Build the toolchain through chipyard (whether as top or as library)
cd "$target_chipyard_dir"
if [ "$FASTINSTALL" = "true" ] ; then
./scripts/build-toolchains.sh ec2fast
else
./scripts/build-toolchains.sh
fi
)
#generate env.sh file which sources the chipyard env.sh file
echo "if [ -f \"$target_chipyard_dir/env.sh\" ]; then" > env.sh
echo " source $target_chipyard_dir/env.sh" >> env.sh
echo " export FIRESIM_ENV_SOURCED=1" >> env.sh
echo "else" >> env.sh
echo " echo \"Error: You may have forgot to build or source the toolchains (build them independently in firesim-as-a-library mode)\"" >> env.sh
echo "fi" >> env.sh
if [ "$IS_LIBRARY" = false ]; then
echo "export FIRESIM_STANDALONE=1" >> env.sh
fi
cd $RDIR
# 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
cd "$RDIR/platforms/f1/aws-fpga/sdk/linux_kernel_drivers/xdma"
make
# Install firesim-software dependencies
# We always setup the symlink correctly above, so use sw/firesim-software
marshal_dir=$RDIR/sw/firesim-software
cd $RDIR
sudo pip3 install -r $marshal_dir/python-requirements.txt
cat $marshal_dir/centos-requirements.txt | sudo xargs yum install -y
wget https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/snapshot/e2fsprogs-1.45.4.tar.gz
tar xvzf e2fsprogs-1.45.4.tar.gz
cd e2fsprogs-1.45.4/
mkdir build && cd build
../configure
make
sudo make install
cd ../..
rm -rf e2fsprogs*
# Setup for using qcow2 images
cd $RDIR
./scripts/install-nbd-kmod.sh
# 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
cd $RDIR
source env.sh && ./scripts/build-libelf.sh
cd $RDIR
source env.sh && ./scripts/build-libdwarf.sh
cd $RDIR
./gen-tags.sh
echo "Setup complete!"
echo "To generate simulator RTL and run sw-RTL simulation, source env.sh"
echo "To use the manager to deploy builds/simulations on EC2, 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."