From 7aed761507b2ca7d04aee1fb75b662522922a587 Mon Sep 17 00:00:00 2001 From: Diederik de Haas Date: Thu, 9 Sep 2021 00:23:05 +0200 Subject: [PATCH 01/10] Change 'sed' separator to '#'. For (at least) rpi4 Buster target, it gets replaced (again) by a package from backports, resulting in /backports, making the sed statement invalid. That isn't the case when using '#' as separator. Signed-off-by: Diederik de Haas --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d41c60c..f3830a0 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ raspi_base_buster.yaml: raspi_master.yaml sed "s/__FIRMWARE_PKG__/raspi3-firmware/" | \ sed "s/__RELEASE__/buster/" |\ sed "s/__SECURITY_SUITE__/buster\/updates/" |\ - sed "s/__FIX_FIRMWARE_PKG_NAME__/sed -i s\/raspi-firmware\/raspi3-firmware\/ \$${ROOT?}\/etc\/systemd\/system\/rpi-reconfigure-raspi-firmware.service/" |\ + sed "s/__FIX_FIRMWARE_PKG_NAME__/sed -i s#raspi-firmware#raspi3-firmware# \$${ROOT?}\/etc\/systemd\/system\/rpi-reconfigure-raspi-firmware.service/" |\ grep -v '__EXTRA_SHELL_CMDS__' > $@ raspi_1_buster.yaml: raspi_base_buster.yaml From 26a7de63b0bb3de1b5d0c4d0529240721c322dbb Mon Sep 17 00:00:00 2001 From: Diederik de Haas Date: Mon, 23 Aug 2021 20:48:17 +0200 Subject: [PATCH 02/10] Fix machine-id mechanism for Buster. The logic wrt /etc/machine-id changed between Buster and Bullseye. While on Bullseye the file should not exist, on Buster the file must exist, but be empty, in order to generate a new machine-id on first boot. It seems that /var/lib/dbus/machine-id is a symlink to /etc/machine-id on Buster, while a separate file on Bullseye, so nothing needs to be done with that file/symlink. Signed-off-by: Diederik de Haas --- Makefile | 1 + raspi_master.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Makefile b/Makefile index f3830a0..f42d38c 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,7 @@ raspi_base_bullseye.yaml: raspi_master.yaml cat raspi_master.yaml | \ sed "s/__RELEASE__/bullseye/" |\ sed "s/__FIRMWARE_PKG__/raspi-firmware/" | \ + sed "/touch \/etc\/machine-id/d" | \ grep -v "__OTHER_APT_ENABLE__" |\ grep -v "__FIX_FIRMWARE_PKG_NAME__" |\ sed "s/__SECURITY_SUITE__/bullseye-security/" > $@ diff --git a/raspi_master.yaml b/raspi_master.yaml index d8ffae6..9a8cb3f 100644 --- a/raspi_master.yaml +++ b/raspi_master.yaml @@ -161,6 +161,9 @@ steps: # populated during installation. # # Note this will also trigger ConditionFirstBoot=yes for systemd. + # On Buster, /etc/machine-id should be an emtpy file, not an absent file + # On Bullseye, /etc/machine-id should not exist in an image - chroot: / shell: | rm -f /etc/machine-id /var/lib/dbus/machine-id + touch /etc/machine-id From 611b5c6d5cd0ac0b0615f3300beb2415b2f99fe0 Mon Sep 17 00:00:00 2001 From: Diederik de Haas Date: Tue, 24 Aug 2021 01:55:16 +0200 Subject: [PATCH 03/10] Fix missing firmware error on RPi 3 Buster. The RPi 3 wants an extra firmware file which isn't available in normal Buster, but is available in buster-backports, so install that version of firmware-brcm80211. Note that dmesg shows it as an error, but wifi should work without it. Signed-off-by: Diederik de Haas --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f42d38c..239b96f 100644 --- a/Makefile +++ b/Makefile @@ -55,10 +55,10 @@ raspi_2_buster.yaml: raspi_base_buster.yaml raspi_3_buster.yaml: raspi_base_buster.yaml cat raspi_base_buster.yaml | sed "s/__ARCH__/arm64/" | \ sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \ - sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \ + sed "s/__EXTRA_PKGS__/- firmware-brcm80211\/buster-backports/" | \ sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" |\ sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\ - sed "s/__OTHER_APT_ENABLE__//" |\ + sed "s/__OTHER_APT_ENABLE__/# raspi 3 needs firmware-brcm80211 newer than buster's for wifi\n deb http:\/\/deb.debian.org\/debian\/ buster-backports main contrib non-free/" |\ sed "s/__HOST__/rpi3/" |\ grep -v '__EXTRA_SHELL_CMDS__' > $@ From 60513d46f6f687a2582be3b9a9589ea6259813b9 Mon Sep 17 00:00:00 2001 From: Diederik de Haas Date: Thu, 9 Sep 2021 01:00:59 +0200 Subject: [PATCH 04/10] Fix _clean_shasums to also remove *.img.sha256. Commit 422a0d60 fixed the img.sha256 target itself, but it didn't update the corresponding clean variant, so add that too. Signed-off-by: Diederik de Haas --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 239b96f..9bc4569 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ _clean_xzimages: _clean_bmaps: rm -f $(addsuffix .img.bmap,$(platforms)) _clean_shasums: - rm -f $(addsuffix .sha256,$(platforms)) $(addsuffix .img.xz.sha256,$(platforms)) + rm -f $(addsuffix .img.sha256,$(platforms)) $(addsuffix .img.xz.sha256,$(platforms)) _clean_logs: rm -f $(addsuffix .log,$(platforms)) _clean_tarballs: From 3f9e671fedd54b4a332e5a93e156489600203fad Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Thu, 21 Oct 2021 16:05:00 +0200 Subject: [PATCH 05/10] Drop extraneous sed-ing of cma= in z50-raspi-firmware hook for Pi 4. For starters, the pattern no longer exists since this commit in raspi-firmware: commit dd456f4746a800ac85bdf376b5efcdb1fac133de Author: Gunnar Wolf Date: Wed Aug 5 12:02:57 2020 -0500 Don't set CMA in RPi4 unless specified expressly and there's now a SET_CMA variable instead. And more importantly, the Pi 4 gets appropriate treatment thanks to this commit (empty SET_CMA), which the Pi Compute Module 4 might get soon too (see #996937). This commit first shipped in debian/1.20200601-2, and we are using one of those at the moment for the Pi 4 family: - 1.20210303+ds-2 (bullseye) - 1.20210303+ds-2~bpo10+1 (buster-backports) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9bc4569..31a1f14 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ raspi_4_buster.yaml: raspi_base_buster.yaml cat raspi_base_buster.yaml | sed "s/__ARCH__/arm64/" | \ sed "s#raspi3-firmware#raspi-firmware/buster-backports#" | \ sed "s#apt-get update#echo 'APT::Default-Release \"buster\";' > /etc/apt/apt.conf\n apt-get update#" | \ - sed "s#\(RASPIROOT.*cmdline.txt\)#\1\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt\n sed -i 's/cma=\\\$$CMA //' /etc/kernel/postinst.d/z50-raspi-firmware#" | \ + sed "s#\(RASPIROOT.*cmdline.txt\)#\1\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt#" | \ sed "s/__LINUX_IMAGE__/linux-image-arm64\/buster-backports/" | \ sed "s/__EXTRA_PKGS__/- firmware-brcm80211\/buster-backports/" | \ sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" |\ @@ -113,7 +113,7 @@ raspi_3_bullseye.yaml: raspi_base_bullseye.yaml raspi_4_bullseye.yaml: raspi_base_bullseye.yaml cat raspi_base_bullseye.yaml | sed "s/__ARCH__/arm64/" | \ - sed "s#\(RASPIROOT.*cmdline.txt\)#\1\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt\n sed -i 's/cma=\\\$$CMA //' /etc/kernel/postinst.d/z50-raspi-firmware#" | \ + sed "s#\(RASPIROOT.*cmdline.txt\)#\1\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt#" | \ sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \ sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \ sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" |\ From 46ead8a58dcc3e267627e329cd73f2a1013a7003 Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Thu, 21 Oct 2021 16:32:55 +0200 Subject: [PATCH 06/10] Improve pattern when replacing root=/dev/mmcblk0p2 in cmdline.txt Let's make it clear what we are replacing. --- raspi_master.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raspi_master.yaml b/raspi_master.yaml index 9a8cb3f..41b1a90 100644 --- a/raspi_master.yaml +++ b/raspi_master.yaml @@ -144,7 +144,7 @@ steps: - chroot: / shell: | sed -i 's/^/console=__SERIAL_CONSOLE__ /' /boot/firmware/cmdline.txt - sed -i 's/.dev.mmcblk0p2/LABEL=RASPIROOT/' /boot/firmware/cmdline.txt + sed -i 's#root=/dev/mmcblk0p2#root=LABEL=RASPIROOT#' /boot/firmware/cmdline.txt # TODO(https://github.com/larswirzenius/vmdb2/issues/24): remove once vmdb # clears /etc/resolv.conf on its own. From f89f71560d2ca1bd60d97dbb26b89782657d56ae Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Thu, 21 Oct 2021 16:35:40 +0200 Subject: [PATCH 07/10] Make label-based booting persistent (see: #996915). Without this, the block device holding the root filesystem would be resolved at the first boot when reconfiguring raspi-firmware (e.g. /dev/mmcblk1p2) which would then make the system fail to boot if it ever shows up under a different name (e.g. /dev/mmcblk0p2). Set ROOTPART parameter explicitly to stick to label-based booting. --- raspi_master.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/raspi_master.yaml b/raspi_master.yaml index 41b1a90..e4383a0 100644 --- a/raspi_master.yaml +++ b/raspi_master.yaml @@ -140,11 +140,13 @@ steps: # the partition labeled raspiroot instead of forcing it to mmcblk0p2 # # These changes will be overwritten after the hardware is probed - # after dpkg reconfigures raspi-firmware (upon first boot). + # after dpkg reconfigures raspi-firmware (upon first boot), so make + # sure we don't lose label-based booting. - chroot: / shell: | sed -i 's/^/console=__SERIAL_CONSOLE__ /' /boot/firmware/cmdline.txt sed -i 's#root=/dev/mmcblk0p2#root=LABEL=RASPIROOT#' /boot/firmware/cmdline.txt + sed -i 's/^#ROOTPART=.*/ROOTPART=LABEL=RASPIROOT/' /etc/default/raspi-firmware # TODO(https://github.com/larswirzenius/vmdb2/issues/24): remove once vmdb # clears /etc/resolv.conf on its own. From 6251ebfbe0808d5c792f12891f7d4f961cd6da8e Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Thu, 21 Oct 2021 16:47:55 +0200 Subject: [PATCH 08/10] Move the console= parameter for the serial console. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://salsa.debian.org/raspi-team/image-specs/-/issues/57 for detailed background. Summary, e.g. on the Pi 4: - fresh build and first boot means: console=ttyS1,115200 console=tty0 - after dpkg-reconfigure raspi-firmware has run, with the default settings: console=tty0 console=ttyS1,115200 Having some consistency across boots seems desirable (esp. when the Pi fails to boot and the hints are on a serial console which might not be wired), so insert the console= parameter for the serial console right before the root= parameter. Currently, the /etc/kernel/postinst.d/z50-raspi-firmware hook uses: ${pre_cmdline} root=$ROOTPART […] and console= parameters are inserted via ${pre_cmdline}, so inserting the serial console before root= should get us the same results. --- raspi_master.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/raspi_master.yaml b/raspi_master.yaml index e4383a0..5289525 100644 --- a/raspi_master.yaml +++ b/raspi_master.yaml @@ -137,14 +137,15 @@ steps: rm -rf /var/lib/apt/lists # Modify the kernel commandline we take from the firmware to boot from - # the partition labeled raspiroot instead of forcing it to mmcblk0p2 + # the partition labeled raspiroot instead of forcing it to mmcblk0p2. + # Also insert the serial console right before the root= parameter. # # These changes will be overwritten after the hardware is probed # after dpkg reconfigures raspi-firmware (upon first boot), so make # sure we don't lose label-based booting. - chroot: / shell: | - sed -i 's/^/console=__SERIAL_CONSOLE__ /' /boot/firmware/cmdline.txt + sed -i 's/root=/console=__SERIAL_CONSOLE__ root=/' /boot/firmware/cmdline.txt sed -i 's#root=/dev/mmcblk0p2#root=LABEL=RASPIROOT#' /boot/firmware/cmdline.txt sed -i 's/^#ROOTPART=.*/ROOTPART=LABEL=RASPIROOT/' /etc/default/raspi-firmware From 68ebe5c3858d02b5b7b0de60ad56b29481484ca7 Mon Sep 17 00:00:00 2001 From: Gunnar Wolf Date: Tue, 9 Nov 2021 23:48:29 -0600 Subject: [PATCH 09/10] Enable builds for Bookworm --- Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9bc4569..64b7327 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ all: shasums # List all the supported and built Pi platforms here. They get expanded # to names like 'raspi_2_buster.yaml' and 'raspi_3_bullseye.img.xz'. BUILD_FAMILIES := 1 2 3 4 -BUILD_RELEASES := buster bullseye +BUILD_RELEASES := buster bullseye bookworm platforms := $(foreach plat, $(BUILD_FAMILIES),$(foreach rel, $(BUILD_RELEASES), raspi_$(plat)_$(rel))) @@ -121,6 +121,51 @@ raspi_4_bullseye.yaml: raspi_base_bullseye.yaml sed "s/__HOST__/rpi_4/" |\ grep -v '__EXTRA_SHELL_CMDS__' > $@ +raspi_base_bookworm.yaml: raspi_master.yaml + cat raspi_master.yaml | \ + sed "s/__RELEASE__/bookworm/" |\ + sed "s/__FIRMWARE_PKG__/raspi-firmware/" | \ + grep -v "__OTHER_APT_ENABLE__" |\ + grep -v "__FIX_FIRMWARE_PKG_NAME__" |\ + grep -v "__SECURITY_SUITE__" > $@ + +raspi_1_bookworm.yaml: raspi_base_bookworm.yaml + cat raspi_base_bookworm.yaml | sed "s/__ARCH__/armel/" | \ + sed "s/__LINUX_IMAGE__/linux-image-rpi/" | \ + sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \ + sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-rpi\\/bcm*rpi-*.dtb/" |\ + sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" |\ + sed "s/__HOST__/rpi_1/" |\ + grep -v '__EXTRA_SHELL_CMDS__' > $@ + +raspi_2_bookworm.yaml: raspi_base_bookworm.yaml + cat raspi_base_bookworm.yaml | sed "s/__ARCH__/armhf/" | \ + sed "s/__LINUX_IMAGE__/linux-image-armmp/" | \ + grep -v "__EXTRA_PKGS__" | \ + sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-armmp\\/bcm*rpi*.dtb/" |\ + sed "s/__SERIAL_CONSOLE__/ttyAMA0,115200/" |\ + sed "s/__HOST__/rpi_2/" |\ + grep -v '__EXTRA_SHELL_CMDS__' > $@ + +raspi_3_bookworm.yaml: raspi_base_bookworm.yaml + cat raspi_base_bookworm.yaml | sed "s/__ARCH__/arm64/" | \ + sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \ + sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \ + sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" |\ + sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\ + sed "s/__HOST__/rpi_3/" |\ + grep -v '__EXTRA_SHELL_CMDS__' > $@ + +raspi_4_bookworm.yaml: raspi_base_bookworm.yaml + cat raspi_base_bookworm.yaml | sed "s/__ARCH__/arm64/" | \ + sed "s#\(RASPIROOT.*cmdline.txt\)#\1\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt\n sed -i 's/cma=\\\$$CMA //' /etc/kernel/postinst.d/z50-raspi-firmware#" | \ + sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \ + sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \ + sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" |\ + sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\ + sed "s/__HOST__/rpi_4/" |\ + grep -v '__EXTRA_SHELL_CMDS__' > $@ + %.img.sha256: %.img echo $@ sha256sum $< > $@ @@ -144,7 +189,7 @@ _ck_root: [ `whoami` = 'root' ] # Only root can summon vmdb2 ☹ _clean_yaml: - rm -f $(addsuffix .yaml,$(platforms)) raspi_base_buster.yaml raspi_base_bullseye.yaml + rm -f $(addsuffix .yaml,$(platforms)) raspi_base_buster.yaml raspi_base_bullseye.yaml raspi_base_bookworm.yaml _clean_images: rm -f $(addsuffix .img,$(platforms)) _clean_xzimages: From 2b2bb9d6d78404c53bc1ccd31e8094aa1acb2921 Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Sat, 20 Nov 2021 13:51:56 +0100 Subject: [PATCH 10/10] Drop extraneous sed-ing of cma= in z50-raspi-firmware hook for Pi 4 (bookworm). Commit 3f9e671fedd54b4a332e5a93e156489600203fad in the boot-consistency branch, which requires an extension to cover the new raspi_4_bookworm build. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5edce42..7806781 100644 --- a/Makefile +++ b/Makefile @@ -158,7 +158,7 @@ raspi_3_bookworm.yaml: raspi_base_bookworm.yaml raspi_4_bookworm.yaml: raspi_base_bookworm.yaml cat raspi_base_bookworm.yaml | sed "s/__ARCH__/arm64/" | \ - sed "s#\(RASPIROOT.*cmdline.txt\)#\1\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt\n sed -i 's/cma=\\\$$CMA //' /etc/kernel/postinst.d/z50-raspi-firmware#" | \ + sed "s#\(RASPIROOT.*cmdline.txt\)#\1\n sed -i 's/cma=64M //' /boot/firmware/cmdline.txt#" | \ sed "s/__LINUX_IMAGE__/linux-image-arm64/" | \ sed "s/__EXTRA_PKGS__/- firmware-brcm80211/" | \ sed "s/__DTB__/\\/usr\\/lib\\/linux-image-*-arm64\\/broadcom\\/bcm*rpi*.dtb/" |\