feat(core): add suspend, resume and wakeup params into rgb led driver.
What changed, and why it matters
This commit adds new power-management functions to the RGB LED driver in Trezor's hardware wallet firmware. It lets the device remember what LED effect was running before sleep, then restore it after waking up. There is no obvious security bug in the change itself.
No security action required. Review as normal feature code; ensure callers validate the wakeup params pointer and that suspend/resume integrate correctly with the kernel's power-state machine.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces rgb_led_set_wakeup_params(), rgb_led_suspend(), and rgb_led_resume() for the STM32U5 low-power RGB LED driver. set_wakeup_params() records whether an indefinite LED effect is active and its type under an IRQ lock. suspend() deinitializes the driver, and resume() reinitializes it and restarts the saved effect. The code is purely additive and does not modify cryptographic, USB, storage, or authentication logic.
Changed components
core/embed/io/rgb_led/stm32u5/rgb_led_lp.ccore/embed/io/rgb_led/inc/io/rgb_led.hInspect captured patch +56 / −0
diff --git a/core/embed/io/rgb_led/inc/io/rgb_led.h b/core/embed/io/rgb_led/inc/io/rgb_led.h
index daacdc6ea..baeaeb041 100644
--- a/core/embed/io/rgb_led/inc/io/rgb_led.h
+++ b/core/embed/io/rgb_led/inc/io/rgb_led.h
@@ -49,6 +49,14 @@ typedef enum {
#ifdef KERNEL_MODE
+/**
+ * @brief RGB LED wakeup parameters
+ */
+typedef struct {
+ bool ongoing_effect;
+ rgb_led_effect_type_t effect_type;
+} rgb_led_wakeup_params_t;
+
/**
* @brief Initialize RGB LED driver
*/
@@ -59,6 +67,25 @@ void rgb_led_init(void);
*/
void rgb_led_deinit(void);
+/**
+ * @brief set RGB LED wakeup parameters
+ *
+ * @param params: Pointer to the wakeup parameters structure
+ */
+void rgb_led_set_wakeup_params(rgb_led_wakeup_params_t *params);
+
+/**
+ * @brief Suspend RGB LED driver
+ */
+void rgb_led_suspend(void);
+
+/**
+ * @brief Resume RGB LED driver
+ *
+ * @param params: Pointer to the wakeup parameters structure
+ */
+void rgb_led_resume(const rgb_led_wakeup_params_t *params);
+
#endif // KERNEL_MODE
/**
diff --git a/core/embed/io/rgb_led/stm32u5/rgb_led_lp.c b/core/embed/io/rgb_led/stm32u5/rgb_led_lp.c
index 3cc73d48e..a6b895aa2 100644
--- a/core/embed/io/rgb_led/stm32u5/rgb_led_lp.c
+++ b/core/embed/io/rgb_led/stm32u5/rgb_led_lp.c
@@ -343,4 +343,33 @@ static void rgb_led_systimer_callback(void* context) {
}
}
+void rgb_led_set_wakeup_params(rgb_led_wakeup_params_t* params) {
+ rgb_led_t* drv = &g_rgb_led;
+
+ memset(params, 0, sizeof(rgb_led_wakeup_params_t));
+
+ if (!drv->initialized) {
+ return;
+ }
+
+ // Store the ongoing effect into the wakeup params if it was requested
+ // for indefinite number of cycles.
+ if (drv->ongoing_effect && drv->effect.data.requested_cycles == 0) {
+ irq_key_t key = irq_lock();
+ params->ongoing_effect = drv->ongoing_effect;
+ params->effect_type = drv->effect.type;
+ irq_unlock(key);
+ }
+}
+
+void rgb_led_suspend() { rgb_led_deinit(); }
+
+void rgb_led_resume(const rgb_led_wakeup_params_t* params) {
+ rgb_led_init();
+
+ if (params->ongoing_effect) {
+ rgb_led_effect_start(params->effect_type, 0);
+ }
+}
+
#endif
Why this scored 11/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.