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

Subversion Repositories or1k

[/] [or1k/] [web_uploads/] [vmware_image/] [MOF_ORSOC_TCHN_v3b.sh] - Blame information for rev 1771

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

Line No. Rev Author Line
1 1767 root
#!/bin/bash
2
 
3
# Copyright (C) 2008, www.meansoffreedom.org, www.orsoc.se
4
# This file is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
# General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 
18
##Date: 04/28/2008
19
##Title: MOF_ORSOC_TCN_1.sh
20
##Purpose: Complete Toolchain Builder from MOF & ORSoC.
21
##initial rgd
22
 
23
##Beginning globals
24
HOST="195.67.9.12"
25
LUSER="ocuser"
26
PASSWD="oc"
27
START_DIR=`pwd`
28
DN="n"
29
FTP_DIR="toolchain"
30
DIR="empty"
31
 
32
##Versions
33
BINUTILS_VER=binutils-2.18.50
34
GCC_VER=gcc-4.2.2
35
UCLIC_VER=uClibc-0.9.29
36
LINUX_VER=linux-2.6.19
37
BUSY_VER=busybox-1.7.5
38
SIM_VER=or1ksim-0.2.0rc2
39
 
40
##Patches
41
PATCH1="$BINUTILS_VER.or32_fixed_patch.bz2"
42
PATCH2=$GCC_VER.or32patch.bz2
43
PATCH3="linux_2.6.19_or32_unified_simtested.bz2"
44
PATCH4="uClibc-0.9.29_test_patch"
45
 
46
##Configs
47
CONFIG1="rgd_uc_29dotconfig"
48
CONFIG2="rgd_bb_1.75dotconfig"
49
 
50
##Tarballs
51
ZBALL1=$BINUTILS_VER.tar.bz2
52
TBALL1=$BINUTILS_VER.tar
53
ZBALL2=$GCC_VER.tar.bz2
54
TBALL2=$GCC_VER.tar
55
ZBALL3=$UCLIC_VER.tar.bz2
56
TBALL3=$UCLIC_VER.tar
57
ZBALL4=$LINUX_VER.tar.bz2
58
TBALL4=$LINUX_VER.tar
59
ZBALL5=$BUSY_VER.tar.bz2
60
TBALL5=$BUSY_VER.tar
61
ZBALL6="or1ksim-0.2.0rc2.tar.bz2"
62
TBALL6="or1ksim-0.2.0rc2.tar"
63
ZBALL7="initrd-fb-03.ext2.last.work.1.7.5.bz2"
64
 
65
##Welcome message
66
echo
67
echo "Hello & Welcome to the ORSoC & MOF toolchain builder"
68
echo
69
echo "############################README#############################"
70
echo
71
echo "To use this script you have to answer 2 easy y/n questions."
72
echo "There is a third question after everything is built."
73
echo
74
echo "The first question asks if you need to download all the code."
75
echo "The second checks the download area and permits change if req."
76
echo "Typically the answers to all the questions are  y,y ."
77
echo
78
echo "The third question asks if you want to run the freshly"
79
echo "built linux image built with the new toolchain as a nice test"
80
echo "in the or1k simulator that is build with this package."
81
echo
82
echo "Finally note that it is best to run this script in a clean dir"
83
echo "as root.If you can't run as root things will work fine, but"
84
echo "the simulator run of the linux image will use a default"
85
echo "ramdisk with a prebuilt busybox rather than the fresh"
86
echo "one built by this program.      Enjoy"
87
echo
88
echo "############################README#############################"
89
echo
90
 
91
 
92
## You need to install these packages in order to be able to create
93
## the toolchain. You can use the commands below if you use a
94
## matching Linux distribution, for example Ubuntu.
95
 
96
 
97
#apt-get update
98
#apt-get -y install build-essential
99
#apt-get -y install gcc
100
#apt-get -y install g++
101
#apt-get -y install flex
102
#apt-get -y install bison
103
#apt-get -y install patch
104
#apt-get -y install texinfo
105
#apt-get -y install libncurses-dev
106
 
107
 
108
##Find out what user wants to do
109
echo "Get sources & patches select['y'] else you have them select['n'](y/n)"
110
read YN
111
 
112
##Case control
113
VAL=$(echo $YN | tr [:upper:] [:lower:])
114
echo
115
 
116
##Get user input
117
if [ $VAL = "y" ];then
118
  CDIR=pwd
119
  echo "This is the current working directory: `$CDIR`"
120
  echo
121
  echo "[`$CDIR`] for install select ['y'] else select ['n'] alternate:(y/n)"
122
  read YN
123
  VAL=$(echo $YN | tr [:upper:] [:lower:])
