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

57 lines
1.7 KiB
Python
Raw Normal View History

# isort:skip_file
# fmt: off
# We are tightly controlling the memory layout. Order of imports is important.
# Modules imported directly from here also must take care to have as few dependencies
# as possible.
# === Import always-active modules
# trezor imports only C modules
import trezor
# trezor.utils import only C modules
from trezor import utils
# we need space for 30 items in the trezor module
utils.presize_module("trezor", 30)
# storage imports storage.common, storage.cache and storage.device.
# These import trezor, trezor.config (which is a C module), trezor.utils, and each other.
2024-03-26 13:25:05 +00:00
import storage # noqa: E402
# we will need space for 12 items in the storage module
utils.presize_module("storage", 12)
2017-10-24 11:59:09 +00:00
if not utils.BITCOIN_ONLY:
# storage.fido2 only imports C modules
import storage.fido2 # noqa: F401
if __debug__:
# storage.debug only imports C modules
import storage.debug
# trezor.pin imports trezor.utils
# We need it as an always-active module because trezor.pin.show_pin_timeout is used
# as a UI callback for storage, which can be invoked at any time
2024-03-26 13:20:36 +00:00
import trezor.pin # noqa: F401, E402
# === Prepare the USB interfaces first. Do not connect to the host yet.
# usb imports trezor.utils and trezor.io which is a C module
import usb # noqa: E402
# create an unimport manager that will be reused in the main loop
unimport_manager = utils.unimport()
2017-08-15 13:09:09 +00:00
# unlock the device, unload the boot module afterwards
with unimport_manager:
import boot
del boot
2019-07-11 14:52:25 +00:00
# start the USB
import storage.device # noqa: E402
usb.bus.open(storage.device.get_device_id())
# run the endless loop
while True:
with unimport_manager:
import session # noqa: F401
del session