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

Subversion Repositories minsoc

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

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

powered by: WebSVN 2.1.0

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