Not really a package, but... I tried right now to build gc-linux kernel from scratch, and it was successfull - right now i see gc-linux kernel panic on my gc, because it cant find root (it's ok, because there is no any rootfs as of now)
Btw, i compiled 2.6.32 kernel with mikep5 patch and not the newer kernel (like 2.6.38), because i want to be sure that cross building works. I know that 2.6.32 builds ok, and i never tried to build newer kernels. I will try to build newer kernel later today, or you may do it yourself, and report your results
So, i write this quick tutorial on cross building gc-linux kernel. Please, report your results and any questions if you have
How to build gc-linux kernel from scratch v0.1
Prerequisites: any working linux system with current general devtools (make, gcc, binutils, etc.)
0) I would recommend to do all work in your home subdir or in tmp subdir, so, you cant mess with your working system.
1) Create working subdir and get all needed sources there (for example, i will do everything in
/home/arcticfox/gclinux/):
Code: Select all
$ mkdir ~/gclinux && cd ~/gclinux
$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
$ wget http://ftp.gnu.org/gnu/gcc/gcc-4.3.2/gcc-core-4.3.2.tar.bz2
$ wget http://slackware.sukkology.net/packages/devkitpro-gc/doltool.0.3.2.linux-TenOfTen.tgz
$ wget http://mirror.transact.net.au/sourceforge/g/project/gc/gc-linux/kernel/2.6.32/mikep5-patch-2.6.32-gc.bz2
$ wget http://ftp.halifax.rwth-aachen.de/kernel/linux/kernel/v2.6/linux-2.6.32.tar.bz2
2) Build stage1 crosstoolchain,
sufficient only for building kernel.
Code: Select all
$ tar xjf binutils-2.18.tar.bz2
$ tar xjf gcc-core-4.3.2.tar.bz2
$ mkdir build-binutils && mkdir build-gcc && mkdir gccross && cd build-binutils
$ export PREFIX=/home/arcticfox/gclinux/gccross
$ export TARGET=powerpc-linux-gnu
$ sed -i "s/\[4-9\]|\[5-9\]/([4-9]|[1-9][0-9])|[5-9]/" ../binutils-2.18/configure
$ ../binutils-2.18/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-werror=no
$ make all
$ make install
$ export PATH=$PATH:/home/arcticfox/gclinux/gccross/bin
$ cd .. && cd build-gcc
$ ../gcc-4.3.2/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c --disable-nls --without-headers
$ make all-gcc
$ make install-gcc
3) We have stage1 crosscompiler ready. Now we may build the kernel. We will patch it with mikep5 patch, and then will use default gamecube config:
Code: Select all
$ cd /home/arcticfox/gclinux/
$ tar xjf linux-2.6.32.tar.bz2
$ cd linux-2.6.32
$ bzip2 -cd <../mikep5-patch-2.6.32-gc.bz2 | patch -p1
$ cd ..
$ cp linux-2.6.32/arch/powerpc/configs/gamecube_defconfig linux-2.6.32/.config
If you want to make a changes in default config:
Code: Select all
$ make -C linux-2.6.32 ARCH=powerpc CROSS32_COMPILE=powerpc-linux-gnu- CROSS_COMPILE=powerpc-linux-gnu- menuconfig
also, if you want to modify kernel command line, edit this file (search for
bootargs)
linux-2.6.32/arch/powerpc/boot/dts/gamecube.dts
Now building the kenrel itself!
Code: Select all
$ make -C linux-2.6.32 ARCH=powerpc CROSS32_COMPILE=powerpc-linux-gnu- CROSS_COMPILE=powerpc-linux-gnu- zImage
4) If you get to this step without errors, you already have freshly builded kernel in
linux-2.6.32/arch/powerpc/boot/zImage But you may want to "convert" it to dol file:
Code: Select all
$ cd /home/arcticfox/gclinux
$ tar xzf doltool.0.3.2.linux-TenOfTen.tgz
$ cd doltool.0.3.2.linux-TenOfTen
$ g++ -o doltool *cpp
$ cp doltool /home/arcticfox/gclinux/gccross/bin/
$ cd ..
$ touch build-dol.sh
(Now paste following code in build-dol.sh with your favorite file editor):
Code: Select all
#!/bin/bash
target=${1:-zImage}
ofile=zImage1
[ -r ${KSRC}/arch/powerpc/boot/${target} ] || {
echo "Can't find target image ${KSRC}/arch/powerpc/boot/${target}"
exit 1
}
cp ${KSRC}/arch/powerpc/boot/${target} ${ofile}
CROSS=powerpc-linux-gnu-
echo "+ building DOL"
load=$(${CROSS}readelf -l "$ofile" | \
perl -lane'printf"%08x\n",hex($F[3])+0x80000000 if /LOAD/;')
echo " LOAD: $load"
entry=$(${CROSS}readelf -l "$ofile" | \
perl -lane'printf"%08x\n",hex($F[2])+0x80000000 if /Entry point/;')
echo " EP : $entry"
${CROSS}objcopy -O binary \
-R .comment -R .shstrtab -R .symtab -R .strtab \
-R .gnu.attributes \
${ofile} ${ofile}.bin
doltool -c ${ofile}.bin $load $entry
doltool -i ${ofile}.dol
echo ""
then continue:
Code: Select all
$ chmod u+x build-dol.sh
$ KSRC=linux-2.6.32/ ./build-dol.sh
You will have then
zImage.dol file in current dir!
I tried all of this, right now - and it works. And thanks to all gc-linux team, becuase this guide is mostly based on their works.
Please, if you have any questions - i will glad to help!