2017-06-07 17:06:26 +00:00
|
|
|
from micropython import const
|
|
|
|
|
2017-08-14 09:08:47 +00:00
|
|
|
from trezor import io
|
2016-09-21 12:21:18 +00:00
|
|
|
from trezor import wire
|
2017-08-14 09:08:47 +00:00
|
|
|
from trezor import main
|
2016-04-28 21:48:27 +00:00
|
|
|
|
2017-08-14 09:08:47 +00:00
|
|
|
# Load applications
|
|
|
|
from apps.common import storage
|
2016-12-15 11:36:55 +00:00
|
|
|
if __debug__:
|
|
|
|
from apps import debug
|
2016-05-25 12:27:22 +00:00
|
|
|
from apps import homescreen
|
2016-06-01 13:06:00 +00:00
|
|
|
from apps import management
|
2016-05-25 12:27:22 +00:00
|
|
|
from apps import wallet
|
2016-11-18 14:23:10 +00:00
|
|
|
from apps import ethereum
|
2017-07-12 14:04:03 +00:00
|
|
|
from apps import fido_u2f
|
2016-04-28 21:48:27 +00:00
|
|
|
|
2017-08-14 09:08:47 +00:00
|
|
|
# Boot applications
|
2016-12-15 11:36:55 +00:00
|
|
|
if __debug__:
|
|
|
|
debug.boot()
|
2016-05-25 12:27:22 +00:00
|
|
|
homescreen.boot()
|
2016-06-01 13:06:00 +00:00
|
|
|
management.boot()
|
2016-05-25 12:27:22 +00:00
|
|
|
wallet.boot()
|
2016-11-18 14:23:10 +00:00
|
|
|
ethereum.boot()
|
2017-07-12 14:04:03 +00:00
|
|
|
fido_u2f.boot()
|
2016-04-28 21:48:27 +00:00
|
|
|
|
2017-08-14 09:08:47 +00:00
|
|
|
# Intialize the USB stack
|
|
|
|
usb_wire = io.HID(
|
|
|
|
iface_num=0x00,
|
2017-04-19 15:10:17 +00:00
|
|
|
ep_in=0x81,
|
|
|
|
ep_out=0x01,
|
2017-04-21 14:06:22 +00:00
|
|
|
report_desc=bytes([
|
|
|
|
0x06, 0x00, 0xff, # USAGE_PAGE (Vendor Defined)
|
|
|
|
0x09, 0x01, # USAGE (1)
|
|
|
|
0xa1, 0x01, # COLLECTION (Application)
|
|
|
|
0x09, 0x20, # USAGE (Input Report Data)
|
|
|
|
0x15, 0x00, # LOGICAL_MINIMUM (0)
|
|
|
|
0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255)
|
|
|
|
0x75, 0x08, # REPORT_SIZE (8)
|
|
|
|
0x95, 0x40, # REPORT_COUNT (64)
|
|
|
|
0x81, 0x02, # INPUT (Data,Var,Abs)
|
|
|
|
0x09, 0x21, # USAGE (Output Report Data)
|
|
|
|
0x15, 0x00, # LOGICAL_MINIMUM (0)
|
|
|
|
0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255)
|
|
|
|
0x75, 0x08, # REPORT_SIZE (8)
|
|
|
|
0x95, 0x40, # REPORT_COUNT (64)
|
|
|
|
0x91, 0x02, # OUTPUT (Data,Var,Abs)
|
|
|
|
0xc0, # END_COLLECTION
|
|
|
|
]),
|
2017-04-19 15:10:17 +00:00
|
|
|
)
|
2017-08-14 09:08:47 +00:00
|
|
|
usb_vcp = io.VCP(
|
|
|
|
iface_num=0x01,
|
|
|
|
data_iface_num=0x02,
|
2017-07-12 14:04:03 +00:00
|
|
|
ep_in=0x82,
|
|
|
|
ep_out=0x02,
|
|
|
|
ep_cmd=0x83,
|
|
|
|
)
|
2017-08-14 09:08:47 +00:00
|
|
|
usb_u2f = io.HID(
|
|
|
|
iface_num=0x03,
|
2017-07-12 14:04:03 +00:00
|
|
|
ep_in=0x84,
|
|
|
|
ep_out=0x03,
|
2017-05-09 14:12:02 +00:00
|
|
|
report_desc=bytes([
|
|
|
|
0x06, 0xd0, 0xf1, # USAGE_PAGE (FIDO Alliance)
|
|
|
|
0x09, 0x01, # USAGE (U2F HID Authenticator Device)
|
|
|
|
0xa1, 0x01, # COLLECTION (Application)
|
|
|
|
0x09, 0x20, # USAGE (Input Report Data)
|
|
|
|
0x15, 0x00, # LOGICAL_MINIMUM (0)
|
|
|
|
0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255)
|
|
|
|
0x75, 0x08, # REPORT_SIZE (8)
|
|
|
|
0x95, 0x40, # REPORT_COUNT (64)
|
|
|
|
0x81, 0x02, # INPUT (Data,Var,Abs)
|
|
|
|
0x09, 0x21, # USAGE (Output Report Data)
|
|
|
|
0x15, 0x00, # LOGICAL_MINIMUM (0)
|
|
|
|
0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255)
|
|
|
|
0x75, 0x08, # REPORT_SIZE (8)
|
|
|
|
0x95, 0x40, # REPORT_COUNT (64)
|
|
|
|
0x91, 0x02, # OUTPUT (Data,Var,Abs)
|
|
|
|
0xc0, # END_COLLECTION
|
|
|
|
]),
|
|
|
|
)
|
2017-08-14 09:08:47 +00:00
|
|
|
usb = io.USB(
|
2017-04-21 14:06:22 +00:00
|
|
|
vendor_id=0x1209,
|
|
|
|
product_id=0x53C1,
|
|
|
|
release_num=0x0002,
|
2017-08-14 09:08:47 +00:00
|
|
|
manufacturer="SatoshiLabs",
|
|
|
|
product="TREZOR",
|
|
|
|
serial_number="000000000000000000000000",
|
|
|
|
)
|
|
|
|
usb.add(usb_wire)
|
|
|
|
usb.add(usb_vcp)
|
|
|
|
usb.add(usb_u2f)
|
|
|
|
usb.open()
|
2016-10-11 10:33:02 +00:00
|
|
|
|
2016-09-21 12:21:18 +00:00
|
|
|
# Initialize the wire codec pipeline
|
2017-08-14 09:08:47 +00:00
|
|
|
wire.setup(usb_wire.iface_num())
|
2016-09-21 12:21:18 +00:00
|
|
|
|
2016-04-28 21:48:27 +00:00
|
|
|
# Load default homescreen
|
2016-12-08 15:18:58 +00:00
|
|
|
from apps.homescreen.homescreen import layout_homescreen
|
2016-04-28 21:48:27 +00:00
|
|
|
|
2016-12-08 15:18:58 +00:00
|
|
|
# Run main even loop and specify which screen is default
|
2017-08-14 09:08:47 +00:00
|
|
|
main.run(default_workflow=layout_homescreen)
|