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

Subversion Repositories minsoc

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

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
# Wizard
52
if [ -z "${ALTDIR}" ]
53
then
54
    cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
55
    read ALTDIR;
56
    if [ ! -z "${ALTDIR}" ]
57
    then
58
        DIR_TO_INSTALL=${ALTDIR}
59
    fi
60
    cecho "${DIR_TO_INSTALL} selected";
61
fi
62
 
63
# Directory exists?
64
if [ ! -d ${DIR_TO_INSTALL} ]
65
then
66
    errormsg "Directory doesn't exist. Please create it";
67
fi;
68
 
69
cd ${DIR_TO_INSTALL}
70
 
71
 
72
#setting environment
73
ENV=`uname -o`
74
if [ "$ENV" != "GNU/Linux" ] && [ "$ENV" != "Cygwin" ]
75
then
76
    errormsg "Environment $ENV not supported by this script."
77
fi
78
cecho "Building tools for ${ENV} system"
79
 
80
 
81
# Testing necessary tools
82
cecho "Testing if necessary tools are installed, program "whereis" is required."
83
testtool wget
84
testtool svn
85
testtool tar
86
testtool sed
87
testtool patch
88
testtool gcc
89
testtool make
90
testtool libncurses
91
if [ "$ENV" == "Cygwin" ]
92
then
93
    testtool ioperm
94
    testtool libusb
95
fi
96
 
97
 
98
# Which Version?
99
if [ -z ${VERSION} ]
100
then
101
    while [ "$VERSION" != "trunk" -a   "$VERSION" != "stable" ]
102
    do
103
        cnecho "Select MinSOC Version [stable/trunk]: "
104
        read VERSION;
105
    done
106
fi
107
 
108
 
109
# Checkout MinSOC
110
if [ "${VERSION}" = "trunk" ]
111
then
112
    execcmd "Download minsoc" "svn co -q http://opencores.org/ocsvn/minsoc/minsoc/trunk/ minsoc"
113
    execcmd "cd minsoc/backend/std"
114
    execcmd "Selecting standard configuration (not synthesizable)" "./configure"
115
    execcmd "cd ${DIR_TO_INSTALL}"
116
else
117
    execcmd "Download minsoc" "svn co -q http://opencores.org/ocsvn/minsoc/minsoc/tags/release-0.9/ minsoc"
118
    execcmd "cd minsoc/rtl/verilog"
119
 
120
    execcmd "Checkout adv_jtag_bridge" "svn co -q http://opencores.org/ocsvn/adv_debug_sys/adv_debug_sys/trunk adv_debug_sys"
121
    execcmd "Checkout ethmac" "svn co -q http://opencores.org/ocsvn/ethmac/ethmac/trunk ethmac"
122
    execcmd "Checkout openrisc" "svn co -q  http://opencores.org/ocsvn/openrisc/openrisc/trunk/or1200 or1200"
123
    execcmd "Checkout uart" "svn co -q http://opencores.org/ocsvn/uart16550/uart16550/trunk uart16550"
124
fi
125
 
126
 
127
#Tools directory
128
if [ ! -d ${DIR_TO_INSTALL}/tools ]
129
then
130
    execcmd "mkdir tools"
131
fi;
132
 
133
 
134
#Installing GDB
135
execcmd "cd ${DIR_TO_INSTALL}/tools"
136
execcmd "Downloading GDB sources" "wget ftp://anonymous:anonymous@ftp.gnu.org/gnu/gdb/gdb-6.8.tar.bz2"
137
execcmd "Downloading GDB OpenRISC patch" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-gdb-6.8-patch-2.4.bz2"
138
execcmd "Downloading GDB Advanced Debug System patch" "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"
139
 
140
execcmd "Uncompressing GDB" "tar -jxf gdb-6.8.tar.bz2"
141
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
142
execcmd "cd gdb-6.8"
143
execcmd "Patching GDB" "patch -p1 < ../or32-gdb-6.8-patch-2.4"
144
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
145
 
146
execcmd "Compiling GDB" "mkdir b-gdb"
147
execcmd "cd b-gdb"
148
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
149
execcmd "make"
150
make install    #avoid Fedora failing due to missing Makeinfo
151
PATH=$PATH:$DIR_TO_INSTALL/tools/bin
152
 
153
 
154
# Installing the GNU Toolchain
155
cecho "Installing the GNU Toolchain"
156
 
157
is_arch64=`uname -m | grep 64`
158
if [ -z $is_arch64 ]
159
then
160
    KERNEL_ARCH="32"
161
else
162
    KERNEL_ARCH="64"
163
fi
164
 
165
cd $DIR_TO_INSTALL/tools;
166
 
167
if [ "$ENV" == "Cygwin" ]
168
then
169
    execcmd "Download toolchain (it may take a while)" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-cygwin-1.7.tar.bz2";
170
    execcmd "Un-tar" "tar xf or32-elf-cygwin-1.7.tar.bz2";
