1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-24 23:48:13 +00:00
This commit is contained in:
tychovrahe 2023-08-24 11:33:50 +02:00
parent 0556ed9e0e
commit 9bb0ce5582
22 changed files with 340 additions and 19 deletions

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', 'T3W1', 'DISC1'):
elif TREZOR_MODEL in ('T', 'T3T1', 'T3W1', 'DISC1'):
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', 'T3W1'):
elif TREZOR_MODEL in ('T', 'T3T1', 'T3W1'):
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', 'T3W1'):
elif TREZOR_MODEL in ('T', 'T3T1', 'T3W1'):
FONT_NORMAL='Font_TTHoves_Regular_21'
FONT_DEMIBOLD=None
FONT_BOLD='Font_TTHoves_Bold_17'
@ -159,7 +159,7 @@ env.Replace(
env.Replace(
TREZOR_MODEL=TREZOR_MODEL, )
if TREZOR_MODEL in ('T', 'R', 'T3W1'):
if TREZOR_MODEL in ('T', 'R', 'T3T1', 'T3W1'):
CPU_MODEL = 'STM32F427xx'
elif TREZOR_MODEL in ('DISC1', ):
CPU_MODEL = 'STM32F429xx'

View File

@ -38,7 +38,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', 'T3W1', 'DISC1'):
elif TREZOR_MODEL in ('T', 'T3T1', 'T3W1', 'DISC1'):
FONT_NORMAL='Font_TTHoves_Regular_21'
FONT_DEMIBOLD='Font_TTHoves_DemiBold_21'
FONT_BOLD='Font_TTHoves_Bold_17'
@ -379,7 +379,7 @@ env = Environment(ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODU
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL)
if TREZOR_MODEL in ('T', 'T3W1', 'DISC1'):
if TREZOR_MODEL in ('T', 'T3T1', 'T3W1', 'DISC1'):
LAYOUT = 'LAYOUT_TTV2'
elif TREZOR_MODEL in ('1', 'R'):
LAYOUT = 'LAYOUT_TR'
@ -813,7 +813,7 @@ BINARY_NAME += "-dirty" if tools.get_git_modified() else ""
BINARY_NAME += ".bin"
if TREZOR_MODEL in ('T', 'R', 'T3W1', 'DISC1'):
if TREZOR_MODEL in ('T', 'R', 'T3T1', 'T3W1', 'DISC1'):
action_bin=[
'$OBJCOPY -O binary -j .vendorheader -j .header -j .flash -j .data --pad-to 0x08100000 $SOURCE ${TARGET}.p1',
'$OBJCOPY -O binary -j .flash2 $SOURCE ${TARGET}.p2',

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', 'T3W1'):
elif TREZOR_MODEL in ('T', 'T3T1', 'T3W1'):
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', 'T3W1'):
elif TREZOR_MODEL in ('T', 'T3T1', 'T3W1'):
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', 'T3W1')
DMA2D = TREZOR_MODEL in ('T', 'T3T1', 'T3W1')
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
if TREZOR_MODEL in ('DISC1', ):
@ -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', 'T3W1'):
elif TREZOR_MODEL in ('T', 'T3T1', 'T3W1'):
FONT_NORMAL='Font_TTHoves_Regular_21'
FONT_DEMIBOLD='Font_TTHoves_DemiBold_21'
FONT_BOLD='Font_TTHoves_Bold_17'
@ -174,7 +174,7 @@ if FEATURE_FLAGS["SECP256K1_ZKP"]:
SOURCE_MOD += [
'embed/extmod/modtrezorio/modtrezorio.c',
]
if TREZOR_MODEL in ('T', 'T3W1'):
if TREZOR_MODEL in ('T', 'T3T1', 'T3W1'):
SOURCE_MOD += [
'embed/extmod/modtrezorio/ff.c',
'embed/extmod/modtrezorio/ffunicode.c',
@ -384,7 +384,7 @@ SOURCE_UNIX = [
'vendor/micropython/ports/unix/input.c',
'vendor/micropython/ports/unix/unix_mphal.c',
]
if TREZOR_MODEL in ('T', 'R', 'T3W1'):
if TREZOR_MODEL in ('T', 'R', 'T3T1', 'T3W1'):
SOURCE_UNIX += [
'embed/trezorhal/unix/sbu.c',
]
@ -416,7 +416,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', 'T3W1'):
if TREZOR_MODEL in ('T', 'T3T1', 'T3W1'):
LAYOUT = 'LAYOUT_TTV2'
elif TREZOR_MODEL in ('1', 'R'):
LAYOUT = 'LAYOUT_TR'
@ -479,7 +479,7 @@ if ARGUMENTS.get('TREZOR_MEMPERF', '0') == '1':
env.Replace(
TREZOR_MODEL=TREZOR_MODEL, )
if TREZOR_MODEL in ('T', 'R', 'T3W1'):
if TREZOR_MODEL in ('T', 'R', 'T3T1', 'T3W1'):
CPU_MODEL = 'STM32F427xx'
elif TREZOR_MODEL in ('DISC1', ):
CPU_MODEL = 'STM32F429xx'
@ -781,6 +781,9 @@ def cargo_build():
if TREZOR_MODEL in ('T'):
features.append('touch')
features.append('sd_card')
if TREZOR_MODEL in ('T3T1'):
features.append('touch')
features.append('sd_card')
if TREZOR_MODEL in ('T3W1'):
features.append('touch')
features.append('button')

Binary file not shown.

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_T3W1
#include "model_T3W1.h"
#elif defined TREZOR_MODEL_DISC1

View File

@ -0,0 +1,29 @@
#ifndef MODELS_MODEL_T3T1_H_
#define MODELS_MODEL_T3T1_H_
#define MODEL_NAME "T3T1"
#define MODEL_INTERNAL_NAME "T3T1"
#define MODEL_INTERNAL_NAME_TOKEN T3T1
#define MODEL_NAME_QSTR MP_QSTR_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 0x08000000
#define BOOTLOADER_START 0x08020000
#define FIRMWARE_START 0x08040000
#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,82 @@
#include "flash.h"
#include "model.h"
const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT] = {
{
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 4,
.num_sectors = 1,
},
},
{
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 16,
.num_sectors = 1,
},
},
};
const flash_area_t BOARDLOADER_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 0,
.num_sectors = 3,
},
};
const flash_area_t BOOTLOADER_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 5,
.num_sectors = 1,
},
};
const flash_area_t FIRMWARE_AREA = {
.num_subareas = 2,
.subarea[0] =
{
.first_sector = 6,
.num_sectors = 6,
},
.subarea[1] =
{
.first_sector = 17,
.num_sectors = 7,
},
};
const flash_area_t WIPE_AREA = {
.num_subareas = 3,
.subarea[0] =
{
.first_sector = 4,
.num_sectors = 1,
},
.subarea[1] =
{
.first_sector = 6,
.num_sectors =
9, // sector 15 skipped due to bootloader MPU settings
},
.subarea[2] =
{
.first_sector = 16,
.num_sectors = 8,
},
};
const flash_area_t ALL_WIPE_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 3,
.num_sectors = 21,
},
};

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_T3W1
#define USE_TOUCH 1
#define USE_SD_CARD 1

View File

@ -0,0 +1,63 @@
#ifndef _TREZOR_T3T1_H
#define _TREZOR_T3T1_H
#define DISPLAY_RESX 240
#define DISPLAY_RESY 240
#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 1
#define I2C_INSTANCE_1 I2C1
#define I2C_INSTANCE_1_CLK_EN __HAL_RCC_I2C1_CLK_ENABLE
#define I2C_INSTANCE_1_CLK_DIS __HAL_RCC_I2C1_CLK_DISABLE
#define I2C_INSTANCE_1_PIN_AF GPIO_AF4_I2C1
#define I2C_INSTANCE_1_SDA_PORT GPIOB
#define I2C_INSTANCE_1_SDA_PIN GPIO_PIN_7
#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_6
#define I2C_INSTANCE_1_SCL_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
#define I2C_INSTANCE_1_RESET_FLG RCC_APB1RSTR_I2C1RST
#define TOUCH_I2C_NUM 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 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,19 @@
{
"header_len": 4608,
"text": "UNSAFE, DO NOT USE!",
"hw_model": "T3T1",
"expiry": 0,
"version": [0, 1],
"sig_m": 2,
"trust": {
"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 T3W1 D001)
MODELS=(T2T1 T2B1 T3T1 T3W1 D001)
for MODEL in ${MODELS[@]}; do
cd $MODEL

View File

@ -0,0 +1,102 @@
from __future__ import annotations
from . import get_hw_model_as_number
from .stm32f4_common import stm32f4_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.h"
display = "st7789v.c"
hw_model = get_hw_model_as_number("T3T1")
hw_revision = 0
features_available.append("disp_i8080_8bit_dw")
mcu = "STM32F427xx"
stm32f4_common_files(env, defines, sources, paths)
env.get("ENV")[
"CPU_ASFLAGS"
] = "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16"
env.get("ENV")[
"CPU_CCFLAGS"
] = "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 "
env.get("ENV")["RUST_TARGET"] = "thumbv7em-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/stm32f4/displays/{display}"]
sources += ["embed/trezorhal/stm32f4/backlight_pwm.c"]
sources += [
"embed/trezorhal/stm32f4/displays/panels/tf15411a.c",
]
sources += [
"embed/trezorhal/stm32f4/displays/panels/154a.c",
]
sources += [
"embed/trezorhal/stm32f4/displays/panels/lx154a2411.c",
]
sources += [
"embed/trezorhal/stm32f4/displays/panels/lx154a2422.c",
]
features_available.append("backlight")
if "input" in features_wanted:
sources += ["embed/trezorhal/stm32f4/i2c.c"]
sources += ["embed/trezorhal/stm32f4/touch/ft6x36.c"]
sources += ["embed/lib/touch.c"]
features_available.append("touch")
if "haptic" in features_wanted:
sources += ['embed/trezorhal/stm32f4/haptic/drv2625/drv2625.c', ]
if "sd_card" in features_wanted:
sources += ["embed/trezorhal/stm32f4/sdcard.c"]
sources += ["embed/extmod/modtrezorio/ff.c"]
sources += ["embed/extmod/modtrezorio/ffunicode.c"]
sources += [
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"
]
sources += ["embed/trezorhal/stm32f4/dma.c"]
features_available.append("sd_card")
if "sbu" in features_wanted:
sources += ["embed/trezorhal/stm32f4/sbu.c"]
features_available.append("sbu")
if "usb" in features_wanted:
sources += [
"embed/trezorhal/stm32f4/usb.c",
"embed/trezorhal/stm32f4/usbd_conf.c",
"embed/trezorhal/stm32f4/usbd_core.c",
"embed/trezorhal/stm32f4/usbd_ctlreq.c",
"embed/trezorhal/stm32f4/usbd_ioreq.c",
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
]
features_available.append("usb")
if "dma2d" in features_wanted:
defines += ["USE_DMA2D"]
sources += ["embed/trezorhal/stm32f4/dma2d.c"]
sources += [
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c"
]
features_available.append("dma2d")
env.get("ENV")["TREZOR_BOARD"] = board
env.get("ENV")["MCU_TYPE"] = mcu
return features_available

View File

@ -13,6 +13,7 @@ from boards import (
trezor_r_v6,
trezor_r_v10,
trezor_t,
trezor_t3t1_v1,
trezor_t3w1_d1,
)
@ -59,6 +60,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_v1.configure(env, features_wanted, defines, sources, paths)
elif model in ('T3W1',):
return trezor_t3w1_d1.configure(env, features_wanted, defines, sources, paths)
elif model in ("DISC1",):
@ -73,6 +76,8 @@ def get_model_identifier(model: str) -> str:
return "T2T1"
elif model == "R":
return "T2B1"
elif model == "T3T1":
return "T3T1"
elif model == "T3W1":
return "T3W1"
elif model == "DISC1":

View File

@ -70,6 +70,15 @@ TREZOR_DISC1 = TrezorModel(
default_mapping=mapping.DEFAULT_MAPPING,
)
TREZOR_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,
)
TREZOR_T3W1 = TrezorModel(
name="T3W1",
internal_name="T3W1",
@ -79,7 +88,7 @@ TREZOR_T3W1 = TrezorModel(
default_mapping=mapping.DEFAULT_MAPPING,
)
TREZORS = {TREZOR_ONE, TREZOR_T, TREZOR_R, TREZOR_T3W1, TREZOR_DISC1}
TREZORS = {TREZOR_ONE, TREZOR_T, TREZOR_R, TREZOR_T3T1, TREZOR_T3W1, TREZOR_DISC1}
def by_name(name: Optional[str]) -> Optional[TrezorModel]: