Fixes to almost-ensure there is a working serial console

Why almost? Because Rpi0w uses ttyS1 instead of ttyAMA0 desipte being part of the RPi1 family...
...But it will work fine for the _second_ boot onwards, if things go according to plan.
For all other RPi models, it should work from the first boot on.
This commit is contained in:
Gunnar Wolf 2021-02-18 11:31:23 -06:00
parent 791dfacde6
commit a146c3a7f7
3 changed files with 30 additions and 2 deletions

View File

@ -25,6 +25,7 @@ raspi_1_buster.yaml: raspi_base_buster.yaml
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__/ttyACM0,115200/" |\
grep -v "__OTHER_APT_ENABLE__" |\
sed "s/__HOST__/rpi1/" > $@
@ -33,6 +34,7 @@ raspi_2_buster.yaml: raspi_base_buster.yaml
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__/ttyACM0,115200/" |\
sed "s/__OTHER_APT_ENABLE__//" |\
sed "s/__HOST__/rpi2/" > $@
@ -41,6 +43,7 @@ raspi_3_buster.yaml: raspi_base_buster.yaml
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/__OTHER_APT_ENABLE__//" |\
sed "s/__HOST__/rpi3/" > $@
@ -52,6 +55,7 @@ raspi_4_buster.yaml: raspi_base_buster.yaml
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/" |\
sed "s/__SERIAL_CONSOLE__/ttyS1,115200/" |\
sed "s/__OTHER_APT_ENABLE__/deb http:\/\/deb.debian.org\/debian\/ buster-backports main contrib non-free # raspi 4 needs a kernel and raspi-firmware newer than buster's/" |\
sed "s/__HOST__/rpi4/" > $@
@ -67,6 +71,7 @@ raspi_1_bullseye.yaml: raspi_base_bullseye.yaml
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__/ttyACM0,115200/" |\
sed "s/__HOST__/rpi_1/" > $@
raspi_2_bullseye.yaml: raspi_base_bullseye.yaml
@ -74,6 +79,7 @@ raspi_2_bullseye.yaml: raspi_base_bullseye.yaml
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__/ttyACM0,115200/" |\
sed "s/__HOST__/rpi_2/" > $@
raspi_3_bullseye.yaml: raspi_base_bullseye.yaml
@ -81,6 +87,7 @@ raspi_3_bullseye.yaml: raspi_base_bullseye.yaml
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/" > $@
raspi_4_bullseye.yaml: raspi_base_bullseye.yaml
@ -89,6 +96,7 @@ raspi_4_bullseye.yaml: raspi_base_bullseye.yaml
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/" > $@
%.sha256: %.img.xz

View File

@ -102,8 +102,11 @@ steps:
mkdir -p "${ROOT?}/etc/systemd/system/systemd-remount-fs.service.requires/"
ln -s /etc/systemd/system/rpi-resizerootfs.service "${ROOT?}/etc/systemd/system/systemd-remount-fs.service.requires/rpi-resizerootfs.service"
install -m 644 -o root -g root rootfs/etc/systemd/system/rpi-generate-ssh-host-keys.service "${ROOT?}/etc/systemd/system/"
install -m 644 -o root -g root rootfs/etc/systemd/system/rpi-reconfigure-raspi-firmware.service "${ROOT?}/etc/systemd/system/"
mkdir -p "${ROOT?}/etc/systemd/system/multi-user.target.requires/"
ln -s /etc/systemd/system/rpi-reconfigure-raspi-firmware.service "${ROOT?}/etc/systemd/system/multi-user.target.requires/rpi-reconfigure-raspi-firmware.service"
install -m 644 -o root -g root rootfs/etc/systemd/system/rpi-generate-ssh-host-keys.service "${ROOT?}/etc/systemd/system/"
ln -s /etc/systemd/system/rpi-generate-ssh-host-keys.service "${ROOT?}/etc/systemd/system/multi-user.target.requires/rpi-generate-ssh-host-keys.service"
rm -f "${ROOT?}"/etc/ssh/ssh_host_*_key*
root-fs: /
@ -122,9 +125,12 @@ steps:
# Modify the kernel commandline we take from the firmware to boot from
# 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).
- chroot: /
shell: |
ls -aR /boot
sed -i 's/^/console=__SERIAL_CONSOLE__ /' /boot/firmware/cmdline.txt
sed -i 's/.dev.mmcblk0p2/LABEL=RASPIROOT/' /boot/firmware/cmdline.txt
# TODO(https://github.com/larswirzenius/vmdb2/issues/24): remove once vmdb

View File

@ -0,0 +1,14 @@
[Unit]
Description=Reconfigure raspi-firmware to regenerate config.txt matching actual hardware
Before=local-fs-pre.target
DefaultDependencies=no
RequiresMountsFor=/boot/firmware
[Service]
Type=oneshot
TimeoutSec=infinity
ExecStart=/usr/sbin/dpkg-reconfigure raspi-firmware
ExecStart=/bin/systemctl --no-reload disable %n
[Install]
RequiredBy=local-fs-pre.target