1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-09 06:50:58 +00:00

feat(core): support optiga on T3W1

[no changelog]
This commit is contained in:
tychovrahe 2024-11-15 13:24:03 +01:00 committed by TychoVrahe
parent c5b3dd72b9
commit 0f0f54f185
3 changed files with 33 additions and 2 deletions

View File

@ -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

View File

@ -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);

View File

@ -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"]