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

Subversion Repositories minsoc

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

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

powered by: WebSVN 2.1.0

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