mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
refactor(core): introduce emulator boards
[no changelog]
This commit is contained in:
parent
e6f2fa711e
commit
0b5e8ed480
@ -7,7 +7,6 @@ TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
||||
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
||||
HW_REVISION = 'emulator'
|
||||
NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
|
||||
DMA2D = False
|
||||
|
||||
if TREZOR_MODEL in ('1', 'DISC1'):
|
||||
# skip bootloader build
|
||||
@ -21,13 +20,15 @@ if TREZOR_MODEL in ('1', 'DISC1'):
|
||||
)
|
||||
Return()
|
||||
|
||||
FEATURES_WANTED = ["input", "rgb_led", "dma2d"]
|
||||
FEATURES_WANTED = ["input", "rgb_led", "dma2d", "optiga_hal"]
|
||||
|
||||
if NEW_RENDERING:
|
||||
FEATURES_WANTED.append("new_rendering")
|
||||
|
||||
CCFLAGS_MOD = ''
|
||||
CPPPATH_MOD = []
|
||||
CPPDEFINES_HAL = []
|
||||
PATH_HAL = []
|
||||
CPPDEFINES_MOD = []
|
||||
SOURCE_MOD = []
|
||||
SOURCE_MOD_CRYPTO = []
|
||||
@ -116,39 +117,14 @@ SOURCE_MOD += [
|
||||
|
||||
if NEW_RENDERING:
|
||||
CPPDEFINES_MOD += ['NEW_RENDERING']
|
||||
if TREZOR_MODEL in ('T',):
|
||||
CPPDEFINES_MOD += ['DISPLAY_RGB565']
|
||||
elif TREZOR_MODEL in ('R', '1',):
|
||||
CPPDEFINES_MOD += ['XFRAMEBUFFER', 'DISPLAY_MONO']
|
||||
elif TREZOR_MODEL in ('T3T1',):
|
||||
CPPDEFINES_MOD += ['XFRAMEBUFFER', 'DISPLAY_RGB565']
|
||||
SOURCE_MOD += [
|
||||
'embed/lib/gfx_draw.c',
|
||||
]
|
||||
else:
|
||||
SOURCE_MOD += [
|
||||
'embed/lib/display_draw.c',
|
||||
'embed/lib/dma2d_emul.c',
|
||||
]
|
||||
|
||||
if TREZOR_MODEL in ('1', ):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T1B1_layout.c',
|
||||
]
|
||||
elif TREZOR_MODEL in ('T', ):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T2T1_layout.c',
|
||||
]
|
||||
elif TREZOR_MODEL in ('R', ):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T2B1_layout.c',
|
||||
]
|
||||
elif TREZOR_MODEL in ('T3T1',):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T3T1_layout.c',
|
||||
]
|
||||
|
||||
|
||||
SOURCE_NANOPB = [
|
||||
'vendor/nanopb/pb_common.c',
|
||||
'vendor/nanopb/pb_decode.c',
|
||||
@ -187,11 +163,6 @@ else:
|
||||
'embed/trezorhal/unix/display-unix.c',
|
||||
]
|
||||
|
||||
if TREZOR_MODEL in ('R', 'T3T1'):
|
||||
SOURCE_TREZORHAL += [
|
||||
'embed/trezorhal/unix/optiga_hal.c',
|
||||
]
|
||||
|
||||
SOURCE_UNIX = [
|
||||
'embed/unix/profile.c',
|
||||
]
|
||||
@ -209,6 +180,8 @@ tools.add_font('BOLD_UPPER', FONT_BOLD_UPPER, CPPDEFINES_MOD, SOURCE_MOD)
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DCONFIDENTIAL= -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||
|
||||
FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_UNIX, PATH_HAL)
|
||||
|
||||
env.Replace(
|
||||
CP='cp',
|
||||
AS='as',
|
||||
@ -221,22 +194,6 @@ env.Replace(
|
||||
PYTHON='python',
|
||||
MAKECMAKELISTS='$PYTHON tools/make_cmakelists.py', )
|
||||
|
||||
env.Replace(
|
||||
TREZOR_MODEL=TREZOR_MODEL, )
|
||||
|
||||
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', ):
|
||||
CPU_MODEL = 'STM32U5A9xx'
|
||||
elif TREZOR_MODEL in ('1',):
|
||||
CPU_MODEL = 'STM32F405xx'
|
||||
else:
|
||||
raise ValueError('Unknown Trezor model')
|
||||
|
||||
MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL)
|
||||
MODEL_AS_NUMBER = str(models.get_hw_model_as_number(MODEL_IDENTIFIER))
|
||||
|
||||
@ -251,7 +208,7 @@ ALLPATHS = ['embed/rust',
|
||||
'embed/unix',
|
||||
'embed/extmod/modtrezorui',
|
||||
'vendor/nanopb',
|
||||
] + CPPPATH_MOD
|
||||
] + CPPPATH_MOD + PATH_HAL
|
||||
|
||||
env.Replace(
|
||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||
@ -267,18 +224,11 @@ env.Replace(
|
||||
CPPDEFINES=[
|
||||
'BOOTLOADER',
|
||||
'TREZOR_EMULATOR',
|
||||
CPU_MODEL,
|
||||
'HW_MODEL=' + MODEL_AS_NUMBER,
|
||||
'HW_REVISION=' + ('10' if TREZOR_MODEL in ('R',) else '0'),
|
||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
||||
('FLASH_BIT_ACCESS', '1'),
|
||||
('FLASH_BLOCK_WORDS', '1'),
|
||||
'MCU_TYPE='+CPU_MODEL,
|
||||
'PB_FIELD_16BIT',
|
||||
'PB_ENCODE_ARRAYS_UNPACKED',
|
||||
'PB_VALIDATE_UTF8',
|
||||
] + CPPDEFINES_MOD,
|
||||
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||
|
||||
try:
|
||||
@ -326,24 +276,10 @@ def cargo_build():
|
||||
|
||||
if NEW_RENDERING:
|
||||
features.append('new_rendering')
|
||||
if TREZOR_MODEL in ('T',):
|
||||
features.append('display_rgb565')
|
||||
elif TREZOR_MODEL in ('R', '1',):
|
||||
features.append('display_mono')
|
||||
features.append('xframebuffer')
|
||||
elif TREZOR_MODEL in ('T3T1',):
|
||||
features.append('display_rgb565')
|
||||
features.append('xframebuffer')
|
||||
|
||||
if TREZOR_MODEL in ('T', 'T3T1'):
|
||||
features.append('touch')
|
||||
features.append('backlight')
|
||||
features.append('dma2d')
|
||||
if TREZOR_MODEL in ('R', '1'):
|
||||
features.append('button')
|
||||
|
||||
features.append("ui")
|
||||
features.append("bootloader")
|
||||
features.extend(FEATURES_AVAILABLE)
|
||||
|
||||
|
||||
cargo_opts = [
|
||||
|
@ -7,13 +7,16 @@ import tools, models
|
||||
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
|
||||
EVERYTHING = BITCOIN_ONLY != '1'
|
||||
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
||||
DMA2D = TREZOR_MODEL in ('T', 'T3T1')
|
||||
OPTIGA = TREZOR_MODEL in ('R', 'T3T1')
|
||||
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
||||
HW_REVISION ='emulator'
|
||||
THP = ARGUMENTS.get('THP', '0') == '1' # Trezor-Host Protocol
|
||||
NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
|
||||
|
||||
|
||||
FEATURES_WANTED = ["input", "sd_card", "dma2d", "optiga", "sbu"]
|
||||
if NEW_RENDERING:
|
||||
FEATURES_WANTED.append("new_rendering")
|
||||
|
||||
if TREZOR_MODEL in ('DISC1', 'DISC2'):
|
||||
# skip unix build
|
||||
env = Environment()
|
||||
@ -32,6 +35,8 @@ FEATURE_FLAGS = {
|
||||
|
||||
CCFLAGS_MOD = ''
|
||||
CPPPATH_MOD = []
|
||||
CPPDEFINES_HAL = []
|
||||
PATH_HAL = []
|
||||
CPPDEFINES_MOD = []
|
||||
SOURCE_MOD = [
|
||||
'vendor/micropython/extmod/vfs_posix_file.c',
|
||||
@ -206,11 +211,6 @@ if THP:
|
||||
SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorio/modtrezorio.c',
|
||||
]
|
||||
if TREZOR_MODEL in ('T', 'T3T1'):
|
||||
SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorio/ff.c',
|
||||
'embed/extmod/modtrezorio/ffunicode.c',
|
||||
]
|
||||
|
||||
# modtrezorui
|
||||
CPPPATH_MOD += [
|
||||
@ -245,26 +245,6 @@ else:
|
||||
'embed/lib/display_draw.c',
|
||||
]
|
||||
|
||||
|
||||
if TREZOR_MODEL in ('1', ):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T1B1_layout.c',
|
||||
]
|
||||
elif TREZOR_MODEL in ('T', ):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T2T1_layout.c',
|
||||
]
|
||||
elif TREZOR_MODEL in ('R', ):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T2B1_layout.c',
|
||||
]
|
||||
elif TREZOR_MODEL in ('T3T1', ):
|
||||
SOURCE_MOD += [
|
||||
'embed/models/model_T3T1_layout.c',
|
||||
]
|
||||
|
||||
|
||||
|
||||
CPPDEFINES_MOD += [
|
||||
'TREZOR_UI2',
|
||||
'TRANSLATIONS',
|
||||
@ -281,14 +261,6 @@ if RASPI:
|
||||
|
||||
if NEW_RENDERING:
|
||||
CPPDEFINES_MOD += ['NEW_RENDERING']
|
||||
if TREZOR_MODEL in ('T',):
|
||||
CPPDEFINES_MOD += ['DISPLAY_RGB565']
|
||||
elif TREZOR_MODEL in ('R', '1',):
|
||||
CPPDEFINES_MOD += ['XFRAMEBUFFER', 'DISPLAY_MONO']
|
||||
elif TREZOR_MODEL in ('T3T1',):
|
||||
CPPDEFINES_MOD += ['XFRAMEBUFFER', 'DISPLAY_RGB565']
|
||||
|
||||
|
||||
|
||||
# modtrezorutils
|
||||
SOURCE_MOD += [
|
||||
@ -453,32 +425,13 @@ SOURCE_UNIX = [
|
||||
if NEW_RENDERING:
|
||||
SOURCE_MOD += [
|
||||
'embed/trezorhal/unix/display_driver.c',
|
||||
'embed/trezorhal/unix/dma2d_bitblt.c',
|
||||
'embed/trezorhal/xdisplay_legacy.c',
|
||||
]
|
||||
else:
|
||||
SOURCE_MOD += [
|
||||
'embed/trezorhal/unix/display-unix.c',
|
||||
'embed/lib/dma2d_emul.c',
|
||||
]
|
||||
|
||||
|
||||
if TREZOR_MODEL in ('T', 'R', 'T3T1'):
|
||||
SOURCE_UNIX += [
|
||||
'embed/trezorhal/unix/sbu.c',
|
||||
]
|
||||
|
||||
if OPTIGA:
|
||||
SOURCE_UNIX += [
|
||||
'embed/trezorhal/unix/optiga.c',
|
||||
]
|
||||
|
||||
if DMA2D:
|
||||
CPPDEFINES_MOD += [
|
||||
'USE_DMA2D',
|
||||
]
|
||||
|
||||
|
||||
TRANSLATION_DATA = [
|
||||
"translations/en.json",
|
||||
"translations/order.json",
|
||||
@ -504,6 +457,7 @@ else:
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DCONFIDENTIAL= -DPYOPT=%s -DBITCOIN_ONLY=%s %s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT, BITCOIN_ONLY, STATIC))
|
||||
|
||||
FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_UNIX, PATH_HAL)
|
||||
|
||||
if TREZOR_MODEL in ('T', 'T3T1'):
|
||||
UI_LAYOUT = 'UI_LAYOUT_TT'
|
||||
@ -514,14 +468,17 @@ elif TREZOR_MODEL in ('1', 'R'):
|
||||
else:
|
||||
raise ValueError('Unknown Trezor model')
|
||||
|
||||
if TREZOR_MODEL in ('T', 'T3T1'):
|
||||
|
||||
if 'sd_card' in FEATURES_AVAILABLE:
|
||||
SDCARD = True
|
||||
SOURCE_UNIX += [
|
||||
'embed/trezorhal/unix/sdcard.c',
|
||||
]
|
||||
else:
|
||||
SDCARD = False
|
||||
|
||||
if 'optiga' in FEATURES_AVAILABLE:
|
||||
OPTIGA = True
|
||||
else:
|
||||
OPTIGA = False
|
||||
|
||||
|
||||
env.Tool('micropython')
|
||||
|
||||
@ -571,19 +528,6 @@ if ARGUMENTS.get('TREZOR_MEMPERF', '0') == '1':
|
||||
env.Replace(
|
||||
TREZOR_MODEL=TREZOR_MODEL, )
|
||||
|
||||
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', ):
|
||||
CPU_MODEL = 'STM32U5A9xx'
|
||||
elif TREZOR_MODEL in ('1',):
|
||||
CPU_MODEL = 'STM32F405xx'
|
||||
else:
|
||||
raise ValueError('Unknown Trezor model')
|
||||
|
||||
ALLPATHS=['.',
|
||||
'embed/rust',
|
||||
'embed/lib',
|
||||
@ -595,7 +539,7 @@ ALLPATHS=['.',
|
||||
'vendor/micropython',
|
||||
'vendor/micropython/ports/unix',
|
||||
'vendor/micropython/lib/mp-readline',
|
||||
] + CPPPATH_MOD
|
||||
] + CPPPATH_MOD + PATH_HAL
|
||||
|
||||
env.Replace(
|
||||
CCFLAGS='$COPT '
|
||||
@ -606,16 +550,11 @@ env.Replace(
|
||||
LIBS=['m'],
|
||||
CPPPATH=ALLPATHS,
|
||||
CPPDEFINES=[
|
||||
CPU_MODEL,
|
||||
'TREZOR_EMULATOR',
|
||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
||||
('FLASH_BIT_ACCESS', '1'),
|
||||
('FLASH_BLOCK_WORDS', '1'),
|
||||
'MCU_TYPE='+CPU_MODEL,
|
||||
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
||||
UI_LAYOUT,
|
||||
] + CPPDEFINES_MOD,
|
||||
] + CPPDEFINES_MOD + CPPDEFINES_HAL,
|
||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||
|
||||
try:
|
||||
@ -841,7 +780,7 @@ if FROZEN:
|
||||
source=SOURCE_PY,
|
||||
source_dir=SOURCE_PY_DIR,
|
||||
bitcoin_only=BITCOIN_ONLY,
|
||||
backlight=TREZOR_MODEL in ('T', 'T3T1'),
|
||||
backlight='backlight' in FEATURES_AVAILABLE,
|
||||
optiga=OPTIGA,
|
||||
ui_layout=UI_LAYOUT,
|
||||
thp=THP,
|
||||
@ -917,27 +856,16 @@ def cargo_build():
|
||||
|
||||
if PYOPT == '0':
|
||||
features.append('debug')
|
||||
if DMA2D:
|
||||
features.append('dma2d')
|
||||
|
||||
features.extend(FEATURES_AVAILABLE)
|
||||
|
||||
if TREZOR_MODEL in ('T', 'T3T1'):
|
||||
features.append('touch')
|
||||
features.append('sd_card')
|
||||
features.append('ui_blurring')
|
||||
features.append('ui_jpeg_decoder')
|
||||
if TREZOR_MODEL in ('R', '1'):
|
||||
features.append('button')
|
||||
|
||||
|
||||
if NEW_RENDERING:
|
||||
features.append('new_rendering')
|
||||
if TREZOR_MODEL in ('T',):
|
||||
features.append('display_rgb565')
|
||||
elif TREZOR_MODEL in ('R', '1',):
|
||||
features.append('display_mono')
|
||||
features.append('xframebuffer')
|
||||
elif TREZOR_MODEL in ('T3T1',):
|
||||
features.append('display_rgb565')
|
||||
features.append('xframebuffer')
|
||||
|
||||
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
||||
|
||||
|
@ -28,7 +28,6 @@ const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[
|
||||
"-I../trezorhal/unix",
|
||||
"-I../models",
|
||||
"-DTREZOR_EMULATOR",
|
||||
"-DTREZOR_BOARD=\"boards/board-unix.h\"",
|
||||
];
|
||||
|
||||
#[cfg(feature = "model_tt")]
|
||||
@ -37,6 +36,7 @@ const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[
|
||||
"-DTREZOR_MODEL_T",
|
||||
"-DFLASH_BIT_ACCESS=1",
|
||||
"-DFLASH_BLOCK_WORDS=1",
|
||||
"-DTREZOR_BOARD=\"T2T1/boards/t2t1-unix.h\"",
|
||||
];
|
||||
#[cfg(not(feature = "model_tt"))]
|
||||
const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[];
|
||||
@ -47,6 +47,7 @@ const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[
|
||||
"-DTREZOR_MODEL_R",
|
||||
"-DFLASH_BIT_ACCESS=1",
|
||||
"-DFLASH_BLOCK_WORDS=1",
|
||||
"-DTREZOR_BOARD=\"T2B1/boards/t2b1-unix.h\"",
|
||||
];
|
||||
#[cfg(not(feature = "model_tr"))]
|
||||
const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[];
|
||||
|
@ -1,33 +0,0 @@
|
||||
#ifndef _BOARD_UNIX_H
|
||||
#define _BOARD_UNIX_H
|
||||
|
||||
#ifdef TREZOR_MODEL_T
|
||||
#define USE_TOUCH 1
|
||||
#define USE_SD_CARD 1
|
||||
#define USE_SBU 1
|
||||
#define USE_RGB_COLORS 1
|
||||
#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
|
||||
#define USE_BACKLIGHT 1
|
||||
#define USE_OPTIGA 1
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_MODEL_1
|
||||
#define USE_BUTTON 1
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_MODEL_R
|
||||
#define USE_BUTTON 1
|
||||
#define USE_SBU 1
|
||||
#define USE_OPTIGA 1
|
||||
#endif
|
||||
|
||||
#include "display-unix.h"
|
||||
|
||||
#endif //_BOARD_UNIX_H
|
22
core/embed/trezorhal/boards/t1b1-unix.h
Normal file
22
core/embed/trezorhal/boards/t1b1-unix.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef BOARDS_T1B1_UNIX_H
|
||||
#define BOARDS_T1B1_UNIX_H
|
||||
|
||||
#define USE_BUTTON 1
|
||||
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
|
||||
#define WINDOW_WIDTH 200
|
||||
#define WINDOW_HEIGHT 340
|
||||
#define TOUCH_OFFSET_X 36
|
||||
#define TOUCH_OFFSET_Y 92
|
||||
|
||||
#define ORIENTATION_NS 1
|
||||
|
||||
#define BACKGROUND_FILE "background_1.h"
|
||||
#define BACKGROUND_NAME background_1_jpg
|
||||
|
||||
#endif // BOARDS_T1B1_UNIX_H
|
24
core/embed/trezorhal/boards/t2b1-unix.h
Normal file
24
core/embed/trezorhal/boards/t2b1-unix.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef BOARDS_T2B1_UNIX_H
|
||||
#define BOARDS_T2B1_UNIX_H
|
||||
|
||||
#define USE_BUTTON 1
|
||||
#define USE_SBU 1
|
||||
#define USE_OPTIGA 1
|
||||
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
|
||||
#define WINDOW_WIDTH 193
|
||||
#define WINDOW_HEIGHT 339
|
||||
#define TOUCH_OFFSET_X 32
|
||||
#define TOUCH_OFFSET_Y 84
|
||||
|
||||
#define ORIENTATION_NS 1
|
||||
|
||||
#define BACKGROUND_FILE "background_T2B1.h"
|
||||
#define BACKGROUND_NAME background_T2B1_jpg
|
||||
|
||||
#endif // BOARDS_T2B1_UNIX_H
|
39
core/embed/trezorhal/boards/t2t1-unix.h
Normal file
39
core/embed/trezorhal/boards/t2t1-unix.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef BOARDS_T2T1_UNIX_H
|
||||
#define BOARDS_T2T1_UNIX_H
|
||||
|
||||
#define USE_TOUCH 1
|
||||
#define USE_SD_CARD 1
|
||||
#define USE_SBU 1
|
||||
#define USE_RGB_COLORS 1
|
||||
#define USE_BACKLIGHT 1
|
||||
|
||||
// ILI9341V, GC9307 and ST7789V drivers support 240px x 320px display resolution
|
||||
#define MAX_DISPLAY_RESX 240
|
||||
#define MAX_DISPLAY_RESY 320
|
||||
#define DISPLAY_RESX 240
|
||||
#define DISPLAY_RESY 240
|
||||
#define TREZOR_FONT_BPP 4
|
||||
|
||||
#define ORIENTATION_NSEW 1
|
||||
|
||||
#ifdef TREZOR_EMULATOR_RASPI
|
||||
#define WINDOW_WIDTH 480
|
||||
#define WINDOW_HEIGHT 320
|
||||
#define TOUCH_OFFSET_X 110
|
||||
#define TOUCH_OFFSET_Y 40
|
||||
|
||||
#define BACKGROUND_FILE "background_raspi.h"
|
||||
#define BACKGROUND_NAME background_raspi_jpg
|
||||
|
||||
#else
|
||||
#define WINDOW_WIDTH 400
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define TOUCH_OFFSET_X 80
|
||||
#define TOUCH_OFFSET_Y 110
|
||||
|
||||
#define BACKGROUND_FILE "background_T.h"
|
||||
#define BACKGROUND_NAME background_T_jpg
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOARDS_T2T1_UNIX_H
|
27
core/embed/trezorhal/boards/t3t1-unix.h
Normal file
27
core/embed/trezorhal/boards/t3t1-unix.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef BOARDS_T3T1_UNIX_H
|
||||
#define BOARDS_T3T1_UNIX_H
|
||||
|
||||
#define USE_TOUCH 1
|
||||
#define USE_SD_CARD 1
|
||||
#define USE_SBU 1
|
||||
#define USE_RGB_COLORS 1
|
||||
#define USE_BACKLIGHT 1
|
||||
#define USE_OPTIGA 1
|
||||
|
||||
#define MAX_DISPLAY_RESX 240
|
||||
#define MAX_DISPLAY_RESY 240
|
||||
#define DISPLAY_RESX 240
|
||||
#define DISPLAY_RESY 240
|
||||
#define TREZOR_FONT_BPP 4
|
||||
|
||||
#define WINDOW_WIDTH 400
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define TOUCH_OFFSET_X 80
|
||||
#define TOUCH_OFFSET_Y 110
|
||||
|
||||
#define ORIENTATION_NSEW 1
|
||||
|
||||
#define BACKGROUND_FILE "background_T.h"
|
||||
#define BACKGROUND_NAME background_T_jpg
|
||||
|
||||
#endif // BOARDS_T3T1_UNIX_H
|
@ -30,51 +30,13 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "display-unix.h"
|
||||
#include "display.h"
|
||||
#include "profile.h"
|
||||
|
||||
#include TREZOR_BOARD
|
||||
|
||||
#define EMULATOR_BORDER 16
|
||||
|
||||
#if defined TREZOR_MODEL_T
|
||||
|
||||
#ifdef TREZOR_EMULATOR_RASPI
|
||||
#define WINDOW_WIDTH 480
|
||||
#define WINDOW_HEIGHT 320
|
||||
#define TOUCH_OFFSET_X 110
|
||||
#define TOUCH_OFFSET_Y 40
|
||||
#else
|
||||
#define WINDOW_WIDTH 400
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define TOUCH_OFFSET_X 80
|
||||
#define TOUCH_OFFSET_Y 110
|
||||
#endif
|
||||
|
||||
#elif defined TREZOR_MODEL_1
|
||||
|
||||
#define WINDOW_WIDTH 200
|
||||
#define WINDOW_HEIGHT 340
|
||||
#define TOUCH_OFFSET_X 36
|
||||
#define TOUCH_OFFSET_Y 92
|
||||
|
||||
#elif defined TREZOR_MODEL_R
|
||||
|
||||
#define WINDOW_WIDTH 193
|
||||
#define WINDOW_HEIGHT 339
|
||||
#define TOUCH_OFFSET_X 32
|
||||
#define TOUCH_OFFSET_Y 84
|
||||
|
||||
#elif defined TREZOR_MODEL_T3T1
|
||||
|
||||
#define WINDOW_WIDTH 400
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define TOUCH_OFFSET_X 80
|
||||
#define TOUCH_OFFSET_Y 110
|
||||
|
||||
#else
|
||||
#error Unknown Trezor model
|
||||
#endif
|
||||
|
||||
static SDL_Window *WINDOW;
|
||||
static SDL_Renderer *RENDERER;
|
||||
static SDL_Surface *BUFFER;
|
||||
@ -107,7 +69,7 @@ static struct {
|
||||
} PIXELWINDOW;
|
||||
|
||||
void display_pixeldata(pixel_color c) {
|
||||
#if defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R
|
||||
#if !defined USE_RGB_COLORS
|
||||
// set to white if highest bits of all R, G, B values are set to 1
|
||||
// bin(10000 100000 10000) = hex(0x8410)
|
||||
// otherwise set to black
|
||||
@ -202,26 +164,11 @@ void display_init(void) {
|
||||
SDL_PumpEvents();
|
||||
SDL_SetWindowSize(WINDOW, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
#endif
|
||||
#ifdef TREZOR_EMULATOR_RASPI
|
||||
#include "background_raspi.h"
|
||||
#include BACKGROUND_FILE
|
||||
#define CONCAT_LEN_HELPER(name) name##_len
|
||||
#define CONCAT_LEN(name) CONCAT_LEN_HELPER(name)
|
||||
BACKGROUND = IMG_LoadTexture_RW(
|
||||
RENDERER, SDL_RWFromMem(background_raspi_jpg, background_raspi_jpg_len),
|
||||
0);
|
||||
#else
|
||||
#if defined TREZOR_MODEL_T
|
||||
#include "background_T.h"
|
||||
BACKGROUND = IMG_LoadTexture_RW(
|
||||
RENDERER, SDL_RWFromMem(background_T_jpg, background_T_jpg_len), 0);
|
||||
#elif defined TREZOR_MODEL_1
|
||||
#include "background_1.h"
|
||||
BACKGROUND = IMG_LoadTexture_RW(
|
||||
RENDERER, SDL_RWFromMem(background_1_jpg, background_1_jpg_len), 0);
|
||||
#elif defined TREZOR_MODEL_R
|
||||
#include "background_T2B1.h"
|
||||
BACKGROUND = IMG_LoadTexture_RW(
|
||||
RENDERER, SDL_RWFromMem(background_T2B1_png, background_T2B1_png_len), 0);
|
||||
#endif
|
||||
#endif
|
||||
RENDERER, SDL_RWFromMem(BACKGROUND_NAME, CONCAT_LEN(BACKGROUND_NAME)), 0);
|
||||
if (BACKGROUND) {
|
||||
SDL_SetTextureBlendMode(BACKGROUND, SDL_BLENDMODE_NONE);
|
||||
sdl_touch_offset_x = TOUCH_OFFSET_X;
|
||||
@ -232,8 +179,8 @@ void display_init(void) {
|
||||
sdl_touch_offset_x = EMULATOR_BORDER;
|
||||
sdl_touch_offset_y = EMULATOR_BORDER;
|
||||
}
|
||||
#if defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R
|
||||
// T1 and TR do not have backlight capabilities in hardware, so
|
||||
#if !USE_BACKLIGHT
|
||||
// some models do not have backlight capabilities in hardware, so
|
||||
// setting its value here for emulator to avoid
|
||||
// calling any `set_backlight` functions
|
||||
DISPLAY_BACKLIGHT = 255;
|
||||
@ -291,12 +238,12 @@ void display_refresh(void) {
|
||||
|
||||
int display_orientation(int degrees) {
|
||||
if (degrees != DISPLAY_ORIENTATION) {
|
||||
#if defined TREZOR_MODEL_T || defined TREZOR_MODEL_T3T1
|
||||
#if defined ORIENTATION_NSEW
|
||||
if (degrees == 0 || degrees == 90 || degrees == 180 || degrees == 270) {
|
||||
#elif defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R
|
||||
#elif defined ORIENTATION_NS
|
||||
if (degrees == 0 || degrees == 180) {
|
||||
#else
|
||||
#error Unknown Trezor model
|
||||
if (degrees == 0) {
|
||||
#endif
|
||||
DISPLAY_ORIENTATION = degrees;
|
||||
display_refresh();
|
||||
@ -308,7 +255,7 @@ int display_orientation(int degrees) {
|
||||
int display_get_orientation(void) { return DISPLAY_ORIENTATION; }
|
||||
|
||||
int display_backlight(int val) {
|
||||
#if defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R
|
||||
#if !USE_BACKLIGHT
|
||||
val = 255;
|
||||
#endif
|
||||
if (DISPLAY_BACKLIGHT != val && val >= 0 && val <= 255) {
|
||||
|
@ -1,41 +0,0 @@
|
||||
#ifndef _DISPLAY_UNIX_H
|
||||
#define _DISPLAY_UNIX_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef TREZOR_MODEL_T
|
||||
// ILI9341V, GC9307 and ST7789V drivers support 240px x 320px display resolution
|
||||
#define MAX_DISPLAY_RESX 240
|
||||
#define MAX_DISPLAY_RESY 320
|
||||
#define DISPLAY_RESX 240
|
||||
#define DISPLAY_RESY 240
|
||||
#define TREZOR_FONT_BPP 4
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_MODEL_R
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_MODEL_T3T1
|
||||
#define MAX_DISPLAY_RESX 240
|
||||
#define MAX_DISPLAY_RESY 240
|
||||
#define DISPLAY_RESX 240
|
||||
#define DISPLAY_RESY 240
|
||||
#define TREZOR_FONT_BPP 4
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_MODEL_1
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
#endif
|
||||
|
||||
extern uint8_t *const DISPLAY_DATA_ADDRESS;
|
||||
|
||||
#endif //_DISPLAY_UNIX_H
|
@ -19,6 +19,8 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include TREZOR_BOARD
|
||||
|
||||
#include <xdisplay.h>
|
||||
|
||||
#include <SDL.h>
|
||||
@ -29,45 +31,6 @@
|
||||
|
||||
#define EMULATOR_BORDER 16
|
||||
|
||||
#if defined TREZOR_MODEL_T
|
||||
|
||||
#ifdef TREZOR_EMULATOR_RASPI
|
||||
#define WINDOW_WIDTH 480
|
||||
#define WINDOW_HEIGHT 320
|
||||
#define TOUCH_OFFSET_X 110
|
||||
#define TOUCH_OFFSET_Y 40
|
||||
#else
|
||||
#define WINDOW_WIDTH 400
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define TOUCH_OFFSET_X 80
|
||||
#define TOUCH_OFFSET_Y 110
|
||||
#endif
|
||||
|
||||
#elif defined TREZOR_MODEL_1
|
||||
|
||||
#define WINDOW_WIDTH 200
|
||||
#define WINDOW_HEIGHT 340
|
||||
#define TOUCH_OFFSET_X 36
|
||||
#define TOUCH_OFFSET_Y 92
|
||||
|
||||
#elif defined TREZOR_MODEL_R
|
||||
|
||||
#define WINDOW_WIDTH 193
|
||||
#define WINDOW_HEIGHT 339
|
||||
#define TOUCH_OFFSET_X 32
|
||||
#define TOUCH_OFFSET_Y 84
|
||||
|
||||
#elif defined TREZOR_MODEL_T3T1
|
||||
|
||||
#define WINDOW_WIDTH 400
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define TOUCH_OFFSET_X 80
|
||||
#define TOUCH_OFFSET_Y 110
|
||||
|
||||
#else
|
||||
#error Unknown Trezor model
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
// Current display orientation (0 or 180)
|
||||
int orientation_angle;
|
||||
@ -167,27 +130,12 @@ void display_init(void) {
|
||||
SDL_PumpEvents();
|
||||
SDL_SetWindowSize(drv->window, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
#endif
|
||||
#ifdef TREZOR_EMULATOR_RASPI
|
||||
#include "background_raspi.h"
|
||||
#include BACKGROUND_FILE
|
||||
#define CONCAT_LEN_HELPER(name) name##_len
|
||||
#define CONCAT_LEN(name) CONCAT_LEN_HELPER(name)
|
||||
drv->background = IMG_LoadTexture_RW(
|
||||
drv->renderer,
|
||||
SDL_RWFromMem(background_raspi_jpg, background_raspi_jpg_len), 0);
|
||||
#else
|
||||
#if defined TREZOR_MODEL_T
|
||||
#include "background_T.h"
|
||||
drv->background = IMG_LoadTexture_RW(
|
||||
drv->renderer, SDL_RWFromMem(background_T_jpg, background_T_jpg_len), 0);
|
||||
#elif defined TREZOR_MODEL_1
|
||||
#include "background_1.h"
|
||||
drv->background = IMG_LoadTexture_RW(
|
||||
drv->renderer, SDL_RWFromMem(background_1_jpg, background_1_jpg_len), 0);
|
||||
#elif defined TREZOR_MODEL_R
|
||||
#include "background_T2B1.h"
|
||||
drv->background = IMG_LoadTexture_RW(
|
||||
drv->renderer,
|
||||
SDL_RWFromMem(background_T2B1_png, background_T2B1_png_len), 0);
|
||||
#endif
|
||||
#endif
|
||||
SDL_RWFromMem(BACKGROUND_NAME, CONCAT_LEN(BACKGROUND_NAME)), 0);
|
||||
if (drv->background) {
|
||||
SDL_SetTextureBlendMode(drv->background, SDL_BLENDMODE_NONE);
|
||||
sdl_touch_offset_x = TOUCH_OFFSET_X;
|
||||
@ -198,8 +146,8 @@ void display_init(void) {
|
||||
sdl_touch_offset_x = EMULATOR_BORDER;
|
||||
sdl_touch_offset_y = EMULATOR_BORDER;
|
||||
}
|
||||
#if defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R
|
||||
// T1 and TR do not have backlight capabilities in hardware, so
|
||||
#if !USE_BACKLIGHT
|
||||
// some models do not have backlight capabilities in hardware, so
|
||||
// setting its value here for emulator to avoid
|
||||
// calling any `set_backlight` functions
|
||||
drv->backlight_level = 255;
|
||||
@ -225,7 +173,7 @@ void display_finish_actions(void) {
|
||||
int display_set_backlight(int level) {
|
||||
display_driver_t *drv = &g_display_driver;
|
||||
|
||||
#if defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R
|
||||
#if !USE_BACKLIGHT
|
||||
level = 255;
|
||||
#endif
|
||||
|
||||
@ -245,12 +193,12 @@ int display_get_backlight(void) {
|
||||
int display_set_orientation(int angle) {
|
||||
display_driver_t *drv = &g_display_driver;
|
||||
if (angle != drv->orientation_angle) {
|
||||
#if defined TREZOR_MODEL_T || defined TREZOR_MODEL_T3T1
|
||||
#if defined ORIENTATION_NSEW
|
||||
if (angle == 0 || angle == 90 || angle == 180 || angle == 270) {
|
||||
#elif defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R
|
||||
#elif defined ORIENTATION_NS
|
||||
if (angle == 0 || angle == 180) {
|
||||
#else
|
||||
#error Unknown Trezor model
|
||||
if (angle == 0) {
|
||||
#endif
|
||||
drv->orientation_angle = angle;
|
||||
display_refresh();
|
||||
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from .emulator import configure as emul
|
||||
from .trezor_1 import configure
|
||||
|
||||
|
||||
@ -13,4 +14,7 @@ def configure_board(
|
||||
sources: list[str],
|
||||
paths: list[str],
|
||||
):
|
||||
if revision == "emulator":
|
||||
return emul(env, features_wanted, defines, sources, paths)
|
||||
else:
|
||||
return configure(env, features_wanted, defines, sources, paths)
|
||||
|
38
core/site_scons/models/T1B1/emulator.py
Normal file
38
core/site_scons/models/T1B1/emulator.py
Normal file
@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import get_hw_model_as_number
|
||||
|
||||
|
||||
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 = "t1b1-unix.h"
|
||||
hw_model = get_hw_model_as_number("T1B1")
|
||||
hw_revision = 0
|
||||
mcu = "STM32F405xx"
|
||||
|
||||
if "new_rendering" in features_wanted:
|
||||
defines += ["XFRAMEBUFFER", "DISPLAY_MONO"]
|
||||
features_available.append("xframebuffer")
|
||||
features_available.append("display_mono")
|
||||
|
||||
defines += [mcu]
|
||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||
defines += [f"HW_MODEL={hw_model}"]
|
||||
defines += [f"HW_REVISION={hw_revision}"]
|
||||
defines += [f"MCU_TYPE={mcu}"]
|
||||
defines += ["FLASH_BIT_ACCESS=1"]
|
||||
defines += ["FLASH_BLOCK_WORDS=1"]
|
||||
|
||||
if "input" in features_wanted:
|
||||
features_available.append("button")
|
||||
|
||||
sources += ["embed/models/model_T1B1_layout.c"]
|
||||
|
||||
return features_available
|
@ -2,10 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from .trezor_r_v3 import configure as configure_r3
|
||||
from .trezor_r_v4 import configure as configure_r4
|
||||
from .trezor_r_v6 import configure as configure_r6
|
||||
from .trezor_r_v10 import configure as configure_r10
|
||||
from . import emulator, trezor_r_v3, trezor_r_v4, trezor_r_v6, trezor_r_v10
|
||||
|
||||
|
||||
def configure_board(
|
||||
@ -16,14 +13,21 @@ def configure_board(
|
||||
sources: list[str],
|
||||
paths: list[str],
|
||||
):
|
||||
if revision is None:
|
||||
revision = 10
|
||||
if revision == 3:
|
||||
return configure_r3(env, features_wanted, defines, sources, paths)
|
||||
elif revision == 4:
|
||||
return configure_r4(env, features_wanted, defines, sources, paths)
|
||||
elif revision == 6:
|
||||
return configure_r6(env, features_wanted, defines, sources, paths)
|
||||
elif revision == 10:
|
||||
return configure_r10(env, features_wanted, defines, sources, paths)
|
||||
# Set default revision if None
|
||||
revision = revision or 10
|
||||
|
||||
# Mapping of revisions to their respective configurations
|
||||
revision_map = {
|
||||
"emulator": emulator,
|
||||
3: trezor_r_v3,
|
||||
4: trezor_r_v4,
|
||||
6: trezor_r_v6,
|
||||
10: trezor_r_v10,
|
||||
}
|
||||
|
||||
module = revision_map.get(revision)
|
||||
|
||||
if module:
|
||||
return module.configure(env, features_wanted, defines, sources, paths)
|
||||
|
||||
raise Exception("Unknown model_r_version")
|
||||
|
48
core/site_scons/models/T2B1/emulator.py
Normal file
48
core/site_scons/models/T2B1/emulator.py
Normal file
@ -0,0 +1,48 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import get_hw_model_as_number
|
||||
|
||||
|
||||
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 = "t2b1-unix.h"
|
||||
hw_model = get_hw_model_as_number("T2B1")
|
||||
hw_revision = 0
|
||||
mcu = "STM32F427xx"
|
||||
|
||||
if "new_rendering" in features_wanted:
|
||||
defines += ["XFRAMEBUFFER", "DISPLAY_MONO"]
|
||||
features_available.append("xframebuffer")
|
||||
features_available.append("display_mono")
|
||||
|
||||
defines += [mcu]
|
||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||
defines += [f"HW_MODEL={hw_model}"]
|
||||
defines += [f"HW_REVISION={hw_revision}"]
|
||||
defines += [f"MCU_TYPE={mcu}"]
|
||||
defines += ["FLASH_BIT_ACCESS=1"]
|
||||
defines += ["FLASH_BLOCK_WORDS=1"]
|
||||
|
||||
if "sbu" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/sbu.c"]
|
||||
|
||||
if "optiga_hal" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/optiga_hal.c"]
|
||||
|
||||
if "optiga" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/optiga.c"]
|
||||
features_available.append("optiga")
|
||||
|
||||
if "input" in features_wanted:
|
||||
features_available.append("button")
|
||||
|
||||
sources += ["embed/models/model_T2B1_layout.c"]
|
||||
|
||||
return features_available
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from .emulator import configure as emul
|
||||
from .trezor_t import configure
|
||||
|
||||
|
||||
@ -13,4 +14,7 @@ def configure_board(
|
||||
sources: list[str],
|
||||
paths: list[str],
|
||||
):
|
||||
if revision == "emulator":
|
||||
return emul(env, features_wanted, defines, sources, paths)
|
||||
else:
|
||||
return configure(env, features_wanted, defines, sources, paths)
|
||||
|
60
core/site_scons/models/T2T1/emulator.py
Normal file
60
core/site_scons/models/T2T1/emulator.py
Normal file
@ -0,0 +1,60 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import get_hw_model_as_number
|
||||
|
||||
|
||||
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 = "t2t1-unix.h"
|
||||
hw_model = get_hw_model_as_number("T2T1")
|
||||
hw_revision = 0
|
||||
mcu = "STM32F427xx"
|
||||
|
||||
if "new_rendering" in features_wanted:
|
||||
defines += ["DISPLAY_RGB565"]
|
||||
features_available.append("display_rgb565")
|
||||
|
||||
defines += [mcu]
|
||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||
defines += [f"HW_MODEL={hw_model}"]
|
||||
defines += [f"HW_REVISION={hw_revision}"]
|
||||
defines += [f"MCU_TYPE={mcu}"]
|
||||
defines += ["FLASH_BIT_ACCESS=1"]
|
||||
defines += ["FLASH_BLOCK_WORDS=1"]
|
||||
|
||||
if "dma2d" in features_wanted:
|
||||
features_available.append("dma2d")
|
||||
if "new_rendering" in features_wanted:
|
||||
sources += [
|
||||
"embed/trezorhal/unix/dma2d_bitblt.c",
|
||||
]
|
||||
else:
|
||||
sources += ["embed/lib/dma2d_emul.c"]
|
||||
defines += ["USE_DMA2D"]
|
||||
|
||||
if "sd_card" in features_wanted:
|
||||
features_available.append("sd_card")
|
||||
sources += [
|
||||
"embed/trezorhal/unix/sdcard.c",
|
||||
"embed/extmod/modtrezorio/ff.c",
|
||||
"embed/extmod/modtrezorio/ffunicode.c",
|
||||
]
|
||||
|
||||
if "sbu" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/sbu.c"]
|
||||
|
||||
if "input" in features_wanted:
|
||||
features_available.append("touch")
|
||||
|
||||
features_available.append("backlight")
|
||||
|
||||
sources += ["embed/models/model_T2T1_layout.c"]
|
||||
|
||||
return features_available
|
@ -2,8 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from .trezor_t3t1_revE import configure as configure_revE
|
||||
from .trezor_t3t1_v4 import configure as configure_v4
|
||||
from . import emulator, trezor_t3t1_revE, trezor_t3t1_v4
|
||||
|
||||
|
||||
def configure_board(
|
||||
@ -14,10 +13,19 @@ def configure_board(
|
||||
sources: list[str],
|
||||
paths: list[str],
|
||||
):
|
||||
if revision is None:
|
||||
revision = "E"
|
||||
if revision == 4:
|
||||
return configure_v4(env, features_wanted, defines, sources, paths)
|
||||
elif revision == "E":
|
||||
return configure_revE(env, features_wanted, defines, sources, paths)
|
||||
raise Exception("Unknown model_t3t1_version")
|
||||
# Set default revision if None
|
||||
revision = revision or "E"
|
||||
|
||||
# Mapping of revisions to their respective configurations
|
||||
revision_map = {
|
||||
"emulator": emulator,
|
||||
4: trezor_t3t1_v4,
|
||||
"E": trezor_t3t1_revE,
|
||||
}
|
||||
|
||||
module = revision_map.get(revision)
|
||||
|
||||
if module:
|
||||
return module.configure(env, features_wanted, defines, sources, paths)
|
||||
|
||||
raise Exception("Unknown model_r_version")
|
||||
|
68
core/site_scons/models/T3T1/emulator.py
Normal file
68
core/site_scons/models/T3T1/emulator.py
Normal file
@ -0,0 +1,68 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import get_hw_model_as_number
|
||||
|
||||
|
||||
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 = "t3t1-unix.h"
|
||||
hw_model = get_hw_model_as_number("T3T1")
|
||||
hw_revision = 0
|
||||
mcu = "STM32FU585xx"
|
||||
|
||||
if "new_rendering" in features_wanted:
|
||||
defines += ["XFRAMEBUFFER", "DISPLAY_RGB565"]
|
||||
features_available.append("xframebuffer")
|
||||
features_available.append("display_rgb565")
|
||||
|
||||
defines += [mcu]
|
||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||
defines += [f"HW_MODEL={hw_model}"]
|
||||
defines += [f"HW_REVISION={hw_revision}"]
|
||||
defines += [f"MCU_TYPE={mcu}"]
|
||||
# todo change to blockwise flash when implemented in unix
|
||||
defines += ["FLASH_BIT_ACCESS=1"]
|
||||
defines += ["FLASH_BLOCK_WORDS=1"]
|
||||
|
||||
if "dma2d" in features_wanted:
|
||||
features_available.append("dma2d")
|
||||
if "new_rendering" in features_wanted:
|
||||
sources += [
|
||||
"embed/trezorhal/unix/dma2d_bitblt.c",
|
||||
]
|
||||
else:
|
||||
sources += ["embed/lib/dma2d_emul.c"]
|
||||
defines += ["USE_DMA2D"]
|
||||
|
||||
if "sd_card" in features_wanted:
|
||||
features_available.append("sd_card")
|
||||
sources += [
|
||||
"embed/trezorhal/unix/sdcard.c",
|
||||
"embed/extmod/modtrezorio/ff.c",
|
||||
"embed/extmod/modtrezorio/ffunicode.c",
|
||||
]
|
||||
|
||||
if "sbu" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/sbu.c"]
|
||||
|
||||
if "optiga_hal" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/optiga_hal.c"]
|
||||
|
||||
if "optiga" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/optiga.c"]
|
||||
|
||||
if "input" in features_wanted:
|
||||
features_available.append("touch")
|
||||
|
||||
features_available.append("backlight")
|
||||
|
||||
sources += ["embed/models/model_T3T1_layout.c"]
|
||||
|
||||
return features_available
|
Loading…
Reference in New Issue
Block a user