-
-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(core): add support for T3W1 revB
[no changelog]
- Loading branch information
1 parent
1f8c982
commit 4264b6b
Showing
3 changed files
with
347 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
#ifndef TREZOR_T3W1_REVA_H_ | ||
#define TREZOR_T3W1_REVA_H_ | ||
|
||
#define VDD_1V8 1 | ||
#define USE_SMPS 1 | ||
|
||
#define BTN_POWER_PIN GPIO_PIN_5 | ||
#define BTN_POWER_PORT GPIOE | ||
#define BTN_POWER_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE | ||
#define BTN_EXTI_INTERRUPT_GPIOSEL EXTI_GPIOE | ||
#define BTN_EXTI_INTERRUPT_LINE EXTI_LINE_5 | ||
#define BTN_EXTI_INTERRUPT_PIN GPIO_PIN_5 | ||
#define BTN_EXTI_INTERRUPT_NUM EXTI5_IRQn | ||
#define BTN_EXTI_INTERRUPT_HANDLER EXTI5_IRQHandler | ||
|
||
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_ARGB8888 | ||
#define DISPLAY_PANEL_LX250A2401A | ||
#define DISPLAY_GFXMMU 1 | ||
#define DISPLAY_RESET_PIN GPIO_PIN_2 | ||
#define DISPLAY_RESET_PORT GPIOE | ||
#define DISPLAY_RESET_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE | ||
#define DISPLAY_PWREN_PIN GPIO_PIN_1 | ||
#define DISPLAY_PWREN_PORT GPIOG | ||
#define DISPLAY_PWREN_CLK_ENA __HAL_RCC_GPIOG_CLK_ENABLE | ||
|
||
#define BACKLIGHT_PWM_FREQ 200 | ||
#define BACKLIGHT_PWM_TIM TIM17 | ||
#define BACKLIGHT_PWM_TIM_CLK_EN __HAL_RCC_TIM17_CLK_ENABLE | ||
#define BACKLIGHT_PWM_TIM_CLK_DIS __HAL_RCC_TIM17_CLK_DISABLE | ||
#define BACKLIGHT_PWM_TIM_FORCE_RESET __HAL_RCC_TIM17_FORCE_RESET | ||
#define BACKLIGHT_PWM_TIM_RELEASE_RESET __HAL_RCC_TIM17_RELEASE_RESET | ||
#define BACKLIGHT_PWM_TIM_AF GPIO_AF14_TIM17 | ||
#define BACKLIGHT_PWM_TIM_OCMODE TIM_OCMODE_PWM1 | ||
#define BACKLIGHT_PWM_TIM_CHANNEL TIM_CHANNEL_1 | ||
#define BACKLIGHT_PWM_TIM_CCR CCR1 | ||
#define BACKLIGHT_PWM_PIN GPIO_PIN_9 | ||
#define BACKLIGHT_PWM_PORT GPIOB | ||
#define BACKLIGHT_PWM_PORT_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE | ||
|
||
#define NPM1300_I2C_INSTANCE 0 | ||
|
||
#define STWLC38_I2C_INSTANCE 1 | ||
|
||
#define I2C_COUNT 4 | ||
|
||
#define I2C_INSTANCE_0 I2C1 | ||
#define I2C_INSTANCE_0_CLK_EN __HAL_RCC_I2C1_CLK_ENABLE | ||
#define I2C_INSTANCE_0_CLK_DIS __HAL_RCC_I2C1_CLK_DISABLE | ||
#define I2C_INSTANCE_0_PIN_AF GPIO_AF4_I2C1 | ||
#define I2C_INSTANCE_0_SDA_PORT GPIOG | ||
#define I2C_INSTANCE_0_SDA_PIN GPIO_PIN_13 | ||
#define I2C_INSTANCE_0_SDA_CLK_EN __HAL_RCC_GPIOG_CLK_ENABLE | ||
#define I2C_INSTANCE_0_SCL_PORT GPIOG | ||
#define I2C_INSTANCE_0_SCL_PIN GPIO_PIN_14 | ||
#define I2C_INSTANCE_0_SCL_CLK_EN __HAL_RCC_GPIOG_CLK_ENABLE | ||
#define I2C_INSTANCE_0_RESET_REG &RCC->APB1RSTR1 | ||
#define I2C_INSTANCE_0_RESET_BIT RCC_APB1RSTR1_I2C1RST | ||
#define I2C_INSTANCE_0_EV_IRQHandler I2C1_EV_IRQHandler | ||
#define I2C_INSTANCE_0_ER_IRQHandler I2C1_ER_IRQHandler | ||
#define I2C_INSTANCE_0_EV_IRQn I2C1_EV_IRQn | ||
#define I2C_INSTANCE_0_ER_IRQn I2C1_ER_IRQn | ||
#define I2C_INSTANCE_0_GUARD_TIME 0 | ||
|
||
#define I2C_INSTANCE_1 I2C2 | ||
#define I2C_INSTANCE_1_CLK_EN __HAL_RCC_I2C2_CLK_ENABLE | ||
#define I2C_INSTANCE_1_CLK_DIS __HAL_RCC_I2C2_CLK_DISABLE | ||
#define I2C_INSTANCE_1_PIN_AF GPIO_AF4_I2C2 | ||
#define I2C_INSTANCE_1_SDA_PORT GPIOF | ||
#define I2C_INSTANCE_1_SDA_PIN GPIO_PIN_0 | ||
#define I2C_INSTANCE_1_SDA_CLK_EN __HAL_RCC_GPIOF_CLK_ENABLE | ||
#define I2C_INSTANCE_1_SCL_PORT GPIOF | ||
#define I2C_INSTANCE_1_SCL_PIN GPIO_PIN_1 | ||
#define I2C_INSTANCE_1_SCL_CLK_EN __HAL_RCC_GPIOF_CLK_ENABLE | ||
#define I2C_INSTANCE_1_RESET_REG &RCC->APB1RSTR1 | ||
#define I2C_INSTANCE_1_RESET_BIT RCC_APB1RSTR1_I2C2RST | ||
#define I2C_INSTANCE_1_EV_IRQHandler I2C2_EV_IRQHandler | ||
#define I2C_INSTANCE_1_ER_IRQHandler I2C2_ER_IRQHandler | ||
#define I2C_INSTANCE_1_EV_IRQn I2C2_EV_IRQn | ||
#define I2C_INSTANCE_1_ER_IRQn I2C2_ER_IRQn | ||
#define I2C_INSTANCE_1_GUARD_TIME 0 | ||
|
||
#define I2C_INSTANCE_2 I2C3 | ||
#define I2C_INSTANCE_2_CLK_EN __HAL_RCC_I2C3_CLK_ENABLE | ||
#define I2C_INSTANCE_2_CLK_DIS __HAL_RCC_I2C3_CLK_DISABLE | ||
#define I2C_INSTANCE_2_PIN_AF GPIO_AF4_I2C3 | ||
#define I2C_INSTANCE_2_SDA_PORT GPIOC | ||
#define I2C_INSTANCE_2_SDA_PIN GPIO_PIN_1 | ||
#define I2C_INSTANCE_2_SDA_CLK_EN __HAL_RCC_GPIOC_CLK_ENABLE | ||
#define I2C_INSTANCE_2_SCL_PORT GPIOC | ||
#define I2C_INSTANCE_2_SCL_PIN GPIO_PIN_0 | ||
#define I2C_INSTANCE_2_SCL_CLK_EN __HAL_RCC_GPIOC_CLK_ENABLE | ||
#define I2C_INSTANCE_2_RESET_REG &RCC->APB3RSTR | ||
#define I2C_INSTANCE_2_RESET_BIT RCC_APB3RSTR_I2C3RST | ||
#define I2C_INSTANCE_2_EV_IRQHandler I2C3_EV_IRQHandler | ||
#define I2C_INSTANCE_2_ER_IRQHandler I2C3_ER_IRQHandler | ||
#define I2C_INSTANCE_2_EV_IRQn I2C3_EV_IRQn | ||
#define I2C_INSTANCE_2_ER_IRQn I2C3_ER_IRQn | ||
#define I2C_INSTANCE_2_GUARD_TIME 0 | ||
|
||
#define I2C_INSTANCE_3 I2C4 | ||
#define I2C_INSTANCE_3_CLK_EN __HAL_RCC_I2C4_CLK_ENABLE | ||
#define I2C_INSTANCE_3_CLK_DIS __HAL_RCC_I2C4_CLK_DISABLE | ||
#define I2C_INSTANCE_3_PIN_AF GPIO_AF4_I2C4 | ||
#define I2C_INSTANCE_3_SDA_PORT GPIOD | ||
#define I2C_INSTANCE_3_SDA_PIN GPIO_PIN_13 | ||
#define I2C_INSTANCE_3_SDA_CLK_EN __HAL_RCC_GPIOD_CLK_ENABLE | ||
#define I2C_INSTANCE_3_SCL_PORT GPIOD | ||
#define I2C_INSTANCE_3_SCL_PIN GPIO_PIN_12 | ||
#define I2C_INSTANCE_3_SCL_CLK_EN __HAL_RCC_GPIOD_CLK_ENABLE | ||
#define I2C_INSTANCE_3_RESET_REG &RCC->APB1RSTR2 | ||
#define I2C_INSTANCE_3_RESET_BIT RCC_APB1RSTR2_I2C4RST | ||
#define I2C_INSTANCE_3_EV_IRQHandler I2C4_EV_IRQHandler | ||
#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 50 | ||
|
||
#define TOUCH_SENSITIVITY 0x40 | ||
#define TOUCH_I2C_INSTANCE 2 | ||
#define TOUCH_INT_PORT GPIOC | ||
#define TOUCH_INT_PIN GPIO_PIN_3 | ||
|
||
#define DRV2625_I2C_INSTANCE 2 | ||
#define HAPTIC_ACTUATOR "actuators/vg1040003d.h" | ||
#define DRV2625_TRIG_PIN GPIO_PIN_2 | ||
#define DRV2625_TRIG_PORT GPIOA | ||
#define DRV2625_TRIG_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE | ||
#define DRV2625_TRIG_AF GPIO_AF14_TIM15 | ||
#define DRV2625_TRIG_TIM TIM15 | ||
#define DRV2625_TRIG_TIM_CLK_ENA __HAL_RCC_TIM15_CLK_ENABLE | ||
#define DRV2625_TRIG_TIM_CLK_DIS __HAL_RCC_TIM15_CLK_DISABLE | ||
#define DRV2625_TRIG_TIM_FORCE_RESET __HAL_RCC_TIM15_FORCE_RESET | ||
#define DRV2625_TRIG_TIM_RELEASE_RESET __HAL_RCC_TIM15_RELEASE_RESET | ||
#define DRV2625_RESET_PIN GPIO_PIN_3 | ||
#define DRV2625_RESET_PORT GPIOA | ||
#define DRV2625_RESET_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE | ||
|
||
#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 | ||
#define SBU_2_PIN GPIO_PIN_9 | ||
#define SBU_2_PORT GPIOC | ||
#define SBU_2_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE | ||
|
||
#define NRF_IN_GPIO0_PIN GPIO_PIN_7 | ||
#define NRF_IN_GPIO0_PORT GPIOE | ||
#define NRF_IN_GPIO0_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE | ||
#define NRF_IN_FW_RUNNING_PIN GPIO_PIN_13 | ||
#define NRF_IN_FW_RUNNING_PORT GPIOE | ||
#define NRF_IN_FW_RUNNING_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE | ||
#define NRF_OUT_RESET_PIN GPIO_PIN_0 | ||
#define NRF_OUT_RESET_PORT GPIOG | ||
#define NRF_OUT_RESET_CLK_ENA __HAL_RCC_GPIOG_CLK_ENABLE | ||
#define NRF_OUT_STAY_IN_BLD_PIN GPIO_PIN_15 | ||
#define NRF_OUT_STAY_IN_BLD_PORT GPIOE | ||
#define NRF_OUT_STAY_IN_BLD_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE | ||
#define NRF_OUT_FW_RUNNING_PIN GPIO_PIN_11 | ||
#define NRF_OUT_FW_RUNNING_PORT GPIOE | ||
#define NRF_OUT_FW_RUNNING_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE | ||
|
||
#endif // TREZOR_T3W1_REVA_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
from __future__ import annotations | ||
|
||
from .. import get_hw_model_as_number | ||
from ..stm32u5_common import stm32u5_common_files | ||
|
||
|
||
def configure( | ||
env: dict, | ||
features_wanted: list[str], | ||
defines: list[str | tuple[str, str]], | ||
sources: list[str], | ||
paths: list[str], | ||
) -> list[str]: | ||
features_available: list[str] = [] | ||
board = "T3W1/boards/trezor_t3w1_revB.h" | ||
hw_model = get_hw_model_as_number("T3W1") | ||
hw_revision = 0 | ||
|
||
mcu = "STM32U5G9xx" | ||
linker_script = """embed/sys/linker/stm32u5g/{target}.ld""" | ||
|
||
stm32u5_common_files(env, defines, sources, paths) | ||
|
||
env.get("ENV")[ | ||
"CPU_ASFLAGS" | ||
] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 " | ||
env.get("ENV")[ | ||
"CPU_CCFLAGS" | ||
] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mtune=cortex-m33 -mcmse " | ||
env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf" | ||
|
||
defines += [ | ||
mcu, | ||
("TREZOR_BOARD", f'"{board}"'), | ||
("HW_MODEL", str(hw_model)), | ||
("HW_REVISION", str(hw_revision)), | ||
("HSE_VALUE", "32000000"), | ||
("USE_HSE", "1"), | ||
("FIXED_HW_DEINIT", "1"), | ||
] | ||
|
||
sources += [ | ||
"embed/io/display/ltdc_dsi/display_driver.c", | ||
"embed/io/display/ltdc_dsi/panels/lx250a2401a/lx250a2401a.c", | ||
"embed/io/display/ltdc_dsi/display_fb.c", | ||
"embed/io/display/ltdc_dsi/display_fb_rgb888.c", | ||
"embed/io/display/ltdc_dsi/display_gfxmmu.c", | ||
"embed/io/display/fb_queue/fb_queue.c", | ||
"embed/io/display/backlight/stm32/backlight_pwm.c", | ||
] | ||
|
||
paths += ["embed/io/display/inc"] | ||
features_available.append("backlight") | ||
defines += [("USE_BACKLIGHT", "1")] | ||
|
||
if "input" in features_wanted: | ||
sources += ["embed/io/touch/ft6x36/ft6x36.c"] | ||
paths += ["embed/io/touch/inc"] | ||
features_available.append("touch") | ||
sources += ["embed/io/button/stm32/button.c"] | ||
paths += ["embed/io/button/inc"] | ||
features_available.append("button") | ||
defines += [ | ||
("USE_TOUCH", "1"), | ||
("USE_BUTTON", "1"), | ||
] | ||
|
||
sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"] | ||
paths += ["embed/io/i2c_bus/inc"] | ||
defines += [("USE_I2C", "1")] | ||
|
||
if "haptic" in features_wanted: | ||
sources += [ | ||
"embed/io/haptic/drv2625/drv2625.c", | ||
] | ||
paths += ["embed/io/haptic/inc"] | ||
features_available.append("haptic") | ||
defines += ["USE_HAPTIC=1"] | ||
|
||
if "ble" in features_wanted: | ||
sources += ["embed/io/ble/stm32/ble.c"] | ||
paths += ["embed/io/ble/inc"] | ||
features_available.append("ble") | ||
defines += [("USE_BLE", "1")] | ||
sources += ["embed/io/nrf/stm32u5/nrf.c"] | ||
sources += ["embed/io/nrf/crc8.c"] | ||
paths += ["embed/io/nrf/inc"] | ||
sources += [ | ||
"vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_uart.c", | ||
"vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_uart_ex.c", | ||
] | ||
|
||
if "optiga" in features_wanted: | ||
sources += ["embed/sec/optiga/stm32/optiga_hal.c"] | ||
sources += ["embed/sec/optiga/optiga.c"] | ||
sources += ["embed/sec/optiga/optiga_commands.c"] | ||
sources += ["embed/sec/optiga/optiga_config.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"] | ||
features_available.append("sbu") | ||
defines += [("USE_SBU", "1")] | ||
|
||
if "rgb_led" in features_wanted: | ||
sources += ["embed/io/rgb_led/stm32u5/rgb_led_lp.c"] | ||
paths += ["embed/io/rgb_led/inc"] | ||
features_available.append("rgb_led") | ||
defines += [("USE_RGB_LED", "1")] | ||
|
||
if "usb" in features_wanted: | ||
sources += [ | ||
"embed/io/usb/stm32/usb_class_hid.c", | ||
"embed/io/usb/stm32/usb_class_vcp.c", | ||
"embed/io/usb/stm32/usb_class_webusb.c", | ||
"embed/io/usb/stm32/usb.c", | ||
"embed/io/usb/stm32/usbd_conf.c", | ||
"embed/io/usb/stm32/usbd_core.c", | ||
"embed/io/usb/stm32/usbd_ctlreq.c", | ||
"embed/io/usb/stm32/usbd_ioreq.c", | ||
"vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_usb.c", | ||
] | ||
features_available.append("usb") | ||
paths += ["embed/io/usb/inc"] | ||
defines += [("USE_USB", "1")] | ||
|
||
defines += [ | ||
"FRAMEBUFFER", | ||
"DISPLAY_RGBA8888", | ||
("UI_COLOR_32BIT", "1"), | ||
("USE_RGB_COLORS", "1"), | ||
("DISPLAY_RESX", "380"), | ||
("DISPLAY_RESY", "520"), | ||
] | ||
features_available.append("ui_color_32bit") | ||
features_available.append("framebuffer") | ||
features_available.append("display_rgba8888") | ||
|
||
defines += [ | ||
"USE_DMA2D", | ||
] | ||
features_available.append("dma2d") | ||
sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] | ||
|
||
defines += [ | ||
("USE_HASH_PROCESSOR", "1"), | ||
("USE_STORAGE_HWKEY", "1"), | ||
("USE_TAMPER", "1"), | ||
("USE_FLASH_BURST", "1"), | ||
("USE_OEM_KEYS_CHECK", "1"), | ||
("USE_RESET_TO_BOOT", "1"), | ||
] | ||
|
||
sources += [ | ||
"embed/sys/powerctl/npm1300/npm1300.c", | ||
"embed/sys/powerctl/stwlc38/stwlc38.c", | ||
"embed/sys/powerctl/stwlc38/stwlc38_patching.c", | ||
"embed/sys/powerctl/stm32u5/powerctl.c", | ||
"embed/sys/powerctl/stm32u5/powerctl_suspend.c", | ||
"embed/sys/powerctl/wakeup_flags.c", | ||
] | ||
paths += ["embed/sys/powerctl/inc"] | ||
defines += [("USE_POWERCTL", "1")] | ||
|
||
env.get("ENV")["LINKER_SCRIPT"] = linker_script | ||
|
||
defs = env.get("CPPDEFINES_IMPLICIT") | ||
defs += ["__ARM_FEATURE_CMSE=3"] | ||
|
||
return features_available |