171
else
172
    if [ $KERNEL_ARCH == "32" ];
173
    then
174
        execcmd "Download toolchain (it may take a while)" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86.tar.bz2";
175
        execcmd "Un-tar" "tar xf or32-elf-linux-x86.tar.bz2";
176
    elif [ $KERNEL_ARCH == "64" ];
177
    then
178
        execcmd "Download toolchain (it may take a while)" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86_64.tar.bz2";
179
        execcmd "Un-tar" "tar xf or32-elf-linux-x86_64.tar.bz2";
180
    else
181
        errormsg "Not a correct architecture, $KERNEL_ARCH. Check Configurations";
182
    fi
183
fi
184
 
185
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
186
 
187
 
188
# Preparing MinSoC Specifics
189
cecho "I will now start to compile everything that's needed";
190
 
191
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/utils"
192
execcmd "Make utils" "make"
193
 
194
execcmd "cd ../support"
195
execcmd "Make support tools" "make"
196
 
197
execcmd "cd ../drivers"
198
execcmd "Make drivers" "make"
199
 
200
execcmd "cd ../uart"
201
execcmd "Make UART" "make"
202
 
203
 
204
# adv_jtag_bridge install
205
if [ "$ENV" != "Cygwin" ]
206
then
207
    execcmd "cd ${DIR_TO_INSTALL}/tools"
208
    execcmd "Acquiring 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"
209
    execcmd "tar zxf libusb-0.1.12.tar.gz"
210
    execcmd "cd libusb-0.1.12"
211
    execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
212
    execcmd "make"
213
    execcmd "make install"
214
fi
215
 
216
execcmd "cd ${DIR_TO_INSTALL}/tools"
217
execcmd "Acquiring libftdi for Advanced Debug System" "wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.19.tar.gz"
218
execcmd "tar zxf libftdi-0.19.tar.gz"
219
execcmd "cd libftdi-0.19"
220
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
221
execcmd "make"
222
execcmd "make install"
223
 
224
execcmd "Compiling Advanced JTAG Bridge" "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
225
 
226
if [ `grep "INCLUDE_JSP_SERVER=true" Makefile` != "" ]
227
then
228
    cecho "Switching off the adv_jtag_bridge JSP_SERVER option";
229
    sed 's/INCLUDE_JSP_SERVER=true/INCLUDE_JSP_SERVER=false/' Makefile > TMPFILE && mv TMPFILE Makefile
230
fi
231
 
232
if [ "${ENV}" == "GNU/Linux" ]
233
then
234
    cecho "Setting the right build environment";
235
    sed 's/BUILD_ENVIRONMENT=cygwin/BUILD_ENVIRONMENT=linux/' Makefile > TMPFILE && mv TMPFILE Makefile
236
fi
237
 
238
sed "s%prefix = /usr/local%prefix = ${DIR_TO_INSTALL}/tools%" Makefile > TMPFILE && mv TMPFILE Makefile
239
sed "s%\$(CC) \$(CFLAGS)%\$(CC) \$(CFLAGS) \$(INCLUDEDIRS)%" Makefile > TMPFILE && mv TMPFILE Makefile
240
sed "s%INCLUDEDIRS =%INCLUDEDIRS = -I${DIR_TO_INSTALL}/tools/include%" Makefile > TMPFILE && mv TMPFILE Makefile
241
sed "s%LIBS =%LIBS = -L${DIR_TO_INSTALL}/tools/lib%" Makefile > TMPFILE && mv TMPFILE Makefile
242
 
243
execcmd "Make adv_jtag_bridge" "make"
244
execcmd "Installing adv_jtag_bridge" "make install"
245
 
246
 
247
#install extra tools
248
execcmd "cd ${DIR_TO_INSTALL}/tools"
249
 
250
execcmd "Acquiring Icarus Verilog Tool" "wget ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.4.tar.gz"
251
execcmd "tar zxf verilog-0.9.4.tar.gz"
252
execcmd "cd verilog-0.9.4"
253
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
254
execcmd "make"
255
execcmd "make install"
256
 
257
 
258
#Configuring Advanced Debug System to work with MinSoC
259
cecho "Configuring Advanced Debug System to work with MinSoC"
260
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Hardware/adv_dbg_if/rtl/verilog"
261
sed "s%\`define DBG_JSP_SUPPORTED%//\`define DBG_JSP_SUPPORTED%" adbg_defines.v > TMPFILE && mv TMPFILE adbg_defines.v
262
 
263
cecho "Compiling and moving adv_jtag_bridge debug modules for simulation"
264
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge/sim_lib/icarus"
265
execcmd "make"
266
execcmd "cp jp-io-vpi.vpi ${DIR_TO_INSTALL}/minsoc/bench/verilog/vpi"
267
 
268
 
269
#trying to set-up new variables
270
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
271
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
272
cecho "Installation Finished"
273
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"

powered by: WebSVN 2.1.0

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