Raspberry Pi4 64 Bit Install

Overview
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 (by me)
Analogue Video Output Analogue Audio Output Camera Screen

I don't have hardware to test the camera or screen.

The Installation Method
Follow the method described in Raspberry Pi 3 64 bit Install

The Pi 4 differs in the kernel build, the /boot/config.txt content and the requirement for some code from raspberrypi/tools

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

To cross compile the kernel, start with

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

Kernel Tweaks
The Pi 4 USB 3 supports USB Attached SCSI. 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 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 install the kernel binary, install the device tree, now named and install the kernel modules.

/boot/config.txt
The following is a bare minimum /boot/config.txt arm_64bit=1 enable_gic=1 armstub=armstub8-gic.bin
 * 1) set 64 bit mode

The usual disable_overscan=1 hdmi_drive=2 dtparam=audio=on may or may not be useful and are unchanged from earlier versions of the Raspberry Pi.
 * 1) have a properly sized image
 * 1) for sound over HDMI
 * 1) Enable audio (loads snd_bcm2835)

rasberrypi/tools
Rasberrypi/tools provides which must be copied to /boot

Naturally, its in a git repo. Clone it beside the Pi Sources and Pi Firmware repos.

build the contents of

microSD trim/discard
The microSD interface supports the trim command. Pi4_~arm64 ~ # fstrim -av /boot: 7.7 GiB (8250073088 bytes) trimmed on /dev/mmcblk0p1 If you have a suitable microSD card, consider using the discard option in /etc/fstab

USB Attached SCSI
The USB3 interface appears to support the kernels UAS (USB Attached SCSI) option. Its harmless to enable. Unfortunately, my USB3 to SATA cable does not work with UAS. Enable it in the kernel as its harmless. Search for USB_UAS <*>  USB Attached SCSI

WiFi
WiFi needs three firmware files in /lib/firmware/brcm/ 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 works but not WiFi.

Firmware Updates
The Pi4 has firmware. It no longer uses bootcode.bin, even if its present.

Be sure to keep your firmware up to date. New features are promised and optimisations like [//cnx-software.com/2019/06/29/new-raspberry-pi-4-vli-firmware-lowers-temperature/ Power Reduction] are already available.

There is a small trap for the unwary. The firmware updater program as distributed is an arm 32 bit program. The good news is that Sakakis [//github.com/sakaki-/genpi64-overlay/ genpi64 overlay] has all the bits required to build an arm64 version in the normal Gentoo fashion. media-libs/raspberrypi-userland::genpi64 dev-embedded/rpi4-eeprom-images::genpi64 dev-embedded/rpi4-eeprom-updater::genpi64
 * 1) Required to update Pi4 firmware.

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

Fan control works.

Acknowledgements
sakakis 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 repo