1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

feat(core): add basic support for T3T1

This commit is contained in:
tychovrahe 2023-08-24 11:33:50 +02:00 committed by TychoVrahe
parent 7d7ccc9dde
commit a71a608ea7
40 changed files with 554 additions and 24 deletions

View File

@ -55,6 +55,16 @@ BOOTLOADER_MAXSIZE = 131072
FIRMWARE_P1_MAXSIZE = 786432
FIRMWARE_P2_MAXSIZE = 917504
FIRMWARE_MAXSIZE = 1703936
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T3T1))
OPENOCD_TARGET = target/stm32u5x.cfg
BOARDLOADER_START = 0x0C004000
BOARDLOADER_END = 0x0C010000
BOOTLOADER_START = 0x0C010000
FIRMWARE_START = 0x0C050000
PRODTEST_START = 0x0C050000
BOARDLOADER_MAXSIZE = 49152
BOOTLOADER_MAXSIZE = 131072
FIRMWARE_MAXSIZE = 1703936
else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC2))
OPENOCD_TARGET = target/stm32u5x.cfg
BOARDLOADER_START = 0x0C004000

View File

@ -36,11 +36,11 @@ if TREZOR_MODEL in ('R', ):
FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO='Font_PixelOperator_Regular_8'
FONT_BIG=None
elif TREZOR_MODEL in ('T', 'DISC1', 'DISC2'):
elif TREZOR_MODEL in ('T', 'T3T1', 'DISC1', 'DISC2'):
FONT_NORMAL='Font_TTHoves_Regular_21'
FONT_DEMIBOLD=None
FONT_DEMIBOLD='Font_TTHoves_Regular_21'
FONT_BOLD='Font_TTHoves_Bold_17'
FONT_MONO=None
FONT_MONO='Font_TTHoves_Regular_21'
FONT_BIG=None
# modtrezorcrypto

View File

@ -34,7 +34,7 @@ if TREZOR_MODEL in ('1', 'R'):
FONT_BOLD=None
FONT_MONO='Font_PixelOperatorMono_Regular_8'
FONT_BIG=None
elif TREZOR_MODEL in ('T', ):
elif TREZOR_MODEL in ('T', 'T3T1'):
FONT_NORMAL='Font_Roboto_Regular_20'
FONT_DEMIBOLD=None
FONT_BOLD=None

View File

