refactor(core): move rsod to io/gfx and sec/rsod
What changed, and why it matters
This commit is a pure code reorganization (refactor) that moves the 'Red Screen of Death' (RSOD) error-display code from one directory to another and updates the build files and #include paths accordingly. No security vulnerability is introduced or fixed; the visible behavior of the device is unchanged.
No security action required. Treat as routine maintenance/refactor. Verify that all build targets compile and that RSOD screens still display correctly in tests.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change relocates RSOD implementation files from core/embed/util/rsod/ to core/embed/io/gfx/ and core/embed/sec/rsod/, splitting the generic display logic (io/gfx) from security-specialized screens (sec/rsod). It updates all SConscript build scripts and source files to reference the new header paths (
Changed components
core/embed/io/gfx/rsod.ccore/embed/sec/rsod/rsod_special.ccore/SConscript.* build scriptscore/embed/projects/*/main.ccore/embed/sec/secret/*core/embed/sec/tamper/stm32u5/tamper.ccore/embed/sys/startup/unix/bootutils.cInspect captured patch +443 / −434
diff --git a/core/SConscript.boardloader b/core/SConscript.boardloader
index 8a1d83e7..cef10163 100644
--- a/core/SConscript.boardloader
+++ b/core/SConscript.boardloader
@@ -91,14 +91,14 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_mono8.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/error_handling.c',
'embed/rtl/scm_revision.c',
'embed/rtl/strutils.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'embed/sys/flash/flash_utils.c',
]
@@ -154,8 +154,8 @@ env.Replace(
'embed/io/touch/inc',
'embed/io/usb/inc',
'embed/sec/image/inc',
+ 'embed/sec/rsod/inc',
'embed/sys/bsp/inc',
- 'embed/util/rsod/inc',
'vendor/micropython/lib/cmsis/inc',
] + CPPPATH_MOD + PATH_HAL,
CPPDEFINES=[
diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader
index 8c082b06..894dec8b 100644
--- a/core/SConscript.bootloader
+++ b/core/SConscript.bootloader
@@ -116,14 +116,14 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_rgba8888.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/error_handling.c',
'embed/rtl/scm_revision.c',
'embed/rtl/strutils.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'embed/sys/flash/flash_utils.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
@@ -209,8 +209,8 @@ ALLPATHS = [
'embed/io/gfx/inc',
'embed/io/translations/inc',
'embed/sec/image/inc',
+ 'embed/sec/rsod/inc',
'embed/sys/bsp/inc',
- 'embed/util/rsod/inc',
'embed/upymod/modtrezorui',
'vendor/nanopb',
] + CPPPATH_MOD + PATH_HAL
diff --git a/core/SConscript.bootloader_ci b/core/SConscript.bootloader_ci
index a72294e2..09a3192c 100644
--- a/core/SConscript.bootloader_ci
+++ b/core/SConscript.bootloader_ci
@@ -95,14 +95,14 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_rgba8888.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/error_handling.c',
'embed/rtl/scm_revision.c',
'embed/rtl/strutils.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'embed/sys/flash/flash_utils.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
@@ -169,8 +169,8 @@ env.Replace(
'embed/models',
'embed/io/gfx/inc',
'embed/sec/image/inc',
+ 'embed/sec/rsod/inc',
'embed/sys/bsp/inc',
- 'embed/util/rsod/inc',
'embed/upymod/modtrezorui',
'vendor/nanopb',
] + CPPPATH_MOD + PATH_HAL,
diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu
index f00c6fa3..f5b627f4 100644
--- a/core/SConscript.bootloader_emu
+++ b/core/SConscript.bootloader_emu
@@ -90,14 +90,14 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_rgba8888.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/error_handling.c',
'embed/rtl/scm_revision.c',
'embed/rtl/strutils.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'embed/sys/flash/flash_utils.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
@@ -183,7 +183,7 @@ ALLPATHS = ['embed/rust',
'embed/io/gfx/inc',
'embed/io/translations/inc',
'embed/sec/image/inc',
- 'embed/util/rsod/inc',
+ 'embed/sec/rsod/inc',
'vendor/nanopb',
] + CPPPATH_MOD + PATH_HAL
diff --git a/core/SConscript.firmware b/core/SConscript.firmware
index 5f119c58..3f1403b6 100644
--- a/core/SConscript.firmware
+++ b/core/SConscript.firmware
@@ -258,10 +258,10 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_mono8.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
'embed/io/translations/translations.c',
- 'embed/util/rsod/rsod.c',
'embed/rtl/error_handling.c',
'embed/rtl/scm_revision.c',
'embed/rtl/strutils.c',
@@ -492,7 +492,7 @@ ALLPATHS = [
'embed/io/translations/inc',
'embed/sys/bsp/inc',
'embed/sec/image/inc',
- 'embed/util/rsod/inc',
+ 'embed/sec/rsod/inc',
'embed/upymod/modtrezorui',
'vendor/micropython',
] + CPPPATH_MOD + PATH_HAL
diff --git a/core/SConscript.kernel b/core/SConscript.kernel
index f9cd0654..4fb7f2ac 100644
--- a/core/SConscript.kernel
+++ b/core/SConscript.kernel
@@ -215,15 +215,15 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_mono8.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
'embed/io/translations/translations.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/error_handling.c',
'embed/rtl/strutils.c',
'embed/sec/image/boot_image.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
'vendor/micropython/lib/uzlib/tinflate.c',
@@ -316,8 +316,8 @@ ALLPATHS = [
'embed/io/gfx/inc',
'embed/io/translations/inc',
'embed/sec/image/inc',
+ 'embed/sec/rsod/inc',
'embed/sys/bsp/inc',
- 'embed/util/rsod/inc',
] + CPPPATH_MOD + PATH_HAL
env.Replace(
diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest
index d60585f0..3b2c2d54 100644
--- a/core/SConscript.prodtest
+++ b/core/SConscript.prodtest
@@ -168,10 +168,9 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_mono8.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/cli.c',
'embed/rtl/error_handling.c',
'embed/rtl/printf.c',
@@ -180,6 +179,7 @@ SOURCE_MOD += [
'embed/rtl/unit_test.c',
'embed/sec/image/boot_image.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
'vendor/micropython/lib/uzlib/tinflate.c',
@@ -258,8 +258,8 @@ ALLPATHS = [
'embed/io/translations/inc',
'embed/sys/bsp/inc',
'embed/sec/image/inc',
+ 'embed/sec/rsod/inc',
'embed/sec/storage/inc',
- 'embed/util/rsod/inc',
'embed/upymod/modtrezorui',
]
diff --git a/core/SConscript.prodtest_emu b/core/SConscript.prodtest_emu
index 184e1ffb..d2f033ea 100644
--- a/core/SConscript.prodtest_emu
+++ b/core/SConscript.prodtest_emu
@@ -134,10 +134,9 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_mono8.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/cli.c',
'embed/rtl/error_handling.c',
'embed/rtl/printf.c',
@@ -146,6 +145,7 @@ SOURCE_MOD += [
'embed/rtl/unit_test.c',
'embed/sec/image/boot_image.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
'vendor/micropython/lib/uzlib/tinflate.c',
@@ -223,7 +223,7 @@ ALLPATHS = ['embed/rust',
'embed/io/gfx/inc',
'embed/io/translations/inc',
'embed/sec/image/inc',
- 'embed/util/rsod/inc',
+ 'embed/sec/rsod/inc',
] + CPPPATH_MOD + PATH_HAL
env.Replace(
diff --git a/core/SConscript.secmon b/core/SConscript.secmon
index bd1370da..124d8dc4 100644
--- a/core/SConscript.secmon
+++ b/core/SConscript.secmon
@@ -214,11 +214,11 @@ if 'boot_ucb' in FEATURES_AVAILABLE:
SOURCE_MOD += [
'embed/io/translations/translations.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/error_handling.c',
'embed/rtl/strutils.c',
'embed/sec/image/boot_image.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
'vendor/micropython/lib/uzlib/tinflate.c',
@@ -310,8 +310,8 @@ ALLPATHS = [
'embed/io/gfx/inc',
'embed/io/translations/inc',
'embed/sec/image/inc',
+ 'embed/sec/rsod/inc',
'embed/sys/bsp/inc',
- 'embed/util/rsod/inc',
] + CPPPATH_MOD + PATH_HAL
env.Replace(
diff --git a/core/SConscript.unix b/core/SConscript.unix
index 55ad2188..0925df59 100644
--- a/core/SConscript.unix
+++ b/core/SConscript.unix
@@ -241,15 +241,15 @@ SOURCE_MOD += [
'embed/io/gfx/bitblt/gfx_bitblt_mono8.c',
'embed/io/gfx/gfx_color.c',
'embed/io/gfx/gfx_draw.c',
+ 'embed/io/gfx/rsod.c',
'embed/io/gfx/terminal/font_bitmap.c',
'embed/io/gfx/terminal/terminal.c',
'embed/io/translations/translations.c',
- 'embed/util/rsod/rsod.c',
- 'embed/util/rsod/rsod_special.c',
'embed/rtl/error_handling.c',
'embed/rtl/strutils.c',
'embed/rtl/scm_revision.c',
'embed/sec/image/image.c',
+ 'embed/sec/rsod/rsod_special.c',
'vendor/micropython/lib/uzlib/adler32.c',
'vendor/micropython/lib/uzlib/crc32.c',
'vendor/micropython/lib/uzlib/tinflate.c',
@@ -500,7 +500,7 @@ ALLPATHS=['.',
'embed/io/gfx/inc',
'embed/io/translations/inc',
'embed/sec/image/inc',
- 'embed/util/rsod/inc',
+ 'embed/sec/rsod/inc',
'vendor/micropython',
'vendor/micropython/ports/unix',
'vendor/micropython/lib/mp-readline',
diff --git a/core/embed/io/gfx/inc/io/rsod.h b/core/embed/io/gfx/inc/io/rsod.h
new file mode 100644
index 00000000..36b759b7
--- /dev/null
+++ b/core/embed/io/gfx/inc/io/rsod.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <sys/bootutils.h>
+#include <sys/systask.h>
+
+/**
+ * Shows RSOD (Red Screen of Death) using terminal.
+ *
+ * @param pminfo Pointer to the post mortem to display
+ */
+void rsod_terminal(const systask_postmortem_t* pminfo);
+
+/**
+ * Shows RSOD (Red Screen of Death) using Rust GUI.
+ *
+ * @param pminfo Pointer to the post mortem to display
+ */
+void rsod_gui(const systask_postmortem_t* pminfo);
+
+#ifdef KERNEL_MODE
+
+/**
+ * Universal panic handler that can be passed to `system_init()` function
+ * to show RSOD screen describing the system error and halt the device
+ *
+ * (may be called from interrupt context)
+ *
+ * @param pminfo Pointer to the post mortem to display
+ */
+void rsod_panic_handler(const systask_postmortem_t* pminfo);
+
+/**
+ * Shows RSOD screen with "Device wiped" message
+ * and shuts down the device.
+ */
+void show_wipe_info(const bootutils_wipe_info_t* info);
+
+#endif // KERNEL_MODE
diff --git a/core/embed/io/gfx/rsod.c b/core/embed/io/gfx/rsod.c
new file mode 100644
index 00000000..b8ca4e4f
--- /dev/null
+++ b/core/embed/io/gfx/rsod.c
@@ -0,0 +1,232 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <trezor_rtl.h>
+
+#include <io/display.h>
+#include <io/rsod.h>
+#include <io/terminal.h>
+#include <sec/rsod_special.h>
+#include <sys/bootutils.h>
+#include <sys/system.h>
+
+#include <rtl/strutils.h>
+
+#ifdef SCM_REVISION_INIT
+#include <rtl/scm_revision.h>
+#endif
+
+#define RSOD_DEFAULT_TITLE "Internal error";
+#define RSOD_DEFAULT_MESSAGE "Unspecified";
+#define RSOD_DEFAULT_FOOTER "Please visit trezor.io/rsod";
+#define RSOD_EXIT_MESSAGE "Exit " // followed by exit code
+
+#ifdef KERNEL_MODE
+
+#define RSOD_FG_COLOR COLOR_WHITE
+
+#ifdef USE_RGB_COLORS
+#define RSOD_BG_COLOR gfx_color_rgb(0x7F, 0x00, 0x00)
+#else
+#define RSOD_BG_COLOR COLOR_BLACK
+#endif
+
+void rsod_terminal(const systask_postmortem_t* pminfo) {
+ display_set_orientation(0);
+ term_set_color(RSOD_FG_COLOR, RSOD_BG_COLOR);
+
+ const char* title = RSOD_DEFAULT_TITLE;
+ const char* message = RSOD_DEFAULT_MESSAGE;
+ const char* footer = RSOD_DEFAULT_FOOTER;
+ const char* file = NULL;
+ char message_buf[32] = "";
+ int line = 0;
+
+ switch (pminfo->reason) {
+ case TASK_TERM_REASON_EXIT:
+ cstr_append(message_buf, sizeof(message_buf), RSOD_EXIT_MESSAGE);
+ cstr_append_int32(message_buf, sizeof(message_buf), pminfo->exit.code);
+ message = message_buf;
+ break;
+ case TASK_TERM_REASON_ERROR:
+ if (pminfo->error.title[0] != '\0') {
+ title = pminfo->error.title;
+ }
+ if (pminfo->error.message[0] != '\0') {
+ message = pminfo->error.message;
+ }
+ if (pminfo->error.footer[0] != '\0') {
+ footer = pminfo->error.footer;
+ }
+ break;
+ case TASK_TERM_REASON_FATAL:
+ message = pminfo->fatal.expr;
+ file = pminfo->fatal.file;
+ line = pminfo->fatal.line;
+ break;
+ case TASK_TERM_REASON_FAULT:
+ message = system_fault_message(&pminfo->fault);
+ break;
+ }
+
+ if (title != NULL) {
+ term_print(title);
+ term_print("\n");
+ }
+
+ if (message != NULL) {
+ term_print("msg : ");
+ term_print(message);
+ term_print("\n");
+ }
+
+ if (file) {
+ term_print("file: ");
+ term_print(file);
+ term_print(":");
+ term_print_int32(line);
+ term_print("\n");
+ }
+
+#ifdef SCM_REVISION_INIT
+ char rev[10 + 1];
+ cstr_encode_hex(rev, sizeof(rev), SCM_REVISION, (sizeof(rev) - 1) / 2);
+ term_print("rev : ");
+ term_print(rev);
+#endif
+
+ if (footer != NULL) {
+ term_print("\n");
+ term_print(footer);
+ term_print("\n");
+ }
+
+ display_set_backlight(255);
+}
+
+#endif // KERNEL_MODE
+
+#ifdef FANCY_FATAL_ERROR
+
+#include "rust_ui_common.h"
+
+void rsod_gui(const systask_postmortem_t* pminfo) {
+ const char* title = RSOD_DEFAULT_TITLE;
+ const char* message = RSOD_DEFAULT_MESSAGE;
+ const char* footer = RSOD_DEFAULT_FOOTER;
+ char message_buf[128] = "";
+
+ switch (pminfo->reason) {
+ case TASK_TERM_REASON_EXIT:
+ cstr_append(message_buf, sizeof(message_buf), RSOD_EXIT_MESSAGE);
+ cstr_append_int32(message_buf, sizeof(message_buf), pminfo->exit.code);
+ message = message_buf;
+ break;
+
+ case TASK_TERM_REASON_ERROR:
+ if (pminfo->error.title[0] != '\0') {
+ title = pminfo->error.title;
+ }
+ if (pminfo->error.message[0] != '\0') {
+ message = pminfo->error.message;
+ }
+ if (pminfo->error.footer[0] != '\0') {
+ footer = pminfo->error.footer;
+ }
+ break;
+
+ case TASK_TERM_REASON_FATAL:
+ message = pminfo->fatal.expr;
+ if (message[0] == '\0') {
+ cstr_append(message_buf, sizeof(message_buf), pminfo->fatal.file);
+ cstr_append(message_buf, sizeof(message_buf), ":");
+ cstr_append_int32(message_buf, sizeof(message_buf), pminfo->fatal.line);
+ } else {
+ cstr_append(message_buf, sizeof(message_buf), message);
+ cstr_append(message_buf, sizeof(message_buf), "\n");
+ cstr_append(message_buf, sizeof(message_buf), pminfo->fatal.file);
+ cstr_append(message_buf, sizeof(message_buf), ":");
+ cstr_append_int32(message_buf, sizeof(message_buf), pminfo->fatal.line);
+ }
+ message = message_buf;
+ break;
+
+ case TASK_TERM_REASON_FAULT:
+ message = system_fault_message(&pminfo->fault);
+ break;
+ }
+
+ // Render the RSOD in Rust
+ display_rsod_rust(title, message, footer);
+}
+
+void show_wipe_info(const bootutils_wipe_info_t* info) {
+ const char* title = "Device wiped";
+ const char* message = ALL_DATA_ERASED_MESSAGE;
+ const char* footer = "Please visit trezor.io/rsod";
+
+ if (info->title[0] != '\0') {
+ title = info->title;
+ }
+ if (info->message[0] != '\0') {
+ message = info->message;
+ }
+ if (info->footer[0] != '\0') {
+ footer = info->footer;
+ }
+
+ display_rsod_rust(title, message, footer);
+}
+
+#endif // FANCY_FATAL_ERROR
+
+#ifdef KERNEL_MODE
+
+// Initializes system in emergency mode and shows RSOD
+static void init_and_show_rsod(const systask_postmortem_t* pminfo) {
+ // Initialize the system's core services
+ // Pass NULL as error handler => if the system crashes in this routine
+ // we will not try to re-enter emergency mode again and reboot directly.
+ system_init(NULL);
+
+ // Initialize necessary drivers
+ display_init(DISPLAY_RESET_CONTENT);
+
+#ifdef FANCY_FATAL_ERROR
+ // Show the RSOD using Rust GUI
+ rsod_gui(pminfo);
+#else
+ // Show the RSOD using terminal
+ rsod_terminal(pminfo);
+#endif
+
+ // Reboots or halts (if RSOD_INFINITE_LOOP is defined)
+ reboot_or_halt_after_rsod();
+}
+
+// Universal panic handler
+// (may be called from interrupt context)
+void rsod_panic_handler(const systask_postmortem_t* pminfo) {
+ // Since the system state is unreliable, enter emergency mode
+ // and show the RSOD.
+ system_emergency_rescue(&init_and_show_rsod, pminfo);
+ // The previous function call never returns
+}
+
+#endif // KERNEL_MODE
diff --git a/core/embed/projects/boardloader/main.c b/core/embed/projects/boardloader/main.c
index 437e1f1b..606f589f 100644
--- a/core/embed/projects/boardloader/main.c
+++ b/core/embed/projects/boardloader/main.c
@@ -21,6 +21,7 @@
#include <trezor_rtl.h>
#include <io/display.h>
+#include <io/rsod.h>
#include <sec/board_capabilities.h>
#include <sec/option_bytes.h>
#include <sec/secret.h>
@@ -30,7 +31,6 @@
#include <sys/rng.h>
#include <sys/system.h>
#include <sys/systick.h>
-#include <util/rsod.h>
#ifdef USE_BOOT_UCB
#include <sec/boot_header.h>
diff --git a/core/embed/projects/bootloader/main.c b/core/embed/projects/bootloader/main.c
index 4706fd78..0ce196fa 100644
--- a/core/embed/projects/bootloader/main.c
+++ b/core/embed/projects/bootloader/main.c
@@ -23,9 +23,11 @@
#include <io/display.h>
#include <io/display_utils.h>
#include <io/notify.h>
+#include <io/rsod.h>
#include <io/usb_config.h>
#include <sec/image.h>
#include <sec/random_delays.h>
+#include <sec/rsod_special.h>
#include <sec/secret.h>
#include <sec/unit_properties.h>
#include <sys/bootargs.h>
@@ -34,8 +36,6 @@
#include <sys/system.h>
#include <sys/systick.h>
#include <sys/types.h>
-#include <util/rsod.h>
-#include <util/rsod_special.h>
#ifdef USE_BOOT_UCB
#include <sec/boot_ucb.h>
diff --git a/core/embed/projects/bootloader/workflow/wf_firmware_update.c b/core/embed/projects/bootloader/workflow/wf_firmware_update.c
index fe3b2bb5..154e79da 100644
--- a/core/embed/projects/bootloader/workflow/wf_firmware_update.c
+++ b/core/embed/projects/bootloader/workflow/wf_firmware_update.c
@@ -20,12 +20,12 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
+#include <sec/rsod_special.h>
#include <sys/bootargs.h>
#include <sys/bootutils.h>
#include <sys/flash.h>
#include <sys/flash_utils.h>
#include <sys/systick.h>
-#include <util/rsod_special.h>
#if defined(LOCKABLE_BOOTLOADER) || USE_STORAGE_HWKEY
#include <sec/secret.h>
diff --git a/core/embed/projects/bootloader_ci/main.c b/core/embed/projects/bootloader_ci/main.c
index 3f724d46..a47f44b6 100644
--- a/core/embed/projects/bootloader_ci/main.c
+++ b/core/embed/projects/bootloader_ci/main.c
@@ -24,6 +24,7 @@
#include <io/display.h>
#include <io/gfx_draw.h>
+#include <io/rsod.h>
#include <io/usb.h>
#include <io/usb_config.h>
#include <sec/image.h>
@@ -36,7 +37,6 @@
#include <sys/sysevent.h>
#include <sys/system.h>
#include <sys/systick.h>
-#include <util/rsod.h>
#include "version.h"
diff --git a/core/embed/projects/firmware/main.c b/core/embed/projects/firmware/main.c
index 6ace23ca..43051f67 100644
--- a/core/embed/projects/firmware/main.c
+++ b/core/embed/projects/firmware/main.c
@@ -35,12 +35,12 @@
#include <io/display.h>
#include <io/notify.h>
+#include <io/rsod.h>
#include <sec/boot_image.h>
#include <sys/linker_utils.h>
#include <sys/logging.h>
#include <sys/systask.h>
#include <sys/system.h>
-#include <util/rsod.h>
#include "rust_ui_common.h"
#include <blake2s.h>
diff --git a/core/embed/projects/kernel/main.c b/core/embed/projects/kernel/main.c
index c0cfbd77..4d48eb4d 100644
--- a/core/embed/projects/kernel/main.c
+++ b/core/embed/projects/kernel/main.c
@@ -22,6 +22,7 @@
#include <io/display.h>
#include <io/gfx_bitblt.h>
+#include <io/rsod.h>
#include <sec/board_capabilities.h>
#include <sec/boot_image.h>
#include <sec/option_bytes.h>
@@ -36,7 +37,6 @@
#include <sys/sysevent.h>
#include <sys/system.h>
#include <sys/systick.h>
-#include <util/rsod.h>
#ifdef USE_BUTTON
#include <io/button.h>
diff --git a/core/embed/projects/prodtest/main.c b/core/embed/projects/prodtest/main.c
index c07f7173..12a33fdf 100644
--- a/core/embed/projects/prodtest/main.c
+++ b/core/embed/projects/prodtest/main.c
@@ -23,6 +23,7 @@
#include <trezor_rtl.h>
#include <io/display.h>
+#include <io/rsod.h>
#include <io/usb.h>
#include <io/usb_config.h>
#include <rtl/cli.h>
@@ -31,7 +32,6 @@
#include <sys/flash_otp.h>
#include <sys/system.h>
#include <sys/systick.h>
-#include <util/rsod.h>
#include "commands.h"
#include "rust_types.h"
diff --git a/core/embed/projects/unix/main.c b/core/embed/projects/unix/main.c
index 7c013b23..9f33d13b 100644
--- a/core/embed/projects/unix/main.c
+++ b/core/embed/projects/unix/main.c
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <io/display.h>
+#include <io/rsod.h>
#include <io/usb_config.h>
#include <sec/secret.h>
#include <sec/unit_properties.h>
@@ -44,7 +45,6 @@
#include <sys/flash_otp.h>
#include <sys/system.h>
#include <sys/systimer.h>
-#include <util/rsod.h>
#include "extmod/misc.h"
#include "extmod/vfs_posix.h"
#include "genhdr/mpversion.h"
diff --git a/core/embed/rtl/inc/common.h b/core/embed/rtl/inc/common.h
index e76f0541..5b7f35d4 100644
--- a/core/embed/rtl/inc/common.h
+++ b/core/embed/rtl/inc/common.h
@@ -24,5 +24,5 @@
// storage.
#include <rtl/error_handling.h>
+#include <sec/rsod_special.h>
#include <sys/systick.h>
-#include <util/rsod_special.h>
diff --git a/core/embed/sec/rsod/inc/sec/rsod_special.h b/core/embed/sec/rsod/inc/sec/rsod_special.h
new file mode 100644
index 00000000..d25d8746
--- /dev/null
+++ b/core/embed/sec/rsod/inc/sec/rsod_special.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#define ALL_DATA_ERASED_MESSAGE "All data has been erased from the device"
+
+/**
+ * Shows RSOD screen with "Wipe code entered" message
+ * and shuts down the device.
+ */
+void __attribute__((noreturn)) show_wipe_code_screen(void);
+
+/**
+ * Shows RSOD screen with "Pin attempts exceeded" message
+ * and shuts down the device.
+ */
+void __attribute__((noreturn)) show_pin_too_many_screen(void);
+
+/**
+ * Shows RSOD screen with "Install restricted" message
+ * and shuts down the device.
+ */
+void __attribute__((noreturn)) show_install_restricted_screen(void);
diff --git a/core/embed/sec/rsod/rsod_special.c b/core/embed/sec/rsod/rsod_special.c
new file mode 100644
index 00000000..5b49020b
--- /dev/null
+++ b/core/embed/sec/rsod/rsod_special.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <trezor_rtl.h>
+
+#include <rtl/strutils.h>
+#include <sec/rsod_special.h>
+#include <sys/bootutils.h>
+#include <sys/system.h>
+
+#ifdef TREZOR_MODEL_T3W1
+// empty message for T3W1 so that it falls to the more appropriate default
+#define RECONNECT_DEVICE_MESSAGE ""
+#else
+#define RECONNECT_DEVICE_MESSAGE "Please reconnect\nthe device"
+#endif
+
+void __attribute__((noreturn)) show_wipe_code_screen(void) {
+ bootutils_wipe_info_t info = {0};
+
+ const char *title = "Wipe code entered";
+
+ strncpy(info.title, title, sizeof(info.title) - 1);
+ strncpy(info.message, ALL_DATA_ERASED_MESSAGE, sizeof(info.message) - 1);
+ strncpy(info.footer, RECONNECT_DEVICE_MESSAGE, sizeof(info.footer) - 1);
+
+ reboot_and_wipe(&info);
+
+ while (1)
+ ;
+}
+
+void __attribute__((noreturn)) show_pin_too_many_screen(void) {
+ bootutils_wipe_info_t info = {0};
+
+ const char *title = "Pin attempts exceeded";
+
+ strncpy(info.title, title, sizeof(info.title) - 1);
+ strncpy(info.message, ALL_DATA_ERASED_MESSAGE, sizeof(info.message) - 1);
+ strncpy(info.footer, RECONNECT_DEVICE_MESSAGE, sizeof(info.footer) - 1);
+
+ reboot_and_wipe(&info);
+ while (1)
+ ;
+}
+
+void __attribute__((noreturn)) show_install_restricted_screen(void) {
+ error_shutdown_ex("Install restricted",
+ "Installation of custom firmware is currently restricted.",
+ "Please visit trezor.io/bootloader");
+}
diff --git a/core/embed/sec/secret/stm32f4/secret.c b/core/embed/sec/secret/stm32f4/secret.c
index b9d7debe..038af0e4 100644
--- a/core/embed/sec/secret/stm32f4/secret.c
+++ b/core/embed/sec/secret/stm32f4/secret.c
@@ -20,11 +20,11 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
+#include <sec/rsod_special.h>
#include <sec/secret.h>
#include <sys/flash.h>
#include <sys/flash_utils.h>
#include <sys/mpu.h>
-#include <util/rsod_special.h>
#ifdef KERNEL_MODE
diff --git a/core/embed/sec/secret/stm32u5/secret.c b/core/embed/sec/secret/stm32u5/secret.c
index a8445621..8c2a7126 100644
--- a/core/embed/sec/secret/stm32u5/secret.c
+++ b/core/embed/sec/secret/stm32u5/secret.c
@@ -21,6 +21,7 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
+#include <sec/rsod_special.h>
#include <sec/secret.h>
#include <sec/secure_aes.h>
#include <sys/bootutils.h>
@@ -28,7 +29,6 @@
#include <sys/flash_utils.h>
#include <sys/mpu.h>
#include <sys/rng.h>
-#include <util/rsod_special.h>
#include "memzero.h"
#ifdef SECURE_MODE
diff --git a/core/embed/sec/secret/unix/secret.c b/core/embed/sec/secret/unix/secret.c
index 4e6139d2..f4d277c3 100644
--- a/core/embed/sec/secret/unix/secret.c
+++ b/core/embed/sec/secret/unix/secret.c
@@ -22,8 +22,8 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
+#include <sec/rsod_special.h>
#include <sec/secret.h>
-#include <util/rsod_special.h>
#ifdef KERNEL_MODE
diff --git a/core/embed/sec/tamper/stm32u5/tamper.c b/core/embed/sec/tamper/stm32u5/tamper.c
index 7f35d815..5bbc1918 100644
--- a/core/embed/sec/tamper/stm32u5/tamper.c
+++ b/core/embed/sec/tamper/stm32u5/tamper.c
@@ -22,12 +22,12 @@
#include <trezor_bsp.h>
#include <trezor_rtl.h>
+#include <io/rsod.h>
#include <sec/tamper.h>
#include <sys/bootutils.h>
#include <sys/irq.h>
#include <sys/mpu.h>
#include <sys/systick.h>
-#include <util/rsod.h>
// Fixes a typo in CMSIS Device library for STM32U5
#undef TAMP_CR3_ITAMP7NOER_Msk
diff --git a/core/embed/sys/startup/unix/bootutils.c b/core/embed/sys/startup/unix/bootutils.c
index f9020b3d..61bb1da1 100644
--- a/core/embed/sys/startup/unix/bootutils.c
+++ b/core/embed/sys/startup/unix/bootutils.c
@@ -25,7 +25,6 @@
#include <sys/bootutils.h>
#include <sys/logging.h>
#include <sys/systick.h>
-#include <util/rsod_special.h>
LOG_DECLARE(bootutils)
@@ -83,6 +82,11 @@ __attribute__((noreturn)) void reboot_to_off(void) {
exit(3);
}
+// To avoid including higher-layer code, we declare this function here.
+// We expect to remove the show_wipe_info() call in the future as soon as
+// we are able to test the bootargs content using automated tests.
+extern void show_wipe_info(const bootutils_wipe_info_t* info);
+
__attribute__((noreturn)) void reboot_and_wipe(
const bootutils_wipe_info_t* info) {
show_wipe_info(info);
diff --git a/core/embed/util/rsod/inc/util/rsod.h b/core/embed/util/rsod/inc/util/rsod.h
deleted file mode 100644
index 9cd858bb..00000000
--- a/core/embed/util/rsod/inc/util/rsod.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIB_RSOD_H
-#define LIB_RSOD_H
-
-#include <sys/systask.h>
-
-// Shows RSOD (Red Screen of Death) using terminal.
-void rsod_terminal(const systask_postmortem_t* pminfo);
-
-// Shows RSOD (Red Screen of Death) using Rust GUI.
-void rsod_gui(const systask_postmortem_t* pminfo);
-
-#ifdef KERNEL_MODE
-
-// Universal panic handler that can be passed to `system_init()` function
-// to show RSOD screen describing the system error.
-// (may be called from interrupt context)
-void rsod_panic_handler(const systask_postmortem_t* pminfo);
-
-#endif // KERNEL_MODE
-
-#endif // LIB_RSOD_H
diff --git a/core/embed/util/rsod/inc/util/rsod_special.h b/core/embed/util/rsod/inc/util/rsod_special.h
deleted file mode 100644
index 0a1b0044..00000000
--- a/core/embed/util/rsod/inc/util/rsod_special.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <sys/bootutils.h>
-
-/**
- * Shows RSOD screen with "Wipe code entered" message
- * and shuts down the device.
- */
-void __attribute__((noreturn)) show_wipe_code_screen(void);
-
-/**
- * Shows RSOD screen with "Pin attempts exceeded" message
- * and shuts down the device.
- */
-void __attribute__((noreturn)) show_pin_too_many_screen(void);
-
-/**
- * Shows RSOD screen with "Install restricted" message
- * and shuts down the device.
- */
-void __attribute__((noreturn)) show_install_restricted_screen(void);
-
-/**
- * Shows RSOD screen with "Device wiped" message
- * and shuts down the device.
- */
-void show_wipe_info(const bootutils_wipe_info_t *info);
diff --git a/core/embed/util/rsod/rsod.c b/core/embed/util/rsod/rsod.c
deleted file mode 100644
index 199a4d01..00000000
--- a/core/embed/util/rsod/rsod.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <trezor_rtl.h>
-
-#include <io/display.h>
-#include <io/terminal.h>
-#include <sys/bootutils.h>
-#include <sys/system.h>
-#include <util/rsod.h>
-
-#include <rtl/strutils.h>
-
-#ifdef SCM_REVISION_INIT
-#include <rtl/scm_revision.h>
-#endif
-
-#define RSOD_DEFAULT_TITLE "Internal error";
-#define RSOD_DEFAULT_MESSAGE "Unspecified";
-#define RSOD_DEFAULT_FOOTER "Please visit trezor.io/rsod";
-#define RSOD_EXIT_MESSAGE "Exit " // followed by exit code
-
-#ifdef KERNEL_MODE
-
-#define RSOD_FG_COLOR COLOR_WHITE
-
-#ifdef USE_RGB_COLORS
-#define RSOD_BG_COLOR gfx_color_rgb(0x7F, 0x00, 0x00)
-#else
-#define RSOD_BG_COLOR COLOR_BLACK
-#endif
-
-void rsod_terminal(const systask_postmortem_t* pminfo) {
- display_set_orientation(0);
- term_set_color(RSOD_FG_COLOR, RSOD_BG_COLOR);
-
- const char* title = RSOD_DEFAULT_TITLE;
- const char* message = RSOD_DEFAULT_MESSAGE;
- const char* footer = RSOD_DEFAULT_FOOTER;
- const char* file = NULL;
- char message_buf[32] = "";
- int line = 0;
-
- switch (pminfo->reason) {
- case TASK_TERM_REASON_EXIT:
- cstr_append(message_buf, sizeof(message_buf), RSOD_EXIT_MESSAGE);
- cstr_append_int32(message_buf, sizeof(message_buf), pminfo->exit.code);
- message = message_buf;
- break;
- case TASK_TERM_REASON_ERROR:
- if (pminfo->error.title[0] != '\0') {
- title = pminfo->error.title;
- }
- if (pminfo->error.message[0] != '\0') {
- message = pminfo->error.message;
- }
- if (pminfo->error.footer[0] != '\0') {
- footer = pminfo->error.footer;
- }
- break;
- case TASK_TERM_REASON_FATAL:
- message = pminfo->fatal.expr;
- file = pminfo->fatal.file;
- line = pminfo->fatal.line;
- break;
- case TASK_TERM_REASON_FAULT:
- message = system_fault_message(&pminfo->fault);
- break;
- }
-
- if (title != NULL) {
- term_print(title);
- term_print("\n");
- }
-
- if (message != NULL) {
- term_print("msg : ");
- term_print(message);
- term_print("\n");
- }
-
- if (file) {
- term_print("file: ");
- term_print(file);
- term_print(":");
- term_print_int32(line);
- term_print("\n");
- }
-
-#ifdef SCM_REVISION_INIT
- char rev[10 + 1];
- cstr_encode_hex(rev, sizeof(rev), SCM_REVISION, (sizeof(rev) - 1) / 2);
- term_print("rev : ");
- term_print(rev);
-#endif
-
- if (footer != NULL) {
- term_print("\n");
- term_print(footer);
- term_print("\n");
- }
-
- display_set_backlight(255);
-}
-
-#endif // KERNEL_MODE
-
-#ifdef FANCY_FATAL_ERROR
-
-#include "rust_ui_common.h"
-
-void rsod_gui(const systask_postmortem_t* pminfo) {
- const char* title = RSOD_DEFAULT_TITLE;
- const char* message = RSOD_DEFAULT_MESSAGE;
- const char* footer = RSOD_DEFAULT_FOOTER;
- char message_buf[128] = "";
-
- switch (pminfo->reason) {
- case TASK_TERM_REASON_EXIT:
- cstr_append(message_buf, sizeof(message_buf), RSOD_EXIT_MESSAGE);
- cstr_append_int32(message_buf, sizeof(message_buf), pminfo->exit.code);
- message = message_buf;
- break;
-
- case TASK_TERM_REASON_ERROR:
- if (pminfo->error.title[0] != '\0') {
- title = pminfo->error.title;
- }
- if (pminfo->error.message[0] != '\0') {
- message = pminfo->error.message;
- }
- if (pminfo->error.footer[0] != '\0') {
- footer = pminfo->error.footer;
- }
- break;
-
- case TASK_TERM_REASON_FATAL:
- message = pminfo->fatal.expr;
- if (message[0] == '\0') {
- cstr_append(message_buf, sizeof(message_buf), pminfo->fatal.file);
- cstr_append(message_buf, sizeof(message_buf), ":");
- cstr_append_int32(message_buf, sizeof(message_buf), pminfo->fatal.line);
- } else {
- cstr_append(message_buf, sizeof(message_buf), message);
- cstr_append(message_buf, sizeof(message_buf), "\n");
- cstr_append(message_buf, sizeof(message_buf), pminfo->fatal.file);
- cstr_append(message_buf, sizeof(message_buf), ":");
- cstr_append_int32(message_buf, sizeof(message_buf), pminfo->fatal.line);
- }
- message = message_buf;
- break;
-
- case TASK_TERM_REASON_FAULT:
- message = system_fault_message(&pminfo->fault);
- break;
- }
-
- // Render the RSOD in Rust
- display_rsod_rust(title, message, footer);
-}
-
-#endif // FANCY_FATAL_ERROR
-
-#ifdef KERNEL_MODE
-
-// Initializes system in emergency mode and shows RSOD
-static void init_and_show_rsod(const systask_postmortem_t* pminfo) {
- // Initialize the system's core services
- // Pass NULL as error handler => if the system crashes in this routine
- // we will not try to re-enter emergency mode again and reboot directly.
- system_init(NULL);
-
- // Initialize necessary drivers
- display_init(DISPLAY_RESET_CONTENT);
-
-#ifdef FANCY_FATAL_ERROR
- // Show the RSOD using Rust GUI
- rsod_gui(pminfo);
-#else
- // Show the RSOD using terminal
- rsod_terminal(pminfo);
-#endif
-
- // Reboots or halts (if RSOD_INFINITE_LOOP is defined)
- reboot_or_halt_after_rsod();
-}
-
-// Universal panic handler
-// (may be called from interrupt context)
-void rsod_panic_handler(const systask_postmortem_t* pminfo) {
- // Since the system state is unreliable, enter emergency mode
- // and show the RSOD.
- system_emergency_rescue(&init_and_show_rsod, pminfo);
- // The previous function call never returns
-}
-
-#endif // KERNEL_MODE
diff --git a/core/embed/util/rsod/rsod_special.c b/core/embed/util/rsod/rsod_special.c
deleted file mode 100644
index 6175531c..00000000
--- a/core/embed/util/rsod/rsod_special.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <trezor_rtl.h>
-
-#include <rtl/strutils.h>
-#include <sys/bootutils.h>
-#include <sys/system.h>
-
-#ifdef FANCY_FATAL_ERROR
-#include "rust_ui_common.h"
-#endif
-
-#define ALL_DATA_ERASED_MESSAGE "All data has been erased from the device"
-
-#ifdef TREZOR_MODEL_T3W1
-// empty message for T3W1 so that it falls to the more appropriate default
-#define RECONNECT_DEVICE_MESSAGE ""
-#else
-#define RECONNECT_DEVICE_MESSAGE "Please reconnect\nthe device"
-#endif
-
-void __attribute__((noreturn)) show_wipe_code_screen(void) {
- bootutils_wipe_info_t info = {0};
-
- const char *title = "Wipe code entered";
-
- strncpy(info.title, title, sizeof(info.title) - 1);
- strncpy(info.message, ALL_DATA_ERASED_MESSAGE, sizeof(info.message) - 1);
- strncpy(info.footer, RECONNECT_DEVICE_MESSAGE, sizeof(info.footer) - 1);
-
- reboot_and_wipe(&info);
-
- while (1)
- ;
-}
-
-#ifdef FANCY_FATAL_ERROR
-void show_wipe_info(const bootutils_wipe_info_t *info) {
- const char *title = "Device wiped";
- const char *message = ALL_DATA_ERASED_MESSAGE;
- const char *footer = "Please visit trezor.io/rsod";
-
- if (info->title[0] != '\0') {
- title = info->title;
- }
- if (info->message[0] != '\0') {
- message = info->message;
- }
- if (info->footer[0] != '\0') {
- footer = info->footer;
- }
-
- display_rsod_rust(title, message, footer);
-}
-#endif
-
-void __attribute__((noreturn)) show_pin_too_many_screen(void) {
- bootutils_wipe_info_t info = {0};
-
- const char *title = "Pin attempts exceeded";
-
- strncpy(info.title, title, sizeof(info.title) - 1);
- strncpy(info.message, ALL_DATA_ERASED_MESSAGE, sizeof(info.message) - 1);
- strncpy(info.footer, RECONNECT_DEVICE_MESSAGE, sizeof(info.footer) - 1);
-
- reboot_and_wipe(&info);
- while (1)
- ;
-}
-
-void __attribute__((noreturn)) show_install_restricted_screen(void) {
- error_shutdown_ex("Install restricted",
- "Installation of custom firmware is currently restricted.",
- "Please visit trezor.io/bootloader");
-}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.