1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-24 22:31:35 +00:00

feat(core): use lx250a2401a display panel on T3W1

[no changelog]
This commit is contained in:
tychovrahe 2025-01-02 13:12:04 +01:00 committed by TychoVrahe
parent b97390a73a
commit 1c59442f89
5 changed files with 340 additions and 14 deletions

View File

@ -13,8 +13,9 @@
#define BTN_EXTI_INTERRUPT_NUM EXTI5_IRQn
#define BTN_EXTI_INTERRUPT_HANDLER EXTI5_IRQHandler
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565
#define DISPLAY_PANEL_LX200D2406A
#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

View File

@ -0,0 +1,146 @@
#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_RGB565
#define DISPLAY_PANEL_LX200D2406A
#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_0
#define DISPLAY_PWREN_PORT GPIOE
#define DISPLAY_PWREN_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
#define BACKLIGHT_PWM_FREQ 1000
#define BACKLIGHT_PWM_TIM TIM17
#define BACKLIGHT_PWM_TIM_CLK_EN __HAL_RCC_TIM17_CLK_ENABLE
#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_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
#endif // TREZOR_T3W1_REVA_H_

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Optional
from . import emulator, trezor_t3w1_revA
from . import emulator, trezor_t3w1_revA, trezor_t3w1_revA0
def configure_board(
@ -19,6 +19,7 @@ def configure_board(
# Mapping of revisions to their respective configurations
revision_map = {
"emulator": emulator,
"A0": trezor_t3w1_revA0,
"A": trezor_t3w1_revA,
}

View File

@ -41,9 +41,10 @@ def configure(
sources += [
"embed/io/display/ltdc_dsi/display_driver.c",
"embed/io/display/ltdc_dsi/panels/lx200d2406a/lx200d2406a.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_rgb565.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",
]
@ -54,7 +55,6 @@ def configure(
if "input" in features_wanted:
sources += ["embed/io/touch/ft6x36/ft6x36.c"]
sources += ["embed/io/touch/ft6x36/panels/lhs200kb-if21.c"]
paths += ["embed/io/touch/inc"]
features_available.append("touch")
sources += ["embed/io/button/stm32/button.c"]
@ -132,17 +132,22 @@ def configure(
paths += ["embed/io/usb/inc"]
defines += [
"USE_DMA2D",
"FRAMEBUFFER",
"DISPLAY_RGBA8888",
("UI_COLOR_32BIT", "1"),
("USE_RGB_COLORS", "1"),
("DISPLAY_RESX", "380"),
("DISPLAY_RESY", "520"),
]
sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"]
features_available.append("dma2d")
defines += ["FRAMEBUFFER"]
defines += ["DISPLAY_RGB565"]
features_available.append("ui_color_32bit")
features_available.append("framebuffer")
features_available.append("display_rgb565")
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"),

View File

@ -0,0 +1,173 @@
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_revA0.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/lx200d2406a/lx200d2406a.c",
"embed/io/display/ltdc_dsi/display_fb.c",
"embed/io/display/ltdc_dsi/display_fb_rgb565.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/trezorhal/stm32f4/ble/ble_hal.c"]
# sources += ["embed/trezorhal/stm32f4/ble/dfu.c"]
# sources += ["embed/trezorhal/stm32f4/ble/fwu.c"]
# sources += ["embed/trezorhal/stm32f4/ble/ble.c"]
# sources += ["embed/trezorhal/stm32f4/ble/messages.c"]
# sources += [
# "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c"
# ]
# features_available.append("ble")
# defines += [("USE_BLE", "1")]
if "ble" in features_wanted:
sources += [
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.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_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/stm32/rgb_led.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 += [
"FRAMEBUFFER",
"DISPLAY_RGB565",
("USE_RGB_COLORS", "1"),
("DISPLAY_RESX", "240"),
("DISPLAY_RESY", "320"),
]
features_available.append("framebuffer")
features_available.append("display_rgb565")
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/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