2021-01-13 23:39:19 +00:00
|
|
|
import os
|
2019-10-04 13:22:39 +00:00
|
|
|
import sys
|
|
|
|
|
2024-02-08 17:27:40 +00:00
|
|
|
from device.core import TrezorCore
|
|
|
|
from device.legacy import TrezorOne
|
|
|
|
|
|
|
|
# https://www.uugear.com/product/mega4-4-port-usb-3-ppps-hub-for-raspberry-pi-4b/
|
|
|
|
# as long as every runner has this hub we don't have to configure a per-runner hub location
|
|
|
|
HUB_VENDOR = "2109:2817"
|
2019-10-04 13:22:39 +00:00
|
|
|
|
|
|
|
|
2020-09-03 09:11:21 +00:00
|
|
|
def main(model: str, file: str = None):
|
2019-10-04 13:22:39 +00:00
|
|
|
t1 = TrezorOne(
|
2024-02-08 17:27:40 +00:00
|
|
|
os.getenv("T1_UHUB_LOCATION"),
|
|
|
|
os.getenv("T1_ARDUINO_SERIAL"),
|
|
|
|
os.getenv("T1_UHUB_PORT"),
|
2019-10-04 13:22:39 +00:00
|
|
|
)
|
2024-02-08 17:27:40 +00:00
|
|
|
tt = TrezorCore(hub_vendor=HUB_VENDOR, device_port=os.getenv("TT_UHUB_PORT"))
|
2020-09-03 09:11:21 +00:00
|
|
|
|
2024-02-08 17:27:40 +00:00
|
|
|
if model == "T1B1":
|
|
|
|
# tt.power_off()
|
2021-01-21 23:18:34 +00:00
|
|
|
path = t1.update_firmware(file)
|
2024-02-08 17:27:40 +00:00
|
|
|
elif model == "T2T1":
|
|
|
|
# t1.power_off()
|
|
|
|
path = tt.update_firmware(file, "Trezor T")
|
|
|
|
elif model == "T2B1":
|
|
|
|
path = tt.update_firmware(file, "Safe 3")
|
2020-09-03 09:11:21 +00:00
|
|
|
else:
|
|
|
|
raise ValueError("Unknown Trezor model.")
|
2019-10-04 13:22:39 +00:00
|
|
|
|
2021-01-21 23:18:34 +00:00
|
|
|
print(path)
|
|
|
|
|
2019-10-04 13:22:39 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-09-03 09:11:21 +00:00
|
|
|
model = sys.argv[1]
|
|
|
|
if len(sys.argv) == 3:
|
|
|
|
main(model, file=sys.argv[2])
|
|
|
|
else:
|
|
|
|
main(model)
|