Skip to content

Building powerpc kernels

Michael Ellerman edited this page Sep 19, 2017 · 9 revisions

How to build the kernel for powerpc

Toolchain

If you're not lucky enough to have a powerpc laptop, you can build with a cross compiler.

Some distros ship a cross toolchain.

On Fedora you can install the required toolchain with:

sudo dnf install gcc-c++-powerpc64-linux-gnu binutils-powerpc64-linux-gnu gcc-powerpc64-linux-gnu

On Ubuntu use:

sudo apt-get install gcc-powerpc64le-linux-gnu gcc-powerpc-linux-gnu libc-dev-powerpc-cross libc-dev-ppc64el-cross

Otherwise you can use the toolchains helpfully provided by free-electrons.

cd /tmp
wget http://toolchains.free-electrons.com/downloads/releases/toolchains/powerpc64le-power8/tarballs/powerpc64le-power8--glibc--bleeding-edge-2017.05-toolchains-1-1.tar.bz2
tar -xf powerpc64le-power8--glibc--bleeding-edge-2017.05-toolchains-1-1.tar.bz2

wget http://toolchains.free-electrons.com/downloads/releases/toolchains/powerpc64-power8/tarballs/powerpc64-power8--glibc--bleeding-edge-2017.05-toolchains-1-1.tar.bz2
tar -xf powerpc64-power8--glibc--bleeding-edge-2017.05-toolchains-1-1.tar.bz2

Building

When cross-building you need to tell the kernel build system that you want to build for the powerpc architecture, and tell it where your toolchain is. You can do that by setting environment variables (as we'll show here), or on the make command line.

To set the architecture use:

export ARCH=powerpc

Then set the cross compiler. Depending on which one you're using, and which endian you're building for it differs slightly.

For Little Endian

On Fedora:

export CROSS_COMPILE=powerpc64-linux-gnu-

On Ubuntu:

export CROSS_COMPILE=powerpc64le-linux-gnu-

With the free-electrons toolchain:

export CROSS_COMPILE=/tmp/powerpc64le-power8--glibc--bleeding-edge/bin/powerpc64le-linux-

Then you can build the kernel with:

make powernv_defconfig        # or pseries_le_defconfig, or ppc64le_defconfig
make                          # for a faster build add: -j $(nproc)

For Big Endian

On Fedora:

export CROSS_COMPILE=powerpc64-linux-gnu-

On Ubuntu:

export CROSS_COMPILE=powerpc-linux-gnu-

With the free-electrons toolchain:

export CROSS_COMPILE=/tmp/powerpc64-power8--glibc--bleeding-edge/bin/powerpc64-linux-

Then build the kernel with:

make ppc64_defconfig        # or pseries_defconfig etc.
make                        # for a faster build add: -j $(nproc)
Clone this wiki locally