#language en <> This page provides details about Raspberry Pi 4. You probably want to read the [[RaspberryPi]] page first (and maybe look at the images available at [[https://raspi.debian.net/]]), and then decide whether you want to read this page. = Current status (2021-06) = * Debian bullseye (and buster-backports) kernel (Linux 5.10) supports most of what is required (except hardware-accelerated 3D graphics). == Pulse Audio and Sound don't work as of 2021-04-07 == You won't get sound using pulse audio using and the current debian installs using HDMI or A/V. = Boot and Installing Debian on the Raspberry PI 4 = == Tested and Daily Debian Images == We are automatically building [[https://wiki.debian.org/RaspberryPiImages|daily images]] to run on all of the [[RaspberryPi|Raspberry Pi]] models, including the Raspberry Pi 4. There are also Tested Images that are verified to work and have their issues documented. This is currently the recommended way of using Debian on the Raspberry Pi 4 == Using EFI Firmware and the regular Debian Installer == The [[https://github.com/pftf|Pi Firmware Task Force]] works on an [[https://github.com/pftf/RPi4|SBBR-compliant (UEFI+ACPI) AArch64 firmware for the Raspberry Pi 4]] which allows the normal, vanilla [[https://cdimage.debian.org/cdimage/release/11.0.0/arm64/iso-cd/|Debian aarch64 installer]] to run and install a working Debian bullseye on the Raspberry PI. Instructions to doing so are [[https://www.raspberrypi.org/forums/viewtopic.php?t=282839|here]] and [[https://flosslinuxblog.blogspot.com/2021/08/vanilla-debian-on-raspberry-pi-4-with.html|here.]] The installed system does not use the Device Tree approach that is common on the ARM platforms to detect and enumerate hardware. Instead, vanilla ACPI is used like this is the case on the normal PC/Intel architecture. This might cause Raspberry Pi device drivers to support ACPI which some of today's device drivers (2021-06) don't do. If hardware that works on a device tree system doesn't work on an EFI/ACPI system, it might be possible that the device driver doesn't support ACPI yet. Unfortunately, the most prominent driver suffering from this lack of ACPI support is vc4, making this installation method unsuitable for systems that need a graphical console. 2021-06, the EFI firmware limits the usable memory amount to 3 GB to cater for a hardware issue that has been worked around in the recent kernels that Debian ships in bullseye and buster-backports. The option to enable the full memory is accessible in the EFI Setup at system startup: Device Manager → Raspberry Pi Configuration → Advanced Configuration and set Limit RAM to 3 GB to . This setting is safe for those kernels. == Booting from USB == Earlier versions of the Raspberry Pi 4 can only boot from the Micro SD card. Since April 2020, a boot loader EEPROM that can also boot from USB storage and UASP media is used. The EEPROM can be updated with media from [[https://github.com/raspberrypi/rpi-eeprom/releases|here.]] == Boot Methods == There are several ways to boot... === Directly load kernel and initramfs from RPI firmware === That's what the Debian images currently do. === RPI firmware loads u-boot, which loads kernel/initramfs === That's what the Ubuntu images do, and is promising. FixMe {{{ # https://a-delacruz.github.io/ubuntu/rpi3-setup-64bit-uboot.html # mkimage -A arm64 -O linux -T script -d boot.txt boot.scr # vmlinuz and initrd must be converted. See https://linux-sunxi.org/Initial_Ramdisk or https://andrei.gherzan.ro/linux/uboot-on-rpi/ # mkimage -A arm64 -T ramdisk -C none -n uInitrd -d initrd.img uInitrd # mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n "Linux kernel" -d vmlinuz uImage #setenv bootargs earlyprintk console=ttyS0,115200 console=tty1 root=LABEL=writable rw #fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs }}} === RPI firmware loads u-boot, which loads grub using EFI, which loads kernel/initramfs === That's what OpenSUSE does. See [[https://web.archive.org/web/20200731045618/https://www.suse.com/media/article/UEFI_on_Top_of_U-Boot.pdf|https://www.suse.com/media/article/UEFI_on_Top_of_U-Boot.pdf on archive.org]] === Tianocore EDK II on RPI4 is used to boot iPXE as a Network Boot/Installer for Debian === This method provides a UEFI Network boot environment with a user GUI. SD Card or USB is not required. Requirements: * Post Sept 2020 eeprom/firmware update. * iPXE Compiled for arm64-efi. * Tiancore EDK II from GitHub compiled for RPI4. * Debian Testing/Bullseye on Arm64 === Tianocore EDK II on RPI4 is used to boot Debian === This method provides a UEFI boot environment on the SD card with a user GUI. * Post Sept 2020 eeprom/firmware update. * Tiancore EDK II from GitHub compiled for RPI4. * Debian Testing/Bullseye on Arm64 === Network boot === Some info at http://lig-membres.imag.fr/duble/software/raspberry-pi-netboot/ === U-boot === * U-boot patches for USB support exists and are integrated upstream since u-boot v2020.10 * https://lists.denx.de/pipermail/u-boot/2020-May/413505.html * USB support * Included in u-boot v2020.10 * https://lists.denx.de/pipermail/u-boot/2020-June/417996.html * USB firmware reloader - perhaps only needed for more recent rpi4's ie 8GB version * Included in u-boot v2020.10 * For USB keyboard support need above and the line "CONFIG_USB_KEYBOARD=y" added to configs/rpi_4_defconfig * Included in u-boot v2020.10 = Hardware Information and Issues = * Chip is Broadcom BCM2711 https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/README.md == Raspberry PI 4 8G == * There was an issue with USB, but that was initially fixed in kernel 5.8 and better fixed in 5.10. * So the kernels in Debian Bullseye (and newer) and Buster-backports (with kernel 5.10+) don't suffer from this issue. = Upstream kernel = * Upstream mailing list: http://lists.infradead.org/pipermail/linux-rpi-kernel/ * Issue to track progress of support: https://github.com/lategoodbye/rpi-zero/issues/43 * Many patches already landed in the vanilla kernel, mainly from Nicolas Saenz Julienne. https://github.com/torvalds/linux/search?q=repo%3Atorvalds%2Flinux+Nicolas+Saenz+Julienne&unscoped_q=repo%3Atorvalds%2Flinux+Nicolas+Saenz+Julienne&type=Commits * https://git.kernel.org/pub/scm/linux/kernel/git/nsaenz/linux-rpi.git = Other distros = == Raspberry Pi OS (former Raspbian) == * ships a 64bit image and a lite version now, kernel 5.10, Debian bullseye as base * https://downloads.raspberrypi.org/raspios_arm64/release_notes.txt == Ubuntu == * both armhf and arm64 images. See https://ubuntu.com/download/raspberry-pi/ * Boots using u-boot and a custom 5.3.0 kernel. Serial console, HDMI, network all work. Very nice. * The three important pieces seem to be: * the linux-firmware-raspi2 source package. Maybe equivalent to Debian's raspi-firmware source package? * the u-boot-rpi package (different from Debian's) * the kernel (linux-raspi2 source package https://launchpad.net/ubuntu/eoan/+source/linux-raspi2 ) == openSUSE == * https://en.opensuse.org/HCL:Raspberry_Pi4 * boots using u-boot -> grub -> Linux 5.4.14 == Alpine Linux == * https://www.alpinelinux.org/downloads/ * images for arm64, armv7 and armhf * "includes Raspberry Pi kernel" = Various technical tips = == changing command line == At least in bullseye, raspi-firmware overwrites /boot/firmware/cmdline.txt . This is done on every call of update-initramfs. There is a config file /etc/default/raspi-firmware to adjust the behavior. Extra command line options should go into /etc/default/raspi-extra-cmdline . == changing kernel version to boot == On the VFAT partition, change the entries in config.txt to the kernel and initramfs version. E.g., {{{ kernel=vmlinuz-5.16.0-6-arm64 initramfs initrd.img-5.16.0-6-arm64 }}} == loop-mounting images == {{{ # fdisk -l 2020-02-13-raspbian-buster-lite.img Disk 2020-02-13-raspbian-buster-lite.img: 1,7 GiB, 1849688064 bytes, 3612672 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: 0x738a4d67 Device Boot Start End Sectors Size Id Type 2020-02-13-raspbian-buster-lite.img1 8192 532479 524288 256M c W95 FAT32 (LBA) 2020-02-13-raspbian-buster-lite.img2 532480 3612671 3080192 1,5G 83 Linux # mount -o loop,offset=$((8192*512)) 2020-02-13-raspbian-buster-lite.img mountpoint }}} == serial console == [[https://www.raspberrypi.org/documentation/usage/gpio/|https://www.raspberrypi.org/documentation/usage/gpio/]] || Red || +5V || || Green || Tx || || White || Rx || || Black || GND || || Black || GND || || || White || TXD || GPIO 14 || || Green || RXD || GPIO 15 || add {{{enable_uart=1}}} to {{{/boot/config.txt}}} then connect to the serial port of your client system: * {{{screen /dev/ttyUSB0 115200}}} or use * DebianPkg:ser2net or * DebianPkg:cereal On a Raspberry Pi 4B 4G with bullseye/linux 5.10.13-1, the serial stopped working after the vc4 module was loaded. As a workaround, add module_blacklist=vc4 to the command line to make it work == monitor DHCP traffic using tcpdump == {{{ tcpdump -i eth0 -pvn port 67 and port 68 }}} == Root file system on a USB disk == As of bullseye/linux 5.10.13-1, the xhci/USB3 controller is not initialized until the reset_raspberrypi is loaded. This is by default not included in the initramdisk, making it impossible to use a usb disk as root filesystem. To make it work create an updated initramdisk by booting the Raspberry Pi from a MicroSD card or via network with the same kernel. Add `reset_raspberrypi` to `/etc/initramfs-tools/modules` of the running file system and run `update-initramfs -k all -u` (DebianBug:977694) Then copy the new `/boot/initrd.img-{kernel}-amd64` to same location on your USB disk. (Editor's Note 2021-06: This does not seem to be case for EFI installs in as long as the flashed bootloader is current) == USB 3 enclosures == Many USB3 enclosures (especially with jmicron chip) do not work with uas. To make them work find out the device/vendor id with lsusb and add usb-storage.quirks=152d:9561:u to your kernel command line (replace 152d:9561 with your device/vendor id). == Bluetooth == needs some firmware: {{{ wget -O /lib/firmware/brcm/BCM4345C5.hcd https://github.com/armbian/firmware/raw/master/brcm/BCM4345C5.hcd wget -O /lib/firmware/brcm/BCM4345C0.hcd https://github.com/armbian/firmware/raw/master/BCM4345C0.hcd }}} == Build a kernel as a Debian package == See [[BuildADebianKernelPackage]] To disable DEBUG_INFO before build: scripts/config --disable DEBUG_INFO https://stackoverflow.com/questions/7505164/how-do-you-non-interactively-turn-on-features-in-a-linux-kernel-config-file/39440863#39440863 With some boot methods, vmlinuz must be decompressed in /boot/firmware, or RPI4 won't boot. (zcat vmlinuz-... > vmlinux-... ; then point config.txt to vmlinuz) === Building a custom kernel from upstream (mainline) sources === {{{ # disable debug info scripts/config --disable DEBUG_INFO # build uncompressed kernel sed -i '/KBUILD_IMAGE/ s/.gz//' arch/arm64/Makefile # build debs make -j `nproc` bindeb-pkg }}} === Building a custom kernel from github.com/raspberrypi/linux sources === {{{ # generate config make bcm2711_defconfig # disable debug info scripts/config --disable DEBUG_INFO # build uncompressed kernel sed -i '/KBUILD_IMAGE/ s/.gz//' arch/arm64/Makefile # build debs make -j `nproc` bindeb-pkg }}} Then copy and install the generated deb. After installing: * Copy your vmlinuz file from /boot to /boot/firmware/ * Copy the dtb for your kernel from /usr/lib/linux-image-(...)/broadcom/ to /boot/firmware/ * Copy the dtb overlays for your kernel from /usr/lib/linux-image-(...)/overlays/ to /boot/firmware/overlays Example config.txt: {{{ [pi4] enable_uart=1 # Enable DRM VC4 V3D driver on top of the dispmanx display stack #dtoverlay=vc4-fkms-v3d max_framebuffers=2 arm_64bit=1 kernel=vmlinuz }}} (You don't need an initrd) Example cmdline.txt: {{{ console=tty1 console=ttyS0,115200 root=/dev/mmcblk0p2 rw elevator=deadline fsck.repair=yes net.ifnames=0 rootwait }}} == Accelerated 3D graphics on Debian == To get accelerated 3D graphics on Debian, you will need the following (status on 2021-02): * Run Debian testing, because Mesa is Debian stable is not recent enough * Build a kernel from github.com/raspberrypi/linux as documented above Example config.txt: {{{ arm_64bit=1 enable_uart=1 upstream_kernel=1 #http://lists.infradead.org/pipermail/linux-rpi-kernel/2020-November/007906.html disable_fw_kms_setup=1 kernel=vmlinuz initramfs initrd.img }}} Example cmdline.txt: {{{ console=tty0 console=ttyS1,115200 root=/dev/mmcblk1p2 rw fsck.repair=yes net.ifnames=0 rootwait }}} (Editor's Note 2021-06: Is a running glxgears and present /sys/class/drm/card0 a sure sign of 3D acceleration working?) == GPIO support == All examples below are based on the "blinking led" schema. See https://pimylifeup.com/raspberry-pi-gpio/ The Debian kernel is compiled with CONFIG_STRICT_DEVMEM=y. You need to add iomem=relaxed to the kernel command line (/boot/firmware/cmdline.txt) to allow mmap on /dev/mem. === using RPi.GPIO (python3-rpi.gpio) === RPi.GPIO doesn't support the RPI 4 currently. See this bug https://sourceforge.net/p/raspberry-gpio-python/tickets/191/ (with a patch that makes it working). Debian bug: DebianBug:976114 === using GPIOZERO === Debian has gpiozero version 1.4.1, which doesn't work with the RPI 4. After fixing RPi.GPIO, gpiozero 1.5.1 (current git) works. Debian bug: DebianBug:976118