-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboxlambda_setup.sh
More file actions
executable file
·148 lines (122 loc) · 3.4 KB
/
boxlambda_setup.sh
File metadata and controls
executable file
·148 lines (122 loc) · 3.4 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
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
#! /bin/bash
#This script does not make any file system modifications outside of the boxlambda directory tree.
echo "Setting up BoxLambda. Installing tools if needed. Initializing git submodules and creating build tree."
echo "Note: This script should be sourced from a boxlambda workspace root directory."
if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 1
fi
if [[ "$#" > 0 && "$1" == "-h" ]]
then
echo "$0 [-h] [-s]"
echo "-h: Show help."
echo "-s: Check out all submodules to boxlambda branch head (instead of detached head)."
exit 1
fi
#Checking availability of key tools that user has to provide.
if which vivado ; then
echo "Vivado found."
else
echo "Vivado not found. Please install Vivado and add it to your path."
fi
if [ -z "$RISCV_PREFIX" ]; then
export RISCV_PREFIX=riscv64-unknown-elf
fi
#Install RISCV compiler
pushd . > /dev/null
mkdir -p tools
cd tools
if [ -d riscv32-boxlambda-elf ]; then
echo "riscv32 toolchain found."
else
echo "Unpacking riscv32 toolchain..."
if tar xf ../assets/riscv32-boxlambda-elf.tgz ; then
echo "OK"
else
echo "Unpack of riscv32 toolchain failed. Aborting..."
popd
return 1
fi
fi
#Download and install additional tools.
if [ -d oss-cad-suite ]; then
echo "oss-cad-suite found."
else
echo "Downloading and unpacking oss-cad-suite..."
wget https://github.com/YosysHQ/oss-cad-suite-build/releases/download/2025-02-26/oss-cad-suite-linux-x64-20250226.tgz
if tar xf oss-cad-suite-linux-x64-20250226.tgz ; then
echo "OK"
else
echo "Unpack of oss-cad-suite failed. Aborting..."
popd
return 1
fi
fi
export BENDER_VERSION=0.28.1
if [ -f ./bender ]; then
echo "Bender found."
else
echo "Downloading and installing Bender..."
wget https://github.com/pulp-platform/bender/releases/download/v$BENDER_VERSION/bender-$BENDER_VERSION-x86_64-linux-gnu.tar.gz
if tar xf bender-$BENDER_VERSION-x86_64-linux-gnu.tar.gz ; then
echo "OK"
else
echo "Unpack of Bender failed. Aborting..."
popd
return 1
fi
fi
popd > /dev/null
#Activate the environment
source activate_env.sh
#Install required Python packages.
echo "Installing required Python packages..."
if python3 -m pip install -qq -U -r python-requirements.txt ; then
echo "OK"
else
"Pip install failed. Aborting..."
return 1
fi
cp -f python-requirements.txt ./tools/oss-cad-suite/.python_packages_installed
echo "Retrieving git submodules..."
git submodule update --init --recursive
if [[ "$#" > 0 && "$1" == "-s" ]]
then
echo "Recursively checking out submodules to HEAD of boxlambda branch."
git submodule foreach --recursive git checkout boxlambda
echo "Recursively pulling from remote."
git submodule foreach --recursive git pull
fi
#Install LiteX.
if [ -f ./tools/oss-cad-suite/bin/litedram_gen ]; then
echo "Litex found."
else
echo "Installing Litex..."
pushd . > /dev/null
cd sub/litex/
if ./litex_setup.py --init --install ; then
echo "OK"
else
"Litex install failed. Aborting..."
return 1
fi
popd
fi
echo "Creating build build trees..."
rm -rf build
cmake --fresh --preset=sim-a7-100
cmake --fresh --preset=arty-a7-100
#Run the code generation rules
pushd .
cd build/sim-a7-100
make cgen
popd
pushd .
cd build/arty-a7-100
make cgen
popd
#Deactivate the environment
deactivate
echo
echo "Setup complete."
echo "Source activate_env.sh to activate the environment."