Building a Kernel for PowerPC
In order to build a kernel for PowerPC while on a non-PowerPC machine, you will need a cross-compilation toolchain installed. Then, each time you invoke make
to perform part of the kernel build process, you need to supply the arguments CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc
; if you are using make-kpkg
, you need to supply the arguments --cross-compile powerpc-linux-gnu- --arch ppc --subarch powerpc
.
Obtaining the kernel source package
On a Debian system, install the latest linux-source-2.6.NN
package, as well as make-kpkg
, build-essential
, and libncurses5-dev
. Create a working directory and extract the source there.
PKG=`dpkg -l 'linux-source-*' | tail -n +6 | sort -nk 3 | tail -n 1 | awk '{print $2}'`
sudo aptitude install $PKG make-kpkg build-essential libncurses5-dev
mkdir -p ~/src/kernel/powerpc
cd ~/src/kernel/powerpc
tar xvvjf /usr/src/$PKG.tar.bz2
cd $PKG
Configuring the kernel
Since the kernel's .config contains an x86 configuration by default, you need to replace it with the default PowerPC configuration before configuring the kernel. Note that the defconfig for PowerPC is not in arch/ppc/defconfig as expected; as of 2.6.11 it is located at arch/ppc/configs/common_defconfig.
cp arch/ppc/configs/common_defconfig .config
make CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc menuconfig
This will open the kernel configuration program, allowing you to choose which features you want to include in the kernel.
Building a kernel package
Use make-kpkg
to build a Debian package of the kernel.
make-kpkg --revision 1 --cross-compile powerpc-linux-gnu- --arch ppc --subarch powerpc kernel_image
Building a kernel image by hand
To build a kernel image without using make-kpkg
, use the "zImage" target.
make CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc zImage
This will create kernel images in various formats and place them in arch/ppc/boot/images/
PP01-specific notes
FIXME: integrate this into the above.
To build a PPCBoot image, which the PP01 board might actually boot, use the "uImage" target.
make CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc uImage
The 2.6.9 kernel they use doesn't appear to build with GCC 4.0
Disheveled Notes from Darrick
Run this (on Darrick's not-so-weird ppc boxes, anyway) on the denx linuxppc-2.4-devel.git tree:
(make CROSS_COMPILE= mrproper TQM5200_config ; cp arch/ppc/defconfig .config ; make CROSS_COMPILE= oldconfig dep ; make CROSS_COMPILE= -j2 uImage) 2>&1 | tee BUILDLOG
Non ppc machines need to set CROSS_COMPILE= to something useful. Also see the .config file I put in the Attachments section.
Attachments: