URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [web_uploads/] [vmware_image/] [MOF_ORSOC_TCHN_v3b.sh] - Rev 1767
Compare with Previous | Blame | View Log
#!/bin/bash # Copyright (C) 2008, www.meansoffreedom.org, www.orsoc.se # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ##Date: 04/28/2008 ##Title: MOF_ORSOC_TCN_1.sh ##Purpose: Complete Toolchain Builder from MOF & ORSoC. ##initial rgd ##Beginning globals HOST="195.67.9.12" LUSER="ocuser" PASSWD="oc" START_DIR=`pwd` DN="n" FTP_DIR="toolchain" DIR="empty" ##Versions BINUTILS_VER=binutils-2.18.50 GCC_VER=gcc-4.2.2 UCLIC_VER=uClibc-0.9.29 LINUX_VER=linux-2.6.19 BUSY_VER=busybox-1.7.5 SIM_VER=or1ksim-0.2.0rc2 ##Patches PATCH1="$BINUTILS_VER.or32_fixed_patch.bz2" PATCH2=$GCC_VER.or32patch.bz2 PATCH3="linux_2.6.19_or32_unified_simtested.bz2" PATCH4="uClibc-0.9.29_test_patch" ##Configs CONFIG1="rgd_uc_29dotconfig" CONFIG2="rgd_bb_1.75dotconfig" ##Tarballs ZBALL1=$BINUTILS_VER.tar.bz2 TBALL1=$BINUTILS_VER.tar ZBALL2=$GCC_VER.tar.bz2 TBALL2=$GCC_VER.tar ZBALL3=$UCLIC_VER.tar.bz2 TBALL3=$UCLIC_VER.tar ZBALL4=$LINUX_VER.tar.bz2 TBALL4=$LINUX_VER.tar ZBALL5=$BUSY_VER.tar.bz2 TBALL5=$BUSY_VER.tar ZBALL6="or1ksim-0.2.0rc2.tar.bz2" TBALL6="or1ksim-0.2.0rc2.tar" ZBALL7="initrd-fb-03.ext2.last.work.1.7.5.bz2" ##Welcome message echo echo "Hello & Welcome to the ORSoC & MOF toolchain builder" echo echo "############################README#############################" echo echo "To use this script you have to answer 2 easy y/n questions." echo "There is a third question after everything is built." echo echo "The first question asks if you need to download all the code." echo "The second checks the download area and permits change if req." echo "Typically the answers to all the questions are y,y ." echo echo "The third question asks if you want to run the freshly" echo "built linux image built with the new toolchain as a nice test" echo "in the or1k simulator that is build with this package." echo echo "Finally note that it is best to run this script in a clean dir" echo "as root.If you can't run as root things will work fine, but" echo "the simulator run of the linux image will use a default" echo "ramdisk with a prebuilt busybox rather than the fresh" echo "one built by this program. Enjoy" echo echo "############################README#############################" echo ## You need to install these packages in order to be able to create ## the toolchain. You can use the commands below if you use a ## matching Linux distribution, for example Ubuntu. #apt-get update #apt-get -y install build-essential #apt-get -y install gcc #apt-get -y install g++ #apt-get -y install flex #apt-get -y install bison #apt-get -y install patch #apt-get -y install texinfo #apt-get -y install libncurses-dev ##Find out what user wants to do echo "Get sources & patches select['y'] else you have them select['n'](y/n)" read YN ##Case control VAL=$(echo $YN | tr [:upper:] [:lower:]) echo ##Get user input if [ $VAL = "y" ];then CDIR=pwd echo "This is the current working directory: `$CDIR`" echo echo "[`$CDIR`] for install select ['y'] else select ['n'] alternate:(y/n)" read YN VAL=$(echo $YN | tr [:upper:] [:lower:]) if [ $VAL = "y" ];then DIR=`pwd` else ##Allow user to change path echo "Please Enter complete path to directory you prefer:" read DIR until [ $DN = "y" ];do echo "Is this correct [$DIR]:(y/n)" read DN VAL=$(echo $DN | tr [:upper:] [:lower:]) if [ $DN = "n" ];then echo "Please Enter the correct path again:" read DIR fi done cd $DIR echo "loop done" pwd fi ##second $VAL = "y" mkdir $DIR/download chmod 777 $DIR/download ##Time to ftp it all ##FTP kludge cd $DIR/download echo "Downloading files, it may take a while!" echo echo wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH1 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH2 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH3 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH4 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$CONFIG1 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$CONFIG2 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL1 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL2 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL3 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL4 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL5 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL6 wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL7 fi if [ $DIR = "empty" ];then DIR=$START_DIR fi cd $DIR #Always start with a clean build dir rm -fr $DIR/build mkdir $DIR/build chmod 777 $DIR/build cp $DIR/download/*.bz2 $DIR/build cp $DIR/download/$PATCH1 $DIR/build cp $DIR/download/$PATCH2 $DIR/build cp $DIR/download/$PATCH3 $DIR/build cp $DIR/download/$PATCH4 $DIR/build echo echo "Unbundling the tarballs" echo echo BUILD_TOP=$DIR/build export BUILD_TOP cd $BUILD_TOP cp $DIR/download/$CONFIG1 $BUILD_TOP cp $DIR/download/$CONFIG2 $BUILD_TOP chmod 777 * bunzip2 $BUILD_TOP/$ZBALL1 tar -xvf $BUILD_TOP/$TBALL1 bunzip2 $BUILD_TOP/$ZBALL2 tar -xvf $BUILD_TOP/$TBALL2 bunzip2 $BUILD_TOP/$ZBALL3 tar -xvf $BUILD_TOP/$TBALL3 bunzip2 $BUILD_TOP/$ZBALL4 tar -xvf $BUILD_TOP/$TBALL4 bunzip2 $BUILD_TOP/$ZBALL5 tar -xvf $BUILD_TOP/$TBALL5 bunzip2 $BUILD_TOP/$ZBALL6 tar -xvf $BUILD_TOP/$TBALL6 bunzip2 $BUILD_TOP/$ZBALL7 echo "Done with zips and tars" ##create working directories and delete turds rm -fr $BUILD_TOP/tools rm -fr $BUILD_TOP/b-gcc rm -fr $BUILD_TOP/b-b mkdir $BUILD_TOP/tools mkdir $BUILD_TOP/b-gcc mkdir $BUILD_TOP/b-b ##########################Building Binutils####################### cd $BUILD_TOP echo "Patching and building Binutils" cd $BINUTILS_VER bzip2 -dc ../$PATCH1 |patch -p1 cd .. cd $BUILD_TOP/b-b $BUILD_TOP/$BINUTILS_VER/configure --target=or32-uclinux --prefix=$BUILD_TOP/tools/or32-uclinux --disable-checking make all install export PATH=$BUILD_TOP/tools/or32-uclinux/bin:$PATH cd $BUILD_TOP ##########################Building GCC############################ echo "Patching and building GCC & Linux" cd $BUILD_TOP cd $LINUX_VER bzip2 -dc ../linux_2.6.19_or32_unified_simtested.bz2 |patch -p1 cp rgd_dot_config .config make oldconfig cd $BUILD_TOP mkdir $BUILD_TOP/tools/or32-uclinux/include mkdir $BUILD_TOP/tools/or32-uclinux/include/asm mkdir $BUILD_TOP/tools/or32-uclinux/include/linux cp -f -dR linux-2.6.19/include/linux/* $BUILD_TOP/tools/or32-uclinux/include/linux cp -f -dR linux-2.6.19/include/asm-or32/* $BUILD_TOP/tools/or32-uclinux/include/asm cd $BUILD_TOP/tools/or32-uclinux ln -s include sys-include cd $BUILD_TOP cd $GCC_VER bzip2 -dc ../gcc-4.2.2.or32patch.bz2 |patch -p1 cd $BUILD_TOP cd b-gcc $BUILD_TOP/gcc-4.2.2/configure --target=or32-uclinux --prefix=$BUILD_TOP/tools/or32-uclinux --with-local-prefix=$BUILD_TOP/tools/or32-uclinux/or32-uclinux --with-gnu-as --with-gnu-ld --disable-libssp --enable-languages=c make all install cd $BUILD_TOP cd $LINUX_VER make vmlinux ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux- ##########################Building uClibc######################### echo "Patching and building uClibc" cd $BUILD_TOP cd $UCLIC_VER bzip2 -dc ../$PATCH4 |patch -p1 export CC=or32-uclinux-gcc export BUILD_TOP cp $BUILD_TOP/$CONFIG1 $BUILD_TOP/$UCLIC_VER/.config cp $BUILD_TOP/$CONFIG1 $BUILD_TOP/$UCLIC_VER/.config.old make oldconfig ln -s extra/Configs/Config.or32 Config make all install unset CC ##########################re-Building GCC######################## echo "Patching and re-building GCC" cd $BUILD_TOP cd b-gcc $BUILD_TOP/gcc-4.2.2/configure --target=or32-uclinux --prefix=$BUILD_TOP/tools/or32-uclinux --with-local-prefix=$BUILD_TOP/tools/or32-uclinux/or32-uclinux --with-gnu-as --with-gnu-ld --disable-libssp --enable-languages=c make all install cd $BUILD_TOP/tools/or32-uclinux/or32-uclinux ln -s ../include sys-include cd lib cp -f -dR ../../lib/* . cd $BUILD_TOP echo "Build of the toolchain is complete" ##########################Building Busybox######################## echo "Building $BUSY_VER" cd $BUSY_VER cp $BUILD_TOP/$CONFIG2 $BUILD_TOP/$BUSY_VER/.config cp $BUILD_TOP/$CONFIG2 $BUILD_TOP/$BUSY_VER/.config.old make oldconfig make ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux- make install ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux- cd $BUILD_TOP RT=`whoami` if [ $RT = "root" ];then mkdir seeit chmod 777 seeit mount -t ext2 -o loop initrd-fb-03.ext2.last.work.1.7.5 seeit cp -f -dR $BUILD_TOP/busy_out.1.7.5/* $BUILD_TOP/seeit umount seeit cp -f initrd-fb-03.ext2.last.work.1.7.5 $LINUX_VER/arch/or32/support/initrd-fb-03.ext2 else echo "Using default ramdisk since the User is not root" echo "Note that this program built busybox but did not" echo "install it on the ramdisk. Defaults are used." cp -f initrd-fb-03.ext2.last.work.1.7.5 $LINUX_VER/arch/or32/support/initrd-fb-03.ext2 fi cd $BUILD_TOP ##########################Final Linux kernel build################ echo "Final Linux Kernel build" cd $BUILD_TOP cd $LINUX_VER make vmlinux ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux- cd $BUILD_TOP ##########################Simulator build######################### echo "Building or1k simulator" cd $BUILD_TOP cd $SIM_VER ./configure --target=or32-uclinux --prefix=$BUILD_TOP/tools/or32-uclinux make all install cd $BUILD_TOP ##########################Code Test############################### cd $BUILD_TOP echo "Run Linux image in the simulator['y'] or not['n'](y/n)" read SI SVAL=$(echo $SI | tr [:upper:] [:lower:]) if [ $SVAL = "y" ];then echo "In another window you should: telnet 127.0.0.1 10084" cd $LINUX_VER $BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux-sim -f sim.cfg vmlinux fi echo "Build is complete" echo "Your tools are installed in: $BUILD_TOP/tools/or32-uclinux/bin" exit ##########################End Script##############################