1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-05 22:32:33 +00:00
trezor-firmware/core/src/main.py
matejcik 7ca67cc4d9 feat(core): clear out memory space after every workflow
A small fixed list of modules is kept pre-loaded in the GC arena.
These must not keep references to anything else, as all other modules
are unloaded and the memory is cleared.
2021-05-06 13:14:21 +02:00

26 lines
534 B
Python

# isort:skip_file
# fmt: off
# Import always-active modules
import storage
import storage.device
from trezor import config, pin, utils # noqa: F401
# Prepare the USB interfaces first. Do not connect to the host yet.
import usb
unimport_manager = utils.unimport()
# unlock the device, unload the boot module afterwards
with unimport_manager:
import boot
del boot
# start the USB
usb.bus.open(storage.device.get_device_id())
while True:
with unimport_manager:
import session # noqa: F401
del session