u-boot-sifive does not upgrade u-boot on disk

Bug #1936370 reported by Dimitri John Ledkov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
u-boot (Ubuntu)
Fix Released
Undecided
Unassigned
Focal
Fix Released
Critical
Unassigned
Hirsute
Won't Fix
Undecided
Unassigned
Impish
Fix Released
Undecided
Unassigned

Bug Description

[Impact]

 * u-boot-sifive package currently does not upgrade bootloader on loader1/loader2 partitions.

 * there have now been bugs identified, meaning that upgrading u-boot is required to upgrade from v5.8 kernel to v5.11 (i.e. either in-focal, or from focal to hirsute).

 * Add maintainer script that identifies if the machine one is running on is unleashed or unamtched, and appropriately upgrades the bootloader on loader1/loader2 partitions.

[Test Plan]

 * Boot older unleashed or unmatched image

 * Check version strings of loader1/loader2 partitions

$ sudo strings /dev/disk/by-partlabel/loader* | grep 202 | grep U-Boot

 * Upgrade u-boot-sifive to latest package

 * Check version strings of loader1/loader2 partitions, they should have changed

$ sudo strings /dev/disk/by-partlabel/loader* | grep 202 | grep U-Boot

 * Reboot, and observe on the serial console that u-boot version number is incremented to the latest one.

 * Repeat the test twice, once with unleashed board, once with unmatched board

 * Upgrade the package under qemu VM and observe no side-effects / no attempts to upgrade anything.

[Where problems could occur]

 * It is not possible to atomically upgrade loader1 and loader2 simultaniously.
 * A backup of loader1 and loader2 partitions is not stored anywhere.
 * Thus in case of errors rollback of older u-boot is not performed.
 * However if dd of one or the other partition fails, it is unlikely that one can restore the backup.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

NB! postinst must be executable

Changed in u-boot (Ubuntu Focal):
milestone: none → ubuntu-20.04.3
tags: added: patch
description: updated
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Testing out of ppa:

$ sudo strings /dev/disk/by-partlabel/loader* | grep 202 | grep U-Boot
U-Boot SPL 2021.01+dfsg-3ubuntu0~20.04.1 (Jun 25 2021 - 18:21:47 +0000)
U-Boot 2021.01+dfsg-3ubuntu0~20.04.1 (Jun 25 2021 - 18:21:47 +0000)

$ sudo apt install u-boot-sifive
Preparing to unpack .../u-boot-sifive_2021.01+dfsg-4ubuntu3_riscv64.deb ...
Unpacking u-boot-sifive:riscv64 (2021.01+dfsg-4ubuntu3) over (2021.01+dfsg-3ubuntu0~20.04.1)
...
Setting up u-boot-sifive:riscv64 (2021.01+dfsg-4ubuntu3) ...
155+1 records in
155+1 records out
79363 bytes (79 kB, 78 KiB) copied, 0.0953994 s, 832 kB/s
1160+1 records in
1160+1 records out
594112 bytes (594 kB, 580 KiB) copied, 0.709527 s, 837 kB/s

$ sudo strings /dev/disk/by-partlabel/loader* | grep 202 | grep U-Boot
U-Boot SPL 2021.01+dfsg-4ubuntu3 (Jul 15 2021 - 12:01:50 +0000)
U-Boot 2021.01+dfsg-4ubuntu3 (Jul 15 2021 - 12:01:50 +0000)

Upgrade successful.

Testing boot logs now.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

[10044.522610] reboot: Restarting�
U-Boot SPL 2021.01+dfsg-4ubuntu3 (Jul 15 2021 - 12:01:50 +0000)
Trying to boot from MMC1

U-Boot 2021.01+dfsg-4ubuntu3 (Jul 15 2021 - 12:01:50 +0000)

all is good

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

ubuntu@ubuntu:~$ sudo systemctl is-system-running
running

ubuntu@ubuntu:~$ uname -a
Linux ubuntu 5.11.0-1014-generic #14~20.04.1-Ubuntu SMP Thu Jul 1 13:56:47 UTC 2021 riscv64 riscv64 riscv64 GNU/Linux

it came up fine.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

The attached implementation checks for what one has booted as.

But does not check what was on the partitions before, or if they were used at all or not.

I guess I could do:

```
$ sudo dtc -I dtb -O dts /dev/disk/by-partlabel/loader2 | dtc -I dts -O yaml | grep hifive-unleashed-a00
      description: ["hifive-unleashed-a00"]
      description: ["hifive-unleashed-a00"]
```

