1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 12:08:59 +00:00
trezor-firmware/core/src/main.py

98 lines
2.2 KiB
Python
Raw Normal View History

# isort:skip_file
# unlock the device
import boot # noqa: F401
2017-10-24 11:59:09 +00:00
# prepare the USB interfaces, but do not connect to the host yet
import usb
from trezor import utils
2017-08-15 13:09:09 +00:00
# start the USB
usb.bus.open()
# switch into unprivileged mode, as we don't need the extra permissions anymore
utils.set_mode_unprivileged()
2018-07-03 14:20:58 +00:00
2019-08-06 13:42:23 +00:00
def _boot_recovery() -> None:
2019-07-11 14:52:25 +00:00
# load applications
import apps.homescreen
2019-07-11 14:52:25 +00:00
# boot applications
apps.homescreen.boot(features_only=True)
2019-07-11 14:52:25 +00:00
from apps.management.recovery_device.homescreen import recovery_homescreen
loop.schedule(recovery_homescreen())
2019-08-06 13:42:23 +00:00
def _boot_default() -> None:
2019-07-11 14:52:25 +00:00
# load applications
import apps.homescreen
import apps.management
import apps.wallet
2019-08-22 18:15:16 +00:00
if not utils.BITCOIN_ONLY:
import apps.ethereum
import apps.lisk
import apps.monero
import apps.nem
import apps.stellar
import apps.ripple
import apps.cardano
import apps.tezos
import apps.eos
import apps.binance
2019-07-11 14:52:25 +00:00
if __debug__:
import apps.debug
if not utils.BITCOIN_ONLY:
if not __debug__ or utils.EMULATOR:
2019-08-22 18:15:16 +00:00
import apps.webauthn
2019-07-11 14:52:25 +00:00
# boot applications
apps.homescreen.boot()
apps.management.boot()
apps.wallet.boot()
2019-08-22 18:15:16 +00:00
if not utils.BITCOIN_ONLY:
apps.ethereum.boot()
apps.lisk.boot()
apps.monero.boot()
apps.nem.boot()
apps.stellar.boot()
apps.ripple.boot()
apps.cardano.boot()
apps.tezos.boot()
apps.eos.boot()
apps.binance.boot()
2019-07-11 14:52:25 +00:00
if __debug__:
apps.debug.boot()
if not utils.BITCOIN_ONLY:
if not __debug__ or utils.EMULATOR:
2019-08-22 18:15:16 +00:00
apps.webauthn.boot(usb.iface_webauthn)
2019-07-11 14:52:25 +00:00
# run main event loop and specify which screen is the default
from apps.homescreen.homescreen import homescreen
workflow.start_default(homescreen)
2019-07-11 14:52:25 +00:00
from trezor import loop, wire, workflow
2019-07-11 14:52:25 +00:00
from apps.common.storage import recovery
while True:
# initialize the wire codec
wire.setup(usb.iface_wire)
if __debug__:
wire.setup(usb.iface_debug)
# boot either in recovery or default mode
if recovery.is_in_progress():
_boot_recovery()
else:
_boot_default()
loop.run()
# loop is empty, reboot