Crossdev-Mipsel

The primary goal of this document, is to make a cross-compiling environment for MIPSel.

What is cross compiling?
Cross-compiling is building binaries for one architecture (the target) on another (the host).

Reasons you may wish to do this include:


 * You are an embedded developer, and cannot fit a native toolchain on an embedded system.
 * You are porting Gentoo to a new architecture, and need to cross-compile a stage 1 system to bootstrap.
 * You are building binaries against a different C library. While this is not cross-compiling, a different target tuple can be used to accomplish this.
 * You need 32 bit library on a 64bit system and don't want to build a complete chroot environment

Platforms using MIPsel environment

 * 1) Dingoo A-320 using Dingux (JZ4740 based)
 * 2) DD-WRT compatible routers

Installation and Use
The first thing that is necessary is the creation of an overlay. If you have one, emerge the script:

This will provide you with the crossdev script. This script automates the steps necessary to build a toolchain. These steps are, in short:


 * 1) binutils: Build a cross-binutils, which links and processes for the target architecture.
 * 2) linux-headers: Install a set of C library and kernel headers for the target architecture.
 * 3) libc-headers: Additional header files
 * 4) gcc-stage-1: Build a basic (stage 1) gcc cross-compiler. This will be used to compile the C library. It will be unable to build anything almost else (because it can't link against the C library it doesn't have).
 * 5) libc: Build the cross-compiled C library (using the stage 1 cross compiler).
 * 6) gcc-stage-2: Build a full (stage 2) C cross-compiler.

All cross toolchains will be kept locally in the overlay, separate from native tools.

The script is used like:

This will build a cross-compiling toolchain for MIPsel machines.

By default, the newest stable version of the binutils, libraries, and C compiler will be used. It is quite often the case they will not compile themselves through the entire build process. Less bleeding edge versions can be specified with additional flags:

--b 2.17     # specifies the version of binutils --g 4.2.3    # specifies the version of gcc --l 0.98.3-r2 # specifies the version of the tuple-specified libc --k 2.6.25   # specifies the version of the kernel headers

It is recommended trying older versions, particularly of gcc, if the script fails.

If you want to remove a toolchain, use the clean flag:

This will unmerge the packages created by crossdev.

Recomended Versions
The last version of packages are known to not work with MIPsel cross-compiling build. These is the recomended versions (at this moment):

binutils
sys-devel/binutils-2.19.1-r1

gcc
sys-devel/gcc-4.1.2 Obs: If something goes wrong, fallback to 3.4.6-r2

gentoo-sources
If you're about to compile a kernel, the last known to work kernel for mipsel is 2.6.29.1.

Dingoo A320
For Dingux, it's recommended to use the Dingux-Code mentioned above (2.6.24.3 based).

External References
DD-WRT

Dingux Code

Dingux