BitBoxSwiss / bitbox-wallet-app

The BitBoxApp for desktop and mobile.
https://bitbox.swiss/app
Apache License 2.0
255 stars 82 forks source link

backend/bitbox02bootloader: allow fixing broken install #2711

Closed benma closed 5 months ago

benma commented 5 months ago

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 https://github.com/digitalbitbox/bitbox-wallet-app/pull/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 :pray:

benma commented 5 months ago

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

Beerosagos commented 5 months ago

@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 https://github.com/digitalbitbox/bitbox02-api-go/pull/93/commits/c5e4f77d941fafbe2b133a756e915dae3b3379c8#r1601100822). Probably it doesn't even worth fixing it..

benma commented 5 months ago

@Beerosagos did you mean this? https://github.com/digitalbitbox/bitbox02-api-go/pull/94

Beerosagos commented 5 months ago

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

Yup! Thanks

benma commented 5 months ago

Rebased