But that requires device-tree-compiler to be installed, and should like ideally have either json or yaml parsing to find the right node, rather than just grepping for stuff.

Changed in u-boot (Ubuntu Impish):
status: New → In Progress
Changed in u-boot (Ubuntu Focal):
importance: Undecided → Critical
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package u-boot - 2021.01+dfsg-4ubuntu3

---------------
u-boot (2021.01+dfsg-4ubuntu3) impish; urgency=medium

  * Implement u-boot-sifive.postinst to upgrade u-boot in loader1/loader2
    partitions upon package upgrades. LP: #1936370

 -- Dimitri John Ledkov <email address hidden> Thu, 15 Jul 2021 13:01:50 +0100

Changed in u-boot (Ubuntu Impish):
status: In Progress → Fix Released
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

> But does not check what was on the
> partitions before, or if they were used at all or not.

This is what our impish image looks like:

Number Start (sector) End (sector) Size Code Name
   1 235554 7339998 3.4 GiB 8300
  12 227362 235553 4.0 MiB 8300 CIDATA
  13 34 2081 1024.0 KiB FFFF loader1
  14 2082 10273 4.0 MiB FFFF loader2
  15 10274 227361 106.0 MiB EF00

Partitions 13 and 14 are only protective partitions. They are not needed at all to boot via U-Boot.

The place to flash U-Boot SPL (sector 34) is hard coded in the boot ROM.
The offset of 1 MiB to main U-Boot is encoded as jump address in OpenSBI.
The total length of main U-Boot is well below 4 MiB. But those 4 MiB will be large enough to install EDK II once released.

If U-Boot was previously installed it cannot be in a different place.

What you could check is that no partition with data (type 8300, EF00, ...) collides with what you flash.

Best regards

Heinrich

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

> The place to flash U-Boot SPL (sector 34) is hard coded in the boot ROM.

I don't believe that is true. It is specified by GPT partition type UUID in FSBL, and it doesn't have to be at sector 34. As per sifive manuals.

Furthermore I don't have access to read jumpers, thus I don't know if the system booted using u-boot from sdcard, nvme, or from flash. Symlinks can be racy, and there can be multiple partitions with the same gpt partition type uuid (i.e. on sdcard and on the nvme drive).

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

This is good, although conceptually I always thought flash-kernel is the one responsible for boot partition updates. But that doesn't matter really!

Changed in u-boot (Ubuntu Focal):
status: New → Fix Committed
tags: added: verification-needed verification-needed-focal
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Please test proposed package

Hello Dimitri, or anyone else affected,

Accepted u-boot into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/u-boot/2021.01+dfsg-3ubuntu0~20.04.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Does this also need fixing in hirsute? I don't see any hirsute upload in the queue.

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

Installation of the package fails on HiFive Unmatched:

$ sudo dpkg -i u-boot-sifive_2021.01+dfsg-3ubuntu0~20.04.2_riscv64.deb
(Reading database ... 210527 files and directories currently installed.)
Preparing to unpack u-boot-sifive_2021.01+dfsg-3ubuntu0~20.04.2_riscv64.deb ...
Unpacking u-boot-sifive:riscv64 (2021.01+dfsg-3ubuntu0~20.04.2) over (2021.01+dfsg-3ubuntu0~20.04.2) ...
Setting up u-boot-sifive:riscv64 (2021.01+dfsg-3ubuntu0~20.04.2) ...
dd: failed to open '/usr/lib/u-boot/sifive_unmatched/u-boot-spl.bin': No such file or directory
dpkg: error processing package u-boot-sifive:riscv64 (--install):
 installed u-boot-sifive:riscv64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 u-boot-sifive:riscv64

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

The boot rom and U-Boot use the partuuid for identifying the partitions Why is the package u-boot-sifive_2021.01+dfsg-3ubuntu0~20.04.2_riscv64.deb using /dev/disk/by-partlabel/ and not /dev/disk/by-partuuid/ in postinst?

tags: added: verification-failed-focal
removed: verification-needed-focal
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Dimitri, or anyone else affected,

Accepted u-boot into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/u-boot/2021.01+dfsg-3ubuntu0~20.04.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

tags: added: verification-needed-focal
removed: verification-failed-focal
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Can someone perform validation of this bugfix?

Revision history for this message
William Wilson (jawn-smith) wrote (last edit ):

The verification passed for focal.

