diff --git a/embed/trezorhal/common.c b/embed/trezorhal/common.c index f7cdbcc764..67b68ebc45 100644 --- a/embed/trezorhal/common.c +++ b/embed/trezorhal/common.c @@ -51,6 +51,53 @@ void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, #ifdef GITREV display_printf("rev : %s\n", XSTR(GITREV)); #endif + display_printf("\nPlease contact TREZOR support.\n"); + shutdown(); + for (;;); +} + +void __attribute__((noreturn)) error_shutdown(const char *line1, const char *line2, const char *line3, const char *line4) +{ + display_orientation(0); +#ifdef TREZOR_FONT_NORMAL_ENABLE + display_clear(); + display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_FATAL_ERROR); + int y = 32; + if (line1) { + display_text(8, y, line1, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + y += 32; + } + if (line2) { + display_text(8, y, line2, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + y += 32; + } + if (line3) { + display_text(8, y, line3, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + y += 32; + } + if (line4) { + display_text(8, y, line4, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + y += 32; + } + y += 32; + display_text(8, y, "Please unplug the device.", -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); +#else + display_print_color(COLOR_WHITE, COLOR_FATAL_ERROR); + if (line1) { + display_printf("%s\n", line1); + } + if (line2) { + display_printf("%s\n", line2); + } + if (line3) { + display_printf("%s\n", line3); + } + if (line4) { + display_printf("%s\n", line4); + } + display_printf("\nPlease unplug the device.\n"); +#endif + display_backlight(255); shutdown(); for (;;); } diff --git a/embed/trezorhal/common.h b/embed/trezorhal/common.h index 1b8c8a3b46..7f147956d6 100644 --- a/embed/trezorhal/common.h +++ b/embed/trezorhal/common.h @@ -34,6 +34,7 @@ #endif void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func); +void __attribute__((noreturn)) error_shutdown(const char *line1, const char *line2, const char *line3, const char *line4); #define ensure(expr, msg) (((expr) == sectrue) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__)) diff --git a/embed/unix/common.c b/embed/unix/common.c index c591e66e5a..73047d40e6 100644 --- a/embed/unix/common.c +++ b/embed/unix/common.c @@ -60,11 +60,47 @@ void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, display_printf("rev : %s\n", XSTR(GITREV)); printf("rev : %s\n", XSTR(GITREV)); #endif + display_printf("\nPlease contact TREZOR support.\n"); + printf("\nPlease contact TREZOR support.\n"); hal_delay(3000); __shutdown(); for (;;); } +void __attribute__((noreturn)) error_shutdown(const char *line1, const char *line2, const char *line3, const char *line4) +{ + display_clear(); + display_bar(0, 0, DISPLAY_RESX, DISPLAY_RESY, COLOR_FATAL_ERROR); + int y = 32; + if (line1) { + display_text(8, y, line1, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + printf("%s\n", line1); + y += 32; + } + if (line2) { + display_text(8, y, line2, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + printf("%s\n", line2); + y += 32; + } + if (line3) { + display_text(8, y, line3, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + printf("%s\n", line3); + y += 32; + } + if (line4) { + display_text(8, y, line4, -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + printf("%s\n", line4); + y += 32; + } + y += 32; + display_text(8, y, "Please unplug the device.", -1, FONT_NORMAL, COLOR_WHITE, COLOR_FATAL_ERROR); + printf("\nPlease unplug the device.\n"); + display_backlight(255); + hal_delay(5000); + __shutdown(); + for (;;); +} + void hal_delay(uint32_t ms) { usleep(1000 * ms); diff --git a/embed/unix/common.h b/embed/unix/common.h index af73c80ffe..022fbacdab 100644 --- a/embed/unix/common.h +++ b/embed/unix/common.h @@ -34,6 +34,7 @@ #endif void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func); +void __attribute__((noreturn)) error_shutdown(const char *line1, const char *line2, const char *line3, const char *line4); #define ensure(expr, msg) (((expr) == sectrue) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__))