fix(core/bootloader): service the debuglink in the click and upload loops [no changelog]
What changed, and why it matters
This commit fixes a bootloader responsiveness issue for automated testing: when the Trezor bootloader was showing the 'click to continue' screen or receiving a firmware image, it ignored DebugLink requests until the user or host did something else. The change makes those loops also poll and answer the debug interface immediately. DebugLink is a test-only feature, not present in production devices, so this is a testing/QA fix rather than a user security vulnerability.
No security action required. Treat as a normal QA/testing fix. If reviewing for release, confirm DebugLink is not enabled in production bootloader builds.
Security signals we found
DebugLink-only code path (#ifdef DEBUGLINK)
No production attack surface: DebugLink is disabled in release builds
Fixes a responsiveness/timeout issue in test automation, not a memory safety or cryptographic bug
No privilege escalation, bypass, or data leakage evident in diff
Evidence from the diff
In the bootloader, ui_click() and run_image_upload() previously waited only for touch/button or the main protocol interface. If a DebugLinkGetState message arrived during those waits, it was not serviced until a later UI loop iteration. The patch adds SYSHANDLE_USB_DEBUG to the awaited event masks and calls debuglink_process() when that handle signals, gated by #ifdef DEBUGLINK. This is a debug/test infrastructure fix with no production security boundary crossed.
Changed components
core/embed/projects/bootloader/ui_helpers.ccore/embed/projects/bootloader/workflow/wf_image_upload.cInspect captured patch +31 / −2
### core/embed/projects/bootloader/ui_helpers.c
@@ -34,6 +34,10 @@
#error "No input method defined"
#endif
+#ifdef DEBUGLINK
+#include "workflow/debuglink.h"
+#endif
+
#define TIME_TO_HIBERNATE_MS 40000
typedef enum {
@@ -95,6 +99,9 @@ void ui_click(void) {
#elif defined USE_BUTTON
awaited.read_ready |= 1 << SYSHANDLE_BUTTON;
#endif
+#ifdef DEBUGLINK
+ awaited.read_ready |= 1 << SYSHANDLE_USB_DEBUG;
+#endif
#ifdef USE_TOUCH
// flush touch events if any
@@ -116,6 +123,11 @@ void ui_click(void) {
while (true) {
sysevents_poll(&awaited, &signalled, ticks_timeout(100));
if (signalled.read_ready != 0) {
+#ifdef DEBUGLINK
+ if (signalled.read_ready & (1 << SYSHANDLE_USB_DEBUG)) {
+ debuglink_process();
+ }
+#endif
switch (process_event(&layout_state, &signalled)) {
case RES_CLICKED:
return;
### core/embed/projects/bootloader/workflow/wf_image_upload.c
@@ -28,6 +28,11 @@
#include "protob/protob.h"
#include "wf_image_upload.h"
+
+#ifdef DEBUGLINK
+#include "debuglink.h"
+#endif
+
#include "workflow.h"
#define MESSAGE_RX_TIMEOUT 10000
@@ -327,11 +332,23 @@ workflow_result_t run_image_upload(protob_io_t *iface,
sysevents_t awaited = {0};
sysevents_t signalled = {0};
- awaited.read_ready = 1 << protob_get_iface_flag(iface);
+ const uint32_t wire_flag = 1 << protob_get_iface_flag(iface);
+
+ awaited.read_ready = wire_flag;
+#ifdef DEBUGLINK
+ awaited.read_ready |= 1 << SYSHANDLE_USB_DEBUG;
+#endif
sysevents_poll(&awaited, &signalled, ticks_timeout(100));
- if (awaited.read_ready != signalled.read_ready) {
+#ifdef DEBUGLINK
+ // keep the debuglink responsive while the host uploads
+ if (signalled.read_ready & (1 << SYSHANDLE_USB_DEBUG)) {
+ debuglink_process();
+ }
+#endif
+
+ if ((signalled.read_ready & wire_flag) == 0) {
if (ticks_expired(msg_deadline)) {
// timeout
handler->ui->fail(UPLOAD_ERR_COMMUNICATION);Why this scored 18/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.