diff --git a/core/embed/bootloader/emulator.c b/core/embed/bootloader/emulator.c index f050fde64..1ad001af1 100644 --- a/core/embed/bootloader/emulator.c +++ b/core/embed/bootloader/emulator.c @@ -100,7 +100,6 @@ __attribute__((noreturn)) void display_error_and_die(const char *message, display_init(); display_backlight(180); screen_fatal_error_rust(title, message, footer); - display_refresh(); #if USE_TOUCH printf("Click screen to exit.\n"); #elif USE_BUTTON @@ -210,7 +209,6 @@ __attribute__((noreturn)) void jump_to(void *addr) { "STORAGE WAS RETAINED"); } display_backlight(180); - display_refresh(); hal_delay(3000); exit(0); } diff --git a/core/embed/rust/src/trezorhal/fatal_error.rs b/core/embed/rust/src/trezorhal/fatal_error.rs index b9227bc22..de0e1188f 100644 --- a/core/embed/rust/src/trezorhal/fatal_error.rs +++ b/core/embed/rust/src/trezorhal/fatal_error.rs @@ -14,12 +14,14 @@ fn shutdown() -> ! { #[cfg(feature = "bootloader")] pub fn __fatal_error(_expr: &str, _msg: &str, _file: &str, _line: u32, _func: &str) -> ! { ModelUI::screen_fatal_error("BL.rs", "BL.rs", "PLEASE VISIT\nTREZOR.IO/RSOD"); + ModelUI::backlight_on(); shutdown() } #[cfg(not(feature = "bootloader"))] pub fn __fatal_error(_expr: &str, msg: &str, _file: &str, _line: u32, _func: &str) -> ! { ModelUI::screen_fatal_error("INTERNAL_ERROR", msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); + ModelUI::backlight_on(); shutdown() } diff --git a/core/embed/rust/src/ui/model_tr/screens.rs b/core/embed/rust/src/ui/model_tr/screens.rs index 89efbf00d..ab428272f 100644 --- a/core/embed/rust/src/ui/model_tr/screens.rs +++ b/core/embed/rust/src/ui/model_tr/screens.rs @@ -8,6 +8,7 @@ pub fn screen_fatal_error(title: &str, msg: &str, footer: &str) { let mut frame = ErrorScreen::new(title.into(), msg.into(), footer.into()); frame.place(constant::screen()); frame.paint(); + display::refresh(); } pub fn screen_boot_full() { diff --git a/core/embed/rust/src/ui/model_tt/mod.rs b/core/embed/rust/src/ui/model_tt/mod.rs index 866f07dc8..e7ecfae5a 100644 --- a/core/embed/rust/src/ui/model_tt/mod.rs +++ b/core/embed/rust/src/ui/model_tt/mod.rs @@ -23,6 +23,11 @@ impl UIFeaturesCommon for ModelTTFeatures { crate::ui::display::fade_backlight_duration(theme::BACKLIGHT_DIM, 150); } + fn backlight_on() { + #[cfg(feature = "backlight")] + crate::ui::display::set_backlight(theme::BACKLIGHT_NORMAL); + } + const SCREEN: Rect = constant::SCREEN; fn screen_fatal_error(title: &str, msg: &str, footer: &str) { diff --git a/core/embed/rust/src/ui/model_tt/screens.rs b/core/embed/rust/src/ui/model_tt/screens.rs index db01e8c62..8051c7056 100644 --- a/core/embed/rust/src/ui/model_tt/screens.rs +++ b/core/embed/rust/src/ui/model_tt/screens.rs @@ -12,6 +12,7 @@ pub fn screen_fatal_error(title: &str, msg: &str, footer: &str) { let mut frame = ErrorScreen::new(title.into(), msg.into(), footer.into()); frame.place(constant::screen()); frame.paint(); + display::refresh(); } pub fn screen_boot_full() { diff --git a/core/embed/rust/src/ui/ui_features.rs b/core/embed/rust/src/ui/ui_features.rs index 0f17a3fa7..4b89389a2 100644 --- a/core/embed/rust/src/ui/ui_features.rs +++ b/core/embed/rust/src/ui/ui_features.rs @@ -5,6 +5,7 @@ use crate::{trezorhal::secbool::secbool, ui::display::Color}; pub trait UIFeaturesCommon { fn fadein() {} fn fadeout() {} + fn backlight_on() {} const SCREEN: Rect; diff --git a/core/embed/trezorhal/stm32f4/common.c b/core/embed/trezorhal/stm32f4/common.c index 23f9b8202..ec1cd0e6a 100644 --- a/core/embed/trezorhal/stm32f4/common.c +++ b/core/embed/trezorhal/stm32f4/common.c @@ -53,6 +53,7 @@ uint32_t systick_val_copy = 0; extern void shutdown_privileged(void); void __attribute__((noreturn)) trezor_shutdown(void) { + display_finish_actions(); #ifdef USE_SVC_SHUTDOWN svc_shutdown(); #else @@ -69,9 +70,7 @@ error_uni(const char *label, const char *msg, const char *footer) { display_orientation(0); #ifdef FANCY_FATAL_ERROR - screen_fatal_error_rust(label, msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); if (label) { @@ -85,7 +84,6 @@ error_uni(const char *label, const char *msg, const char *footer) { } #endif display_backlight(255); - display_refresh(); trezor_shutdown(); } @@ -100,7 +98,6 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line, mini_snprintf(buf, sizeof(buf), "%s: %d", file, line); screen_fatal_error_rust("INTERNAL ERROR", msg != NULL ? msg : buf, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); term_printf("\nINTERNAL ERROR:\n"); @@ -133,7 +130,6 @@ error_shutdown(const char *label, const char *msg) { #ifdef FANCY_FATAL_ERROR screen_fatal_error_rust(label, msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); if (label) { diff --git a/core/embed/trezorhal/stm32f4/secret.c b/core/embed/trezorhal/stm32f4/secret.c index 6abc712d6..d299f2068 100644 --- a/core/embed/trezorhal/stm32f4/secret.c +++ b/core/embed/trezorhal/stm32f4/secret.c @@ -105,8 +105,6 @@ void secret_show_install_restricted_screen(void) { "INSTALL RESTRICTED", "Installation of custom firmware is currently restricted.", "Please visit\ntrezor.io/bootloader"); - - display_refresh(); #endif } diff --git a/core/embed/trezorhal/stm32u5/common.c b/core/embed/trezorhal/stm32u5/common.c index 9524acb0a..9dc711458 100644 --- a/core/embed/trezorhal/stm32u5/common.c +++ b/core/embed/trezorhal/stm32u5/common.c @@ -71,9 +71,7 @@ error_uni(const char *label, const char *msg, const char *footer) { display_orientation(0); #ifdef FANCY_FATAL_ERROR - screen_fatal_error_rust(label, msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); if (label) { @@ -87,7 +85,6 @@ error_uni(const char *label, const char *msg, const char *footer) { } #endif display_backlight(255); - display_refresh(); trezor_shutdown(); } @@ -102,7 +99,6 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line, mini_snprintf(buf, sizeof(buf), "%s: %d", file, line); screen_fatal_error_rust("INTERNAL ERROR", msg != NULL ? msg : buf, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); term_printf("\nINTERNAL ERROR:\n"); @@ -133,9 +129,7 @@ error_shutdown(const char *label, const char *msg) { display_orientation(0); #ifdef FANCY_FATAL_ERROR - screen_fatal_error_rust(label, msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); if (label) { diff --git a/core/embed/trezorhal/unix/common.c b/core/embed/trezorhal/unix/common.c index 8abb4887e..aeeb46acd 100644 --- a/core/embed/trezorhal/unix/common.c +++ b/core/embed/trezorhal/unix/common.c @@ -34,6 +34,7 @@ extern void main_clean_exit(int); void __attribute__((noreturn)) trezor_shutdown(void) { + display_finish_actions(); printf("SHUTDOWN\n"); main_clean_exit(3); for (;;) @@ -52,9 +53,7 @@ error_uni(const char *label, const char *msg, const char *footer) { display_orientation(0); #ifdef FANCY_FATAL_ERROR - screen_fatal_error_rust(label, msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); if (label) { @@ -68,7 +67,6 @@ error_uni(const char *label, const char *msg, const char *footer) { } #endif display_backlight(255); - display_refresh(); hal_delay(3000); trezor_shutdown(); } @@ -90,8 +88,6 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line, screen_fatal_error_rust("INTERNAL ERROR", msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); } - - display_refresh(); #else term_set_color(COLOR_WHITE, COLOR_FATAL_ERROR); term_printf("\nINTERNAL ERROR:\n"); @@ -130,7 +126,6 @@ void __attribute__((noreturn)) error_shutdown(const char *label, const char *msg) { #ifdef FANCY_FATAL_ERROR screen_fatal_error_rust(label, msg, "PLEASE VISIT\nTREZOR.IO/RSOD"); - display_refresh(); #else display_clear(); display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_FATAL_ERROR);