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.
Everything that was tested. Read the next paragraph about what is untested.
- Analogue Video Output
- Analogue Audio Output
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 /usr/bin/qemu-aarch64 to the /mnt/gentoo/usr/bin/ 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:
ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make bcm2711_defconfig
Check the other kernel configuration settings given in configure the kernel.
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 CPU 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 dtbs, then copy the resulting device tree and overlay files to /boot
ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make dtbs
mkdir -p /mnt/gentoo/boot/overlays
cp -vR arch/arm64/boot/dts/overlays/*.dtbo /mnt/gentoo/boot/overlays
cp -v arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb /mnt/gentoo/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
cp -v arch/arm64/boot/dts/broadcom/bcm2711-rpi-400.dtb /mnt/gentoo/boot/
Install the firmware
All the firmware needed to boot the Pi is found in the sys-boot/raspberrypi-firmware package:
emerge --ask sys-boot/raspberrypi-firmware
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.
# have a properly sized image disable_overscan=1 # for sound over HDMI hdmi_drive=2 # Enable audio (loads snd_bcm2835) dtparam=audio=on
Take this time to review and edit /boot/cmdline.txt 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
/dev/sdk1 follows the Raspberry Pi 3 64 bit Install guide example.
Odds and Ends
The microSD interface supports the trim command:
Pi4_~arm64 ~ #
/boot: 7.7 GiB (8250073088 bytes) trimmed on /dev/mmcblk0p1
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):
<*> USB Attached SCSI
WiFi needs three firmware files from 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 brcmfmac43455-sdio.txt where grep boardflags3 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 sys-firmware/raspberrypi-wifi-ucode, to install it you'll also need to install sys-kernel/linux-firmware 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
dev-embedded/rpi-eeprom 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 /etc/conf.d/rpi-eeprom-update.
Power over Ethernet
The Pi3b PoE HAT will power the P4 and a USB SSD.
Fan control works.
CFLAGS="-march=armv8-a+crc -mtune=cortex-a72 -ftree-vectorize -O2 -pipe -fomit-frame-pointer"
-mtune=cortex-a72. Cortex-A72 mandatorily supports
+simd. However, specifying
+simd on CFLAGS is not necessary, it is on by default. But no crypto extension on BCM2835/RPi4. Adding
-fomit-frame-pointer to utilize more registers.
gcc-6.x allows the use of
-march=native but that will prevent the use of distcc. The above is
the same as gcc-6.3 would set for
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.
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 Raspberry Pi forums
All the contributors to issue 3032 on the Raspberry Pi GitHub repository.