#!/bin/bash
|
#!/bin/bash
|
# Author: Constantinos Xanthopoulos & Raul Fajardo
|
# Author: Constantinos Xanthopoulos & Raul Fajardo
|
# This script install MinSOC tree
|
# This script install MinSOC tree
|
# under a specific directory.
|
# under a specific directory.
|
|
|
# ===== CONFIGURATIONS =====
|
# ===== CONFIGURATIONS =====
|
# ==========================
|
# ==========================
|
MINSOC_SVN_URL=http://opencores.org/ocsvn/minsoc/minsoc/trunk
|
MINSOC_SVN_URL=http://opencores.org/ocsvn/minsoc/minsoc/trunk
|
export SCRIPT_DIR="$( cd -P "$( dirname "$0" )" && pwd )"
|
export SCRIPT_DIR="$( cd -P "$( dirname "$0" )" && pwd )"
|
export DIR_TO_INSTALL=`pwd`
|
export DIR_TO_INSTALL=`pwd`
|
|
|
# Debug ?
|
# Debug ?
|
export DEBUG=0;
|
export DEBUG=0;
|
. ${SCRIPT_DIR}/beautify.sh
|
. ${SCRIPT_DIR}/beautify.sh
|
|
|
function testtool
|
function testtool
|
{
|
{
|
# is_missing=`which $1 2>&1 | grep no`
|
# is_missing=`which $1 2>&1 | grep no`
|
is_missing=`whereis -b $1 2>&1 | grep :$`
|
is_missing=`whereis -b $1 2>&1 | grep :$`
|
if [ -z "$is_missing" ]
|
if [ -z "$is_missing" ]
|
then
|
then
|
cecho "$1 is installed, pass"
|
cecho "$1 is installed, pass"
|
else
|
else
|
errormsg "$1 is not installed, install it and re-run this installation script."
|
errormsg "$1 is not installed, install it and re-run this installation script."
|
fi
|
fi
|
}
|
}
|
|
|
|
|
#Setting environment
|
#Setting environment
|
ENV=`uname -o`
|
ENV=`uname -o`
|
if [ "$ENV" != "GNU/Linux" ] && [ "$ENV" != "Cygwin" ]
|
if [ "$ENV" != "GNU/Linux" ] && [ "$ENV" != "Cygwin" ]
|
then
|
then
|
errormsg "Environment $ENV not supported by this script."
|
errormsg "Environment $ENV not supported by this script."
|
fi
|
fi
|
cecho "Building tools for ${ENV} system"
|
cecho "Building tools for ${ENV} system"
|
|
|
is_arch64=`uname -m | grep 64`
|
is_arch64=`uname -m | grep 64`
|
if [ -z $is_arch64 ]
|
if [ -z $is_arch64 ]
|
then
|
then
|
KERNEL_ARCH="32"
|
KERNEL_ARCH="32"
|
else
|
else
|
KERNEL_ARCH="64"
|
KERNEL_ARCH="64"
|
fi
|
fi
|
|
|
|
|
# User check!
|
# User check!
|
if [ `whoami` = "root" ];
|
if [ `whoami` = "root" ];
|
then
|
then
|
errormsg "You shouldn't be root for this script to run.";
|
errormsg "You shouldn't be root for this script to run.";
|
fi;
|
fi;
|
|
|
|
|
# Testing necessary tools
|
# Testing necessary tools
|
cecho "Testing if necessary tools are installed, program "whereis" is required."
|
cecho "Testing if necessary tools are installed, program "whereis" is required."
|
testtool wget
|
testtool wget
|
testtool svn
|
testtool svn
|
testtool bzip2
|
testtool bzip2
|
testtool tar
|
testtool tar
|
testtool sed
|
testtool sed
|
testtool patch
|
testtool patch
|
testtool gcc
|
testtool gcc
|
testtool make
|
testtool make
|
testtool makeinfo
|
testtool makeinfo
|
testtool libncurses
|
testtool libncurses
|
testtool flex
|
testtool flex
|
testtool bison
|
testtool bison
|
testtool libz
|
testtool libz
|
if [ "$ENV" == "Cygwin" ]
|
if [ "$ENV" == "Cygwin" ]
|
then
|
then
|
testtool ioperm
|
testtool ioperm
|
testtool libusb
|
testtool libusb
|
fi
|
fi
|
|
|
|
|
# Wizard
|
# Wizard
|
if [ -z "${ALTDIR}" ]
|
if [ -z "${ALTDIR}" ]
|
then
|
then
|
cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
|
cnecho "Give full path (ex. /home/foo/) for installation directory or leave empty for "${DIR_TO_INSTALL}": ";
|
read ALTDIR;
|
read ALTDIR;
|
if [ ! -z "${ALTDIR}" ]
|
if [ ! -z "${ALTDIR}" ]
|
then
|
then
|
DIR_TO_INSTALL=${ALTDIR}
|
DIR_TO_INSTALL=${ALTDIR}
|
fi
|
fi
|
cecho "${DIR_TO_INSTALL} selected";
|
cecho "${DIR_TO_INSTALL} selected";
|
fi
|
fi
|
|
|
if [ ! -d ${DIR_TO_INSTALL} ]
|
if [ ! -d ${DIR_TO_INSTALL} ]
|
then
|
then
|
cecho "Directory ${DIR_TO_INSTALL} doesn't exist."
|
cecho "Directory ${DIR_TO_INSTALL} doesn't exist."
|
execcmd "Creating directory ${DIR_TO_INSTALL}" "mkdir -p ${DIR_TO_INSTALL}"
|
execcmd "Creating directory ${DIR_TO_INSTALL}" "mkdir -p ${DIR_TO_INSTALL}"
|
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
then
|
then
|
errormsg "Connot create ${DIR_TO_INSTALL}";
|
errormsg "Connot create ${DIR_TO_INSTALL}";
|
fi
|
fi
|
fi;
|
fi;
|
|
|
|
|
#Creating directory structure
|
#Creating directory structure
|
cecho "\nCreating directory structure"
|
cecho "\nCreating directory structure"
|
cd ${DIR_TO_INSTALL}
|
cd ${DIR_TO_INSTALL}
|
execcmd "Creating directory ./download for downloaded packages" "mkdir -p download"
|
execcmd "Creating directory ./download for downloaded packages" "mkdir -p download"
|
execcmd "Creating directory ./tools for package binaries" "mkdir -p tools"
|
execcmd "Creating directory ./tools for package binaries" "mkdir -p tools"
|
|
|
|
|
#Downloading everything we need
|
#Downloading everything we need
|
cecho "\nDownloading packages"
|
cecho "\nDownloading packages"
|
cd ${DIR_TO_INSTALL}
|
cd ${DIR_TO_INSTALL}
|
cecho "Download MinSoC"
|
cecho "Download MinSoC"
|
svn co -q ${MINSOC_SVN_URL} minsoc #user need to input password, execcmd omits command output and should be this way
|
svn co -q ${MINSOC_SVN_URL} minsoc #user need to input password, execcmd omits command output and should be this way
|
execcmd "cd ${DIR_TO_INSTALL}/download"
|
execcmd "cd ${DIR_TO_INSTALL}/download"
|
if [ "$ENV" == "Cygwin" ]
|
if [ "$ENV" == "Cygwin" ]
|
then
|
then
|
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-cygwin-1.7.tar.bz2";
|
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-cygwin-1.7.tar.bz2";
|
else
|
else
|
if [ $KERNEL_ARCH == "32" ];
|
if [ $KERNEL_ARCH == "32" ];
|
then
|
then
|
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86.tar.bz2";
|
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86.tar.bz2";
|
elif [ $KERNEL_ARCH == "64" ];
|
elif [ $KERNEL_ARCH == "64" ];
|
then
|
then
|
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86_64.tar.bz2";
|
execcmd "Downloading GNU Toolchain" "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-elf-linux-x86_64.tar.bz2";
|
fi
|
fi
|
fi
|
fi
|
execcmd "Downloading GDB" "wget ftp://anonymous:anonymous@ftp.gnu.org/gnu/gdb/gdb-6.8a.tar.bz2"
|
execcmd "Downloading GDB" "wget ftp://anonymous:anonymous@ftp.gnu.org/gnu/gdb/gdb-6.8a.tar.bz2"
|
execcmd "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-gdb-6.8-patch-2.4.bz2"
|
execcmd "wget ftp://ocuser:ocuser@openrisc.opencores.org/toolchain/or32-gdb-6.8-patch-2.4.bz2"
|
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"
|
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"
|
if [ "$ENV" != "Cygwin" ]
|
if [ "$ENV" != "Cygwin" ]
|
then
|
then
|
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"
|
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"
|
fi
|
fi
|
execcmd "Downloading libftdi for Advanced Debug System" "wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.19.tar.gz"
|
execcmd "Downloading libftdi for Advanced Debug System" "wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.19.tar.gz"
|
execcmd "Downloading Icarus Verilog" "wget ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.4.tar.gz"
|
execcmd "Downloading Icarus Verilog" "wget ftp://icarus.com/pub/eda/verilog/v0.9/verilog-0.9.4.tar.gz"
|
|
|
|
|
#Uncompressing everything
|
#Uncompressing everything
|
cecho "\nUncompressing packages"
|
cecho "\nUncompressing packages"
|
if [ "$ENV" == "Cygwin" ]
|
if [ "$ENV" == "Cygwin" ]
|
then
|
then
|
execcmd "tar xf or32-elf-cygwin-1.7.tar.bz2";
|
execcmd "tar xf or32-elf-cygwin-1.7.tar.bz2";
|
else
|
else
|
if [ $KERNEL_ARCH == "32" ];
|
if [ $KERNEL_ARCH == "32" ];
|
then
|
then
|
execcmd "tar xf or32-elf-linux-x86.tar.bz2";
|
execcmd "tar xf or32-elf-linux-x86.tar.bz2";
|
elif [ $KERNEL_ARCH == "64" ];
|
elif [ $KERNEL_ARCH == "64" ];
|
then
|
then
|
execcmd "tar xf or32-elf-linux-x86_64.tar.bz2";
|
execcmd "tar xf or32-elf-linux-x86_64.tar.bz2";
|
fi
|
fi
|
fi
|
fi
|
execcmd "tar -jxf gdb-6.8a.tar.bz2"
|
execcmd "tar -jxf gdb-6.8a.tar.bz2"
|
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
|
execcmd "bzip2 -d or32-gdb-6.8-patch-2.4.bz2"
|
if [ "$ENV" != "Cygwin" ]
|
if [ "$ENV" != "Cygwin" ]
|
then
|
then
|
execcmd "tar zxf libusb-0.1.12.tar.gz"
|
execcmd "tar zxf libusb-0.1.12.tar.gz"
|
fi
|
fi
|
execcmd "tar zxf libftdi-0.19.tar.gz"
|
execcmd "tar zxf libftdi-0.19.tar.gz"
|
execcmd "tar zxf verilog-0.9.4.tar.gz"
|
execcmd "tar zxf verilog-0.9.4.tar.gz"
|
|
|
|
|
#Compiling and Installing all packages
|
#Compiling and Installing all packages
|
cecho "\nCompiling and installing packages"
|
cecho "\nCompiling and installing packages"
|
# Installing the GNU Toolchain
|
# Installing the GNU Toolchain
|
if [ "$ENV" == "Cygwin" ]
|
if [ "$ENV" == "Cygwin" ]
|
then
|
then
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-cygwin-1.7.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-cygwin-1.7.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
else
|
else
|
if [ $KERNEL_ARCH == "32" ];
|
if [ $KERNEL_ARCH == "32" ];
|
then
|
then
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
elif [ $KERNEL_ARCH == "64" ];
|
elif [ $KERNEL_ARCH == "64" ];
|
then
|
then
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86_64.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
execcmd "Installing GNU Toolchain" "tar xf or32-elf-linux-x86_64.tar.bz2 -C $DIR_TO_INSTALL/tools";
|
fi
|
fi
|
fi
|
fi
|
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
|
PATH=$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin
|
|
|
|
|
#Installing GDB
|
#Installing GDB
|
execcmd "cd gdb-6.8"
|
execcmd "cd gdb-6.8"
|
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
|
execcmd "patch -p1 < ../or32-gdb-6.8-patch-2.4"
|
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
|
execcmd "patch -p1 < ../gdb-6.8-bz436037-reg-no-longer-active.patch"
|
|
|
execcmd "mkdir -p build"
|
execcmd "mkdir -p build"
|
execcmd "cd build"
|
execcmd "cd build"
|
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
|
execcmd "../configure --target=or32-elf --disable-werror --prefix=$DIR_TO_INSTALL/tools"
|
execcmd "Compiling GDB" "make"
|
execcmd "Compiling GDB" "make"
|
make install 1>>${SCRIPT_DIR}/progress.log 2>>${SCRIPT_DIR}/error.log #avoid Fedora failing due to missing Makeinfo
|
make install 1>>${SCRIPT_DIR}/progress.log 2>>${SCRIPT_DIR}/error.log #avoid Fedora failing due to missing Makeinfo
|
PATH=$PATH:${DIR_TO_INSTALL}/tools/bin
|
PATH=$PATH:${DIR_TO_INSTALL}/tools/bin
|
|
|
|
|
#Installing Advanced JTAG Bridge support libraries
|
#Installing Advanced JTAG Bridge support libraries
|
if [ "$ENV" != "Cygwin" ]
|
if [ "$ENV" != "Cygwin" ]
|
then
|
then
|
execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
|
execcmd "cd ${DIR_TO_INSTALL}/download/libusb-0.1.12"
|
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
execcmd "Installing libusb-0.1" "make"
|
execcmd "Installing libusb-0.1" "make"
|
execcmd "make install"
|
execcmd "make install"
|
fi
|
fi
|
|
|
execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
|
execcmd "cd ${DIR_TO_INSTALL}/download/libftdi-0.19"
|
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
execcmd "Compiling libftdi" "make"
|
execcmd "Compiling libftdi" "make"
|
execcmd "make install"
|
execcmd "make install"
|
|
|
|
|
#Installing Advanced JTAG Bridge
|
#Installing Advanced JTAG Bridge
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
|
execcmd "cd ${DIR_TO_INSTALL}/minsoc/rtl/verilog/adv_debug_sys/Software/adv_jtag_bridge"
|
execcmd "./autogen.sh"
|
execcmd "./autogen.sh"
|
execcmd "./configure --enable-jsp-server=yes --prefix=${DIR_TO_INSTALL}/tools CPPFLAGS=-I${DIR_TO_INSTALL}=tools/include LDFLAGS=-L${DIR_TO_INSTALL}/tools/lib LDFLAGS=-Wl,-R${DIR_TO_INSTALL}/tools/lib"
|
execcmd "./configure --enable-jsp-server=yes --prefix=${DIR_TO_INSTALL}/tools CPPFLAGS=-I${DIR_TO_INSTALL}/tools/include LDFLAGS=-L${DIR_TO_INSTALL}/tools/lib LDFLAGS=-Wl,-R${DIR_TO_INSTALL}/tools/lib"
|
execcmd "Compiling Advanced JTAG Bridge" "make"
|
execcmd "Compiling Advanced JTAG Bridge" "make"
|
execcmd "make install"
|
execcmd "make install"
|
|
|
|
|
#Installing Icarus Verilog
|
#Installing Icarus Verilog
|
execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
|
execcmd "cd ${DIR_TO_INSTALL}/download/verilog-0.9.4"
|
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
execcmd "./configure --prefix=${DIR_TO_INSTALL}/tools"
|
execcmd "Compiling Icarus Verilog" "make"
|
execcmd "Compiling Icarus Verilog" "make"
|
execcmd "make install"
|
execcmd "make install"
|
|
|
|
|
#Configuring MinSoC, Advanced Debug System and patching OpenRISC
|
#Configuring MinSoC, Advanced Debug System and patching OpenRISC
|
bash ${SCRIPT_DIR}/configure.sh
|
bash ${SCRIPT_DIR}/configure.sh
|
|
|
|
|
#Setting-up new variables
|
#Setting-up new variables
|
cecho "\nSystem configurations"
|
cecho "\nSystem configurations"
|
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
|
execcmd "Adding MinSoC tools to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/bin\" >> /home/$(whoami)/.bashrc;";
|
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
|
execcmd "Adding OpenRISC toolchain to PATH" "echo \"PATH=\\\$PATH:$DIR_TO_INSTALL/tools/or32-elf/bin/\" >> /home/$(whoami)/.bashrc;";
|
|
|
cecho "\nInstallation Complete!"
|
cecho "\nInstallation Complete!"
|
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
|
cecho "Before using the system, load the new environment variables doing this: source /home/$(whoami)/.bashrc"
|
cecho "You may remove the ${DIR_TO_INSTALL}/download directory if you wish."
|
cecho "You may remove the ${DIR_TO_INSTALL}/download directory if you wish."
|
|
|