2020-09-03 09:11:21 +00:00
|
|
|
from .device import Device
|
|
|
|
|
|
|
|
|
2024-02-08 17:27:40 +00:00
|
|
|
class TrezorCore(Device):
|
|
|
|
def update_firmware(self, file=None, model_name="Trezor T"):
|
2020-09-03 09:11:21 +00:00
|
|
|
if not file:
|
|
|
|
raise ValueError(
|
|
|
|
"Uploading production firmware will replace the bootloader, it is not allowed!"
|
|
|
|
)
|
|
|
|
|
2021-02-15 12:23:23 +00:00
|
|
|
# reset to enter bootloader again
|
|
|
|
self.power_off()
|
2024-02-08 17:27:40 +00:00
|
|
|
self.wait(5)
|
2021-02-15 12:23:23 +00:00
|
|
|
self.power_on()
|
|
|
|
|
2024-02-08 17:27:40 +00:00
|
|
|
self.wait(10)
|
|
|
|
self.check_model("bootloader")
|
2021-02-15 12:23:23 +00:00
|
|
|
|
2021-01-23 22:03:56 +00:00
|
|
|
self.run_trezorctl("device wipe --bootloader || true")
|
|
|
|
self.wait(5)
|
|
|
|
self.power_off()
|
|
|
|
self.power_on()
|
|
|
|
|
2020-09-03 09:11:21 +00:00
|
|
|
self.wait(5)
|
2021-09-27 10:13:51 +00:00
|
|
|
self.log(f"[software] Updating the firmware to {file}")
|
|
|
|
self.run_trezorctl(f"firmware-update -s -f {file}")
|
2020-09-03 09:11:21 +00:00
|
|
|
|
2020-12-04 16:16:57 +00:00
|
|
|
# after firmware-update finishes wait for reboot
|
|
|
|
self.wait(15)
|
2024-02-08 17:27:40 +00:00
|
|
|
return self.check_model(model_name)
|