mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-03 08:46:05 +00:00
feat(core): optimize boot time by drawing full logo sooner and shortening the enforced delay proportionally
[no changelog]
This commit is contained in:
parent
c5fc92e36a
commit
a2f72b1055
@ -47,6 +47,7 @@
|
|||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "mpu.h"
|
#include "mpu.h"
|
||||||
#include "random_delays.h"
|
#include "random_delays.h"
|
||||||
|
#include "rust_ui.h"
|
||||||
|
|
||||||
#include TREZOR_BOARD
|
#include TREZOR_BOARD
|
||||||
|
|
||||||
@ -111,6 +112,8 @@ int main(void) {
|
|||||||
|
|
||||||
display_reinit();
|
display_reinit();
|
||||||
|
|
||||||
|
screen_boot_full();
|
||||||
|
|
||||||
#if !defined TREZOR_MODEL_1
|
#if !defined TREZOR_MODEL_1
|
||||||
parse_boardloader_capabilities();
|
parse_boardloader_capabilities();
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_description;
|
MP_QSTR_description;
|
||||||
MP_QSTR_details_title;
|
MP_QSTR_details_title;
|
||||||
MP_QSTR_disable_animation;
|
MP_QSTR_disable_animation;
|
||||||
MP_QSTR_draw_welcome_screen;
|
|
||||||
MP_QSTR_dry_run;
|
MP_QSTR_dry_run;
|
||||||
MP_QSTR_encode;
|
MP_QSTR_encode;
|
||||||
MP_QSTR_encoded_length;
|
MP_QSTR_encoded_length;
|
||||||
|
@ -23,9 +23,9 @@ void screen_wipe_fail(void);
|
|||||||
uint32_t screen_install_success(uint8_t restart_seconds, bool initial_setup,
|
uint32_t screen_install_success(uint8_t restart_seconds, bool initial_setup,
|
||||||
bool complete_draw);
|
bool complete_draw);
|
||||||
uint32_t screen_install_fail(void);
|
uint32_t screen_install_fail(void);
|
||||||
void screen_welcome_model(void);
|
|
||||||
void screen_welcome(void);
|
void screen_welcome(void);
|
||||||
void screen_boot_empty(bool fading);
|
void screen_boot_empty(bool fading);
|
||||||
|
void screen_boot_full(void);
|
||||||
uint32_t screen_unlock_bootloader_confirm(void);
|
uint32_t screen_unlock_bootloader_confirm(void);
|
||||||
void screen_unlock_bootloader_success(void);
|
void screen_unlock_bootloader_success(void);
|
||||||
void display_image(int16_t x, int16_t y, const uint8_t* data, uint32_t datalen);
|
void display_image(int16_t x, int16_t y, const uint8_t* data, uint32_t datalen);
|
||||||
|
@ -377,12 +377,6 @@ extern "C" fn screen_welcome() {
|
|||||||
show(&mut frame);
|
show(&mut frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
extern "C" fn screen_welcome_model() {
|
|
||||||
let mut frame = WelcomeScreen::new(false);
|
|
||||||
show(&mut frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn bld_continue_label(bg_color: cty::uint16_t) {
|
extern "C" fn bld_continue_label(bg_color: cty::uint16_t) {
|
||||||
display::text_center(
|
display::text_center(
|
||||||
|
@ -1612,15 +1612,6 @@ extern "C" fn new_show_lockscreen(n_args: usize, args: *const Obj, kwargs: *mut
|
|||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn draw_welcome_screen() -> Obj {
|
|
||||||
// No need of util::try_or_raise, this does not allocate
|
|
||||||
let mut screen = WelcomeScreen::new(false);
|
|
||||||
screen.place(constant::screen());
|
|
||||||
display::sync();
|
|
||||||
screen.paint();
|
|
||||||
Obj::const_none()
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn new_confirm_firmware_update(
|
extern "C" fn new_confirm_firmware_update(
|
||||||
n_args: usize,
|
n_args: usize,
|
||||||
args: *const Obj,
|
args: *const Obj,
|
||||||
@ -2069,10 +2060,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
/// """Homescreen for locked device."""
|
/// """Homescreen for locked device."""
|
||||||
Qstr::MP_QSTR_show_lockscreen => obj_fn_kw!(0, new_show_lockscreen).as_obj(),
|
Qstr::MP_QSTR_show_lockscreen => obj_fn_kw!(0, new_show_lockscreen).as_obj(),
|
||||||
|
|
||||||
/// def draw_welcome_screen() -> None:
|
|
||||||
/// """Show logo icon with the model name at the bottom and return."""
|
|
||||||
Qstr::MP_QSTR_draw_welcome_screen => obj_fn_0!(draw_welcome_screen).as_obj(),
|
|
||||||
|
|
||||||
/// def confirm_firmware_update(
|
/// def confirm_firmware_update(
|
||||||
/// *,
|
/// *,
|
||||||
/// description: str,
|
/// description: str,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#[cfg(feature = "micropython")]
|
#[cfg(feature = "micropython")]
|
||||||
use crate::micropython::buffer::StrBuffer;
|
use crate::micropython::buffer::StrBuffer;
|
||||||
use crate::ui::component::base::Component;
|
use crate::ui::{
|
||||||
|
component::base::Component, constant::screen, display, model_tr::component::WelcomeScreen,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{component::ErrorScreen, constant};
|
use super::{component::ErrorScreen, constant};
|
||||||
|
|
||||||
@ -27,3 +29,12 @@ pub fn screen_fatal_error(title: &str, msg: &str, footer: &str) {
|
|||||||
frame.place(constant::screen());
|
frame.place(constant::screen());
|
||||||
frame.paint();
|
frame.paint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
extern "C" fn screen_boot_full() {
|
||||||
|
let mut frame = WelcomeScreen::new(false);
|
||||||
|
frame.place(screen());
|
||||||
|
display::sync();
|
||||||
|
frame.paint();
|
||||||
|
display::refresh();
|
||||||
|
}
|
||||||
|
@ -405,12 +405,6 @@ extern "C" fn screen_install_success(
|
|||||||
display::refresh();
|
display::refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
extern "C" fn screen_welcome_model() {
|
|
||||||
let mut frame = WelcomeScreen::new(false);
|
|
||||||
show(&mut frame, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn screen_welcome() {
|
extern "C" fn screen_welcome() {
|
||||||
let mut frame = Welcome::new();
|
let mut frame = Welcome::new();
|
||||||
|
@ -1579,17 +1579,6 @@ extern "C" fn new_show_lockscreen(n_args: usize, args: *const Obj, kwargs: *mut
|
|||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn draw_welcome_screen() -> Obj {
|
|
||||||
// No need of util::try_or_raise, this does not allocate
|
|
||||||
let mut screen = WelcomeScreen::new(false);
|
|
||||||
screen.place(constant::screen());
|
|
||||||
display::sync();
|
|
||||||
screen.paint();
|
|
||||||
display::refresh();
|
|
||||||
display::set_backlight(theme::BACKLIGHT_NORMAL);
|
|
||||||
Obj::const_none()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub extern "C" fn upy_check_homescreen_format(data: Obj) -> Obj {
|
pub extern "C" fn upy_check_homescreen_format(data: Obj) -> Obj {
|
||||||
let block = || {
|
let block = || {
|
||||||
let buffer = unsafe { get_buffer(data) }?;
|
let buffer = unsafe { get_buffer(data) }?;
|
||||||
@ -2043,10 +2032,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
/// """Homescreen for locked device."""
|
/// """Homescreen for locked device."""
|
||||||
Qstr::MP_QSTR_show_lockscreen => obj_fn_kw!(0, new_show_lockscreen).as_obj(),
|
Qstr::MP_QSTR_show_lockscreen => obj_fn_kw!(0, new_show_lockscreen).as_obj(),
|
||||||
|
|
||||||
/// def draw_welcome_screen() -> None:
|
|
||||||
/// """Show logo icon with the model name at the bottom and return."""
|
|
||||||
Qstr::MP_QSTR_draw_welcome_screen => obj_fn_0!(draw_welcome_screen).as_obj(),
|
|
||||||
|
|
||||||
/// def confirm_firmware_update(
|
/// def confirm_firmware_update(
|
||||||
/// *,
|
/// *,
|
||||||
/// description: str,
|
/// description: str,
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
use crate::micropython::buffer::StrBuffer;
|
use crate::micropython::buffer::StrBuffer;
|
||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
component::Component,
|
component::Component,
|
||||||
model_tt::{component::ErrorScreen, constant},
|
constant::screen,
|
||||||
|
display,
|
||||||
|
model_tt::{
|
||||||
|
component::{ErrorScreen, WelcomeScreen},
|
||||||
|
constant,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "micropython"))]
|
#[cfg(not(feature = "micropython"))]
|
||||||
@ -28,3 +33,12 @@ pub fn screen_fatal_error(title: &str, msg: &str, footer: &str) {
|
|||||||
frame.place(constant::screen());
|
frame.place(constant::screen());
|
||||||
frame.paint();
|
frame.paint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
extern "C" fn screen_boot_full() {
|
||||||
|
let mut frame = WelcomeScreen::new(false);
|
||||||
|
frame.place(screen());
|
||||||
|
display::sync();
|
||||||
|
frame.paint();
|
||||||
|
display::refresh();
|
||||||
|
}
|
||||||
|
@ -439,11 +439,6 @@ def show_lockscreen(
|
|||||||
"""Homescreen for locked device."""
|
"""Homescreen for locked device."""
|
||||||
|
|
||||||
|
|
||||||
# rust/src/ui/model_tr/layout.rs
|
|
||||||
def draw_welcome_screen() -> None:
|
|
||||||
"""Show logo icon with the model name at the bottom and return."""
|
|
||||||
|
|
||||||
|
|
||||||
# rust/src/ui/model_tr/layout.rs
|
# rust/src/ui/model_tr/layout.rs
|
||||||
def confirm_firmware_update(
|
def confirm_firmware_update(
|
||||||
*,
|
*,
|
||||||
@ -896,11 +891,6 @@ def show_lockscreen(
|
|||||||
"""Homescreen for locked device."""
|
"""Homescreen for locked device."""
|
||||||
|
|
||||||
|
|
||||||
# rust/src/ui/model_tt/layout.rs
|
|
||||||
def draw_welcome_screen() -> None:
|
|
||||||
"""Show logo icon with the model name at the bottom and return."""
|
|
||||||
|
|
||||||
|
|
||||||
# rust/src/ui/model_tt/layout.rs
|
# rust/src/ui/model_tt/layout.rs
|
||||||
def confirm_firmware_update(
|
def confirm_firmware_update(
|
||||||
*,
|
*,
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
# isort:skip_file
|
# isort:skip_file
|
||||||
|
|
||||||
import trezorui2
|
|
||||||
import utime
|
import utime
|
||||||
|
|
||||||
# Showing welcome screen as soon as possible
|
# Welcome screen is shown immediately after display init.
|
||||||
|
# Then it takes about 120ms to get here.
|
||||||
# (display is also prepared on that occasion).
|
# (display is also prepared on that occasion).
|
||||||
# Remembering time to control how long we show it.
|
# Remembering time to control how long we show it.
|
||||||
trezorui2.draw_welcome_screen()
|
|
||||||
welcome_screen_start_ms = utime.ticks_ms()
|
welcome_screen_start_ms = utime.ticks_ms()
|
||||||
|
|
||||||
import storage
|
import storage
|
||||||
@ -21,7 +20,7 @@ from trezor.ui.layouts.homescreen import Lockscreen
|
|||||||
|
|
||||||
from apps.common.request_pin import can_lock_device, verify_user_pin
|
from apps.common.request_pin import can_lock_device, verify_user_pin
|
||||||
|
|
||||||
_WELCOME_SCREEN_MS = 1200 # how long do we want to show welcome screen (minimum)
|
_WELCOME_SCREEN_MS = 1000 # how long do we want to show welcome screen (minimum)
|
||||||
|
|
||||||
|
|
||||||
def enforce_welcome_screen_duration() -> None:
|
def enforce_welcome_screen_duration() -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user