[Pkg-raspi-maintainers] raspi3-firmware: container awareness and device tree handling
Matthias Luescher
lueschem at gmail.com
Tue Jan 23 21:35:24 UTC 2018
Uups - and here the patches as plain text:
>From d7cb95f43ae83e3b5d6b8ada84bd850bed7529dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20L=C3=BCscher?= <lueschem at gmail.com>
Date: Sun, 14 Jan 2018 17:27:48 +0100
Subject: [PATCH 1/5] Do not check mount point if virtualization gets
detected.
More and more tools use containers instead of chroots to build OS
images. This change makes sure that the package installation works
within a container.
---
debian/kernel/postinst.d/raspi3-firmware | 12 +++++++-----
debian/raspi3-firmware.postinst | 12 +++++++-----
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/debian/kernel/postinst.d/raspi3-firmware
b/debian/kernel/postinst.d/raspi3-firmware
index 349bfe9..0bd1e70 100755
--- a/debian/kernel/postinst.d/raspi3-firmware
+++ b/debian/kernel/postinst.d/raspi3-firmware
@@ -31,11 +31,13 @@ case "$1" in
;;
esac
-if ! ischroot; then
- if ! mountpoint -q /boot/firmware; then
- echo "raspi3-firmware: missing /boot/firmware, did you forget to mount
it?" >&2
- exit 1
- fi
+if ischroot ; then
+ true # chroot detected - skip mount point check
+elif test -e /usr/bin/systemd-detect-virt && systemd-detect-virt -q ; then
+ true # virtualization detected - skip mount point check
+elif ! mountpoint -q /boot/firmware; then
+ echo "raspi3-firmware: missing /boot/firmware, did you forget to mount
it?" >&2
+ exit 1
fi
# Ensure the target directory exists. See https://bugs.debian.org/887062
diff --git a/debian/raspi3-firmware.postinst
b/debian/raspi3-firmware.postinst
index 5d4e195..224dc92 100644
--- a/debian/raspi3-firmware.postinst
+++ b/debian/raspi3-firmware.postinst
@@ -6,11 +6,13 @@ set -e
case "$1" in
configure)
- if ! ischroot; then
- if ! mountpoint -q /boot/firmware; then
- echo "Error: missing /boot/firmware, did you forget to mount it?"
>&2
- exit 1
- fi
+ if ischroot ; then
+ true # chroot detected - skip mount point check
+ elif test -e /usr/bin/systemd-detect-virt && systemd-detect-virt -q ;
then
+ true # virtualization detected - skip mount point check
+ elif ! mountpoint -q /boot/firmware; then
+ echo "Error: missing /boot/firmware, did you forget to mount it?" >&2
+ exit 1
fi
# Ensure the target directory exists. See
https://bugs.debian.org/887062
--
2.7.4
>From 927a9a4c38064f16aeb0101d7df71d96fcc5e9c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20L=C3=BCscher?= <lueschem at gmail.com>
Date: Mon, 15 Jan 2018 21:58:07 +0100
Subject: [PATCH 2/5] Copy and rename all possible device tree binaries.
This commit removes the hard coded device tree setting from
/boot/firmware/config.txt. As a result an armhf image will run
unmodified on the Raspberry Pi 2 and 3.
---
debian/kernel/postinst.d/raspi3-firmware | 37
++++++++++++++------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/debian/kernel/postinst.d/raspi3-firmware
b/debian/kernel/postinst.d/raspi3-firmware
index 0bd1e70..b76a73e 100755
--- a/debian/kernel/postinst.d/raspi3-firmware
+++ b/debian/kernel/postinst.d/raspi3-firmware
@@ -10,18 +10,6 @@ exec </dev/null >&2
eval set -- "$DEB_MAINT_PARAMS"
-
-# Detect appropriate .dtb
-arch=$(dpkg --print-architecture)
-case ${arch} in
- armhf)
- dtb=bcm2836-rpi-2-b.dtb
- ;;
- arm64)
- dtb=bcm2837-rpi-3-b.dtb
- ;;
-esac
-
# Only run on configure and remove to avoid unnecessary work.
case "$1" in
configure|remove)
@@ -55,20 +43,28 @@ if [ -z "$latest_initrd" ]; then
exit 0
fi
-latest_dtb="/usr/lib/linux-image-${latest_kernel#/boot/vmlinuz-}/broadcom/${dtb}"
+cp "$latest_kernel" /boot/firmware/
+cp "$latest_initrd" /boot/firmware/
-if [ ! -e "$latest_dtb" ]; then
- echo "raspi3-firmware: device tree file ${latest_dtb} does not exist,
cannot populate /boot/firmware"
- exit 0
+# copy and rename the available device tree binaries
+# the bootloader will pick the right device tree binary
+# if it is named according to the system on chip family name
+arch=$(dpkg --print-architecture)
+if [ "arm64" = "$arch" ]; then
+ dtb_path="/usr/lib/linux-image-${latest_kernel#/boot/vmlinuz-}/broadcom"
+else
+ # there is no vendor subdirectory for armhf
+ dtb_path="/usr/lib/linux-image-${latest_kernel#/boot/vmlinuz-}"
fi
-cp "$latest_kernel" /boot/firmware/
-cp "$latest_initrd" /boot/firmware/
-cp "$latest_dtb" /boot/firmware/
+pi2b_dtb=${dtb_path}/bcm2836-rpi-2-b.dtb
+pi3b_dtb=${dtb_path}/bcm2837-rpi-3-b.dtb
+
+[ -e "${pi2b_dtb}" ] && cp "${pi2b_dtb}" /boot/firmware/bcm2709-rpi-2-b.dtb
+[ -e "${pi3b_dtb}" ] && cp "${pi3b_dtb}" /boot/firmware/bcm2710-rpi-3-b.dtb
latest_kernel_basename=$(basename "$latest_kernel")
latest_initrd_basename=$(basename "$latest_initrd")
-latest_dtb_basename=$(basename "$latest_dtb")
if [ "arm64" = "$arch" ]; then
cat >/boot/firmware/config.txt <<EOF
@@ -85,7 +81,6 @@ fi
cat >>/boot/firmware/config.txt <<EOF
enable_uart=1
-device_tree=${latest_dtb_basename}
kernel=${latest_kernel_basename}
# For details on the initramfs directive, see
# https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=10532
--
2.7.4
>From 0a9e958621cee55579477d1614e0e4858dbc5968 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20L=C3=BCscher?= <lueschem at gmail.com>
Date: Mon, 15 Jan 2018 22:27:11 +0100
Subject: [PATCH 3/5] Added missing dosfstools dependency.
dosfstools contains fsck.vfat. If this binary is missing, the script
debian/initramfs-tools/hooks/raspi3-firmware-fsck will fail.
---
debian/control | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/debian/control b/debian/control
index a396b5e..97d7bbf 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ XS-Autobuild: yes
Package: raspi3-firmware
Architecture: arm64 armhf
-Depends: ${shlibs:Depends}, ${misc:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}, dosfstools
Breaks: linux-firmware-raspi3 (<< 1.20161123-2)
Replaces: linux-firmware-raspi3 (<< 1.20161123-2)
Description: Raspberry Pi 3 GPU firmware and bootloaders
--
2.7.4
>From a54efcd48a65ec3c7b3752381eda3dd72f1e9132 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20L=C3=BCscher?= <lueschem at gmail.com>
Date: Thu, 18 Jan 2018 21:29:52 +0100
Subject: [PATCH 4/5] Increase cma memory to 64M to allow proper vc4 GPU
initialization.
On arm64 this has no impact since CONFIG_CMA_SIZE_MBYTES is anyway set
to 64. On armmp-lpae CONFIG_CMA_SIZE_MBYTES is set to 16. 16M are not
sufficient for the vc4 GPU driver initialization.
---
debian/kernel/postinst.d/raspi3-firmware | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/debian/kernel/postinst.d/raspi3-firmware
b/debian/kernel/postinst.d/raspi3-firmware
index b76a73e..857283e 100755
--- a/debian/kernel/postinst.d/raspi3-firmware
+++ b/debian/kernel/postinst.d/raspi3-firmware
@@ -101,7 +101,7 @@ fi
# without parameters for drivers we do not have (e.g. dwc_otg.lpm_enable)
or
# parameters we do not need (e.g. rootfstype=, as we are using an initrd).
cat >/boot/firmware/cmdline.txt <<EOF
-console=tty0 console=${serial} root=/dev/mmcblk0p2 rw elevator=deadline
fsck.repair=yes net.ifnames=0 rootwait
+console=tty0 console=${serial} root=/dev/mmcblk0p2 rw elevator=deadline
fsck.repair=yes net.ifnames=0 cma=64M rootwait
EOF
cd /boot/firmware
--
2.7.4
>From 777815364f0fdacc6806eb43e10d8b6e6f7eca2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20L=C3=BCscher?= <lueschem at gmail.com>
Date: Thu, 18 Jan 2018 21:58:34 +0100
Subject: [PATCH 5/5] Adjusted package description.
---
debian/control | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/debian/control b/debian/control
index 97d7bbf..dfdbae3 100644
--- a/debian/control
+++ b/debian/control
@@ -15,8 +15,8 @@ Architecture: arm64 armhf
Depends: ${shlibs:Depends}, ${misc:Depends}, dosfstools
Breaks: linux-firmware-raspi3 (<< 1.20161123-2)
Replaces: linux-firmware-raspi3 (<< 1.20161123-2)
-Description: Raspberry Pi 3 GPU firmware and bootloaders
+Description: Raspberry Pi 2 and 3 GPU firmware and bootloaders
This package contains all the proprietary files necessary to boot a
- Raspberry Pi 3 board.
+ Raspberry Pi 2 or 3 board.
.
Raspberry Pi is a trademark of the Raspberry Pi Foundation.
--
2.7.4
2018-01-23 22:27 GMT+01:00 Matthias Luescher <lueschem at gmail.com>:
> Hi Michael
>
> Here are the revised patches.
> Many thanks for taking a look at my modifications!
>
> Best regards
> Matthias
>
> P.S.: Here is the temporary GitHub repository containing the same
> modifications:
> https://github.com/lueschem/raspi3-firmware/commits/
> raspi3_firmware_tweaks_v2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-raspi-maintainers/attachments/20180123/699121ba/attachment-0001.html>
More information about the Pkg-raspi-maintainers
mailing list