chore(core): introduce DEBUGLINK build flag
What changed, and why it matters
This commit introduces a new build flag called DEBUGLINK that controls whether Trezor firmware is compiled with debug/test-only USB and screen-recording features enabled. It does not add new runtime behavior; it mostly reorganizes when these debug features are included. The change makes debug builds more explicit, but it also means enabling DEBUGLINK (or disabling optimizations via PYOPT=0) automatically turns on the debug USB interface and screen recording. In a production device this could be risky, but the commit itself is a build-system refactor and the features remain off by default for production builds.
Verify that production release pipelines never set DEBUGLINK=1 or PYOPT=0, and that signed production firmware images do not include the usb_iface_debug or debuglink features. Treat any firmware build with DEBUGLINK enabled as a debug/development image unsuitable for end-user devices.
Security signals we found
Debug/test interface (usb_iface_debug) is conditionally compiled
Screen recording hook moved behind new debuglink feature flag
Build flag DEBUGLINK forces PYOPT=0 (disables MicroPython optimizations)
No changelog entry provided
No explicit security claim or advisory in commit message
Evidence from the diff
The patch adds a DEBUGLINK build variable wired through Makefile and SCons into both firmware and unix emulator builds. When DEBUGLINK=1 (or PYOPT=0), the build forces PYOPT=0, adds the ‘usb_iface_debug’ feature, defines DEBUGLINK, and appends ‘debuglink’ to the feature list. In Rust, the screen-recording refresh hook is now gated by the ‘debuglink’ feature instead of ‘ui_debug_overlay’. This is a build-system change that decouples debuglink from the broader debug/ui_debug flags, making it a separately controllable compile-time feature.
Changed components
core/Makefilecore/SConscript.firmwarecore/SConscript.unixcore/embed/rust/Cargo.tomlcore/embed/rust/src/ui/display/mod.rsInspect captured patch +20 / −2
diff --git a/core/Makefile b/core/Makefile
index c01d44ef..ab10f901 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -28,6 +28,7 @@ UNIX_PORT_OPTS ?=
CROSS_PORT_OPTS ?=
PRODUCTION ?= 0
+DEBUGLINK ?= 0
PYOPT ?= 1
BITCOIN_ONLY ?= 0
BOOTLOADER_QA ?= 0
@@ -132,6 +133,7 @@ SCONS_VARS = \
LOG_STACK_USAGE="$(LOG_STACK_USAGE)" \
MICROPY_ENABLE_SOURCE_LINE="$(MICROPY_ENABLE_SOURCE_LINE)" \
PRODUCTION="$(PRODUCTION)" \
+ DEBUGLINK="$(DEBUGLINK)" \
PYOPT="$(PYOPT)" \
QUIET_MODE="$(QUIET_MODE)" \
SCM_REVISION="$(SCM_REVISION)" \
diff --git a/core/SConscript.firmware b/core/SConscript.firmware
index 898cac99..a1280613 100644
--- a/core/SConscript.firmware
+++ b/core/SConscript.firmware
@@ -14,6 +14,7 @@ EVERYTHING = BITCOIN_ONLY != '1'
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1')
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
PYOPT = ARGUMENTS.get('PYOPT', '1')
+DEBUGLINK = ARGUMENTS.get('DEBUGLINK', '0') == '1'
DISABLE_OPTIGA = ARGUMENTS.get('DISABLE_OPTIGA', '0') == '1'
DISABLE_TROPIC = ARGUMENTS.get('DISABLE_TROPIC', '0') == '1'
HW_REVISION = ARGUMENTS.get('HW_REVISION', None)
@@ -36,6 +37,10 @@ if STORAGE_INSECURE_TESTING_MODE:
DISABLE_TROPIC = True
PYOPT = "0"
+if DEBUGLINK or PYOPT == '0':
+ DEBUGLINK = True
+ PYOPT = '0'
+
if BENCHMARK and PYOPT != '0':
print("BENCHMARK=1 works only with PYOPT=0.")
exit(1)
@@ -85,7 +90,6 @@ if DISABLE_TROPIC:
if PYOPT == '0':
DBG_CONSOLE = DBG_CONSOLE or "VCP"
- FEATURES_WANTED += ["usb_iface_debug"]
if DBG_CONSOLE != "":
FEATURES_WANTED += ["dbg_console"]
@@ -105,6 +109,10 @@ RUST_UI_FEATURES = []
FROZEN = True
+if DEBUGLINK:
+ FEATURES_WANTED += ["usb_iface_debug"]
+ CPPDEFINES_MOD += ['DEBUGLINK']
+
# modtrezorconfig
CPPPATH_MOD += [
'embed/upymod/modtrezorconfig',
@@ -907,6 +915,7 @@ env.Depends(protobuf_blobs, qstr_generated)
features = ['micropython', 'protobuf', 'ui', 'translations'] + FEATURES_AVAILABLE + RUST_UI_FEATURES
if PYOPT == '0':
features.append('debug')
+ features.append('debuglink')
features.append('ui_debug')
features.append('ui_debug_overlay')
if EVERYTHING:
diff --git a/core/SConscript.unix b/core/SConscript.unix
index bdb74aa5..0803a965 100644
--- a/core/SConscript.unix
+++ b/core/SConscript.unix
@@ -14,6 +14,7 @@ THP = ARGUMENTS.get('THP', '0') == '1' # Trezor-Host Protocol
DISABLE_TROPIC = ARGUMENTS.get('DISABLE_TROPIC', '1') == '1'
BENCHMARK = ARGUMENTS.get('BENCHMARK', '0') == '1'
PYOPT = ARGUMENTS.get('PYOPT', '1')
+DEBUGLINK = ARGUMENTS.get('DEBUGLINK', '0') == '1'
FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
RASPI = os.getenv('TREZOR_EMULATOR_RASPI') == '1'
MICROPY_ENABLE_SOURCE_LINE = ARGUMENTS.get('MICROPY_ENABLE_SOURCE_LINE', '1')
@@ -21,6 +22,10 @@ DBG_CONSOLE = ARGUMENTS.get('DBG_CONSOLE', '')
EXTAPP_SUPPORT = ARGUMENTS.get('EXTAPP_SUPPORT', '0') == '1'
+if DEBUGLINK or PYOPT == '0':
+ DEBUGLINK = True
+ PYOPT = '0'
+
if BENCHMARK and PYOPT != '0':
print("BENCHMARK=1 works only with PYOPT=0.")
exit(1)
@@ -933,6 +938,7 @@ else:
features = ['micropython', 'protobuf', 'ui', 'translations'] + FEATURES_AVAILABLE + RUST_UI_FEATURES
if PYOPT == '0':
features.append('debug')
+ features.append('debuglink')
features.append('ui_debug')
features.append('ui_debug_overlay')
if EVERYTHING:
diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml
index 0da4a587..823a7ab8 100644
--- a/core/embed/rust/Cargo.toml
+++ b/core/embed/rust/Cargo.toml
@@ -38,6 +38,7 @@ button = []
touch = []
clippy = []
debug = ["ui_debug", "dev_keys"]
+debuglink = []
dev_keys = []
sbu = []
haptic = []
diff --git a/core/embed/rust/src/ui/display/mod.rs b/core/embed/rust/src/ui/display/mod.rs
index 17027247..e4b937b2 100644
--- a/core/embed/rust/src/ui/display/mod.rs
+++ b/core/embed/rust/src/ui/display/mod.rs
@@ -122,7 +122,7 @@ pub fn sync() {
}
pub fn refresh() {
- #[cfg(feature = "ui_debug_overlay")]
+ #[cfg(feature = "debuglink")]
if display::is_recording() {
display::record_screen();
}
Why this scored 20/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.