1 |
76 |
rfajardo |
#!/bin/bash
|
2 |
|
|
# Author: Constantinos Xanthopoulos
|
3 |
|
|
# This script install MinSOC tree
|
4 |
|
|
# under a specific directory.
|
5 |
|
|
|
6 |
|
|
# ===== CONFIGURATIONS =====
|
7 |
|
|
# ==========================
|
8 |
|
|
|
9 |
|
|
# Where should I put the dir. minsoc?
|
10 |
|
|
# ex. /home/conx/Thesis/
|
11 |
|
|
DIR_TO_INSTALL=`pwd`
|
12 |
|
|
|
13 |
|
|
# This variable should be set to trunk
|
14 |
|
|
# or to stable.
|
15 |
|
|
VERSION=""
|
16 |
|
|
|
17 |
|
|
# This variable should take one of
|
18 |
|
|
# the following values depending
|
19 |
|
|
# to your system: linux, cygwin, freebsd
|
20 |
|
|
ENV=""
|
21 |
|
|
|
22 |
|
|
# !!! DO NOT EDIT BELLOW THIS LINE !!!
|
23 |
|
|
# ===================================
|
24 |
|
|
|
25 |
|
|
# ===== SCRIPT ======
|
26 |
|
|
# ===================
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
# Debug ?
|
30 |
|
|
export DEBUG=0;
|
31 |
|
|
. beautify.sh
|
32 |
|
|
|
33 |
|
|
function testtool
|
34 |
|
|
{
|
35 |
|
|
# is_missing=`which $1 2>&1 | grep no`
|
36 |
|
|
is_missing=`whereis -b $1 2>&1 | grep :$`
|
37 |
|
|
if [ -z "$is_missing" ]
|
38 |
|
|
then
|
39 |
|
|
cecho "$1 is installed, pass"
|
40 |
|
|
else
|
41 |
|
|
errormsg "$1 is not installed, install it and re-run this installation script."
|
42 |
|
|
fi
|
43 |
|
|
}
|
44 |
|
|
|
45 |
106 |
rfajardo |
|
46 |
|
|
#Setting environment
|
47 |
|
|
ENV=`uname -o`
|
48 |
|
|
if [ "$ENV" != "GNU/Linux" ] && [ "$ENV" != "Cygwin" ]
|
49 |
|
|
then
|
50 |
|
|
errormsg "Environment $ENV not supported by this script."
|
51 |
|
|
fi
|
52 |
|
|
cecho "Building tools for ${ENV} system"
|
53 |
|
|
|
54 |
|
|
is_arch64=`uname -m | grep 64`
|
55 |
|
|
if [ -z $is_arch64 ]
|
56 |
|
|
then
|
57 |
|
|
KERNEL_ARCH="32"
|
58 |
|
|
else
|
59 |
|
|
KERNEL_ARCH="64"
|
60 |
|
|
fi
|
61 |
|
|
|
62 |
|
|
|
63 |
76 |
rfajardo |
# User check!
|
64 |
|
|
if [ `whoami` = "root" ];
|
65 |
|
|
then
|
66 |
|
|
errormsg "You shouldn't be root for this script to run.";
|
67 |
|
|
fi;
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
# Testing necessary tools
|
71 |
|
|
cecho "Testing if necessary tools are installed, program "whereis" is required."
|
72 |
|
|
testtool wget
|
73 |
|
|
testtool svn
|
74 |
83 |
rfajardo |
testtool bzip2
|
75 |
76 |
rfajardo |
testtool tar
|
76 |
|
|
testtool sed
|
77 |
|
|
testtool patch
|
78 |
|
|
testtool gcc
|
79 |
|
|
testtool make
|
80 |
|
|
testtool libncurses
|
81 |
77 |
rfajardo |
testtool flex
|
82 |
|
|
testtool bison
|
83 |
76 |
rfajardo |
if [ "$ENV" == "Cygwin" ]
|
84 |
|
|
then
|
85 |
|
|
testtool ioperm
|
86 |
|
|
testtool libusb
|
87 |
|
|
fi
|
88 |
|
|
|
89 |
|
|
|
90 |
81 |
rfajardo |
# Wizard
|
91 |
|
|
if [ -z "${ALTDIR}" ]
|
92 |
76 |
rfajardo |
then
|
93 |
81 |
rfajardo |
cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
|
94 |
|
|
read ALTDIR;
|
95 |
|
|
if [ ! -z "${ALTDIR}" ]
|
96 |
|
|
then
|
97 |
|
|
DIR_TO_INSTALL=${ALTDIR}
|
98 |
|
|
fi
|
99 |
|
|
cecho "${DIR_TO_INSTALL} selected";
|
100 |
76 |
rfajardo |
fi
|
101 |
|
|
|
102 |
81 |
rfajardo |
if [ ! -d ${DIR_TO_INSTALL} ]
|
103 |
76 |
rfajardo |
then
|
104 |
81 |
rfajardo |
errormsg "Directory doesn't exist. Please create it";
|
105 |
|
|
fi;
|
106 |
76 |
rfajardo |
|
107 |
|
|
|
108 |
81 |
rfajardo |
#Creating directory structure
|
109 |
|
|
cecho "\nCreating directory structure"
|
110 |
|
|
cd ${DIR_TO_INSTALL}
|
111 |
|
|
execcmd "Creating directory ./download for downloaded packages" "mkdir -p download"
|
112 |
|
|
execcmd "Creating directory ./tools for package binaries" "mkdir -p tools"
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
#Downloading everything we need
|
116 |
|
|
cecho "\nDownloading packages"
|
117 |
|
|
cd ${DIR_TO_INSTALL}
|
118 |
|
|
cecho "Download MinSoC"
|
119 |
|
|
svn co -q http://opencores.org/ocsvn/minsoc/minsoc/trunk/ minsoc #user need to input password, execcmd omits command output and should be this way
|
120 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/download"
|
121 |
76 |
rfajardo |
if [ "$ENV" == "Cygwin" ]
|
122 |
|
|
then
|
123 |
81 |
rfajardo |
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-cygwin-1.7.tar.bz2";
|
124 |
76 |
rfajardo |
else
|
125 |
|
|
if [ $KERNEL_ARCH == "32" ];
|
126 |
|
|
then
|
127 |
81 |
rfajardo |
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86.tar.bz2";
|
128 |
76 |
rfajardo |
elif [ $KERNEL_ARCH == "64" ];
|
129 |
|
|
then
|
130 |
81 |
rfajardo |
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86_64.tar.bz2";
|
131 |
76 |
rfajardo |
fi
|
132 |
|
|
fi
|
133 |
102 |
rfajardo |
execcmd "Downloading GDB" "wget ftp://anonymous:anonymous@ftp.gnu.org/gnu/gdb/gdb-6.8a.tar.bz2"
|
134 |
81 |
rfajardo |
execcmd "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-gdb-6.8-patch-2.4.bz2"
|
135 |
|
|
execcmd "svn export -q http://opencores.org/ocsvn/adv_debug_sys/adv_debug_sys/trunk/Patches/GDB6.8/gdb-6.8-bz436037-reg-no-longer-active.patch"
|
136 |
|
|
if [ "$ENV" != "Cygwin" ]
|
137 |
|
|
then
|
138 |
|
|
execcmd "Downloading libusb-0.1 for Advanced Debug System" "wget http://sourceforge.net/projects/libusb/files/libusb-0.1%20%28LEGACY%29/0.1.12/libusb-0.1.12.tar.gz"
|
139 |
|
|
fi
|
140 |
|
|
execcmd "Downloading libftdi for Advanced Debug System" "wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.19.tar.gz"
|
141 |
|
|
execcmd "Downloading Icarus Verilog" "wget ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.4.tar.gz"
|
142 |
76 |
rfajardo |
|
143 |
|
|
|
144 |
81 |
rfajardo |
#Uncompressing everything
|
145 |
|
|
cecho "\nUncompressing packages"
|
146 |
|
|
if [ "$ENV" == "Cygwin" ]
|
147 |
|
|
then
|
148 |
|
|
execcmd "tar xf or32-elf-cygwin-1.7.tar.bz2";
|
149 |
|
|
else
|
150 |
|
|
if [ $KERNEL_ARCH == "32" ];
|
151 |
|
|
then
|
152 |
|
|
execcmd "tar xf or32-elf-linux-x86.tar.bz2";
|
153 |
|
|
elif [ $KERNEL_ARCH == "64" ];
|
154 |
|
|
then
|
155 |
|
|
execcmd "tar xf or32-elf-linux-x86_64.tar.bz2";
|
156 |
|
|
fi
|
157 |
|
|
fi
|
158 |
103 |
rfajardo |
execcmd "tar -jxf gdb-6.8a.tar.bz2"
|
159 |
81 |
rfajardo |
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
|
160 |
|
|
if [ "$ENV" != "Cygwin" ]
|
161 |
|
|
then
|
162 |
|
|
execcmd "tar zxf libusb-0.1.12.tar.gz"
|
163 |
|
|
fi
|
164 |
|
|
execcmd "tar zxf libftdi-0.19.tar.gz"
|
165 |
|
|
execcmd "tar zxf verilog-0.9.4.tar.gz"
|
166 |
76 |
rfajardo |
|
167 |
|
|
|
168 |
81 |
rfajardo |
#Compiling and Installing all packages
|
169 |
|
|
cecho "\nCompiling and installing packages"
|
170 |
|
|
# Installing the GNU Toolchain
|
171 |
82 |
rfajardo |
if [ "$ENV" == "Cygwin" ]
|
172 |
|
|
then
|
173 |
|
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-cygwin-1.7.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
174 |
|
|
else
|
175 |
|
|
if [ $KERNEL_ARCH == "32" ];
|
176 |
|
|
then
|
177 |
|
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
178 |
|
|
elif [ $KERNEL_ARCH == "64" ];
|
179 |
|
|
then
|
180 |
|
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86_64.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
181 |
|
|
fi
|
182 |
|
|
fi
|
183 |
81 |
rfajardo |
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
|
184 |
76 |
rfajardo |
|
185 |
|
|
|
186 |
81 |
rfajardo |
#Installing GDB
|
187 |
|
|
execcmd "cd gdb-6.8"
|
188 |
|
|
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
|
189 |
|
|
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
|
190 |
76 |
rfajardo |
|
191 |
81 |
rfajardo |
execcmd "mkdir -p build"
|
192 |
|
|
execcmd "cd build"
|
193 |
|
|
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
|
194 |
|
|
execcmd "Compiling GDB" "make"
|
195 |
|
|
make install 1>>${DIR_TO_INSTALL}/progress.log 2>>${DIR_TO_INSTALL}/error.log #avoid Fedora failing due to missing Makeinfo
|
196 |
|
|
PATH=$PATH:${DIR_TO_INSTALL}/tools/bin
|
197 |
76 |
rfajardo |
|
198 |
|
|
|
199 |
81 |
rfajardo |
#Installing Advanced JTAG Bridge support libraries
|
200 |
76 |
rfajardo |
if [ "$ENV" != "Cygwin" ]
|
201 |
|
|
then
|
202 |
81 |
rfajardo |
execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
|
203 |
76 |
rfajardo |
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
204 |
81 |
rfajardo |
execcmd "Installing libusb-0.1" "make"
|
205 |
76 |
rfajardo |
execcmd "make install"
|
206 |
|
|
fi
|
207 |
|
|
|
208 |
81 |
rfajardo |
execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
|
209 |
76 |
rfajardo |
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
210 |
81 |
rfajardo |
execcmd "Compiling libftdi" "make"
|
211 |
76 |
rfajardo |
execcmd "make install"
|
212 |
|
|
|
213 |
|
|
|
214 |
81 |
rfajardo |
#Installing Advanced JTAG Bridge
|
215 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
|
216 |
76 |
rfajardo |
if [ `grep "INCLUDE_JSP_SERVER=true" Makefile` != "" ]
|
217 |
|
|
then
|
218 |
81 |
rfajardo |
#Switching off the adv_jtag_bridge JSP_SERVER option
|
219 |
76 |
rfajardo |
sed 's/INCLUDE_JSP_SERVER=true/INCLUDE_JSP_SERVER=false/' Makefile > TMPFILE && mv TMPFILE Makefile
|
220 |
|
|
fi
|
221 |
|
|
|
222 |
|
|
if [ "${ENV}" == "GNU/Linux" ]
|
223 |
|
|
then
|
224 |
81 |
rfajardo |
#Setting the right build environment
|
225 |
76 |
rfajardo |
sed 's/BUILD_ENVIRONMENT=cygwin/BUILD_ENVIRONMENT=linux/' Makefile > TMPFILE && mv TMPFILE Makefile
|
226 |
|
|
fi
|
227 |
|
|
|
228 |
81 |
rfajardo |
#preparing the Makefile to find and link libraries
|
229 |
76 |
rfajardo |
sed "s%prefix = /usr/local%prefix = ${DIR_TO_INSTALL}/tools%" Makefile > TMPFILE && mv TMPFILE Makefile
|
230 |
|
|
sed "s%\$(CC) \$(CFLAGS)%\$(CC) \$(CFLAGS) \$(INCLUDEDIRS)%" Makefile > TMPFILE && mv TMPFILE Makefile
|
231 |
|
|
sed "s%INCLUDEDIRS =%INCLUDEDIRS = -I${DIR_TO_INSTALL}/tools/include%" Makefile > TMPFILE && mv TMPFILE Makefile
|
232 |
79 |
rfajardo |
sed "s%LIBS =%LIBS = -L${DIR_TO_INSTALL}/tools/lib -Wl,-R${DIR_TO_INSTALL}/tools/lib%" Makefile > TMPFILE && mv TMPFILE Makefile
|
233 |
76 |
rfajardo |
|
234 |
81 |
rfajardo |
#properly installing Advanced JTAG Bridge
|
235 |
|
|
execcmd "Compiling Advanced JTAG Bridge" "make"
|
236 |
|
|
execcmd "make install"
|
237 |
76 |
rfajardo |
|
238 |
|
|
|
239 |
81 |
rfajardo |
#Installing Icarus Verilog
|
240 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
|
241 |
76 |
rfajardo |
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
242 |
81 |
rfajardo |
execcmd "Compiling Icarus Verilog" "make"
|
243 |
76 |
rfajardo |
execcmd "make install"
|
244 |
|
|
|
245 |
|
|
|
246 |
81 |
rfajardo |
#Configuring MinSoC
|
247 |
|
|
cecho "\nConfiguring MinSoC"
|
248 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/backend/std"
|
249 |
|
|
execcmd "Configuring MinSoC as standard board (simulatable but not synthesizable)" "./configure"
|
250 |
|
|
execcmd "cd ${DIR_TO_INSTALL}"
|
251 |
|
|
|
252 |
|
|
|
253 |
76 |
rfajardo |
#Configuring Advanced Debug System to work with MinSoC
|
254 |
81 |
rfajardo |
cecho "\nConfiguring Advanced Debug System to work with MinSoC"
|
255 |
76 |
rfajardo |
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Hardware/adv_dbg_if/rtl/verilog"
|
256 |
|
|
sed "s%\`define DBG_JSP_SUPPORTED%//\`define DBG_JSP_SUPPORTED%" adbg_defines.v > TMPFILE && mv TMPFILE adbg_defines.v
|
257 |
|
|
|
258 |
81 |
rfajardo |
#Compiling and moving adv_jtag_bridge debug modules for simulation
|
259 |
76 |
rfajardo |
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge/sim_lib/icarus"
|
260 |
|
|
execcmd "make"
|
261 |
|
|
execcmd "cp jp-io-vpi.vpi ${DIR_TO_INSTALL}/minsoc/bench/verilog/vpi"
|
262 |
|
|
|
263 |
|
|
|
264 |
81 |
rfajardo |
#Precompiling firmwares
|
265 |
|
|
cecho "\nPrecompiling delivered firmwares";
|
266 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/utils"
|
267 |
|
|
execcmd "Make utils" "make"
|
268 |
|
|
|
269 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/support"
|
270 |
|
|
execcmd "Make support tools" "make"
|
271 |
|
|
|
272 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/drivers"
|
273 |
|
|
execcmd "Make drivers" "make"
|
274 |
|
|
|
275 |
|
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/uart"
|
276 |
|
|
execcmd "Make UART" "make"
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
#Setting-up new variables
|
280 |
|
|
cecho "\nSystem configurations"
|
281 |
76 |
rfajardo |
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
|
282 |
|
|
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
|
283 |
81 |
rfajardo |
|
284 |
|
|
cecho "\nInstallation Complete!"
|
285 |
76 |
rfajardo |
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
|
286 |
81 |
rfajardo |
cecho "You may remove the ${DIR_TO_INSTALL}/download directory if you wish."
|