diff --git a/core/SConscript.kernel b/core/SConscript.kernel index 61598225ee..8e0c6756bf 100644 --- a/core/SConscript.kernel +++ b/core/SConscript.kernel @@ -219,15 +219,9 @@ else: CPPDEFINES_MOD += [ 'TRANSLATIONS', + 'RSOD_IN_COREAPP', ] -if TREZOR_MODEL not in ('1', ): - CPPDEFINES_MOD += [ - 'FANCY_FATAL_ERROR', - ] - -CPPDEFINES_MOD += ['USE_SVC_SHUTDOWN'] - if FEATURE_FLAGS["RDI"]: CPPDEFINES_MOD += ['RDI'] diff --git a/core/embed/kernel/main.c b/core/embed/kernel/main.c index d960dda178..db314137da 100644 --- a/core/embed/kernel/main.c +++ b/core/embed/kernel/main.c @@ -194,7 +194,7 @@ static void coreapp_init(applet_t *applet) { // Shows RSOD (Red Screen of Death) static void show_rsod(const systask_postmortem_t *pminfo) { -#ifdef FANCY_FATAL_ERROR +#ifdef RSOD_IN_COREAPP applet_t coreapp; coreapp_init(&coreapp); diff --git a/core/embed/lib/rsod.c b/core/embed/lib/rsod.c index 7be3da488b..0b9a97611a 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 74ce9d7cb1..70f3815351 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 5cb7b2314f..d4b7939ac2 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 58ef808131..0666325b91 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);