Build a 64-bit Kernel for your Raspberry Pi 3

EDIT : After writing this blog post I’ve started a 64-bit OS for the Raspberry Pi 3, based on Debian. You can find it here.

The Raspberry Pi 3 ships with a Broadcom BCM2837 64bit ARMv8 quad core Cortex A53 processor, which is a 64-bit CPU. If you own one of these, running the following command might surprise you :

> uname -a
Linux raspberrypi 4.4.34-v7+ #930 SMP Wed Nov 23 15:20:41 GMT 2016 armv7l GNU/Linux

Yes, this is a 32-bit kernel. The reason for this is that the Raspberry Pi foundation doesn’t yet provides a 64-bit version of Raspbian, the official OS for Raspberry Pi. It is however possible to build one, thanks to the various patches sent by Electron752.

Build the Kernel

The Raspberry Pi foundation maintains their own fork of the Linux Kernel which is especially tailored for their devices, while upstream gets merged regularly.

We’re going to adapt instructions from that page to build a 64-bit Kernel.

We cannot use the “Local building” method as it’d require a 64-bit Raspberry Pi, which we obviously don’t have yet. So we have to cross-compile it, Ubuntu is the recommended OS for this. I personally don’t have Ubuntu so I’ll make my build on a 2 CPUs Ubuntu 16.04 Digital Ocean droplet, which should cost me $0.03. If you also want to proceed like this, you can get $10 free credits through this link. Alternatively, you could use a Ubuntu VM through Virtualbox for instance.

First, we’d need a few build tools and the aarch64 cross-compiler :

> apt-get update
> apt-get install -y bc build-essential gcc-aarch64-linux-gnu git unzip

Then we can download the Linux Kernel sources :

> git clone –depth=1 -b rpi-4.8.y

Enter now inside the created git directory. Optionally, you can add an extra version tag for your kernel. This is done by editing the beginning of the Makefile :


In order to build it, run the following commands :

> make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcmrpi3_defconfig
> make -j 3 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

The first one should be pretty fast. For the second one it’s a whole different story, I haven’t timed it exactly but it was around 30 minutes for me. Make sure to adapt the -j flag depending on your number of CPUs (nproc * 1.5).

Choose a Linux distribution

While the Kernel is being built, we can start preparing a Linux distribution for it. I’ll be using Raspbian for simplicity in this tutorial, even though this is a 32-bit only distribution.

If you want to go 64-bit all the way you should pick up a distribution available in aarch64, Debian has a robust ARM64Port. To grab it there are basically 3 options :
– download a pre-built root filesystem, this would most likely give you an outdated one as mentioned in that page
– build your own with debootstrap if you’re familiar with it (otherwise it can be tricky as it requires some manual tweaks, the original purpose of it is to chroot from an already running host, not build a root filesystem for another machine).
– the one I’d recommend, using multistrap, there seems to be a nice tutorial on this page :

Back to Raspbian, we can now download the official OS and start preparing it.

Open a new shell session and run the following commands :

> wget -O
> unzip

We can inspect it with the following command :

> fdisk -l 2016-11-25-raspbian-jessie-lite.img
Disk 2016-11-25-raspbian-jessie-lite.img: 1.3 GiB, 1390411776 bytes, 2715648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x244b8248

Device Boot Start End Sectors Size Id Type
2016-11-25-raspbian-jessie-lite.img1 8192 137215 129024 63M c W95 FAT32 (LBA)
2016-11-25-raspbian-jessie-lite.img2 137216 2715647 2578432 1.2G 83 Linux

We can see it has two partitions. The first one is the boot partition, it mainly contains the bootloader, the Linux Kernel and a few config files. The second one is the root partition.

We can mount those partitions on our filesystem, starting with the root partition :

> mount -o loop,offset=70254592 2016-11-25-raspbian-jessie-lite.img /mnt

The offset depends on the sector size, which is 512 : 70254592 = 512 * 137216

Then the boot partition :

> mount -o loop,offset=4194304,sizelimit=66060288 2016-11-25-raspbian-jessie-lite.img /mnt/boot

(offset : 4194304 = 512 * 8192, sizelimit: 66060288 = 512 * 129024)

The Raspbian OS can now be seen under /mnt. We’re almost there.

Wrapping it up

Once the Kernel build is finished, the last steps involve copying the Linux Kernel and the device tree to the boot partition :

> cp arch/arm64/boot/Image /mnt/boot/kernel8.img
> cp arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b.dtb /mnt/boot/

Tweaking config.txt :

> echo “kernel=kernel8.img” >> /mnt/boot/config.txt

Installing Kernel modules :

> make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu INSTALL_MOD_PATH=/mnt modules_install
> umount /mnt/boot
> umount /mnt

And… that’s it, a freshly baked ARM64 Linux Kernel for our Raspberry Pi 3!

You can now compress the image, download it through scp for instance and follow the standard instructions to put it on your SD card.

Eventually you’ll get :

