Build 64-bit kernel for Raspberry Pi 3, using native tools

24/07/2018 - 16:18
Average: 4.2 (9 votes)

Guide on how to build a 64-bit kernel for the Raspberry Pi 3 & 3+ boards, on device, using native 64-bit cross-compilation tools. Using kernel version 4.14 at time of writing.

The SoC on the Raspberry Pi 3 supports 64-bit mode, unfortunately raspbian and the foundation does not provide 64-bit support even if they are advertising the Pi 3 as a 64-bit platform.

There are 3 ways to get a 64-bit kernel compiled:

  1. Native build on another 64-bit ARM platform
  2. Cross-compilation on another platform
  3. Cross-compilation on the Pi 3 itself

This tutorial will explain how to do option number 3. (And will actually work just fine for option number 2 as they are pretty much the same)

Install essential build tools and development packages

As we need to build the tools we need, that is aarch64 binutils and gcc, we need to install the required build tools first. Start by first installing required dependencies for compilation of these tools:

sudo apt-get install build-essential libgmp-dev libmpfr-dev libmpc-dev libisl-dev libncurses5-dev bc git-core

Build the cross compilation tools

To be able to cross-compile we need to build a couple of tools ourselves as they are not provided. These are aarch64 versions of binutils (assembler, linker) and gcc (C compiler). We will install these tools in their own prefix or path,


Build and install Binutils

Download the latest binutils, (Tested with 2.29.1 at time of writing, feel free to try any later versions (2.30 is reported not to work!) when available)


Untar the binutils archive

tar xf binutils-2.29.1.tar.bz2

Configure build and install

cd binutils-2.29.1
./configure --prefix=/opt/aarch64 --target=aarch64-linux-gnu --disable-nls
make -j4
sudo make install

Binutils is now installed, to be able to use it add "/opt/aarch64/bin/" to your path:

export PATH=$PATH:/opt/aarch64/bin/

Build and install GCC

Next up is gcc, the C compiler. We will build a minimal compiler for C only and no userland support. This is enough to get a aarch64 kernel compiled.

Download latest stable gcc (Tested with 6.4.0 at time of writing, feel free to try any later version when available):


Untar the gcc archive

tar xf gcc-6.4.0.tar.xz

Next configure gcc and build gcc. We will configure the build for only a minimal C compiler, that is enough for building a kernel.

mkdir gcc-out
cd gcc-out
../gcc-6.4.0/configure --prefix=/opt/aarch64 --target=aarch64-linux-gnu --with-newlib --without-headers \
 --disable-nls --disable-shared --disable-threads --disable-libssp --disable-decimal-float \
 --disable-libquadmath --disable-libvtv --disable-libgomp --disable-libatomic \
make all-gcc -j4
sudo make install-gcc

Test that the cross gcc runs ok, run:

aarch64-linux-gnu-gcc -v

It should report something close to this is everything is ok:

Using built-in specs.
Target: aarch64-linux-gnu
Configured with: ../gcc-6.4.0/configure --prefix=/opt/aarch64 --target=aarch64-linux-gnu --with-newlib --without-headers --disable-shared --enable-languages=c
Thread model: posix
gcc version 6.4.0 (GCC)

If all is well, then you can continue to building the kernel itself!

Build the Linux kernel

Now you have a toolchain that is able to build 64-bit ARM kernels. So the next step is to download the Raspberry Pi kernel sources, configure them and build a 64-bit kernel and modules.

Download Linux kernel sources

Get the most up to date stable branch kernel sources (4.14 branch at time of writing) directly from the Raspberry Pi GitHub repository with

git clone --depth=1 -b rpi-4.14.y
Keeping sources fresh

The Linux kernel is a moving target and evolves almost daily. To keep updated with latest changes, run the following command in the directory you checked out above:

git pull

Configure Linux kernel for 64-bit Raspberry Pi 3

We use output directory for kernel build so we can use the same source tree for other configuration (32-bit for example)

mkdir kernel-out
cd linux
make O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-  bcmrpi3_defconfig

The kernel build is now configured with a default configuration for a 64-bit Raspberry Pi kernel.

In case you need to customize the configuration (Add support for some specific hardware, trim out things you don't need or otherwise mess around with the configuration) run

make O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig

and adjust the configuration for your needs.

Build the kernel and modules

Next build the kernel and modules with:

make -j4 O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

If all goes well, as it should, you should now have a 64-bit kernel, modules and device tree built.

Keep up with kernel development

The Linux kernel evolves and so does the Raspberry Pi kernel too. To keep up with development changes you can ask git to download changes to your kernel source tree. To do that run the following command in the kernel source locations:

git pull

This will download any changes made to the kernel source.

Update kernel configuration

After pulling in changes I personally like to always run, just in case:

make -j4 O=../kernel-out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- oldconfig
11/04/2018 - 13:15
  • Update to 4.14
64-bit, Raspberry Pi, Linux, stretch, jessie