From bf375b1188bed73e45f407a18a22d0e238f94d27 Mon Sep 17 00:00:00 2001 From: cepetr Date: Thu, 3 Oct 2024 14:27:53 +0200 Subject: [PATCH] fix(emulator): fix rsod drawing in emulator [no changelog] --- core/embed/lib/rsod.c | 6 +++--- core/embed/lib/terminal.c | 21 +++++---------------- core/embed/trezorhal/unix/display_driver.c | 2 +- core/embed/unix/main.c | 13 +++++++------ 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/core/embed/lib/rsod.c b/core/embed/lib/rsod.c index 7be3da488b9..0b9a97611a5 100644 --- a/core/embed/lib/rsod.c +++ b/core/embed/lib/rsod.c @@ -98,7 +98,7 @@ void rsod_terminal(const systask_postmortem_t* pminfo) { #endif // KERNEL_MODE -#if (defined(FIRMWARE) || defined(BOOTLOADER)) && defined(FANCY_FATAL_ERROR) +#ifdef FANCY_FATAL_ERROR #include "rust_ui.h" @@ -139,7 +139,7 @@ void rsod_gui(const systask_postmortem_t* pminfo) { display_rsod_rust(title, message, footer); } -#endif +#endif // FANCY_FATAL_ERROR #ifdef KERNEL_MODE @@ -153,7 +153,7 @@ static void init_and_show_rsod(const systask_postmortem_t* pminfo) { // Initialize necessary drivers display_init(DISPLAY_RESET_CONTENT); -#if (defined(FIRMWARE) || defined(BOOTLOADER)) && defined(FANCY_FATAL_ERROR) +#ifdef FANCY_FATAL_ERROR // Show the RSOD using Rust GUI rsod_gui(pminfo); #else diff --git a/core/embed/lib/terminal.c b/core/embed/lib/terminal.c index 74ce9d7cb1d..70f38153517 100644 --- a/core/embed/lib/terminal.c +++ b/core/embed/lib/terminal.c @@ -17,15 +17,17 @@ * along with this program. If not, see . */ -#include "terminal.h" +#include TREZOR_BOARD + #include #include #include -#include "display.h" -#include TREZOR_BOARD +#include "display.h" #include "fonts/fonts.h" #include "gfx_draw.h" +#include "mini_printf.h" +#include "terminal.h" #define TERMINAL_COLS (DISPLAY_RESX / 6) #define TERMINAL_ROWS (DISPLAY_RESY / 8) @@ -169,29 +171,16 @@ void term_print(const char *text, int textlen) { #endif } -#ifdef TREZOR_EMULATOR -#define mini_vsnprintf vsnprintf -#include -#else -#include "mini_printf.h" -#endif - // variadic term_print void term_printf(const char *fmt, ...) { if (!strchr(fmt, '%')) { term_print(fmt, strlen(fmt)); -#ifdef TREZOR_EMULATOR - printf("%s", fmt); -#endif } else { va_list va; va_start(va, fmt); char buf[256] = {0}; int len = mini_vsnprintf(buf, sizeof(buf), fmt, va); term_print(buf, len); -#ifdef TREZOR_EMULATOR - vprintf(fmt, va); -#endif va_end(va); } } diff --git a/core/embed/trezorhal/unix/display_driver.c b/core/embed/trezorhal/unix/display_driver.c index 5cb7b2314f5..d4b7939ac20 100644 --- a/core/embed/trezorhal/unix/display_driver.c +++ b/core/embed/trezorhal/unix/display_driver.c @@ -370,7 +370,7 @@ void display_copy_mono1p(const gfx_bitblt_t *bb) { gfx_bitblt_t bb_new = *bb; bb_new.dst_row = (uint8_t *)drv->buffer->pixels + (drv->buffer->pitch * bb_new.dst_y); - bb_new.dst_stride = DISPLAY_RESX; + bb_new.dst_stride = drv->buffer->pitch; gfx_rgb565_copy_mono1p(&bb_new); } diff --git a/core/embed/unix/main.c b/core/embed/unix/main.c index 58ef8081313..0666325b917 100644 --- a/core/embed/unix/main.c +++ b/core/embed/unix/main.c @@ -37,6 +37,7 @@ #include #include +#include "common.h" #include "display.h" #include "extmod/misc.h" #include "extmod/vfs_posix.h" @@ -44,6 +45,11 @@ #include "flash_otp.h" #include "genhdr/mpversion.h" #include "input.h" +#include "rsod.h" +#include "system.h" +#include "systimer.h" +#include "touch.h" + #include "py/builtin.h" #include "py/compile.h" #include "py/gc.h" @@ -53,10 +59,6 @@ #include "py/repl.h" #include "py/runtime.h" #include "py/stackctrl.h" -#include "systimer.h" -#include "touch.h" - -#include "common.h" // Command line options, with their defaults STATIC bool compile_only = false; @@ -487,8 +489,7 @@ MP_NOINLINE int main_(int argc, char **argv) { pre_process_options(argc, argv); - systick_init(); - systimer_init(); + system_init(&rsod_panic_handler); display_init(DISPLAY_RESET_CONTENT);