chore(core): move repeated platform-specific includes to BSP
What changed, and why it matters
This is a routine code cleanup that moves repeated low-level hardware header includes into a shared board-support header. It does not change what code runs, only where the include statements live. There is no security issue visible in the diff.
No security action required; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors platform-specific STM32 LL utility includes (stm32u5xx_ll_utils.h / stm32f4xx_ll_utils.h) into trezor_bsp.h so both storage_salt.c and cpuid.c get them transitively. The effective preprocessor state and linked symbols remain unchanged; it is a pure include consolidation with no functional modifications.
Changed components
core/embed/sec/storage/stm32u5/storage_salt.ccore/embed/sys/bsp/inc/trezor_bsp.hcore/embed/sys/cpuid/stm32/cpuid.cInspect captured patch +8 / −8
diff --git a/core/embed/sec/storage/stm32u5/storage_salt.c b/core/embed/sec/storage/stm32u5/storage_salt.c
index eda8bc6c..7e23e73b 100644
--- a/core/embed/sec/storage/stm32u5/storage_salt.c
+++ b/core/embed/sec/storage/stm32u5/storage_salt.c
@@ -19,6 +19,7 @@
#ifdef SECURE_MODE
+#include <trezor_bsp.h>
#include <trezor_model.h>
#include <trezor_rtl.h>
@@ -28,8 +29,6 @@
#include <sys/mpu.h>
#include <sys/rng.h>
-#include "stm32u5xx_ll_utils.h"
-
#include "../storage_salt.h"
#ifdef SECRET_PRIVILEGED_MASTER_KEY_SLOT
diff --git a/core/embed/sys/bsp/inc/trezor_bsp.h b/core/embed/sys/bsp/inc/trezor_bsp.h
index cb04758d..9203cb64 100644
--- a/core/embed/sys/bsp/inc/trezor_bsp.h
+++ b/core/embed/sys/bsp/inc/trezor_bsp.h
@@ -33,6 +33,13 @@
#ifndef TREZOR_EMULATOR
#include STM32_HAL_H
+#ifdef STM32U5
+#include "stm32u5xx_ll_utils.h"
+#endif
+#ifdef STM32F4
+#include "stm32f4xx_ll_utils.h"
+#endif
+
// HAL status code helpers
static inline ts_t hal_status_to_ts(HAL_StatusTypeDef hal_status) {
switch (hal_status) {
diff --git a/core/embed/sys/cpuid/stm32/cpuid.c b/core/embed/sys/cpuid/stm32/cpuid.c
index c4e1d89c..7158cecd 100644
--- a/core/embed/sys/cpuid/stm32/cpuid.c
+++ b/core/embed/sys/cpuid/stm32/cpuid.c
@@ -25,12 +25,6 @@
#include <sys/cpuid.h>
#include <sys/mpu.h>
-#ifdef STM32U5
-#include "stm32u5xx_ll_utils.h"
-#else
-#include "stm32f4xx_ll_utils.h"
-#endif
-
void cpuid_get(cpuid_t* cpuid) {
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_OTP);
cpuid->id[0] = LL_GetUID_Word0();
Why this scored 15/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.