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

Subversion Repositories minsoc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 76 rfajardo
#!/bin/bash
2 141 rfajardo
# Author: Constantinos Xanthopoulos & Raul Fajardo
3 76 rfajardo
# This script install MinSOC tree
4
# under a specific directory.
5
 
6
# ===== CONFIGURATIONS =====
7
# ==========================
8 141 rfajardo
MINSOC_SVN_URL=http://opencores.org/ocsvn/minsoc/minsoc/trunk
9
export SCRIPT_DIR="$( cd -P "$( dirname "$0" )" && pwd )"
10
export DIR_TO_INSTALL=`pwd`
11 76 rfajardo
 
12
# Debug ?
13
export DEBUG=0;
14 141 rfajardo
. ${SCRIPT_DIR}/beautify.sh
15 76 rfajardo
 
16
function testtool
17
{
18
    #    is_missing=`which $1 2>&1 | grep no`
19
    is_missing=`whereis -b $1 2>&1 | grep :$`
20
    if [ -z "$is_missing" ]
21
    then
22
        cecho "$1 is installed, pass"
23
    else
24
        errormsg "$1 is not installed, install it and re-run this installation script."
25
    fi
26
}
27
 
28 106 rfajardo
 
29
#Setting environment
30
ENV=`uname -o`
31
if [ "$ENV" != "GNU/Linux" ] && [ "$ENV" != "Cygwin" ]
32
then
33
    errormsg "Environment $ENV not supported by this script."
34
fi
35
cecho "Building tools for ${ENV} system"
36
 
37
is_arch64=`uname -m | grep 64`
38
if [ -z $is_arch64 ]
39
then
40
    KERNEL_ARCH="32"
41
else
42
    KERNEL_ARCH="64"
43
fi
44
 
45
 
46 76 rfajardo
# User check!
47
if [ `whoami` = "root" ];
48
then
49
    errormsg "You shouldn't be root for this script to run.";
50
fi;
51
 
52
 
53
# Testing necessary tools
54
cecho "Testing if necessary tools are installed, program "whereis" is required."
55
testtool wget
56
testtool svn
57 83 rfajardo
testtool bzip2
58 76 rfajardo
testtool tar
59
testtool sed
60
testtool patch
61
testtool gcc
62
testtool make
63 135 rfajardo
testtool makeinfo
64 76 rfajardo
testtool libncurses
65 77 rfajardo
testtool flex
66
testtool bison
67 149 rfajardo
testtool libz
68 76 rfajardo
if [ "$ENV" == "Cygwin" ]
69
then
70
    testtool ioperm
71
    testtool libusb
72
fi
73
 
74
 
75 81 rfajardo
# Wizard
76
if [ -z "${ALTDIR}" ]
77 76 rfajardo
then
78 81 rfajardo
    cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
79
    read ALTDIR;
80
    if [ ! -z "${ALTDIR}" ]
81
    then
82
        DIR_TO_INSTALL=${ALTDIR}
83
    fi
84
    cecho "${DIR_TO_INSTALL} selected";
85 76 rfajardo
fi
86
 
87 81 rfajardo
if [ ! -d ${DIR_TO_INSTALL} ]
88 76 rfajardo
then
89 141 rfajardo
     cecho "Directory ${DIR_TO_INSTALL} doesn't exist."
90
     execcmd "Creating directory ${DIR_TO_INSTALL}" "mkdir -p ${DIR_TO_INSTALL}"
91
     if [ $? -ne 0 ]
92
     then
93
          errormsg "Connot create ${DIR_TO_INSTALL}";
94
     fi
95 81 rfajardo
fi;
96 76 rfajardo
 
97
 
98 81 rfajardo
#Creating directory structure
99
cecho "\nCreating directory structure"
100
cd ${DIR_TO_INSTALL}
101
execcmd "Creating directory ./download for downloaded packages" "mkdir -p download"
102
execcmd "Creating directory ./tools for package binaries" "mkdir -p tools"
103
 
104
 
105
#Downloading everything we need
106
cecho "\nDownloading packages"
107
cd ${DIR_TO_INSTALL}
108
cecho "Download MinSoC"
109 141 rfajardo
svn co -q ${MINSOC_SVN_URL} minsoc      #user need to input password, execcmd omits command output and should be this way
110 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download"
111 76 rfajardo
if [ "$ENV" == "Cygwin" ]
112
then
113 81 rfajardo
    execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-cygwin-1.7.tar.bz2";
114 76 rfajardo
else
115
    if [ $KERNEL_ARCH == "32" ];
116
    then
117 81 rfajardo
        execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86.tar.bz2";
118 76 rfajardo
    elif [ $KERNEL_ARCH == "64" ];
119
    then
120 81 rfajardo
        execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86_64.tar.bz2";
121 76 rfajardo
    fi
122
fi
123 102 rfajardo
execcmd "Downloading GDB" "wget ftp://anonymous:anonymous@ftp.gnu.org/gnu/gdb/gdb-6.8a.tar.bz2"
124 81 rfajardo
execcmd "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-gdb-6.8-patch-2.4.bz2"
125
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"
126
if [ "$ENV" != "Cygwin" ]
127
then
128
    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"
