What changed, and why it matters
This commit adds extra debug-only log messages that describe when the Trezor device goes to sleep and what event wakes it up. These messages only appear in debug builds and do not change how the device behaves. There is no security issue visible in this change.
No action required. This is a routine instrumentation change. If reviewing a larger feature branch, confirm that no sensitive data (PINs, seeds, keys) is being logged elsewhere, but this commit itself does not do so.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch imports the log module and, inside __debug__ guards, emits log.debug() calls before and after io.pm.suspend(). It also adds a lookup table mapping wakeup flag constants to human-readable names. The functional logic—suspending, waking, and re-suspending on unhandled flags—is unchanged. The logging is gated by __debug__, so it is compiled out in production/release firmware builds.
Changed components
core/src/trezor/power_management/suspend.pyInspect captured patch +14 / −1
diff --git a/core/src/trezor/power_management/suspend.py b/core/src/trezor/power_management/suspend.py
index bdce87a63..6be08d1db 100644
--- a/core/src/trezor/power_management/suspend.py
+++ b/core/src/trezor/power_management/suspend.py
@@ -1,4 +1,4 @@
-from trezor import io
+from trezor import io, log
_HANDLED_WAKEUP_FLAGS = (
io.pm.WAKEUP_FLAG_BUTTON,
@@ -6,11 +6,24 @@ _HANDLED_WAKEUP_FLAGS = (
io.pm.WAKEUP_FLAG_POWER,
)
+if __debug__:
+ _NAMED_WAKEUP_FLAGS = {
+ io.pm.WAKEUP_FLAG_BUTTON: "BUTTON",
+ io.pm.WAKEUP_FLAG_BLE: "BLE",
+ io.pm.WAKEUP_FLAG_POWER: "POWER",
+ io.pm.WAKEUP_FLAG_NFC: "NFC",
+ io.pm.WAKEUP_FLAG_RTC: "RTC",
+ }
+
def suspend_device() -> int:
"""Suspend the device and wait for a wakeup event. Wakeup flag is returned."""
while True:
+ if __debug__:
+ log.debug(__name__, "Suspending device...")
wakeup_flag = io.pm.suspend()
+ if __debug__:
+ log.debug(__name__, "Awoke, wakeup flag: %s", _NAMED_WAKEUP_FLAGS[wakeup_flag])
if wakeup_flag not in _HANDLED_WAKEUP_FLAGS:
# other wakeup flags are ignored, suspend again
continue
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.