[FFe] flash-kernel displays wrong "selected" DTB on various Pi models

Bug #2038087 reported by Juerg Haefliger
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
flash-kernel (Ubuntu)
Fix Released
Undecided
Dave Jones

Bug Description

[ Impact ]

flash-kernel displays a "selected" DTB at the top of its output. On a Pi this isn't actually that relevant as it goes on to copy every DTB associated with the kernel anyway, but this is still confusing for users, especially when they see a completely different board model than the one they expected (e.g. at present on the Pi 400 or Pi 5, the output will indicate that the rpi-4-b dtb is being used).

[ Test Plan ]

* Boot a mantic daily image on an affected model of Pi (400, 5, CM3, CM3+, Zero 2W)
* Run "sudo flash-kernel" and confirm it outputs "Using DTB: bcm2711-rpi-4-b.dtb" at the top of its messages
* Enable the -proposed pocket and "sudo apt update"
* "sudo apt install flash-kernel" to update flash-kernel to the proposed version
* Run "sudo flash-kernel" and confirm it outputs the correct DTB for the selected model of Pi.

[ Regression Potential ]

Low; the existing flash-kernel already copies all DTBs found and the proposed one will too (all Pi related entries use "Method: pi", the method isn't changing in its behaviour, the only db entries that are changing are Pi related). Thus the worst-case scenario is that flash-kernel continues to output the "wrong" DTB at the top of its output, which is no worse than the present situation.

[ Original Description ]
flash-kernel probably shouldn't even be dealing with the DTBs on Pi but it's picking the wrong one for some machine models. For example on a Raspberry Pi 400 Rev 1.0 it uses bcm2711-rpi-4-b.dtb. Same one Compute Module 3 and 3+.

It's probably because in /usr/share/flash-kernel/db/all.db the catch-all

Machine: Raspberry Pi *

is listed before these above mentioned models (and others as well).

Revision history for this message
Heinrich Schuchardt (xypron) wrote (last edit ):

The problem is reproducible:

Create file /etc/flash-kernel/machine with content

   Raspberry Pi 400 Rev 1.0

on any arm64 system and run flash-kernel:

$ sudo flash-kernel $(uname -r)
Using DTB: bcm2711-rpi-4-b.dtb
Installing /lib/firmware/6.2.0-1013-raspi/device-tree/broadcom/bcm2711-rpi-4-b.dtb into /boot/dtbs/6.2.0-1013-raspi/./bcm2711-rpi-4-b.dtb
Taking backup of bcm2711-rpi-4-b.dtb.
Installing new bcm2711-rpi-4-b.dtb.
flash-kernel: installing version 6.2.0-1013-raspi

The following change is enough to fix the issue:
--- db/all.db 2023-06-22 14:18:53.000000000 +0000
+++ /usr/share/flash-kernel/db/all.db 2023-10-02 11:46:14.211402418 +0000
@@ -1823,7 +1805,7 @@
 Machine: Raspberry Pi 4 Model B Rev 1.2
 Machine: Raspberry Pi 4 Model B Rev 1.4
 Machine: Raspberry Pi 4 Model B Rev 1.5
-Machine: Raspberry Pi *
+Machine: Raspberry Pi 4 *
 Kernel-Flavors: raspi raspi-nolpae
 Method: pi
 DTB-Id: bcm2711-rpi-4-b.dtb

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in flash-kernel (Ubuntu):
status: New → Confirmed
Revision history for this message
Dave Jones (waveform) wrote :

You are correct that the "wrong" DTB is picked in the case of flash-kernel not recognizing the specific model in question. However, this doesn't matter provided the "Method" of the selected entry is "pi" (which it is, as they're currently the only entry that uses this method).

The "pi" method specifically copies *all* DTBs (and overlays) found to the boot partition, deliberately, to permit boot media to be moved between Pi models. However, the way flash-kernel works it still reports the "selected" DTB at the top of the output (and then goes on to copy all the found DTBs anyway).

 Still, I should add an entry for the Pi 5, and move the "Raspberry Pi *" catch-all down to that (and adjust the other catch-alls for various board revisions).

Revision history for this message
Heinrich Schuchardt (xypron) wrote :

Hello Dave,

when using GRUB to boot via EFI the devicetree command in grub.cfg will use the device-tree in /boot/dtb-$(uname -r). It is important that this device-tree matches the actual machine.

Best regards

Heinrich

Dave Jones (waveform)
Changed in flash-kernel (Ubuntu):
assignee: nobody → Dave Jones (waveform)
Dave Jones (waveform)
summary: - flash-kernel installs wrong DTB on Pi
+ [FFe] flash-kernel displays wrong "selected" DTB on various Pi models
Dave Jones (waveform)
description: updated
Revision history for this message
Dave Jones (waveform) wrote :

@xypron Sure, that matters if you're using GRUB via EFI, but none of the Pi images do. I'll patch this to fix it because it does look sloppy on our part, but this is basically a cosmetic fix -- it doesn't change which DTBs are copied because in the case of the Raspberry Pi images all DTBs are always copied.

It also doesn't affect any non-Pi boards because none of them match "Raspberry Pi *" (at least I'd be rather surprised if they do!).

Dave Jones (waveform)
Changed in flash-kernel (Ubuntu):
milestone: none → ubuntu-23.10
Revision history for this message
Juerg Haefliger (juergh) wrote :

Can we not just leave 'DTB-Id' empty and then the whole copying of the single/running DTB is skipped?

Revision history for this message
Dave Jones (waveform) wrote :

@juergh That would be the "proper" way to fix this, but the last time I tried that it broke several other places in flash-kernel. It might be easier now, but I don't fancy that invasive a change in an FFe. I ought to look into it for the next cycle, though (really I ought to look into completely overhauling the rather hacky "pi" method and stop it spewing pages of output into the terminal every time it runs, and speed it up further for that matter).

Revision history for this message
Graham Inggs (ginggs) wrote :

FFe granted

Changed in flash-kernel (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package flash-kernel - 3.107ubuntu2

---------------
flash-kernel (3.107ubuntu2) mantic; urgency=medium

  * Use generic-revision catch-alls for each model rather than relying on a
    single Pi catch-all to avoid a confusing selection of "the one DTB" for a
    given board (even though all other DTBs will still be copied anyway)
    (LP: #2038087)
    - Add missing Pi Zero 2W entry
    - Add missing Pi 5B entry

 -- Dave Jones <email address hidden> Mon, 02 Oct 2023 12:59:44 +0100

Changed in flash-kernel (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.