129
fi
130
execcmd "Downloading libftdi for Advanced Debug System" "wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.19.tar.gz"
131
execcmd "Downloading Icarus Verilog" "wget ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.4.tar.gz"
132 76 rfajardo
 
133
 
134 81 rfajardo
#Uncompressing everything
135
cecho "\nUncompressing packages"
136
if [ "$ENV" == "Cygwin" ]
137
then
138
    execcmd "tar xf or32-elf-cygwin-1.7.tar.bz2";
139
else
140
    if [ $KERNEL_ARCH == "32" ];
141
    then
142
        execcmd "tar xf or32-elf-linux-x86.tar.bz2";
143
    elif [ $KERNEL_ARCH == "64" ];
144
    then
145
        execcmd "tar xf or32-elf-linux-x86_64.tar.bz2";
146
    fi
147
fi
148 103 rfajardo
execcmd "tar -jxf gdb-6.8a.tar.bz2"
149 81 rfajardo
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
150
if [ "$ENV" != "Cygwin" ]
151
then
152
    execcmd "tar zxf libusb-0.1.12.tar.gz"
153
fi
154
execcmd "tar zxf libftdi-0.19.tar.gz"
155
execcmd "tar zxf verilog-0.9.4.tar.gz"
156 76 rfajardo
 
157
 
158 81 rfajardo
#Compiling and Installing all packages
159
cecho "\nCompiling and installing packages"
160
# Installing the GNU Toolchain
161 82 rfajardo
if [ "$ENV" == "Cygwin" ]
162
then
163
    execcmd "Installing GNU Toolchain" "tar xf or32-elf-cygwin-1.7.tar.bz2 -C $DIR_TO_INSTALL/tools";
164
else
165
    if [ $KERNEL_ARCH == "32" ];
166
    then
167
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86.tar.bz2 -C $DIR_TO_INSTALL/tools";
168
    elif [ $KERNEL_ARCH == "64" ];
169
    then
170
        execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86_64.tar.bz2 -C $DIR_TO_INSTALL/tools";
171
    fi
172
fi
173 81 rfajardo
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
174 76 rfajardo
 
175
 
176 81 rfajardo
#Installing GDB
177
execcmd "cd gdb-6.8"
178
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
179
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
180 76 rfajardo
 
181 81 rfajardo
execcmd "mkdir -p build"
182
execcmd "cd build"
183
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
184
execcmd "Compiling GDB" "make"
185 141 rfajardo
make install 1>>${SCRIPT_DIR}/progress.log 2>>${SCRIPT_DIR}/error.log   #avoid Fedora failing due to missing Makeinfo
186 81 rfajardo
PATH=$PATH:${DIR_TO_INSTALL}/tools/bin
187 76 rfajardo
 
188
 
189 81 rfajardo
#Installing Advanced JTAG Bridge support libraries
190 76 rfajardo
if [ "$ENV" != "Cygwin" ]
191
then
192 81 rfajardo
    execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
193 76 rfajardo
    execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
194 81 rfajardo
    execcmd "Installing libusb-0.1" "make"
195 76 rfajardo
    execcmd "make install"
196
fi
197
 
198 81 rfajardo
execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
199 166 rfajardo
execcmd "PATH=$PATH:${DIR_TO_INSTALL}/tools/bin ./configure --prefix=${DIR_TO_INSTALL}/tools CPPFLAGS=-I${DIR_TO_INSTALL}/tools/include"
200 81 rfajardo
execcmd "Compiling libftdi" "make"
201 76 rfajardo
execcmd "make install"
202
 
203
 
204 81 rfajardo
#Installing Advanced JTAG Bridge
205
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
206 154 nyawn
execcmd "./autogen.sh"
207 166 rfajardo
execcmd "./configure --enable-jsp-server=yes --prefix=${DIR_TO_INSTALL}/tools CFLAGS=-I${DIR_TO_INSTALL}/tools/include LIBS=-L${DIR_TO_INSTALL}/tools/lib LDFLAGS=-Wl,-R${DIR_TO_INSTALL}/tools/lib"
208 81 rfajardo
execcmd "Compiling Advanced JTAG Bridge" "make"
209
execcmd "make install"
210 76 rfajardo
 
211
 
212 81 rfajardo
#Installing Icarus Verilog
213
execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
214 76 rfajardo
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
215 81 rfajardo
execcmd "Compiling Icarus Verilog" "make"
216 76 rfajardo
execcmd "make install"
217
 
218
 
219 141 rfajardo
#Configuring MinSoC, Advanced Debug System and patching OpenRISC
220
bash ${SCRIPT_DIR}/configure.sh
221 81 rfajardo
 
222
 
223
#Setting-up new variables
224
cecho "\nSystem configurations"
225 76 rfajardo
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
226
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
227 81 rfajardo
 
228
cecho "\nInstallation Complete!"
229 76 rfajardo
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
230 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.