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

Subversion Repositories minsoc

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

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