@ -33,7 +33,7 @@ if TREZOR_MODEL in ('1', 'R'):
FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO='Font_PixelOperator_Regular_8'
FONT_BIG=None
elif TREZOR_MODEL in ('T', 'DISC2'):
elif TREZOR_MODEL in ('T', 'T3T1', 'DISC2'):
FONT_NORMAL='Font_TTHoves_Regular_21'
FONT_DEMIBOLD=None
FONT_BOLD='Font_TTHoves_Bold_17'
@ -173,6 +173,8 @@ env.Replace(
if TREZOR_MODEL in ('T', 'R'):
CPU_MODEL = 'STM32F427xx'
elif TREZOR_MODEL in ('T3T1', ):
CPU_MODEL = 'STM32U585xx'
elif TREZOR_MODEL in ('DISC1', ):
CPU_MODEL = 'STM32F429xx'
elif TREZOR_MODEL in ('DISC2', ):
@ -265,7 +267,7 @@ def cargo_build():
else:
features = ["model_tt"]
if TREZOR_MODEL in ('T',):
if TREZOR_MODEL in ('T', 'T3T1'):
features.append('touch')
features.append('backlight')
if TREZOR_MODEL in ('R', '1'):

View File

@ -41,7 +41,7 @@ if TREZOR_MODEL in ('1', 'R'):
FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO='Font_PixelOperatorMono_Regular_8'
FONT_BIG='Font_Unifont_Regular_16'
elif TREZOR_MODEL in ('T', 'DISC1', 'DISC2'):
elif TREZOR_MODEL in ('T', 'T3T1', 'DISC1', 'DISC2'):
FONT_NORMAL='Font_TTHoves_Regular_21'
FONT_DEMIBOLD='Font_TTHoves_DemiBold_21'
FONT_BOLD='Font_TTHoves_Bold_17'
@ -392,7 +392,7 @@ SOURCE_FIRMWARE = [
]
if TREZOR_MODEL in ('T', 'DISC1', 'DISC2'):
if TREZOR_MODEL in ('T', 'T3T1', 'DISC1', 'DISC2'):
UI_LAYOUT = 'UI_LAYOUT_TT'
ui_layout_feature = 'model_tt'
elif TREZOR_MODEL in ('1', 'R'):
@ -839,8 +839,7 @@ BINARY_NAME += "-dirty" if tools.get_git_modified() else ""
BINARY_NAME += ".bin"
if TREZOR_MODEL in ('1',):
if TREZOR_MODEL in ('1'):
action_bin=[
'$OBJCOPY -O binary -j .header -j .flash -j .data -j .sensitive $SOURCE $TARGET',
'../legacy/bootloader/firmware_sign.py -f $TARGET',

View File

@ -38,7 +38,7 @@ if TREZOR_MODEL in ('1', 'R'):
FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO=None
FONT_BIG=None
elif TREZOR_MODEL in ('T', ):
elif TREZOR_MODEL in ('T', 'T3T1'):
FONT_NORMAL=None
FONT_DEMIBOLD=None
FONT_BOLD='Font_Roboto_Bold_20'

View File

@ -33,7 +33,7 @@ if TREZOR_MODEL in ('1', 'R'):
FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO=None
FONT_BIG=None
elif TREZOR_MODEL in ('T', ):
elif TREZOR_MODEL in ('T', 'T3T1'):
FONT_NORMAL=None
FONT_DEMIBOLD=None
FONT_BOLD='Font_Roboto_Bold_20'

View File

@ -7,7 +7,7 @@ import tools
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
EVERYTHING = BITCOIN_ONLY != '1'
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
DMA2D = TREZOR_MODEL in ('T', )
DMA2D = TREZOR_MODEL in ('T', 'T3T1')
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
if TREZOR_MODEL in ('DISC1', 'DISC2'):
@ -42,7 +42,7 @@ if TREZOR_MODEL in ('1', 'R'):
FONT_BOLD='Font_PixelOperator_Bold_8'
FONT_MONO='Font_PixelOperatorMono_Regular_8'
FONT_BIG='Font_Unifont_Regular_16'
elif TREZOR_MODEL in ('T', 'DISC2'):
elif TREZOR_MODEL in ('T', 'T3T1'):
FONT_NORMAL='Font_TTHoves_Regular_21'
FONT_DEMIBOLD='Font_TTHoves_DemiBold_21'
FONT_BOLD='Font_TTHoves_Bold_17'
@ -177,7 +177,7 @@ if FEATURE_FLAGS["SECP256K1_ZKP"]:
SOURCE_MOD += [
'embed/extmod/modtrezorio/modtrezorio.c',
]
if TREZOR_MODEL in ('T',):
if TREZOR_MODEL in ('T', 'T3T1'):
SOURCE_MOD += [
'embed/extmod/modtrezorio/ff.c',
'embed/extmod/modtrezorio/ffunicode.c',
@ -393,7 +393,7 @@ SOURCE_UNIX = [
'vendor/micropython/ports/unix/input.c',
'vendor/micropython/ports/unix/unix_mphal.c',
]
if TREZOR_MODEL in ('T', 'R'):
if TREZOR_MODEL in ('T', 'R', 'T3T1'):
SOURCE_UNIX += [
'embed/trezorhal/unix/sbu.c',
]
@ -430,7 +430,7 @@ else:
env = Environment(ENV=os.environ, CFLAGS='%s -DPYOPT=%s -DBITCOIN_ONLY=%s %s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT, BITCOIN_ONLY, STATIC))
if TREZOR_MODEL in ('T',):
if TREZOR_MODEL in ('T', 'T3T1'):
UI_LAYOUT = 'UI_LAYOUT_TT'
ui_layout_feature = 'model_tt'
elif TREZOR_MODEL in ('1', 'R'):
@ -497,6 +497,8 @@ env.Replace(
if TREZOR_MODEL in ('T', 'R'):
CPU_MODEL = 'STM32F427xx'
elif TREZOR_MODEL in ('T3T1', ):
CPU_MODEL = 'STM32U585xx'
elif TREZOR_MODEL in ('DISC1', ):
CPU_MODEL = 'STM32F429xx'
elif TREZOR_MODEL in ('DISC2', ):
@ -810,7 +812,7 @@ def cargo_build():
if DMA2D:
features.append('dma2d')
if TREZOR_MODEL in ('T',):
if TREZOR_MODEL in ('T', 'T3T1'):
features.append('touch')
features.append('sd_card')
if TREZOR_MODEL in ('R', '1'):

Binary file not shown.

View File

@ -0,0 +1,122 @@
/* TREZORv2 firmware linker script */
ENTRY(reset_handler)
MEMORY {
FLASH (rx) : ORIGIN = 0x0C050000, LENGTH = 1664K
SRAM1 (wal) : ORIGIN = 0x30000000, LENGTH = 192K - 0x100
BOOT_ARGS (wal) : ORIGIN = 0x3002FF00, LENGTH = 0x100
SRAM2 (wal) : ORIGIN = 0x30030000, LENGTH = 64K
SRAM3 (wal) : ORIGIN = 0x30040000, LENGTH = 512K
SRAM5 (wal) : ORIGIN = 0x30080000, LENGTH = 0K /* SRAM5 is not available */
SRAM6 (wal) : ORIGIN = 0x30080000, LENGTH = 0K /* SRAM6 is not available */
SRAM4 (wal) : ORIGIN = 0x38000000, LENGTH = 16K
}
main_stack_base = ORIGIN(SRAM2) + SIZEOF(.stack); /* 8-byte aligned full descending stack */
_sstack = ORIGIN(SRAM2);
_estack = main_stack_base;
/* used by the startup code to populate variables used by the C code */
data_lma = LOADADDR(.data);
data_vma = ADDR(.data);
data_size = SIZEOF(.data);
/* used by the startup code to populate variables used by the C code */
sensitive_lma = LOADADDR(.sensitive);
sensitive_vma = ADDR(.sensitive);
sensitive_size = SIZEOF(.sensitive);
/* used by the startup code to wipe memory */
sram1_start = ORIGIN(SRAM1);
sram1_end = ORIGIN(SRAM1) + LENGTH(SRAM1);
sram2_start = ORIGIN(SRAM2);
sram2_end = ORIGIN(SRAM2) + LENGTH(SRAM2);
sram3_start = ORIGIN(SRAM3);
sram3_end = ORIGIN(SRAM3) + LENGTH(SRAM3);
sram4_start = ORIGIN(SRAM4);
sram4_end = ORIGIN(SRAM4) + LENGTH(SRAM4);
sram5_start = ORIGIN(SRAM5);
sram5_end = ORIGIN(SRAM5) + LENGTH(SRAM5);
sram6_start = ORIGIN(SRAM6);
sram6_end = ORIGIN(SRAM6) + LENGTH(SRAM6);
/* reserve 256 bytes for bootloader arguments */
boot_args_start = ORIGIN(BOOT_ARGS);
boot_args_end = ORIGIN(BOOT_ARGS) + LENGTH(BOOT_ARGS);
_codelen = SIZEOF(.flash) + SIZEOF(.data) + SIZEOF(.sensitive);
_flash_start = ORIGIN(FLASH);
_flash_end = ORIGIN(FLASH) + LENGTH(FLASH);
_heap_start = ADDR(.heap);
_heap_end = ADDR(.heap) + SIZEOF(.heap);
SECTIONS {
.vendorheader : ALIGN(4) {
KEEP(*(.vendorheader))
} >FLASH AT>FLASH
.header : ALIGN(4) {
KEEP(*(.header));
} >FLASH AT>FLASH
.flash : ALIGN(512) {
KEEP(*(.vector_table));
. = ALIGN(4);
*(.text*);
. = ALIGN(4);
*(.rodata*);
. = ALIGN(4);
KEEP(*(.bootloader));
*(.bootloader*);
. = ALIGN(512);
} >FLASH AT>FLASH
.data : ALIGN(4) {
*(.data*);
. = ALIGN(512);
} >SRAM1 AT>FLASH
/DISCARD/ : {
*(.ARM.exidx*);
}
.bss : ALIGN(4) {
*(.bss*);
. = ALIGN(4);
} >SRAM1
.buf : ALIGN(4) {
*(.buf*);
. = ALIGN(4);
} >SRAM1
.stack : ALIGN(8) {
. = 16K; /* Overflow causes UsageFault */
} >SRAM2
.sensitive : ALIGN(512) {
*(.sensitive*);
. = ALIGN(512);
} >SRAM2 AT>FLASH
.fb : ALIGN(4) {
__fb_start = .;
*(.fb1*);
*(.fb2*);
__fb_end = .;
. = ALIGN(4);
} >SRAM3
.heap : ALIGN(4) {
. = 37K; /* this acts as a build time assertion that at least this much memory is available for heap use */
. = ABSOLUTE(sram3_end); /* this explicitly sets the end of the heap */
} >SRAM3
.boot_args : ALIGN(8) {
*(.boot_command*);
. = ALIGN(8);
*(.boot_args*);
. = ALIGN(8);
} >BOOT_ARGS
}

View File

@ -9,6 +9,8 @@
#include "model_T2T1.h"
#elif defined TREZOR_MODEL_R
#include "model_T2B1.h"
#elif defined TREZOR_MODEL_T3T1
#include "model_T3T1.h"
#elif defined TREZOR_MODEL_DISC1
#include "model_D001.h"
#elif defined TREZOR_MODEL_DISC2

View File

@ -0,0 +1,33 @@
#ifndef MODELS_MODEL_T3T1_H_
#define MODELS_MODEL_T3T1_H_
#include "sizedefs.h"
#define MODEL_NAME "T3T1"
#define MODEL_FULL_NAME "Trezor T3T1"
#define MODEL_INTERNAL_NAME "T3T1"
#define MODEL_INTERNAL_NAME_TOKEN T3T1
#define MODEL_INTERNAL_NAME_QSTR MP_QSTR_T3T1
/*** Using DEV KEYS temporarily ***/
#define MODEL_BOARDLOADER_KEYS \
(const uint8_t *)"\xdb\x99\x5f\xe2\x51\x69\xd1\x41\xca\xb9\xbb\xba\x92\xba\xa0\x1f\x9f\x2e\x1e\xce\x7d\xf4\xcb\x2a\xc0\x51\x90\xf3\x7f\xcc\x1f\x9d", \
(const uint8_t *)"\x21\x52\xf8\xd1\x9b\x79\x1d\x24\x45\x32\x42\xe1\x5f\x2e\xab\x6c\xb7\xcf\xfa\x7b\x6a\x5e\xd3\x00\x97\x96\x0e\x06\x98\x81\xdb\x12", \
(const uint8_t *)"\x22\xfc\x29\x77\x92\xf0\xb6\xff\xc0\xbf\xcf\xdb\x7e\xdb\x0c\x0a\xa1\x4e\x02\x5a\x36\x5e\xc0\xe3\x42\xe8\x6e\x38\x29\xcb\x74\xb6",
#define MODEL_BOOTLOADER_KEYS \
(const uint8_t *)"\xd7\x59\x79\x3b\xbc\x13\xa2\x81\x9a\x82\x7c\x76\xad\xb6\xfb\xa8\xa4\x9a\xee\x00\x7f\x49\xf2\xd0\x99\x2d\x99\xb8\x25\xad\x2c\x48", \
(const uint8_t *)"\x63\x55\x69\x1c\x17\x8a\x8f\xf9\x10\x07\xa7\x47\x8a\xfb\x95\x5e\xf7\x35\x2c\x63\xe7\xb2\x57\x03\x98\x4c\xf7\x8b\x26\xe2\x1a\x56", \
(const uint8_t *)"\xee\x93\xa4\xf6\x6f\x8d\x16\xb8\x19\xbb\x9b\xeb\x9f\xfc\xcd\xfc\xdc\x14\x12\xe8\x7f\xee\x6a\x32\x4c\x2a\x99\xa1\xe0\xe6\x71\x48",
#define BOARDLOADER_START 0x0C004000
#define BOARD_CAPABILITIES_ADDR 0x0C00FF00
#define BOOTLOADER_START 0x0C010000
#define FIRMWARE_START 0x0C050000
#define IMAGE_CHUNK_SIZE (128 * 1024)
#define BOOTLOADER_IMAGE_MAXSIZE (128 * 1024 * 1) // 128 KB
#define FIRMWARE_IMAGE_MAXSIZE (128 * 1024 * 13) // 1664 KB
#define NORCOW_SECTOR_SIZE (64 * 1024)
#endif

View File

@ -0,0 +1,84 @@
#include "flash.h"
#include "model.h"
const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT] = {
{
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0x18,
.num_sectors = 8,
},
},
{
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0x20,
.num_sectors = 8,
},
},
};
const flash_area_t BOARDLOADER_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 2,
.num_sectors = 6,
},
};
const flash_area_t BOOTLOADER_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0x08,
.num_sectors = 16,
},
};
const flash_area_t FIRMWARE_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0x28,
.num_sectors = 208,
},
};
const flash_area_t SECRET_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0,
.num_sectors = 2,
},
};
const flash_area_t BHK_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 1,
.num_sectors = 1,
},
};
const flash_area_t WIPE_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0x18,
.num_sectors = 232,
},
};
const flash_area_t ALL_WIPE_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0x08,
.num_sectors = 248,
},
};

