Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend/bitbox02bootloader: allow fixing broken install #2711

Merged
merged 3 commits into from
May 31, 2024

Conversation

benma
Copy link
Contributor

@benma benma commented May 13, 2024

Problem: a new device ships with the latest firmware monotonic version. User
sees 'Install' because the device is erased (no firmware on it), but during
first install of firmware, unplugs. Upon replug, the device will show 'Invalid
firmware' and boot into bootloader again. Since the monotonic version of the
firmware to be installed is the same as the version stored on the device, and
the device is not erased (half of the firmware is on it), the user sees no
button to upgrade/instll anymore.

This commit fixes this by still showing the upgrade button if the versions are
the same, but the device firmware hash does not match the expected firmware
hash.

Replaces #2700 - @thisconnect suggested to use the firmware hash instead, which is a much nicher solution as it does not show the upgrade button to every user who enters the bootloader, just to the ones where the firmware install is actually broken - thanks @thisconnect 🙏

@benma
Copy link
Contributor Author

benma commented May 13, 2024

@Beerosagos for efficiency I already merged the BitBoxSwiss/bitbox02-api-go#93, exposing the two functions needed here. PTAL anyway and I can add fixes in a new PR should you find any issues there.

Copy link
Contributor Author

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'Take me back' button could/should also be hidden if the install is broken, as the device would not be able to boot anyway.

Edit: on 2nd thought I'll skip this, as it's a bunch of code overhead and only works in this particular edge case - if any regular update is interrupted the button would still be shown as before, and we cannot fix this easily. While not great, clicking the button would still show "Invalid firmware" on the device and the user can fix it by installing again.

@Beerosagos
Copy link
Collaborator

@Beerosagos for efficiency I already merged the digitalbitbox/bitbox02-api-go#93, exposing the two functions needed here. PTAL anyway and I can add fixes in a new PR should you find any issues there.

the PR LGTM! I only found a tiny nit in a comment (see BitBoxSwiss/bitbox02-api-go@c5e4f77#r1601100822). Probably it doesn't even worth fixing it..

@benma
Copy link
Contributor Author

benma commented May 15, 2024

@Beerosagos did you mean this? BitBoxSwiss/bitbox02-api-go#94

@Beerosagos
Copy link
Collaborator

@Beerosagos did you mean this? digitalbitbox/bitbox02-api-go#94

Yup! Thanks

Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK!

benma added 3 commits May 31, 2024 15:28
To disambiguate from the unsigned binary.
By using the newly added `ParseSignedFirmware()` util function.
Problem: a new device ships with the latest firmware monotonic version. User
sees 'Install' because the device is erased (no firmware on it), but during
first install of firmware, unplugs. Upon replug, the device will show 'Invalid
firmware' and boot into bootloader again. Since the monotonic version of the
firmware to be installed is the same as the version stored on the device, and
the device is not erased (half of the firmware is on it), the user sees no
button to upgrade/instll anymore.

This commit fixes this by still showing the upgrade button if the versions are
the same, but the device firmware hash does not match the expected firmware
hash.
@benma
Copy link
Contributor Author

benma commented May 31, 2024

Rebased

@benma benma merged commit e1a972f into BitBoxSwiss:master May 31, 2024
5 checks passed
@benma benma deleted the fix-broken-install branch May 31, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants