chore(core): libtropic - modify `tropic01` to adhere to `libtropic_port` API [no changelog]
What changed, and why it matters
This is a routine code cleanup in Trezor firmware. It updates a hardware driver for the Tropic01 secure chip so its function signatures match a newer version of the underlying library API. The actual behavior of the code is unchanged; only the names of internal data structures were updated. There is no indication this fixes or introduces a security problem.
No security action required. Treat as normal maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors core/embed/sec/tropic/stm32/tropic01.c to align the Trezor Tropic01 HAL port with the libtropic_port API. Specifically, the callback parameter type is changed from lt_handle_t *h to lt_l2_state_t *s2, and accesses to h->l2.buff are replaced with s2->buff. The logic, bounds check (offset + tx_len > LT_L1_LEN_MAX), SPI transmit/receive call, and delay behavior remain identical. The change is purely structural/API conformance.
Changed components
core/embed/sec/tropic/stm32/tropic01.cInspect captured patch +12 / −12
diff --git a/core/embed/sec/tropic/stm32/tropic01.c b/core/embed/sec/tropic/stm32/tropic01.c
index 3df6bf1b3..b9d9e5178 100644
--- a/core/embed/sec/tropic/stm32/tropic01.c
+++ b/core/embed/sec/tropic/stm32/tropic01.c
@@ -41,7 +41,7 @@ void tropic01_reset(void) {
systick_delay_ms(10);
}
-lt_ret_t lt_port_init(lt_handle_t *h) {
+lt_ret_t lt_port_init(lt_l2_state_t *s2) {
tropic01_hal_driver_t *drv = &g_tropic01_hal_driver;
if (drv->initialized) {
@@ -121,7 +121,7 @@ lt_ret_t lt_port_init(lt_handle_t *h) {
return LT_OK;
}
-lt_ret_t lt_port_deinit(lt_handle_t *h) {
+lt_ret_t lt_port_deinit(lt_l2_state_t *s2) {
tropic01_hal_driver_t *drv = &g_tropic01_hal_driver;
if (drv->spi.Instance != NULL) {
@@ -142,8 +142,8 @@ lt_ret_t lt_port_deinit(lt_handle_t *h) {
return LT_OK;
}
-lt_ret_t lt_port_spi_csn_low(lt_handle_t *h) {
- UNUSED(h);
+lt_ret_t lt_port_spi_csn_low(lt_l2_state_t *s2) {
+ UNUSED(s2);
HAL_GPIO_WritePin(TROPIC01_SPI_NSS_PORT, TROPIC01_SPI_NSS_PIN,
GPIO_PIN_RESET);
@@ -151,23 +151,23 @@ lt_ret_t lt_port_spi_csn_low(lt_handle_t *h) {
return LT_OK;
}
-lt_ret_t lt_port_spi_csn_high(lt_handle_t *h) {
- UNUSED(h);
+lt_ret_t lt_port_spi_csn_high(lt_l2_state_t *s2) {
+ UNUSED(s2);
HAL_GPIO_WritePin(TROPIC01_SPI_NSS_PORT, TROPIC01_SPI_NSS_PIN, GPIO_PIN_SET);
return LT_OK;
}
-lt_ret_t lt_port_spi_transfer(lt_handle_t *h, uint8_t offset, uint16_t tx_len,
- uint32_t timeout_ms) {
+lt_ret_t lt_port_spi_transfer(lt_l2_state_t *s2, uint8_t offset,
+ uint16_t tx_len, uint32_t timeout_ms) {
tropic01_hal_driver_t *drv = &g_tropic01_hal_driver;
if (offset + tx_len > LT_L1_LEN_MAX) {
return LT_L1_DATA_LEN_ERROR;
}
- int ret = HAL_SPI_TransmitReceive(&drv->spi, h->l2.buff + offset,
- h->l2.buff + offset, tx_len, timeout_ms);
+ int ret = HAL_SPI_TransmitReceive(&drv->spi, s2->buff + offset,
+ s2->buff + offset, tx_len, timeout_ms);
if (ret != HAL_OK) {
return LT_FAIL;
}
@@ -175,8 +175,8 @@ lt_ret_t lt_port_spi_transfer(lt_handle_t *h, uint8_t offset, uint16_t tx_len,
return LT_OK;
}
-lt_ret_t lt_port_delay(lt_handle_t *h, uint32_t ms) {
- UNUSED(h);
+lt_ret_t lt_port_delay(lt_l2_state_t *s2, uint32_t ms) {
+ UNUSED(s2);
systick_delay_ms(ms);
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.