From a255938903ce633e4401b0c249efefd7620a50e2 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 24 Oct 2017 13:59:09 +0200 Subject: [PATCH] main: unlock storage after boot --- src/boot.py | 27 +++++++++++++++++++++++++++ src/main.py | 6 ++---- src/trezor/loop.py | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/boot.py diff --git a/src/boot.py b/src/boot.py new file mode 100644 index 0000000000..d3afefc176 --- /dev/null +++ b/src/boot.py @@ -0,0 +1,27 @@ +from trezor import config +from trezor import loop +from trezor import ui + +from apps.common.request_pin import request_pin + + +async def unlock_layout(): + while True: + if config.has_pin(): + pin = await request_pin() + else: + pin = '' + if config.unlock(pin): + return + else: + await unlock_failed() + + +async def unlock_failed(): + pass + + +config.init() +ui.display.backlight(ui.BACKLIGHT_DIM) +loop.schedule(unlock_layout()) +loop.run() diff --git a/src/main.py b/src/main.py index c9dcc85494..b3ebac8aaf 100644 --- a/src/main.py +++ b/src/main.py @@ -1,12 +1,11 @@ -from trezor import config +import boot + from trezor import io from trezor import log from trezor import loop from trezor import wire from trezor import workflow -config.init() - log.level = log.DEBUG # initialize the USB stack @@ -102,7 +101,6 @@ usb.add(usb_vcp) usb.add(usb_u2f) # load applications -from apps.common import storage if __debug__: from apps import debug from apps import homescreen diff --git a/src/trezor/loop.py b/src/trezor/loop.py index 714e018aad..83e3393647 100644 --- a/src/trezor/loop.py +++ b/src/trezor/loop.py @@ -86,7 +86,7 @@ def run(): task_entry = [0, 0, 0] # deadline, task, value msg_entry = [0, 0] # iface | flags, value - while True: + while _queue or _paused: # compute the maximum amount of time we can wait for a message if _queue: delay = utime.ticks_diff(_queue.peektime(), utime.ticks_us())