View File

@ -53,8 +53,8 @@
#ifdef TREZOR_MODEL_T
#define MODEL_IDENTIFIER "TREZOR2-"
#elif TREZOR_MODEL_R
#define MODEL_IDENTIFIER "T2B1-"
#else
#define MODEL_IDENTIFIER MODEL_INTERNAL_NAME "-"
#endif
static secbool startswith(const char *s, const char *prefix) {

View File

@ -9,6 +9,13 @@
#define USE_BACKLIGHT 1
#endif
#ifdef TREZOR_MODEL_T3T1
#define USE_TOUCH 1
#define USE_SD_CARD 1
#define USE_SBU 1
#define USE_RGB_COLORS 1
#endif
#ifdef TREZOR_MODEL_1
#define USE_BUTTON 1
#endif

View File

@ -0,0 +1,83 @@
#ifndef _TREZOR_T3T1_H
#define _TREZOR_T3T1_H
#define DISPLAY_RESX 240
#define DISPLAY_RESY 240
#define VDD_1V8 1
#define HSE_16MHZ 1
//#define USE_SD_CARD 1
#define USE_I2C 1
#define USE_TOUCH 1
#define USE_SBU 1
#define USE_RGB_COLORS 1
#define USE_DISP_I8080_8BIT_DW 1
#define USE_HAPTIC 1
#define USE_BACKLIGHT 1
#include "displays/panels/lx154a2422.h"
#include "displays/st7789v.h"
#define DISPLAY_IDENTIFY 1
#define DISPLAY_TE_PORT GPIOD
#define DISPLAY_TE_PIN GPIO_PIN_12
#define DISPLAY_PANEL_INIT_SEQ lx154a2422_init_seq
#define DISPLAY_PANEL_ROTATE lx154a2422_rotate
#define TRANSFORM_TOUCH_COORDS lx154a2422_transform_touch_coords
#define BACKLIGHT_PWM_FREQ 12500
#define BACKLIGHT_PWM_TIM TIM8
#define BACKLIGHT_PWM_TIM_CLK_EN __HAL_RCC_TIM8_CLK_ENABLE
#define BACKLIGHT_PWM_TIM_AF GPIO_AF3_TIM8
#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_6
#define BACKLIGHT_PWM_PORT GPIOC
#define BACKLIGHT_PWM_PORT_CLK_EN __HAL_RCC_GPIOC_CLK_ENABLE
#define I2C_COUNT 2
#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 GPIOB
#define I2C_INSTANCE_0_SDA_PIN GPIO_PIN_7
#define I2C_INSTANCE_0_SDA_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
#define I2C_INSTANCE_0_SCL_PORT GPIOB
#define I2C_INSTANCE_0_SCL_PIN GPIO_PIN_6
#define I2C_INSTANCE_0_SCL_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
#define I2C_INSTANCE_0_RESET_REG &RCC->APB1RSTR1
#define I2C_INSTANCE_0_RESET_BIT RCC_APB1RSTR1_I2C1RST
#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 GPIOB
#define I2C_INSTANCE_1_SDA_PIN GPIO_PIN_14
#define I2C_INSTANCE_1_SDA_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
#define I2C_INSTANCE_1_SCL_PORT GPIOB
#define I2C_INSTANCE_1_SCL_PIN GPIO_PIN_13
#define I2C_INSTANCE_1_SCL_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
#define I2C_INSTANCE_1_RESET_REG &RCC->APB1RSTR1
#define I2C_INSTANCE_1_RESET_BIT RCC_APB1RSTR1_I2C2RST
#define TOUCH_SENSITIVITY 0x40
#define TOUCH_I2C_INSTANCE 0
#define TOUCH_RST_PORT GPIOC
#define TOUCH_RST_PIN GPIO_PIN_5
#define TOUCH_INT_PORT GPIOC
#define TOUCH_INT_PIN GPIO_PIN_4
#define TOUCH_ON_PORT GPIOB
#define TOUCH_ON_PIN GPIO_PIN_0
#define OPTIGA_I2C_INSTANCE 1
#define SD_DETECT_PORT GPIOC
#define SD_DETECT_PIN GPIO_PIN_13
#define SD_ENABLE_PORT GPIOC
#define SD_ENABLE_PIN GPIO_PIN_0
#endif //_TREZOR_T_H

View File

@ -0,0 +1 @@
../stm32f4/backlight_pwm.c

View File

@ -0,0 +1 @@
../stm32f4/backlight_pwm.h

View File

@ -0,0 +1 @@
../../../stm32f4/displays/panels/lx154a2422.c

View File

@ -0,0 +1 @@
../../../stm32f4/displays/panels/lx154a2422.h

View File

@ -0,0 +1 @@
../../stm32f4/displays/st7789v.c

View File

@ -0,0 +1 @@
../../stm32f4/displays/st7789v.h

View File

@ -81,8 +81,8 @@ extern "C" {
/*#define HAL_SMARTCARD_MODULE_ENABLED */
/*#define HAL_SMBUS_MODULE_ENABLED */
/*#define HAL_SPI_MODULE_ENABLED */
/*#define HAL_SRAM_MODULE_ENABLED */
/*#define HAL_TIM_MODULE_ENABLED */
#define HAL_SRAM_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
/*#define HAL_TSC_MODULE_ENABLED */
/*#define HAL_RAMCFG_MODULE_ENABLED */
#define HAL_UART_MODULE_ENABLED

View File

@ -0,0 +1 @@
../../stm32f4/touch/ft6x36.c

View File

@ -0,0 +1 @@
../../stm32f4/touch/ft6x36.h

View File

@ -0,0 +1,20 @@
{
"header_len": 4608,
"text": "DEV ONLY, DO NOT USE!",
"hw_model": "T3T1",
"expiry": 0,
"version": [0, 0],
"sig_m": 2,
"trust": {
"allow_run_with_secret": false,
"show_vendor_string": false,
"require_user_click": false,
"red_background": false,
"delay": 0
},
"pubkeys": [
"e28a8970753332bd72fef413e6b0b2ef1b4aadda7aa2c141f233712a6876b351",
"d4eec1869fb1b8a4e817516ad5a931557cb56805c3eb16e8f3a803d647df7869",
"772c8a442b7db06e166cfbc1ccbcbcde6f3eba76a4e98ef3ffc519502237d6ef"
]
}

View File

@ -0,0 +1,20 @@
{
"header_len": 4608,
"text": "UNSAFE, DO NOT USE!",
"hw_model": "T3T1",
"expiry": 0,
"version": [0, 1],
"sig_m": 2,
"trust": {
"allow_run_with_secret": false,
"show_vendor_string": true,
"require_user_click": true,
"red_background": true,
"delay": 1
},
"pubkeys": [
"e28a8970753332bd72fef413e6b0b2ef1b4aadda7aa2c141f233712a6876b351",
"d4eec1869fb1b8a4e817516ad5a931557cb56805c3eb16e8f3a803d647df7869",
"772c8a442b7db06e166cfbc1ccbcbcde6f3eba76a4e98ef3ffc519502237d6ef"
]
}

Binary file not shown.

View File

@ -16,7 +16,7 @@ for arg in "$@"; do
fi
done
MODELS=(T2T1 T2B1 D001 D002)
MODELS=(T2T1 T2B1 T3T1 D001 D002)
for MODEL in ${MODELS[@]}; do
cd $MODEL

View File

@ -0,0 +1,94 @@
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 = "trezor_t3t1_v4.h"
display = "st7789v.c"
hw_model = get_hw_model_as_number("T3T1")
hw_revision = 0
features_available.append("disp_i8080_8bit_dw")
mcu = "STM32U585xx"
linker_script = "stm32u58"
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]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
defines += [f"HW_MODEL={hw_model}"]
defines += [f"HW_REVISION={hw_revision}"]
sources += [
"embed/models/model_T3T1_layout.c",
]
sources += [f"embed/trezorhal/stm32u5/displays/{display}"]
sources += ["embed/trezorhal/stm32u5/backlight_pwm.c"]
sources += [
"embed/trezorhal/stm32u5/displays/panels/lx154a2422.c",
]
features_available.append("backlight")
if "input" in features_wanted:
sources += ["embed/trezorhal/stm32u5/i2c.c"]
sources += ["embed/trezorhal/stm32u5/touch/ft6x36.c"]
sources += ["embed/lib/touch.c"]
features_available.append("touch")
if "haptic" in features_wanted:
sources += [
"embed/trezorhal/stm32u5/haptic/drv2625/drv2625.c",
]
features_available.append("haptic")
# if "sd_card" in features_wanted:
# sources += ["embed/trezorhal/stm32u5/sdcard.c"]
# sources += ["embed/extmod/modtrezorio/ff.c"]
# sources += ["embed/extmod/modtrezorio/ffunicode.c"]
# sources += [
# "vendor/stm32cube-u5/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_dma.c"
# ]
# features_available.append("sd_card")
if "sbu" in features_wanted:
sources += ["embed/trezorhal/stm32u5/sbu.c"]
features_available.append("sbu")
if "usb" in features_wanted:
sources += [
"embed/trezorhal/stm32u5/usb.c",
"embed/trezorhal/stm32u5/usbd_conf.c",
"embed/trezorhal/stm32u5/usbd_core.c",
"embed/trezorhal/stm32u5/usbd_ctlreq.c",
"embed/trezorhal/stm32u5/usbd_ioreq.c",
"vendor/stm32cube-u5/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_ll_usb.c",
]
features_available.append("usb")
if "dma2d" in features_wanted:
defines += ["USE_DMA2D"]
sources += ["embed/trezorhal/stm32u5/dma2d.c"]
features_available.append("dma2d")
env.get("ENV")["TREZOR_BOARD"] = board
env.get("ENV")["MCU_TYPE"] = mcu
env.get("ENV")["LINKER_SCRIPT"] = linker_script
return features_available

View File

@ -13,6 +13,7 @@ from boards import (
trezor_r_v6,
trezor_r_v10,
trezor_t,
trezor_t3t1_v4,
)
HERE = Path(__file__).parent.resolve()
@ -58,6 +59,8 @@ def configure_board(
elif model_r_version == 10:
return trezor_r_v10.configure(env, features_wanted, defines, sources, paths)
raise Exception("Unknown model_r_version")
elif model in ("T3T1",):
return trezor_t3t1_v4.configure(env, features_wanted, defines, sources, paths)
elif model in ("DISC1",):
return discovery.configure(env, features_wanted, defines, sources, paths)
elif model in ("DISC2",):
@ -72,6 +75,8 @@ def get_model_identifier(model: str) -> str:
return "T2T1"
elif model == "R":
return "T2B1"
elif model == "T3T1":
return "T3T1"
elif model == "DISC1":
return "D001"
elif model == "DISC2":

View File

@ -0,0 +1 @@
Added support for T3T1

View File

@ -30,6 +30,7 @@ if t.TYPE_CHECKING:
class Model(Enum):
T1B1 = b"T1B1"
T2T1 = b"T2T1"
T3T1 = b"T3T1"
T2B1 = b"T2B1"
D001 = b"D001"
D002 = b"D002"
@ -221,6 +222,29 @@ T2B1 = ModelKeys(
firmware_sigs_needed=-1,
)
T3T1 = ModelKeys(
production=False,
boardloader_keys=[
bytes.fromhex(key)
for key in (
"db995fe25169d141cab9bbba92baa01f9f2e1ece7df4cb2ac05190f37fcc1f9d",
"2152f8d19b791d24453242e15f2eab6cb7cffa7b6a5ed30097960e069881db12",
"22fc297792f0b6ffc0bfcfdb7edb0c0aa14e025a365ec0e342e86e3829cb74b6",
)
],
boardloader_sigs_needed=2,
bootloader_keys=[
bytes.fromhex(key)
for key in (
"d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48",
"6355691c178a8ff91007a7478afb955ef7352c63e7b25703984cf78b26e21a56",
"ee93a4f66f8d16b819bb9beb9ffccdfcdc1412e87fee6a324c2a99a1e0e67148",
)
],
bootloader_sigs_needed=2,
firmware_keys=(),
firmware_sigs_needed=-1,
)
LEGACY_HASH_PARAMS = FirmwareHashParameters(
hash_function=hashlib.sha256,
@ -244,6 +268,7 @@ MODEL_MAP = {
Model.T1B1: LEGACY_V3,
Model.T2T1: T2T1,
Model.T2B1: T2B1,
Model.T3T1: TREZOR_CORE_DEV,
Model.D001: TREZOR_CORE_DEV,
Model.D002: TREZOR_CORE_DEV,
}
@ -252,6 +277,7 @@ MODEL_MAP_DEV = {
Model.T1B1: LEGACY_V3_DEV,
Model.T2T1: TREZOR_CORE_DEV,
Model.T2B1: TREZOR_CORE_DEV,
Model.T3T1: TREZOR_CORE_DEV,
Model.D001: TREZOR_CORE_DEV,
Model.D002: TREZOR_CORE_DEV,
}
@ -259,6 +285,7 @@ MODEL_MAP_DEV = {
MODEL_HASH_PARAMS_MAP = {
Model.T1B1: LEGACY_HASH_PARAMS,
Model.T2T1: T2T1_HASH_PARAMS,
Model.T3T1: T2T1_HASH_PARAMS,
Model.T2B1: T2T1_HASH_PARAMS,
Model.D001: T2T1_HASH_PARAMS,
Model.D002: D002_HASH_PARAMS,
@ -273,6 +300,7 @@ TREZOR_ONE_V3_DEV = LEGACY_V3_DEV
TREZOR_T = T2T1
TREZOR_R = T2B1
TREZOR_T3T1 = T3T1
TREZOR_T_DEV = TREZOR_CORE_DEV
TREZOR_R_DEV = TREZOR_CORE_DEV

View File

@ -63,6 +63,15 @@ T2B1 = TrezorModel(
default_mapping=mapping.DEFAULT_MAPPING,
)
T3T1 = TrezorModel(
name="T3T1",
internal_name="T3T1",
minimum_version=(2, 1, 0),
vendors=VENDORS,
usb_ids=((0x1209, 0x53C1), (0x1209, 0x53C0)),
default_mapping=mapping.DEFAULT_MAPPING,
)
DISC1 = TrezorModel(
name="DISC1",
internal_name="D001",
@ -87,10 +96,11 @@ TREZOR_ONE = T1B1
TREZOR_T = T2T1
TREZOR_R = T2B1
TREZOR_SAFE3 = T2B1
TREZOR_T3T1 = T2B1
TREZOR_DISC1 = DISC1
TREZOR_DISC2 = DISC2
TREZORS = {T1B1, T2T1, T2B1, DISC1, DISC2}
TREZORS = {T1B1, T2T1, T2B1, T3T1, DISC1, DISC2}
def by_name(name: Optional[str]) -> Optional[TrezorModel]: