[Pkg-raspi-maintainers] Bug#939727: raspi3-firmware: copy DTB blobs for original Model B and other old boards

J.P. Larocque jpl-debian-bts at thoughtcrime.us
Sun Sep 8 07:29:34 BST 2019


Package: raspi3-firmware
Version: 1.20190215-1

Dear Maintainer,

Can you please add support for original Raspberry Pi boards (the ones
which precede the Pi 2, Pi 3, and Pi 4)?

In my case, I'm using a Raspberry Pi Model B revision 2, and I can get
Debian Buster on armel to work nearly out of the box by using
linux-image-rpi and raspi3-firmware.  However, the bcm2835-rpi-b.dtb
blob provided by linux-image-4.19.0-5-rpi isn't installed by the
kernel postinst.d script supplied in raspi3-firmware, so the Pi
doesn't boot.  (I didn't have a monitor or TV easily available to
connect to the Pi, so I don't know exactly what was on-screen, but it
never booted to a state where I could ping it.)

If I write a custom postinst.d script to copy bcm2835-rpi-b.dtb
similarly to how the raspi3-firmware postinst.d script copies other
DTB files (and to the correct destination file name), or if I modify
the packaged script directly to do the same, then the system is made
bootable (after running the script manually, or reinstalling the
kernel or raspi3-firmware packages, of course).

I've included an example patch below against the version in Buster
which adds support for my board (pi1b_dtb; bcm2835-rpi-b.dtb =>
/boot/firmware/bcm2708-rpi-b.dtb), and which I think will also add
support for the non-wireless Pi Zero and the Pi Compute Module 1.

I notice that the kernel ships with DTB blobs named after the Broadcom
package part numbers (e.g. BCM2835) while the Raspberry Pi bootloader
expects to find the files named after the silicon used (e.g. BCM2708).
While modifying the existing postinst.d script, I noticed that the
script changes the name when it installs firmware for the Pi 2 Model
B, Pi 3 Model B, and the Pi 3 Model B+.  However, it keeps the old
name for the Pi Zero W, Pi Model A+, Pi Model B+.

For example, instead of installing:

  /boot/firmware/bcm2708-rpi-b-plus.dtb

This file gets installed under its original name as shipped by the
kernel:

  /boot/firmware/bcm2835-rpi-b-plus.dtb

