Raspberry Pi4 64 Bit Install

The Raspberry Pi 4 has been out for a few months and already the community has got everything working in 64-bit mode.

Curious users need to be familiar with the use of a cross toolchain or have access to another armv8a system to build a 64-bit kernel for the Pi 4.

What works
Everything.

Not tested

 * Analogue Video Output
 * Analogue Audio Output
 * Camera
 * Screen

Installation method
You may cross compile the kernel as described below, but I suggest installing qemu with static aarch64 user emulation and then treating it as a standard Gentoo installation, following similar to the AMD64 Handbook after taking into account the rest of the Pi specific notes on this page, copying over to the  after unpacking the ARM64 stage 3.

Pi specific: it needs a fat32 partition to boot from, and it does not use a regular bootloader.

The Pi 4 kernel
Get the aarch64-unknown-linux-gnu cross toolchain.

To cross compile the kernel:

Check the other kernel configuration settings given in configure the kernel.

Kernel tweaks
The Pi 4 USB 3 supports USB Attached SCSI (CONFIG_USB_UAS). Unlike bulk mode, it allows commands to USB storage devices to be overlapped. Enable USB Attached SCSI in the kernel if a USB3 storage device will be used.

The default CPU governor (CPU_FREQ_DEFAULT_GOV) is powersave. This runs the CRU at 600MHz all he time. CPU governors can be controlled in /proc or the default CPU governor can be changed to be ondemand.

Power Over Ethernet requires a .dto file to be loaded as well as kernel support.

The 4G RAM Pi 4 can build the 64 bit kernel in about an hour but a 64 bit toolchain is required, so the very first kernel cannot be built natively on the Pi.

Build and install the kernel
Build and install the kernel, device tree, and kernel modules an described in Raspberry Pi 3 article.

Build and install the device tree and overlays by running make dtb, then copy the resulting device tree and overlay files to /boot

Note, that the dtb may change during kernel updates, remember to keep updating them when you update the rest of the kernel.

In order to install the kernel on a Pi 400, install the relative device tree

Install the firmware
All the firmware needed to boot the Pi is found in the package:

/boot/config.txt
The following options may or may not be useful and are unchanged from earlier versions of the Raspberry Pi.

Note as well there is a new alternative audio mode that does not use the audio=on dtparamater.

/boot/cmdline.txt
Take this time to review and edit file to point to the root file system.

Note that rootfstype is not necessarily needed and that elevator=deadline has no effect on recent kernels as well. console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Odds and Ends

microSD trim/discard
The microSD interface supports the trim command:

If you have a suitable microSD card, consider adding fstrim to a weekly or monthly cron job.

USB attached SCSI
The USB3 interface appears to support the kernels UAS (USB Attached SCSI) option. It is harmless to enable, so enabling it in the kernel is a good idea ( USB_UAS ):

WiFi
WiFi needs three firmware files from in :

brcmfmac43455-sdio.bin brcmfmac43455-sdio.clm_blob brcmfmac43455-sdio.txt

Which is almost but not quite the same as the Pi3. The catch is in where  produces different results for the Pi3 and Pi4 files.

The Pi4 version returns boardflags3=0x44200100 The Pi3 version returns boardflags3=0x48200100

With the wrong brcmfmac43455-sdio.txt file, bluetooth will work but not WiFi.

These files, including the Pi 4 version of above file, are found in, to install it you'll also need to install with the savedconfig USE flag and remove the conflicting files from the saved configuration, and then remerge linux-firmware to apply the new de-conflicted saved configuration:

/lib/firmware/brcm/brcmfmac43430-sdio.bin /lib/firmware/brcm/brcmfmac43430-sdio.txt /lib/firmware/brcm/brcmfmac43436-sdio.bin /lib/firmware/brcm/brcmfmac43436-sdio.clm_blob /lib/firmware/brcm/brcmfmac43436-sdio.txt /lib/firmware/brcm/brcmfmac43455-sdio.bin /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob /lib/firmware/brcm/brcmfmac43455-sdio.txt /lib/firmware/brcm/brcmfmac43456-sdio.bin /lib/firmware/brcm/brcmfmac43456-sdio.clm_blob /lib/firmware/brcm/brcmfmac43456-sdio.txt

EEProm updates
provides the eeprom files and the updater, and as well as a service to check and apply the updates.

There are 3 release channels of firmware updates:


 * critical - Default - rarely updated
 * stable - Updated when new/advanced features have been successfully beta tested.
 * beta - New or experimental features are tested here first.

To configure which release channel you'd like the updater service to follow, edit.

Power over Ethernet
The Pi3b PoE HAT will power the P4 and a USB SSD.

Fan control works.

CFLAGS
CFLAGS="-march=armv8-a+crc+simd -mtune=cortex-a72 -ftree-vectorize -O2 -pipe -fomit-frame-pointer"

Using. Cortex-A72 mandatorily supports  and. But no crypto extension on BCM2835/RPi4. Adding  and   to utilize more registers.

gcc-6.x allows the use of  but that will prevent the use of distcc. The above is the same as gcc-6.3 would set for  anyway.

USB attached SSD
Users with USB3 attached SSDs may have noticed that trim is not supported. It is a feature of USB storage that trim is disabled by default. Trim can be enabled with mixed success. Only USB3 is supported and the USB3 to SSD bridge device must be able to pass the trim command.

One other thing to note, the Raspberry pi currently only supports booting from usb mass storage devices (including external hard drives) that have a 512 byte logical sector size. You may need to reformat (with the drive manufacturer's utility) them to enable 512 byte emulation.

Acknowledgements
NeddySeagoon for taking over maintenance and upstreaming many ebuilds from sakaki's overlay after sakaki's retirement ( Neddy's fork )

sakaki's topic on the [//www.raspberrypi.org/forums/viewtopic.php?p=1491136 Raspberry Pi forums]

All the contributors to [//github.com/raspberrypi/linux/issues/3032 issue 3032] on the Raspberry Pi GitHub repository.