124
 
125
  if [ $VAL = "y" ];then
126
    DIR=`pwd`
127
  else ##Allow user to change path
128
    echo "Please Enter complete path to directory you prefer:"
129
    read DIR
130
 
131
    until [ $DN = "y" ];do
132
    echo "Is this correct [$DIR]:(y/n)"
133
    read DN
134
    VAL=$(echo $DN | tr [:upper:] [:lower:])
135
    if [ $DN = "n" ];then
136
      echo "Please Enter the correct path again:"
137
      read DIR
138
    fi
139
    done
140
    cd $DIR
141
    echo "loop done"
142
    pwd
143
  fi ##second $VAL = "y"
144
 
145
  mkdir $DIR/download
146
  chmod 777 $DIR/download
147
 
148
  ##Time to ftp it all
149
  ##FTP kludge
150
  cd $DIR/download
151
  echo "Downloading files, it may take a while!"
152
  echo
153
  echo
154
 
155
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH1
156
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH2
157
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH3
158
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$PATCH4
159
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$CONFIG1
160
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$CONFIG2
161
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL1
162
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL2
163
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL3
164
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL4
165
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL5
166
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL6
167
  wget ftp://$LUSER:$PASSWD@$HOST/$FTP_DIR/$ZBALL7
168
fi
169
 
170
 
171
if [ $DIR = "empty" ];then
172
  DIR=$START_DIR
173
fi
174
 
175
cd $DIR
176
 
