Asisi
Home
Copyright Robert Cragie 2004
IMPORTANT
Please note that this document was originally produced on 11 Feb 2003. For this reason, I would strongly recommend that you attempt to follow the guidelines on the Open Cores website first and perhaps use this document as an aid to show you the right order of the steps you need to take. The latest ATS script will show you the command lines and order you need to use to build everything properly; you can find it here. Alternatively, look at Rich D's website, where there is a ton of useful information and patches.
| Author | Date | Version |
| Robert Cragie | 10 Feb 2004 | 0.4 Draft |
Check you have these tools and what version you have:
| Tool | Version |
| autoconf | 2.13 |
| automake | 1.4-p6 |
| bison | 1.35 |
| yacc | ? |
| flex | 2.5.4 |
| gcc | 2.95.2 or 2.95.3 |
| genromfs | 0.5.1 |
You can download genromfs here or from any other Sourceforge location. The project can be found here
IMPORTANT
Note for non English users:
Before beginning, you have to set LANG environment variable to eng to make your compiler work in English. If you don't do this you can have problems with uclibc.
export LANG=eng
It is assumed that all commands are issued under a bash shell.
The following syntax indicates a command run as a normal user:
$ <command>
The following syntax indicates a command run as a superuser:
# <command>
It is often useful to capture the output of configuration and build runs. To do this, append the following to a configure or make command:
2>&1 | tee <logfile>
where <logfile> is the name of the file you wish to capture the output to.
I am assuming you are logged in as user and you are in your home directory, which is /home/user (replace user as appropriate).
Make a root directory for all source:
$ mkdir or1k-cvs; cd or1k-cvs
Set the CVSROOT environment variable. This will save having to specify the repository each time:
$ export CVSROOT=:pserver:anonymous@cvs.opencores.org:/cvsroot/anonymous
Login to anonymous CVS server. When prompted for a password, just hit return without entering anything
$ cvs login
Checkout all the source:
$ cvs -z9 co or1k/binutils
$ cvs -z9 co or1k/gcc-3.1
$ cvs -z9 co or1k/gdb-5.0
$ cvs -z9 co or1k/uclinux/uClinux-2.0.x
$ cvs -z9 co or1k/uclibc
$ cvs -z9 co or1k/or1ksim
$ cvs -z9 co or1k/uclinux/userland/init
$ cvs -z9 co or1k/uclinux/userland/sash
$ cvs -z9 co or1k/uclinux/userland/route
$ cvs -z9 co or1k/uclinux/userland/ping
Change to or1k directory:
$ cd or1k
Login as superuser:
$ su
You are now ready to start building. It is important to build everything strictly in the specified order.
First, make a build directory and change to it:
# mkdir b-b; cd b-b
Configure and build it:
# ../binutils/configure --target=or32-uclinux
--prefix=/opt/or32-uclinux
# make all install
Note: if you had an error like 'CC enviroment not set' do
# export CC=/usr/bin/
You have to add the binaries you have just built to your path:
# export PATH=/opt/or32-uclinux/bin:$PATH
Finally go up a directory:
# cd ..
First, make a build directory and change to it:
# mkdir b-gcc; cd b-gcc
Configure and build it:
# ../gcc-3.1/configure --target=or32-uclinux
--prefix=/opt/or32-uclinux --local-prefix=/opt/or32-uclinux/or32-uclinux
--with-gnu-as --with-gnu-ld --verbose --enable-languages=c
# make all install
Finally go up a directory:
# cd ..
First, make a build directory and change to it:
# mkdir b-gdb; cd b-gdb
Apply the following patch to gdb/utils.c (this fixes a problem with a previous bool definition):
21a22,25
> #ifdef HAVE_CURSES_H
> #include <curses.h>
> #endif
>
27,29d30
< #ifdef HAVE_CURSES_H
< #include <curses.h>
< #endif
Configure and build it. Current version of readline has a configuration bug, so you must not specify the installation prefix while configuring the package and you have to copy the executable manually:
# ../gdb-5.0/configure --target=or32-uclinux
# make all
# cp gdb/gdb /opt/or32-uclinux/bin/or32-uclinux-gdb
Finally go up a directory:
# cd ..
First, change to simulator directory:
# cd or1ksim
Configure and build it:
# ./configure --target=or32-uclinux --prefix=/opt/or32-uclinux
--enable-ethphy
# make all install
Finally go up a directory:
# cd ..
First, change to uClinux directory:
# cd uclinux/uClinux-2.0.x/
Edit the following line in arch/or32/Rules.make:
LIBGCC = /opt/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/libgcc.a
Build it:
# make oldconfig
# make dep
# make
Finally go up a couple of directories:
# cd ../..
First, change to uclibc directory:
# cd uclibc
You will have a version of GCC which works with glibc, the standard GNU library. However, to work with uClinux you need a compiler working with uclibc. Do the following:
# ln -s ./extra/Configs/Config.cross.or32.uclinux ./Config
Edit Config via the link you have just created and carefully modify these lines (replace user as appropriate):
KERNEL_SOURCE=/home/user/or1k-cvs/or1k/uclinux/uClinux-2.0.x/
DEVEL_PREFIX = /opt/$(TARGET_ARCH)-uclinux
Build it:
# make all install
Remove all the binaries it installed:
# pushd .
# cd /opt/or32-uclinux/bin
# rm -f addr2line ar as cc cpp gasp gcc ld nm objcopy objdump ranlib size
strings strip jar grepjar
# popd
Finally go up a directory:
# cd ..
We need to recompile GCC to make it work with uclibc.
First, change to GCC build directory:
# cd b-gcc
Reconfigure and build it.
Note it is essential that --prefix is /opt/or32-uclinux/, i.e. with the additional '/' at the end. For some strange reason, it is necessary to add this slight difference to force a proper reconfiguration and build, otherwise prefixes are omitted when it comes to running the built GCC:
# ../gcc-3.1/configure --target=or32-uclinux
--prefix=/opt/or32-uclinux/ --with-gnu-as --with-gnu-ld --verbose
--enable-languages=c
# make all install
Finally go up a directory:
# cd ..
First, change to uCLinux user init directory and build it:
# cd uclinux/userland/init
# make
Change to uCLinux user sash directory and build it:
# cd ../sash
# make
Change to uCLinux user route directory and build it:
# cd ../route
# make
Change to uCLinux user ping directory and build it:
# cd ../ping
# make
Finally go up a directory:
# cd ..
To create the ROM filesystem, do the following:
# mkdir -p romfs/bin
# cp or1k/uclinux/userland/init/init romfs/bin/
# cp or1k/uclinux/userland/sash/sh romfs/bin/
# cp or1k/uclinux/userland/route/ifconfig romfs/bin/
# cp or1k/uclinux/userland/route/route romfs/bin/
# cp or1k/uclinux/userland/ping/ping romfs/bin/
# chmod 777 romfs/bin/*
# mkdir romfs/etc
# cp or1k/uclinux/userland/init/rc romfs/etc/
# mkdir romfs/dev
# cd romfs/dev
# mknod ram0 b 1 0
# mknod tty c 4 0
# mknod tty1 c 4 1
# mknod ttyS0 c 4 64
# cd ..
# genromfs -f ../or1k/uclinux/uClinux-2.0.x/arch/or32/board/initrd
# cd ..
To create the ext2 ramdisk image, do the following. This is an alternative to the ROM filesystem.
Note: This doesn't seem to work well with the simulator. It may be better to stick with the ROM filesystem.
# mkdir ext2fs
# mke2fs -m0 -r0 -O none /dev/ram0 1024
# mount /dev/ram0 ext2fs
# mkdir ext2fs/bin
# cp or1k/uclinux/userland/init/init ext2fs/bin/
# cp or1k/uclinux/userland/sash/sh ext2fs/bin/
# cp or1k/uclinux/userland/route/ifconfig ext2fs/bin/
# cp or1k/uclinux/userland/route/route ext2fs/bin/
# cp or1k/uclinux/userland/ping/ping ext2fs/bin/
# chmod 777 ext2fs/bin/*
# mkdir ext2fs/etc
# cp or1k/uclinux/userland/init/rc ext2fs/etc/
# mkdir ext2fs/dev
# cd ext2fs/dev
# mknod ram0 b 1 0
# mknod tty c 4 0
# mknod tty1 c 4 1
# mknod ttyS0 c 4 64
# cd ../../
# umount ext2fs
# dd if=/dev/ram0 of=or1k/uclinux/uClinux-2.0.x/arch/or32/board/initrd
This is necessary to pick up the change to initrd. Note that either the romfs file or the ext2 file can be booted by uClinux; as the ext2 file was built last, this will be used.
# cd or1k/uclinux/uClinux-2.0.x
# make all
If an error occurs regarding the length of the flash disk, edit arch/or32/board/rom.ld and increase the length of the flash disk and the origin of the flash. You also need to edit uclinux/uClinux-2.0.x/sim.cfg and increase the memory size.
Now go to uclinux/uClinux-2.0.x/sim.cfg and modify the UART section to use tty10 as output:
section uart
enabled = 1
nuarts = 1
device 0
baseaddr = 0x90000000
irq = 2
jitter = -1
16550 = 1
channel = "file:/dev/tty10"
enddevice
end
You now have you have uClinux ready to launch.
Then in uclinux/uClinux-2.0.x directory enter:
# or32-uclinux-sim linux
Now press CTRL-ALT-F10 to see the /dev/tty10 console.
You should see something like this.