feat(core): Update charging state evaluation.
What changed, and why it matters
This commit changes the order in which a Trezor hardware wallet decides whether its battery is charging, discharging, or idle. It now asks a dedicated helper function first instead of relying only on raw current readings. There is no indication in the commit that this fixes a security problem; it appears to be a routine improvement to charging-state detection.
No security action required. Treat as a normal firmware maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies power_manager.c for the STM32U5 platform. Previously, the code classified battery state by checking drv->pmic_data.ibat: positive current meant discharging, negative meant charging, zero meant idle. The new code first calls pm_is_charging(), then falls back to the current-sign check for discharging/idle. This suggests the device can report charging through other signals (e.g., charger presence) rather than only via battery current direction. No security-relevant boundary conditions, input validation, access control, or cryptographic code are touched.
Changed components
core/embed/sys/power_manager/stm32u5/power_manager.cInspect captured patch +3 / −3
diff --git a/core/embed/sys/power_manager/stm32u5/power_manager.c b/core/embed/sys/power_manager/stm32u5/power_manager.c
index 9557fac24..be61749f8 100644
--- a/core/embed/sys/power_manager/stm32u5/power_manager.c
+++ b/core/embed/sys/power_manager/stm32u5/power_manager.c
@@ -215,10 +215,10 @@ pm_status_t pm_get_state(pm_state_t* state) {
state->usb_connected = drv->usb_connected;
state->wireless_connected = drv->wireless_connected;
- if (drv->pmic_data.ibat > 0.0f) {
- state->charging_status = PM_BATTERY_DISCHARGING;
- } else if (drv->pmic_data.ibat < 0.0f) {
+ if (pm_is_charging()) {
state->charging_status = PM_BATTERY_CHARGING;
+ } else if (drv->pmic_data.ibat > 0.0f) {
+ state->charging_status = PM_BATTERY_DISCHARGING;
} else {
state->charging_status = PM_BATTERY_IDLE;
}
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.