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

Raspberry Pi 3 64-bit kernel using native tools

The SoC on the Raspberry Pi 3 supports 64-bit mode, unfortunately raspbian and the foundation does not provide 64-bit support (yet?) 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)

We need to build the tools we need, aarch64 binutils and gcc. Start by first installing required dependencies:

sudo apt-get install build-essential libgmp-dev libmpfr-dev libmpc-dev bc

Build the cross compilation tools


Download the latest binutils, 2.28


Untar the binutils archive

tar xf binutils-2.28.tar.bz2

Configure build and install

cd binutils-2.28
./configure --prefix=/opt/aarch64 --target=aarch64-linux-gnu
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/


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 gcc:


Untar the gcc archive

tar xf gcc-6.3.0.tar.bz2

Configure gcc and build gcc

mkdir gcc-out
cd gcc-out
../gcc-6.3.0/configure --prefix=/opt/aarch64 --target=aarch64-linux-gnu --with-newlib --without-headers --disable-shared --enable-languages=c
make all-gcc -j4
sudo make install-gcc


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

Download Linux kernel sources

Get the most up to date kernel sources (4.9 branch at time of writing) directly from git with

git clone --depth=1 -b rpi-4.9.y

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 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, etc) 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-


No votes yet
64-bit, Raspberry Pi, Linux
09/03/2017 - 10:56