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

Subversion Repositories minsoc

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

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
execcmd "Installing GNU Toolchain" "cp -Rp or32-elf $DIR_TO_INSTALL/tools"
170
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
171 76 rfajardo
 
172
 
173 81 rfajardo
#Installing GDB
174
execcmd "cd gdb-6.8"
175
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
176
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
177 76 rfajardo
 
178 81 rfajardo
execcmd "mkdir -p build"
179
execcmd "cd build"
180
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
181
execcmd "Compiling GDB" "make"
182
make install 1>>${DIR_TO_INSTALL}/progress.log 2>>${DIR_TO_INSTALL}/error.log   #avoid Fedora failing due to missing Makeinfo
183
PATH=$PATH:${DIR_TO_INSTALL}/tools/bin
184 76 rfajardo
 
185
 
186 81 rfajardo
#Installing Advanced JTAG Bridge support libraries
187 76 rfajardo
if [ "$ENV" != "Cygwin" ]
188
then
189 81 rfajardo
    execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
190 76 rfajardo
    execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
191 81 rfajardo
    execcmd "Installing libusb-0.1" "make"
192 76 rfajardo
    execcmd "make install"
193
fi
194
 
195 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
196 76 rfajardo
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
197 81 rfajardo
execcmd "Compiling libftdi" "make"
198 76 rfajardo
execcmd "make install"
199
 
200
 
201 81 rfajardo
#Installing Advanced JTAG Bridge
202
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
203 76 rfajardo
if [ `grep "INCLUDE_JSP_SERVER=true" Makefile` != "" ]
204
then
205 81 rfajardo
    #Switching off the adv_jtag_bridge JSP_SERVER option
206 76 rfajardo
    sed 's/INCLUDE_JSP_SERVER=true/INCLUDE_JSP_SERVER=false/' Makefile > TMPFILE && mv TMPFILE Makefile
207
fi
208
 
209
if [ "${ENV}" == "GNU/Linux" ]
210
then
211 81 rfajardo
    #Setting the right build environment
212 76 rfajardo
    sed 's/BUILD_ENVIRONMENT=cygwin/BUILD_ENVIRONMENT=linux/' Makefile > TMPFILE && mv TMPFILE Makefile
213
fi
214
 
215 81 rfajardo
#preparing the Makefile to find and link libraries
216 76 rfajardo
sed "s%prefix = /usr/local%prefix = ${DIR_TO_INSTALL}/tools%" Makefile > TMPFILE && mv TMPFILE Makefile
217
sed "s%\$(CC) \$(CFLAGS)%\$(CC) \$(CFLAGS) \$(INCLUDEDIRS)%" Makefile > TMPFILE && mv TMPFILE Makefile
218
sed "s%INCLUDEDIRS =%INCLUDEDIRS = -I${DIR_TO_INSTALL}/tools/include%" Makefile > TMPFILE && mv TMPFILE Makefile
219 79 rfajardo
sed "s%LIBS =%LIBS = -L${DIR_TO_INSTALL}/tools/lib -Wl,-R${DIR_TO_INSTALL}/tools/lib%" Makefile > TMPFILE && mv TMPFILE Makefile
220 76 rfajardo
 
221 81 rfajardo
#properly installing Advanced JTAG Bridge
222
execcmd "Compiling Advanced JTAG Bridge" "make"
223
execcmd "make install"
224 76 rfajardo
 
225
 
226 81 rfajardo
#Installing Icarus Verilog
227
execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
228 76 rfajardo
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
229 81 rfajardo
execcmd "Compiling Icarus Verilog" "make"
230 76 rfajardo
execcmd "make install"
231
 
232
 
233 81 rfajardo
#Configuring MinSoC
234
cecho "\nConfiguring MinSoC"
235
execcmd "cd ${DIR_TO_INSTALL}/minsoc/backend/std"
236
execcmd "Configuring MinSoC as standard board (simulatable but not synthesizable)" "./configure"
237
execcmd "cd ${DIR_TO_INSTALL}"
238
 
239
 
240 76 rfajardo
#Configuring Advanced Debug System to work with MinSoC
241 81 rfajardo
cecho "\nConfiguring Advanced Debug System to work with MinSoC"
242 76 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Hardware/adv_dbg_if/rtl/verilog"
243
sed "s%\`define DBG_JSP_SUPPORTED%//\`define DBG_JSP_SUPPORTED%" adbg_defines.v > TMPFILE && mv TMPFILE adbg_defines.v
244
 
245 81 rfajardo
#Compiling and moving adv_jtag_bridge debug modules for simulation
246 76 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge/sim_lib/icarus"
247
execcmd "make"
248
execcmd "cp jp-io-vpi.vpi ${DIR_TO_INSTALL}/minsoc/bench/verilog/vpi"
249
 
250
 
251 81 rfajardo
#Precompiling firmwares
252
cecho "\nPrecompiling delivered firmwares";
253
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/utils"
254
execcmd "Make utils" "make"
255
 
256
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/support"
257
execcmd "Make support tools" "make"
258
 
259
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/drivers"
260
execcmd "Make drivers" "make"
261
 
262
execcmd "cd ${DIR_TO_INSTALL}/minsoc/sw/uart"
263
execcmd "Make UART" "make"
264
 
265
 
266
#Setting-up new variables
267
cecho "\nSystem configurations"
268 76 rfajardo
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
269
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
270 81 rfajardo
 
271
cecho "\nInstallation Complete!"
272 76 rfajardo
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
273 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.