chore(core): use backup ram in BLE driver conditionally
What changed, and why it matters
This is a small build-system cleanup in the Bluetooth driver for Trezor hardware wallets. It wraps the use of a special 'backup RAM' feature inside a compile-time flag so the same Bluetooth code can be compiled on devices that do not have that feature. There is no visible security fix or behavior change for shipping products; it simply avoids a build error on configurations without backup RAM.
No security action required. Treat as a normal build/conditional-compilation maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit makes the STM32 BLE driver’s use of backup_ram_read/backup_ram_write conditional on USE_BACKUP_RAM. Previously the driver unconditionally included
Changed components
core/embed/io/ble/stm32/ble.cInspect captured patch +8 / −1
diff --git a/core/embed/io/ble/stm32/ble.c b/core/embed/io/ble/stm32/ble.c
index 7af80ce1..e693038b 100644
--- a/core/embed/io/ble/stm32/ble.c
+++ b/core/embed/io/ble/stm32/ble.c
@@ -28,13 +28,16 @@
#include <io/ble.h>
#include <io/nrf.h>
#include <io/tsqueue.h>
-#include <sec/backup_ram.h>
#include <sec/unit_properties.h>
#include <sys/irq.h>
#include <sys/sysevent_source.h>
#include <sys/systick.h>
#include <sys/systimer.h>
+#ifdef USE_BACKUP_RAM
+#include <sec/backup_ram.h>
+#endif
+
#ifdef USE_POWER_MANAGER
#include <io/power_manager.h>
#endif
@@ -666,6 +669,7 @@ bool ble_init(void) {
}
drv->enabled = true;
+#ifdef USE_BACKUP_RAM
ble_recovery_data_t backup_data;
if (backup_ram_read(BACKUP_RAM_KEY_BLE_SETTINGS, &backup_data,
sizeof(backup_data), NULL)) {
@@ -673,6 +677,7 @@ bool ble_init(void) {
drv->enabled = backup_data.enabled;
}
}
+#endif
drv->power_level = BLE_TX_POWER_PLUS_4_DBM;
drv->initialized = true;
@@ -1374,10 +1379,12 @@ void ble_set_enabled(bool enabled) {
drv->enabled = enabled;
+#ifdef USE_BACKUP_RAM
ble_recovery_data_t data = {.version = 1, .enabled = enabled};
backup_ram_write(BACKUP_RAM_KEY_BLE_SETTINGS, BACKUP_RAM_ITEM_PROTECTED,
&data, sizeof(data));
+#endif
}
bool ble_get_enabled(void) {
Why this scored 12/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.