From 3f9e671fedd54b4a332e5a93e156489600203fad Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Thu, 21 Oct 2021 16:05:00 +0200 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 4/4] 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