177
#Always start with a clean build dir
178
rm -fr $DIR/build
179
mkdir $DIR/build
180
chmod 777 $DIR/build
181
cp $DIR/download/*.bz2 $DIR/build
182
cp $DIR/download/$PATCH1 $DIR/build
183
cp $DIR/download/$PATCH2 $DIR/build
184
cp $DIR/download/$PATCH3 $DIR/build
185
cp $DIR/download/$PATCH4 $DIR/build
186
echo
187
echo "Unbundling the tarballs"
188
echo
189
echo
190
 
191
BUILD_TOP=$DIR/build
192
export BUILD_TOP
193
cd $BUILD_TOP
194
cp $DIR/download/$CONFIG1 $BUILD_TOP
195
cp $DIR/download/$CONFIG2 $BUILD_TOP
196
 
197
chmod 777 *
198
bunzip2 $BUILD_TOP/$ZBALL1
199
tar -xvf $BUILD_TOP/$TBALL1
200
bunzip2 $BUILD_TOP/$ZBALL2
201
tar -xvf $BUILD_TOP/$TBALL2
202
bunzip2 $BUILD_TOP/$ZBALL3
203
tar -xvf $BUILD_TOP/$TBALL3
204
bunzip2 $BUILD_TOP/$ZBALL4
205
tar -xvf $BUILD_TOP/$TBALL4
206
bunzip2 $BUILD_TOP/$ZBALL5
207
tar -xvf $BUILD_TOP/$TBALL5
208
bunzip2 $BUILD_TOP/$ZBALL6
209
tar -xvf $BUILD_TOP/$TBALL6
210
bunzip2 $BUILD_TOP/$ZBALL7
211
 
212
echo "Done with zips and tars"
213
##create working directories and delete turds
214
rm -fr $BUILD_TOP/tools
215
rm -fr $BUILD_TOP/b-gcc
216
rm -fr $BUILD_TOP/b-b
217
 
218
mkdir $BUILD_TOP/tools
219
mkdir $BUILD_TOP/b-gcc
220
mkdir $BUILD_TOP/b-b
221
 
222
##########################Building Binutils#######################
223
cd $BUILD_TOP
224
echo "Patching and building Binutils"
225
 
226
cd $BINUTILS_VER
227
bzip2 -dc ../$PATCH1 |patch -p1
228
 
229
cd ..
230
cd $BUILD_TOP/b-b
231
$BUILD_TOP/$BINUTILS_VER/configure --target=or32-uclinux --prefix=$BUILD_TOP/tools/or32-uclinux --disable-checking
232
make all install
233
export PATH=$BUILD_TOP/tools/or32-uclinux/bin:$PATH
234
cd $BUILD_TOP
235
 
236
##########################Building GCC############################
237
echo "Patching and building GCC & Linux"
238
cd $BUILD_TOP
239
cd $LINUX_VER
240
 
241
bzip2 -dc ../linux_2.6.19_or32_unified_simtested.bz2 |patch -p1
242
cp rgd_dot_config .config
243
make oldconfig
244
 
245
cd $BUILD_TOP
246
 
247
mkdir $BUILD_TOP/tools/or32-uclinux/include
248
mkdir $BUILD_TOP/tools/or32-uclinux/include/asm
249
mkdir $BUILD_TOP/tools/or32-uclinux/include/linux
250
 
251
cp -f -dR linux-2.6.19/include/linux/* $BUILD_TOP/tools/or32-uclinux/include/linux
252
cp -f -dR linux-2.6.19/include/asm-or32/* $BUILD_TOP/tools/or32-uclinux/include/asm
253
 
254
cd $BUILD_TOP/tools/or32-uclinux
255
ln -s include sys-include
256
cd $BUILD_TOP
257
cd $GCC_VER
258
bzip2 -dc ../gcc-4.2.2.or32patch.bz2 |patch -p1
259
cd $BUILD_TOP
260
cd b-gcc
261
$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
262
make all install
263
 
264
cd $BUILD_TOP
265
cd $LINUX_VER
266
make vmlinux ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux-
267
 
268
##########################Building uClibc#########################
269
echo "Patching and building uClibc"
270
cd $BUILD_TOP
271
cd $UCLIC_VER
272
 
273
bzip2 -dc ../$PATCH4 |patch -p1
274
export CC=or32-uclinux-gcc
275
export BUILD_TOP
276
cp $BUILD_TOP/$CONFIG1  $BUILD_TOP/$UCLIC_VER/.config
277
cp $BUILD_TOP/$CONFIG1  $BUILD_TOP/$UCLIC_VER/.config.old
278
make oldconfig
279
ln -s extra/Configs/Config.or32 Config
280
make all install
281
 
282
unset CC
283
 
284
##########################re-Building GCC########################
285
echo "Patching and re-building GCC"
286
cd $BUILD_TOP
287
cd b-gcc
288
$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
289
make all install
290
 
291
cd $BUILD_TOP/tools/or32-uclinux/or32-uclinux
292
ln -s ../include sys-include
293
cd lib
294
cp -f -dR ../../lib/* .
295
cd $BUILD_TOP
296
echo "Build of the toolchain is complete"
297
 
298
##########################Building Busybox########################
299
echo "Building $BUSY_VER"
300
cd $BUSY_VER
301
cp $BUILD_TOP/$CONFIG2  $BUILD_TOP/$BUSY_VER/.config
302
cp $BUILD_TOP/$CONFIG2  $BUILD_TOP/$BUSY_VER/.config.old
303
make oldconfig
304
make ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux-
305
make install ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux-
306
cd $BUILD_TOP
307
RT=`whoami`
308
if [ $RT = "root" ];then
309
  mkdir seeit
310
  chmod 777 seeit
311
  mount -t ext2 -o loop initrd-fb-03.ext2.last.work.1.7.5 seeit
312
  cp -f -dR $BUILD_TOP/busy_out.1.7.5/* $BUILD_TOP/seeit
313
  umount seeit
314
  cp -f initrd-fb-03.ext2.last.work.1.7.5 $LINUX_VER/arch/or32/support/initrd-fb-03.ext2
315
else
316
  echo "Using default ramdisk since the User is not root"
317
  echo "Note that this program built busybox but did not"
318
  echo "install it on the ramdisk. Defaults are used."
319
  cp -f initrd-fb-03.ext2.last.work.1.7.5 $LINUX_VER/arch/or32/support/initrd-fb-03.ext2
320
fi
321
 
322
cd $BUILD_TOP
323
 
324
##########################Final Linux kernel build################
325
echo "Final Linux Kernel build"
326
cd $BUILD_TOP
327
cd $LINUX_VER
328
make vmlinux ARCH=or32 CROSS_COMPILE=$BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux-
329
cd $BUILD_TOP
330
 
331
##########################Simulator build#########################
332
echo "Building or1k simulator"
333
cd $BUILD_TOP
334
cd $SIM_VER
335
./configure --target=or32-uclinux --prefix=$BUILD_TOP/tools/or32-uclinux
336
make all install
337
cd $BUILD_TOP
338
 
339
##########################Code Test###############################
340
cd $BUILD_TOP
341
echo "Run Linux image in the simulator['y'] or not['n'](y/n)"
342
read SI
343
 
344
SVAL=$(echo $SI | tr [:upper:] [:lower:])
345
if [ $SVAL = "y" ];then
346
  echo "In another window you should: telnet 127.0.0.1 10084"
347
  cd $LINUX_VER
348
  $BUILD_TOP/tools/or32-uclinux/bin/or32-uclinux-sim -f sim.cfg vmlinux
349
fi
350
 
351
echo "Build is complete"
352
echo "Your tools are installed in: $BUILD_TOP/tools/or32-uclinux/bin"
353
exit
354
 
355
##########################End Script##############################

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.