> uname -a
Linux raspberrypi 4.8.13+bilal-v8+ #1 SMP Wed Dec 14 14:09:38 UTC 2016 aarch64 GNU/Linux

  • Sébastien Gaïde

    Hi Bilal,

    thanks a lot for this tutorial, it really helps.
    i was wondering, if i go to the ‘raspbian distro’ route as described, will it be possible to make a full 64 bits executable then ? i mean with a 64 bits libc/libc++ and all the 64 bits dependencies, i guess i will have to build/install all this, would it be possible or are we stuck to the 32 bits world ?

    in other word, to be able to compile and run 64 bits app, do i have to use the native ARM64Port distro ?

    thanks a lot,


    • Bilal

      Glad it helped.

      Indeed you’d need a bit more steps to build / run 64 bits programs on raspbian. Personally as it is more for testing purpose I’ve just downloaded a rootfs from from within the raspberry, chrooted inside, updated apt sources and installed what I need to build / run 64-bit stuff from the chroot.

      Otherwise if you want to build a 64 bit distro instead, there are a few params to remove in /boot/cmdline.txt : “quiet init=/usr/lib/raspi-config/”. This is a trick for raspbian so that the root partition is expanded on first boot, then the script edits the cmdline file and reboots, but if the rootfs is not raspbian that can give some fun debugging sessions 🙂

      I also saw recently which seems pretty neat.

  • jo hawkins

    would it be possible for you to upload the .iso?

  • Alex Liu

    I installed centos 7 on the pi with this kernal . The keyboard worked in terminal but will not work in gnome and gdm. Also,the mouse will not work

  • Ivica Mikulandra

    Missing snd-bcm2835.ko audio driver and usb tv stick drivers. Lxde works well on 2017-04-11 version. Boot from usb disk works or not? Can I try it. (sorry for my english)

    • Bilal

      The sound issue should be fixed, if you have other specific problems could you please create an issue with the details there : ?

      • Roland Egger

        I have the same problem that the audio driver snd-bcm2835.ko is not build. I used the to build buntils, gcc cross compiler on my Raspberry 3 and then the latest kernel. Unfortunately I don’t know how to configure the kernel to build snd-bcm2835.ko. What do I need to do?

  • Константин Егоров

    Is it possible install KDE on this kernel?

    • Bilal

      It should be possible, the main limitation could come from the limited resources of the raspberry (specifically memory). I know lxde works nicely, but if kde has a low memory footprint too that should be fine.

  • Sean

    Can the same overclocking on 32-bit be applied the same way with this build?

    • Bilal

      I haven’t tried but I don’t see why it wouldn’t work. However you’d have to make sure to use a proper power supply cable otherwise you might get voltage drop issues (cf.

  • Just set up your 64-bit OS on my RPI3, works a treat, thanks! Now to port 8th over to the 64-bit RPI…

  • Basavaraja M S

    I’m not able to mount, I got error as
    $sudo mount -o loop,offset=70254592 2017-09-07-raspbian-stretch.img /mnt/ -t ext4
    “mount: wrong fs type, bad option, bad superblock on /dev/loop0,
    missing codepage or helper program, or other error
    In some cases useful info is found in syslog – try
    dmesg | tail or so”

    dmesg log showed this message
    “EXT4-fs (loop0): VFS: Can’t find ext4 filesystem”

    Can you please help me to overcome this issue ?

    • Bilal

      Probably the offset changed for the new image you’re using, I’d suggest using kpartx which is more convenient. You can run “kpartx -asv file.img”, it would display the two partitions created under /dev/mapper, then you can mount them (eg. mount /dev/mapper/loop0p2 /mnt/root).

  • Jorge Martinez


    Thank you very much for your great tutorial! I have one question, when the compilation is over and the kernel image (Image) is generated, I can see the following:
    $ file Image
    Image: MS-DOS executable, MZ for MS-DOS

    On the other hand, when I follow the following tutorial , apart from having Image, I also end up having kernel8.img

    $ file kernel8.img Image
    kernel8.img: PCX ver. 2.5 image data bounding box [8223, 54531] – [0, 8], 20-bit uncompressed
    Image: MS-DOS executable, MZ for MS-DOS

    Since you mention that we can compress the kernel image now, do you know, how i can convert Image into kernel8.img as in the aforementioned case?

    My apologies but I am new to AArch 64.

  • Neil T

    Hello, Thank you for sharing. I’ve successfully followed most of the tutorial. Can you elaborate on the following step please?

    “You can now compress the image, download it through scp for instance and follow the standard instructions to put it on your SD card.”

    Specifically I’m not sure how I get from the mounted root and boot filesystem to the single .img file.

  • Christopher A Burns

    Did anyone else get the error about a missing config file when executing the first MAKE statement. I added a “MAKE oldconfig” command and you are prompted to confirm or change EVERY option in the kernel. I must have done something wrong because I got a Makefile:970: recipe for target ‘drivers’ failed error. This happened with both the 4.8.y and 4.9.y branches. Anyone have advice?

  • Brady Dean

    Do you know what is required to get debootstrap working? I put a stable release on my sd card and installed the kernel but I’m not sure if the rpi3 is booting or not. I do not get anything from hdmi

  • TonyR

    I miss the part “Why would I want a 64-bit kernel on the Raspberry Pi 3 ?”

    The cons: I’ve heard that it’d consume more RAM and it’d run slower than 32 bit.