mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 13:38:12 +00:00
41bf9201b5
As the connected Trezors can be left in various weird states, trezorctl list may not always return what is expected or even fail. If it failed TREZOR_PATH was set to empty string which means random device got selected. For now let's avoid using incorrect device by powering down the other usb port. Fix log lines ordering.
36 lines
823 B
Python
Executable File
36 lines
823 B
Python
Executable File
import configparser
|
|
import sys
|
|
|
|
from device.t1 import TrezorOne
|
|
from device.tt import TrezorT
|
|
|
|
|
|
def main(model: str, file: str = None):
|
|
config = configparser.ConfigParser()
|
|
config.read_file(open("hardware.cfg"))
|
|
t1 = TrezorOne(
|
|
config["t1"]["uhub_location"],
|
|
config["t1"]["arduino_serial"],
|
|
config["t1"]["port"],
|
|
)
|
|
tt = TrezorT(config["tt"]["uhub_location"], config["tt"]["port"])
|
|
|
|
if model == "t1":
|
|
tt.power_off()
|
|
path = t1.update_firmware(file)
|
|
elif model == "tt":
|
|
t1.power_off()
|
|
path = tt.update_firmware(file)
|
|
else:
|
|
raise ValueError("Unknown Trezor model.")
|
|
|
|
print(path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
model = sys.argv[1]
|
|
if len(sys.argv) == 3:
|
|
main(model, file=sys.argv[2])
|
|
else:
|
|
main(model)
|