forked from FPGAwars/toolchain-icestorm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-linux_aarch64.sh
225 lines (162 loc) · 5.54 KB
/
build-linux_aarch64.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#####################################################
# Icestorm toolchain builder for Ubunt phone (armhf) #
# It should be execute on a Linux x86_64 machine #
#####################################################
# Generate toolchain-icestorm.tar.gz from source code
# sources: http://www.clifford.at/icestorm/
# This tarball can be unpacked in ~/.platformio/packages
#---- DEBUG
COMPILE_ICEPROG=0
COMPILE_ICEPACK=0
COMPILE_ARACHNE=0
COMPILE_YOSYS=0
COMPILE_YOSYS_ABC=0
CREATE_PACKAGE=1
# -- Upstream folder. This is where all the toolchain is stored
# -- from the github
UPSTREAM=upstream
# -- Git url were to retieve the upstream sources
GIT_ICESTORM=https://github.com/cliffordwolf/icestorm.git
GIT_ARACHNE=https://github.com/cseed/arachne-pnr.git
REL_YOSYS=https://github.com/cliffordwolf/yosys/archive/yosys-0.6.tar.gz
# -- Folder for storing the generated packages
PACK_DIR=packages
# -- Target architecture
ARCH=linux_aarch64
# -- Directory for compiling the tools
BUILD_DIR=build_$ARCH
# -- Icestorm directory
ICESTORM=icestorm
ICEPROG=iceprog
ICEPACK=icepack
ARACHNE=arachne-pnr
# --- Directory where the files for patching the upstream are located
DATA=build-data/$ARCH
# -- toolchain name
NAME=toolchain-icestorm
# -- Directory for installation the target files
INSTALL=$PWD/$BUILD_DIR/$NAME
VERSION=7
PACKNAME=$NAME-$ARCH-$VERSION
TARBALL=$PACKNAME.tar.gz
# Store current dir
WORK=$PWD
# -- TARGET: CLEAN. Remove the build dir and the generated packages
# -- then exit
if [ "$1" == "clean" ]; then
echo "-----> CLEAN"
# -- Remove the final package
rm -r -f $PACK_DIR/$NAME-$ARCH-*
# -- Remove the build dir
rm -r -f $BUILD_DIR
exit
fi
# Install dependencies
echo "Installing dependencies..."
sudo apt-get install build-essential clang bison flex libreadline-dev \
gawk tcl-dev libffi-dev git mercurial graphviz \
xdot pkg-config python python3 libftdi-dev \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# Create the upstream directory and enter into it
mkdir -p $UPSTREAM
cd $WORK/$UPSTREAM
# -------- Clone the toolchain from the github
# -- Icetools
git -C $ICESTORM pull || git clone $GIT_ICESTORM $ICESTORM
# -------- Create the packages directory
cd $WORK
mkdir -p $PACK_DIR
# -------- Create the build dir and enter into it
mkdir -p $BUILD_DIR
cd $WORK/$BUILD_DIR
# --- Create the target folder
mkdir -p $NAME
mkdir -p $NAME/bin
mkdir -p $NAME/share
# -- Create the example folder
mkdir -p $NAME/examples
# -- Copy all the examples into it
cp -r $WORK/build-data/examples/* $WORK/$BUILD_DIR/$NAME/examples
# ---- Copy the upstream sources into the build directory
cp -r $WORK/$UPSTREAM/$ICESTORM/$ICEPROG .
# ---------------------------- Compile the iceprog
if [ $COMPILE_ICEPROG == "1" ]; then
cd $WORK/$BUILD_DIR/$ICEPROG
# -- Apply the patches
cp $WORK/$DATA/Makefile.iceprog $WORK/$BUILD_DIR/$ICEPROG/Makefile
# -- Compile it!
make
# -- Copy the executable to the bin dir
cp iceprog $INSTALL/bin
fi
# ---------------- Compile the icepack
if [ $COMPILE_ICEPACK == "1" ]; then
cd $WORK/$BUILD_DIR
# -- Copy the sources into the build directory
cp -r $WORK/$UPSTREAM/$ICESTORM/$ICEPACK .
cd $ICEPACK
# -- Apply the patches
cp $WORK/$DATA/Makefile.icepack $WORK/$BUILD_DIR/$ICEPACK/Makefile
# -- Compile it
make
# -- Copy the executable to the bin dir
cp icepack $INSTALL/bin
fi
# ----------- Compile Arachne-pnr ----------------------------------
if [ $COMPILE_ARACHNE == "1" ]; then
cd $WORK/$UPSTREAM
git -C $ARACHNE pull || git clone --depth=1 $GIT_ARACHNE
cd $WORK/$BUILD_DIR
cp -r $WORK/$UPSTREAM/$ARACHNE .
cd $ARACHNE
# -- Apply the patches
cp $WORK/$DATA/Makefile.arachne $WORK/$BUILD_DIR/$ARACHNE/Makefile
# -- Copy the chipdb*.bin data files
mkdir -p $WORK/$BUILD_DIR/$NAME/share/$ARACHNE
cp -r $WORK/build-data/$ARACHNE/chip*.bin $WORK/$BUILD_DIR/$NAME/share/$ARACHNE
# -- Compile it
make -j$(( $(nproc) -1))
# -- Copy the executable to the bin dir
cp bin/arachne-pnr $INSTALL/bin
fi
# ------------ Compile Yosys 0.6 --------------------------------
if [ $COMPILE_YOSYS == "1" ]; then
cd $WORK/$UPSTREAM
test -e yosys-0.6.tar.gz || wget $REL_YOSYS
tar vzxf yosys-0.6.tar.gz
cd $WORK/$BUILD_DIR
cp -r $WORK/$UPSTREAM/yosys-yosys-0.6 .
cd yosys-yosys-0.6
# -- Apply the patches
cp $WORK/$DATA/Makefile.yosys $WORK/$BUILD_DIR/yosys-yosys-0.6/Makefile
cp $WORK/build-data/yosys/version*.cc $WORK/$BUILD_DIR/yosys-yosys-0.6/kernel
# -- Compile it
make -j$(( $(nproc) -1))
# -- Copy the share folder to the install folder
mkdir -p $INSTALL/share/
mkdir -p $INSTALL/share/yosys
cp -r $WORK/build-data/yosys/share/* $INSTALL/share/yosys
# -- Copy the executable files
cp yosys $INSTALL/bin
fi
# ----------------- Compile yosys-abc --------------------------------
if [ $COMPILE_YOSYS_ABC == "1" ]; then
echo "-------------> BUILDING YOSYS-ABS:"
cd $WORK/$UPSTREAM
test -d abc || hg clone https://bitbucket.org/alanmi/abc abc
cd $WORK/$BUILD_DIR
cp -r $WORK/$UPSTREAM/abc .
cd abc
# -- Apply the patches
cp $WORK/$DATA/Makefile.yosys-abc $WORK/$BUILD_DIR/abc/Makefile
# -- Compile it
make -j$(( $(nproc) -1))
cp yosys-abc $INSTALL/bin
fi
# ---------------------- Create the package --------------------------
if [ $CREATE_PACKAGE == "1" ]; then
cd $WORK/$BUILD_DIR
tar vzcf $TARBALL $NAME
# -- Move the package to the packages dir
mv $TARBALL $WORK/$PACK_DIR
fi