What changed, and why it matters
This commit simplifies the Trezor hardware wallet's power-monitoring code by using one timer interval (100 ms) everywhere instead of two different intervals (100 ms and 300 ms). It removes a duplicate timer setting and renames the constant. There is no clear security bug being fixed; it appears to be a cleanup or consistency improvement in how often the device checks its battery and power state.
Treat as a routine maintenance/refactoring change. No immediate security action is required. If reviewing for product safety, verify that increasing the monitoring frequency from 300 ms to 100 ms in the turn-on path does not affect power consumption or battery-life assumptions, and that removing the reconfiguration in pm_turn_on() does not change behavior when the power manager is turned on while already initialized.
Security signals we found
No explicit security relevance stated in commit message or diff
Change is a timing/periodic-timer unification in power management subsystem
No input validation, buffer handling, cryptographic, or privilege-boundary changes observed
No references to vulnerabilities, CVEs, or security researchers in commit materials
Evidence from the diff
The patch unifies two previously separate power-manager timer periods. It deletes the PM_BATTERY_SAMPLING_PERIOD_MS (100 ms) constant and changes PM_TIMER_PERIOD_MS from 300 ms to 100 ms. All call sites now use PM_TIMER_PERIOD_MS. The pm_turn_on() function no longer reconfigures the monitoring timer, because the timer is already configured during pm_init() and resume. This reduces code duplication and ensures the same sampling rate is used across init, resume, and PMIC data-ready timestamping.
Changed components
core/embed/sys/power_manager/stm32u5/power_manager.ccore/embed/sys/power_manager/stm32u5/power_manager_internal.hcore/embed/sys/power_manager/stm32u5/power_monitoring.cInspect captured patch +4 / −8
diff --git a/core/embed/sys/power_manager/stm32u5/power_manager.c b/core/embed/sys/power_manager/stm32u5/power_manager.c
index 6515a3060..5eb077468 100644
--- a/core/embed/sys/power_manager/stm32u5/power_manager.c
+++ b/core/embed/sys/power_manager/stm32u5/power_manager.c
@@ -87,7 +87,7 @@ pm_status_t pm_init(bool inherit_state) {
return PM_ERROR;
}
- systimer_set_periodic(drv->monitoring_timer, PM_BATTERY_SAMPLING_PERIOD_MS);
+ systimer_set_periodic(drv->monitoring_timer, PM_TIMER_PERIOD_MS);
// Initial power source measurement
pmic_measure(pm_pmic_data_ready, NULL);
@@ -360,9 +360,6 @@ pm_status_t pm_turn_on(void) {
return PM_REQUEST_REJECTED;
}
- // Set monitoiring timer with longer period
- systimer_set_periodic(drv->monitoring_timer, PM_TIMER_PERIOD_MS);
-
return PM_OK;
}
@@ -666,7 +663,7 @@ bool pm_driver_resume(void) {
pmic_measure(pm_pmic_data_ready, NULL);
// Set the periodic sampling period
- systimer_set_periodic(drv->monitoring_timer, PM_BATTERY_SAMPLING_PERIOD_MS);
+ systimer_set_periodic(drv->monitoring_timer, PM_TIMER_PERIOD_MS);
return true;
}
diff --git a/core/embed/sys/power_manager/stm32u5/power_manager_internal.h b/core/embed/sys/power_manager/stm32u5/power_manager_internal.h
index 009fe5800..dca7b2e90 100644
--- a/core/embed/sys/power_manager/stm32u5/power_manager_internal.h
+++ b/core/embed/sys/power_manager/stm32u5/power_manager_internal.h
@@ -28,8 +28,7 @@
#include "../stwlc38/stwlc38.h"
// Power manager thresholds & timings
-#define PM_TIMER_PERIOD_MS 300
-#define PM_BATTERY_SAMPLING_PERIOD_MS 100
+#define PM_TIMER_PERIOD_MS 100
#define PM_SHUTDOWN_TIMEOUT_MS 15000
#define PM_BATTERY_UNDERVOLT_THR_V 3.0f
#define PM_BATTERY_UNDERVOLT_RECOVERY_THR_V 3.1f
diff --git a/core/embed/sys/power_manager/stm32u5/power_monitoring.c b/core/embed/sys/power_manager/stm32u5/power_monitoring.c
index 8645b40cc..5af15b51e 100644
--- a/core/embed/sys/power_manager/stm32u5/power_monitoring.c
+++ b/core/embed/sys/power_manager/stm32u5/power_monitoring.c
@@ -56,7 +56,7 @@ void pm_pmic_data_ready(void* context, pmic_report_t* report) {
// Store measurement timestamp
if (drv->pmic_last_update_us == 0) {
- drv->pmic_sampling_period_ms = PM_BATTERY_SAMPLING_PERIOD_MS;
+ drv->pmic_sampling_period_ms = PM_TIMER_PERIOD_MS;
drv->vbat_tau = report->vbat;
} else {
// Calculate the time since the last PMIC update
Why this scored 17/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.