Booting 64-bit kernel on Raspberry Pi 3

So now you should have a shiny 64-bit kernel if you followed the 64-bit kernel build tutorial, and if not, do it first.

Now that you have the kernel and modules built, the next step is to install configure your Raspberry Pi 3 to boot it. All commands must be run as root, so either login as root or prefix commands with sudo.

Kernel, device overlays and kernel modules

Install kernel, DTBs, device overlays and kernel modules

First, install the kernel modules and DTBs

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

Then copy the kernel image to /boot

cp ../kernel-out/arch/arm64/boot/Image /boot/kernel8.img

Setup kernel image and DTB in config.txt

Edit /boot/config.txt and add/modify the the following configuration options. The paths are kernel version specific so adjust as needed. Also point the device_tree to the correct model, bcm2710-rpi-3-b.dtb or bcm2710-rpi-3-b-plus.dtb:

device_tree=dtbs/4.14.33-v8+/broadcom/bcm2710-rpi-3-b.dtb
overlay_prefix=dtbs/4.14.33-v8+/overlays/
kernel=kernel8.img

Reboot your device

Reboot your Pi. If all goes well and you did the above steps correctly you should now be running a 64-bit kernel on your Pi 3.

To confirm that you are on a 64-bit kernel, you can check with arch or uname, they should respond with aarch64, like this:

pi@raspberrypi:~ $ arch
aarch64

Or uname -a

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.51-v8+ #1 SMP PREEMPT Mon Oct 2 15:25:25 UTC 2017 aarch64 GNU/Linux

Going back to a 32-bit kernel

If you would like to go back to using a default 32-bit kernel, just remove or comment out (with #) the lines added to config.txt, like so:

#device_tree=dtbs/4.14.33-v8+/broadcom/bcm2710-rpi-3-b.dtb
#overlay_prefix=dtbs/4.14.33-v8+/overlays/
#kernel=kernel8.img

And either set

kernel=kernel7.img

or rename/remove the kernel8.img to something else, as otherwise it will still be used as default. Then reboot your Pi and you should be running the stock 32-bit kernel again.

Problems and issues with 64-bit

The 64-bit Raspberry Pi kernel is not yet complete. There are still some issues with device support.

Silence kernel warnings about deprecated instructions

(This seems to have been fixed in 4.14!)

The 64-bit ARM ABI deprecates some instructions that are still used in the 32-bit userland binaries. The kernel log will be flooded with messages about this, to silence them run:

echo 2 >/proc/sys/abi/setend
echo 2 >/proc/sys/abi/cp15_barrier

These settings can be put in /etc/sysctl.conf like so:

abi.cp15_barrier = 2
abi.setend = 2

Unfortunately there seems to be race condition or timing issue in the kernel with disabling emulation and enabling instructon support as booting will stall so right now this is not a good option.