fix(prodtest): remove st hal calls from prodtest emulator
What changed, and why it matters
This commit fixes a build or runtime problem in the Trezor hardware wallet's production-test firmware when it is compiled for the software emulator. It wraps real hardware calls (deinitializing the Bluetooth module and UART, resetting the NRF chip, and entering direct test mode) inside a check that skips them on the emulator. There is no direct user security impact; it is a build/test-harness fix.
No security action required. Treat as a normal build/test fix. If reviewing, verify that the emulator path still returns cli_ok and does not leave the BLE stack in an inconsistent state for test scripts.
Security signals we found
Hardware abstraction layer (HAL) calls gated by emulator preprocessor macro
Production-test command functions modified to skip physical BLE/NRF operations in emulator builds
No input validation, buffer handling, or cryptographic code changed
Evidence from the diff
In core/embed/projects/prodtest/cmd/prodtest_ble.c, the prodtest_ble_radio_test_cmd() and prodtest_ble_direct_test_mode_cmd() functions now guard their STM32 HAL / NRF hardware sequences with #ifndef TREZOR_EMULATOR. This prevents the emulator build from invoking hardware-specific functions that are unavailable or invalid in the emulator environment. The change is additive (five lines of preprocessor guards) and does not alter behavior on real hardware.
Changed components
core/embed/projects/prodtest/cmd/prodtest_ble.cTrezor firmware production-test BLE commandsTrezor emulator build of prodtestInspect captured patch +5 / −0
diff --git a/core/embed/projects/prodtest/cmd/prodtest_ble.c b/core/embed/projects/prodtest/cmd/prodtest_ble.c
index a5f1af4f..17a8f3a0 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_ble.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_ble.c
@@ -281,6 +281,7 @@ static void prodtest_ble_radio_test_cmd(cli_t* cli) {
return;
}
+#ifndef TREZOR_EMULATOR
// Deinitialize BLE module
ble_deinit();
@@ -361,6 +362,7 @@ static void prodtest_ble_radio_test_cmd(cli_t* cli) {
HAL_UART_DeInit(&huart);
__HAL_RCC_USART3_CLK_DISABLE();
ble_init(); // Reinitialize BLE module
+#endif // TREZOR_EMULATOR
cli_ok(cli, "");
}
@@ -375,6 +377,7 @@ void prodtest_ble_direct_test_mode_cmd(cli_t* cli) {
return;
}
+#ifndef TREZOR_EMULATOR
uint8_t cmd_line_byte;
// Reset NRF
@@ -399,6 +402,8 @@ void prodtest_ble_direct_test_mode_cmd(cli_t* cli) {
nrf_set_dtm_mode(false, NULL);
+#endif // TREZOR_EMULATOR
+
cli_ok(cli, "");
}
Why this scored 18/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.