ubuntu@ubuntu:~$ apt-cache policy u-boot-sifive
u-boot-sifive:
  Installed: 2021.01+dfsg-3ubuntu0~20.04.1
  Candidate: 2021.01+dfsg-3ubuntu0~20.04.3
  Version table:
     2021.01+dfsg-3ubuntu0~20.04.3 500
        500 http://ports.ubuntu.com/ubuntu-ports focal-proposed/main riscv64 Packages
 *** 2021.01+dfsg-3ubuntu0~20.04.1 500
        500 http://ports.ubuntu.com/ubuntu-ports focal-updates/main riscv64 Packages
        100 /var/lib/dpkg/status
ubuntu@ubuntu:~$ sudo strings /dev/disk/by-partlabel/loader* | grep 202 | grep U-Boot
U-Boot SPL 2021.01+dfsg-3ubuntu0~20.04.1 (Jun 25 2021 - 18:21:47 +0000)
U-Boot 2021.01+dfsg-3ubuntu0~20.04.1 (Jun 25 2021 - 18:21:47 +0000)
ubuntu@ubuntu:~$ sudo apt install u-boot-sifive
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  u-boot-sifive
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 442 kB of archives.
After this operation, 10.2 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports focal-proposed/main riscv64 u-boot-sifive riscv64 2021.01+dfsg-3ubuntu0~20.04.3 [442 kB]
Fetched 442 kB in 0s (1010 kB/s)
(Reading database ... 69916 files and directories currently installed.)
Preparing to unpack .../u-boot-sifive_2021.01+dfsg-3ubuntu0~20.04.3_riscv64.deb ...
Unpacking u-boot-sifive:riscv64 (2021.01+dfsg-3ubuntu0~20.04.3) over (2021.01+dfsg-3ubuntu0~20.04.1) ...
Setting up u-boot-sifive:riscv64 (2021.01+dfsg-3ubuntu0~20.04.3) ...
148+1 records in
148+1 records out
76219 bytes (76 kB, 74 KiB) copied, 0.0370269 s, 2.1 MB/s
1378+1 records in
1378+1 records out
705608 bytes (706 kB, 689 KiB) copied, 1.02033 s, 692 kB/s
ubuntu@ubuntu:~$ sudo strings /dev/disk/by-partlabel/loader* | grep 202 | grep U-Boot
U-Boot SPL 2021.01+dfsg-3ubuntu0~20.04.3 (Jul 30 2021 - 14:38:17 +0000)
U-Boot 2021.01+dfsg-3ubuntu0~20.04.3 (Jul 30 2021 - 14:38:17 +0000)

The above test was performed on the Unmatched. I did the same test on the Unleashed via testflinger, and observed the same results. I also booted the images in qemu, and did an apt upgrade of u-boot-sifive, during which I saw no issues.

tags: added: verification-done verification-done-focal
removed: verification-needed verification-needed-focal
Revision history for this message
Chris Halse Rogers (raof) wrote :

Does this need fixing in Hirsute? It looks like this is ready to release to focal-updates, but is blocked waiting on a fix for hirsute (or reasoning why hirsute doesn't need a fix)

Changed in u-boot (Ubuntu Hirsute):
status: New → Incomplete
Revision history for this message
William Wilson (jawn-smith) wrote :

Yes, here is a patch for hirsute.

Revision history for this message
William Wilson (jawn-smith) wrote :

Actually I think the thought process was that if we never needed to update u-boot in hirsute then there was no need to add the postinst script. But there is a patch, fully tested, if anyone thinks it should be uploaded.

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

This bug was fixed in the package u-boot - 2021.01+dfsg-3ubuntu0~20.04.3

---------------
u-boot (2021.01+dfsg-3ubuntu0~20.04.3) focal; urgency=medium

  * debian/u-boot-sifive.postinst: use correct target names for u-boot
    2021.01.

u-boot (2021.01+dfsg-3ubuntu0~20.04.2) focal; urgency=medium

  * Bump opensbi build-dependency to ensure fixed version is used by u-boot
    RISC-V images (LP: #1937277)

  [ Dimitri John Ledkov ]
  * Implement u-boot-sifive.postinst to upgrade u-boot in loader1/loader2
    partitions upon package upgrades. LP: #1936370

 -- Łukasz 'sil2100' Zemczak <email address hidden> Fri, 30 Jul 2021 16:38:17 +0200

Changed in u-boot (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for u-boot has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Brian Murray (brian-murray) wrote :

The Hirsute Hippo has reached End of Life, so this bug will not be fixed for that release.

Changed in u-boot (Ubuntu Hirsute):
status: Incomplete → Won't Fix
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.