1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 15:28:10 +00:00
trezor-firmware/core/src/boot.py

42 lines
1.2 KiB
Python
Raw Normal View History

import storage
import storage.device
import storage.sd_salt
from trezor import config, log, loop, ui, utils, wire
from trezor.pin import show_pin_timeout
2018-07-03 14:20:26 +00:00
from apps.common.request_pin import can_lock_device, verify_user_pin
from apps.homescreen.lockscreen import Lockscreen
2019-07-03 13:07:04 +00:00
async def bootscreen() -> None:
lockscreen = Lockscreen(bootscreen=True)
ui.display.orientation(storage.device.get_rotation())
2017-10-24 11:59:09 +00:00
while True:
2018-02-19 19:36:12 +00:00
try:
if can_lock_device():
await lockscreen
await verify_user_pin()
storage.init_unlocked()
return
except wire.PinCancelled:
# verify_user_pin will convert a SdCardUnavailable (in case of sd salt)
# to PinCancelled exception.
# Ignore exception, retry loop.
pass
except BaseException as e:
# other exceptions here are unexpected and should halt the device
2019-11-06 12:57:00 +00:00
if __debug__:
log.exception(__name__, e)
utils.halt(e.__class__.__name__)
2018-02-19 19:36:12 +00:00
ui.display.backlight(ui.BACKLIGHT_NONE)
2019-05-13 13:06:34 +00:00
ui.backlight_fade(ui.BACKLIGHT_NORMAL)
config.init(show_pin_timeout)
if __debug__ and not utils.EMULATOR:
config.wipe()
2018-02-19 19:36:12 +00:00
loop.schedule(bootscreen())
2017-10-24 11:59:09 +00:00
loop.run()