close

MIPS toolchain, Roll-your-own

 

 

You're adverse to using someone else's toolchains, and cannot remember how to build one yourself, no matter how hard you try. Fear not. Outlined here is the proceedure to build a bootstrap toolchain; one which is minus the C library and is just enough to build the kernel.

What you'll need:

binutils-2.27
gcc-4.8.2
gdb-7.12
 

# mkdir -p /home/tmp
# export WDIR=/home/tmp
# export TARGET=mipsel-linux
# export PREFIX=/opt/toolchain

You'll need to re-export your PATH with the new install location so when building a bootstrap gcc, it may locate the shiny new cross-binutils:
 

# export PATH="${PATH}":${PREFIX}/bin

 

# cd $WDIR
# mkdir ${TARGET}-toolchain && cd ${TARGET}-toolchain


Binutils
 

Extract, configure, build and install:
 

# tar xjf binutils-2.27.tar.bz2
# mkdir build-binutils && cd build-binutils
# ../binutils-2.27.1/configure --target=$TARGET --prefix=$PREFIX
# make
# make install
# cd ..

 

You should now have the cross-binutils installed under ${PREFIX}/bin/ with names prefixed by mipsel-linux- .
 

GCC

 

Extract, configure, build and install a bootstrap GCC.
Enable any other language front-ends as you see fit. For building the kernel however, you can get away with just the C language front-end. Also, tell the configure script not to look for target libc headers -- we don't have them, and don't need them at this point. 
 

# tar xjf gcc-4.8.2.tar.bz2
# mkdir build-gcc-bootstrap && cd build-gcc-bootstrap
# ../gcc-4.8.2/configure --target=$TARGET --prefix=$PREFIX \
--enable-languages=c --without-headers \
--with-gnu-ld --with-gnu-as \
--disable-shared --disable-threads \
--disable-libmudflap --disable-libgomp \
--disable-libssp --disable-libquadmath \
--disable-libatomic
# make -j2
# make install
# cd ..

 

If configure error occured, 

...

configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations. Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also
http://gcc.gnu.org/install/prerequisites.html for additional info. If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files. They may be located in separate packages.
...
 

# apt-get install libmpc-dev

 

install the 'libmpc-dev' to fix the configure error. 

 

GDB

 

You'll need this for debugging either the kernel (with KGDB) or userspace (natively or with gdbserver). If this doesn't apply in your case, you may safely skip this section. Extract, configure, build and install: 
 

# tar zxvf gdb-7.12.tar.gz
# mkdir build-gdb && cd build-gdb
# ../gdb-7.12/configure --target=$TARGET --prefix=$PREFIX
# make
# make install
# cd ..

 

 

Reference

 

https://www.linux-mips.org/wiki/Toolchains

https://www.narf.ssji.net/~shtrom/wiki/research/imara/mipsellinuxtoolchain

 

 

 

 

 

 

arrow
arrow

    Lexra 發表在 痞客邦 留言(0) 人氣()