Because of this, I have doubts that the system will be bootable on
these last three platforms, but I haven't verified this.  In my
example patch below, I add new copy commands with what I think are the
correct destination file names for these three platforms (based on the
DTB blob file names in the official Rasperry Pi firmware repository at
https://github.com/raspberrypi/firmware/tree/master/boot), but to be
conservative I left the original copy commands alone.  Do you know
which style of file name is correct?  If so, can you please keep
whichever copy commands are supposed to be there and remove the ones
which are not?

--- /etc/kernel/postinst.d/z50-raspi3-firmware.dpkg-dist   2019-02-17 19:59:36.000000000 -0800
+++ /etc/kernel/postinst.d/z50-raspi3-firmware       2019-09-07 22:40:49.059041364 -0700
@@ -64,16 +64,25 @@
 fi
 
 if [ "$KERNEL" = "auto" ]; then
+  pi0_dtb=${dtb_path}/bcm2835-rpi-zero.dtb
   pi0w_dtb=${dtb_path}/bcm2835-rpi-zero-w.dtb
   pi1ap_dtb=${dtb_path}/bcm2835-rpi-a-plus.dtb
+  pi1b_dtb=${dtb_path}/bcm2835-rpi-b.dtb
   pi1bp_dtb=${dtb_path}/bcm2835-rpi-b-plus.dtb
+  picm1_dtb=${dtb_path}/bcm2835-rpi-cm1-io1.dtb
   pi2b_dtb=${dtb_path}/bcm2836-rpi-2-b.dtb
   pi3b_dtb=${dtb_path}/bcm2837-rpi-3-b.dtb
   pi3bp_dtb=${dtb_path}/bcm2837-rpi-3-b-plus.dtb
 
+  [ -e "${pi0_dtb}"  ] && cp "${pi0_dtb}"  /boot/firmware/bcm2708-rpi-zero.dtb
   [ -e "${pi0w_dtb}"  ] && cp "${pi0w_dtb}"  /boot/firmware/bcm2835-rpi-zero-w.dtb
+  [ -e "${pi0w_dtb}"  ] && cp "${pi0w_dtb}"  /boot/firmware/bcm2708-rpi-zero-w.dtb
   [ -e "${pi1ap_dtb}"  ] && cp "${pi1ap_dtb}" /boot/firmware/bcm2835-rpi-a-plus.dtb
+  [ -e "${pi1ap_dtb}"  ] && cp "${pi1ap_dtb}" /boot/firmware/bcm2708-rpi-a-plus.dtb
+  [ -e "${pi1b_dtb}"  ] && cp "${pi1b_dtb}" /boot/firmware/bcm2708-rpi-b.dtb
   [ -e "${pi1bp_dtb}"  ] && cp "${pi1bp_dtb}" /boot/firmware/bcm2835-rpi-b-plus.dtb
+  [ -e "${pi1bp_dtb}"  ] && cp "${pi1bp_dtb}" /boot/firmware/bcm2708-rpi-b-plus.dtb
+  [ -e "${picm1_dtb}"  ] && cp "${picm1_dtb}" /boot/firmware/bcm2708-rpi-cm.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
   [ -e "${pi3bp_dtb}" ] && cp "${pi3bp_dtb}" /boot/firmware/bcm2710-rpi-3-b-plus.dtb

In the meantime (and in-case a fix can't be published to Buster), I've
attached the /etc/kernel/postinst.d and /etc/kernel/postrm.d scripts
I'm using as a workaround, in-case it helps anybody else.

Thanks for looking into this!

-- System Information:
Debian Release: 10.0
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: armel (armv6l)

Kernel: Linux 4.19.0-5-rpi
Kernel taint flags: TAINT_CRAP
Locale: LANG=C, LC_CTYPE=C (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8), LANGUAGE=C (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages raspi3-firmware depends on:
ii  dosfstools  4.1-2

raspi3-firmware recommends no packages.

raspi3-firmware suggests no packages.

-- Configuration Files:
/etc/default/raspi3-firmware changed:
ROOTPART=UUID=7ffc98fc-1970-4289-a7ed-d89c844c3675


-- no debconf information

-- 
J.P. Larocque <jpl-debian-bts at thoughtcrime.us>
-------------- next part --------------
#!/bin/sh
set -e

# Play nice when run under debconf.
exec </dev/null >&2

eval set -- "$DEB_MAINT_PARAMS"

# Only run on configure and remove to avoid unnecessary work.
case "$1" in
  configure|remove)
    ;;
  *)
    exit 0
    ;;
esac

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

latest_kernel=$(ls -1 /boot/vmlinuz-* | grep -v '\.dpkg-bak$' | sort -V -r | head -1)
if [ -z "$latest_kernel" ]; then
  echo "raspi3-firmware: no kernel found in /boot/vmlinuz-*, cannot populate /boot/firmware"
  exit 0
fi

# Default configurations, overridable at /etc/default/raspi3-firmware
KERNEL="auto"
if [ -r /etc/default/raspi3-firmware ]; then
        . /etc/default/raspi3-firmware
fi

# 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

if [ "$KERNEL" = "auto" ]; then
  pi0_dtb=${dtb_path}/bcm2835-rpi-zero.dtb
  pi0w_dtb=${dtb_path}/bcm2835-rpi-zero-w.dtb
  pi1ap_dtb=${dtb_path}/bcm2835-rpi-a-plus.dtb
  pi1b_dtb=${dtb_path}/bcm2835-rpi-b.dtb
  pi1bp_dtb=${dtb_path}/bcm2835-rpi-b-plus.dtb
  pi1cm_dtb=${dtb_path}/bcm2835-rpi-cm1-io1.dtb

  [ -e "${pi0_dtb}"  ] && cp "${pi0_dtb}"  /boot/firmware/bcm2708-rpi-zero.dtb
  [ -e "${pi0w_dtb}"  ] && cp "${pi0w_dtb}"  /boot/firmware/bcm2708-rpi-zero-w.dtb
  [ -e "${pi1ap_dtb}"  ] && cp "${pi1ap_dtb}" /boot/firmware/bcm2708-rpi-a-plus.dtb
  [ -e "${pi1b_dtb}"  ] && cp "${pi1b_dtb}" /boot/firmware/bcm2708-rpi-b.dtb
  [ -e "${pi1bp_dtb}"  ] && cp "${pi1bp_dtb}" /boot/firmware/bcm2708-rpi-b-plus.dtb
  [ -e "${pi1cm_dtb}"  ] && cp "${pi1cm_dtb}" /boot/firmware/bcm2708-rpi-cm.dtb
fi
-------------- next part --------------
#!/bin/sh
exec /etc/kernel/postinst.d/"$(basename "$0")" "$@"


More information about the Pkg-raspi-maintainers mailing list