Linux VR Tools HOWTO
By Bradley D. LaRonde (firstname.lastname@example.org)
Thanks to Jay Carlson for his work on the tool set, to Mike Klar for packaging the tools and libraries, and to both for their contributions to this documentation.
This HOWTO describes the Linux VR software development tools and explains how to install and use them.
Because Linux VR targets devices that lack floating-point coprocessors, it has special needs with regards to compilers and libraries. It would be nice if we could use the stock MIPS cross-compilers and libraries for Linux VR, but alas, that is not possible. Linux VR uses GOFAST soft-floating-point routines. The stock MIPS egcs-mipsel-linux i386 cross compiler doesn't (and there may be other problems related to soft-float in the stock MIPS cross compiler). Also, Linux VR requires soft-float libraries (C, C++, etc.). The standard MIPS libraries are built for hardware floating point.
However, we can (and do) use the stock MIPS cross-binutils (as, ld, etc.).
Linux VR runs on MIPS processors. As such, the Linux VR development tools need to produce MIPS executables. Most people do not have MIPS development boxes to "natively" build these executables. Not a problem - cross-compilation to the rescue. It is possible to use an x86 Linux box to build MIPS executables for the Linux VR device. This process of building executables for one type of processor using tools running on a different type of processor is called cross-development, and is used exensively for Linux VR development.
If you just want to build the kernel, then you only need to do the next two sections, "Installing the Cross-Binutils" and "Installing the C Cross-Compiler".
If you plan on building userland applications, then do all of the following sections.
Installing the Cross-Binutils
Building an executable normally involves using a binutil or two, like as (assember) or ld (linker). So install the cross-binutils first.
To install the stock MIPS cross-binutils
- Download the binutils-mipsel-linux rpm from here.
- Install it using "rpm -i". This requires host glibc 2.0 or higher installed.
Installing the C Cross-Compiler
Cross-compiling C programs, including the Linux VR kernel, requires a C cross compiler. For Linux VR we use our own build of egcs-mipsel-linux that supports GOFAST soft-floating-point routines. For the most part, the the kernel can be sucessfully compiled with the stock MIPS C cross-compiler, but since building userland applications and some parts of the kernel requires our own egcs build, it's best to just use that for compiling both kernel and userland applications.
To install the C cross-compiler
- Download the egcs-mipsel-linux rpm from here.
- Install it using "rpm -i". This requires host glibc 2.0 or higher and the cross-binutils (see above) installed.
Installing the Cross-Development C Libraries
As Mike Klar put it, "The Linux kernel is a fine piece of code, but to do anything useful requires user mode applications." Building userland C applications normally requires a C library. For Linux VR we use our own soft-float build of glibc. It is specially packaged for cross-development, which amounts to a simple rearrangement of the native mipsel-linux-soft-float glibc libraries installed in a special place for cross-development.
To install the cross-development C libraries
- Download the glibc-mipsel-linux-softfloat tar from here.
- Change to "/usr".
- Untar the file.
- Adjust the permissions on /usr/mipsel-linux appropriately. For example, a+rx for directories, a+r for files.
Linux Kernel Source Symlinks
Many applications need access to header files in the Linux Kernel sources. To facilitate this, set up the Linux kernel source symlinks.
To set up the Linux kernel source symlinks
- Make sure that the kernel sources are installed.
- Change to the /usr/mipsel-linux/include directory.
- Create symlinks to the Linux kernel sources as follows:
ln -s <kernel source root>/include/linux linux
ln -s <kernel source root>/include/asm-mips asm
Using the C Cross-Compiler and Cross-Binutils
Prepend "mipsel-linux-" to the tool name.
Use -msoft-float in addition to any other options that you pass to mipsel-linux-gcc. This is important both when compiling and when linking.
mipsel-linux-gcc -msoft-float -c foo.c
at compile-time makes sure gcc itself doesn't generate hardware floating point operations, and
mipsel-linux-gcc -msoft-float foo.o bar.o -lbaz -o a.out
is necessary at link-time to get the right version of libgcc.a
In general, if a makefile wants to know what CC is, the answer should be
CC = mipsel-linux-gcc -msoft-float
and if it wants a setting for LD aside from LD = $(CC),
LD = mipsel-linux-gcc -msoft-float
One can't believe everything one hears - there really are other languages than C. :-) We have a few other cross-compilers available.
To install another cross-compiler
- Download the rpm from here.
- Install it using "rpm -i".