diff --git a/core/embed/models/T3W1/boards/trezor_t3w1_revA.h b/core/embed/models/T3W1/boards/trezor_t3w1_revA.h index 854a4b335f..d43f26fa4b 100644 --- a/core/embed/models/T3W1/boards/trezor_t3w1_revA.h +++ b/core/embed/models/T3W1/boards/trezor_t3w1_revA.h @@ -94,13 +94,21 @@ #define I2C_INSTANCE_3_ER_IRQHandler I2C4_ER_IRQHandler #define I2C_INSTANCE_3_EV_IRQn I2C4_EV_IRQn #define I2C_INSTANCE_3_ER_IRQn I2C4_ER_IRQn -#define I2C_INSTANCE_3_GUARD_TIME 0 +#define I2C_INSTANCE_3_GUARD_TIME 50 #define TOUCH_SENSITIVITY 0x40 #define TOUCH_I2C_INSTANCE 2 #define TOUCH_INT_PORT GPIOC #define TOUCH_INT_PIN GPIO_PIN_3 +#define OPTIGA_I2C_INSTANCE 3 +#define OPTIGA_RST_PORT GPIOD +#define OPTIGA_RST_PIN GPIO_PIN_10 +#define OPTIGA_RST_CLK_EN __HAL_RCC_GPIOD_CLK_ENABLE +#define OPTIGA_PWR_PORT GPIOD +#define OPTIGA_PWR_PIN GPIO_PIN_14 +#define OPTIGA_PWR_CLK_EN __HAL_RCC_GPIOD_CLK_ENABLE + #define SBU_1_PIN GPIO_PIN_8 #define SBU_1_PORT GPIOC #define SBU_1_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE diff --git a/core/embed/sec/optiga/stm32f4/optiga_hal.c b/core/embed/sec/optiga/stm32f4/optiga_hal.c index 8aa1346ec5..9a35af5ecc 100644 --- a/core/embed/sec/optiga/stm32f4/optiga_hal.c +++ b/core/embed/sec/optiga/stm32f4/optiga_hal.c @@ -7,15 +7,28 @@ #ifdef KERNEL_MODE void optiga_hal_init(void) { + GPIO_InitTypeDef GPIO_InitStructure = {0}; + OPTIGA_RST_CLK_EN(); // init reset pin - GPIO_InitTypeDef GPIO_InitStructure = {0}; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStructure.Alternate = 0; GPIO_InitStructure.Pin = OPTIGA_RST_PIN; HAL_GPIO_Init(OPTIGA_RST_PORT, &GPIO_InitStructure); + +#ifdef OPTIGA_PWR_PIN + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStructure.Pull = GPIO_NOPULL; + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStructure.Alternate = 0; + GPIO_InitStructure.Pin = OPTIGA_PWR_PIN; + HAL_GPIO_Init(OPTIGA_PWR_PORT, &GPIO_InitStructure); + HAL_GPIO_WritePin(OPTIGA_PWR_PORT, OPTIGA_PWR_PIN, GPIO_PIN_RESET); + hal_delay(10); +#endif + // perform reset on every initialization HAL_GPIO_WritePin(OPTIGA_RST_PORT, OPTIGA_RST_PIN, GPIO_PIN_RESET); hal_delay(10); diff --git a/core/site_scons/models/T3W1/trezor_t3w1_revA.py b/core/site_scons/models/T3W1/trezor_t3w1_revA.py index c27afc9da9..d3d2f0d499 100644 --- a/core/site_scons/models/T3W1/trezor_t3w1_revA.py +++ b/core/site_scons/models/T3W1/trezor_t3w1_revA.py @@ -75,6 +75,16 @@ def configure( "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] + if "optiga" in features_wanted: + sources += ["embed/sec/optiga/stm32u5/optiga_hal.c"] + sources += ["embed/sec/optiga/optiga.c"] + sources += ["embed/sec/optiga/optiga_commands.c"] + sources += ["embed/sec/optiga/optiga_transport.c"] + sources += ["vendor/trezor-crypto/hash_to_curve.c"] + paths += ["embed/sec/optiga/inc"] + features_available.append("optiga") + defines += ["USE_OPTIGA=1"] + if "sbu" in features_wanted: sources += ["embed/io/sbu/stm32/sbu.c"] paths += ["embed/io/sbu/inc"]