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 (11/2020)

Random notes

U-boot

Raspberry PI 4 8G

Other distros

Raspbian Raspberry Pi OS

Ubuntu

openSUSE

Upstream kernel

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://www.suse.com/media/article/UEFI_on_Top_of_U-Boot.pdf

Network boot

Some info at http://lig-membres.imag.fr/duble/software/raspberry-pi-netboot/

Various technical tips

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/
Red: +5V.
Green: Tx.
White : Rx.
Black: GND.

=>
black on GND,
white on TXD (GPIO 14)
Green on RXD (GPIO 15)

add enable_uart=1 to /boot/config.txt

then screen /dev/ttyUSB0 115200

monitor DHCP traffic using tcpdump

tcpdump -i eth0 -pvn port 67 and port 68

bluetooth

needs a firmware:

wget -O /lib/firmware/brcm/BCM4345C5.hcd https://github.com/armbian/firmware/raw/master/brcm/BCM4345C5.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

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.

Copy your vmlinuz file from /boot to /boot/firmware/ Copy the dtb for your kernel from /usr/lib to /boot/firmware/ Copy the dtb overlays for your kernel to /boot/firmware/

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 11/2020):

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