OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [utils/] [setup/] [minsoc-install.sh] - Blame information for rev 82

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2021 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.