diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 97ab41a2f5..4d126d1886 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -133,14 +133,13 @@ jobs: strategy: fail-fast: false matrix: - # model: [T1B1, T2T1, T2B1, T3B1, T3T1] # TODO update exprs below - model: ["1", "T", "R", T3B1, T3T1] + model: [T1B1, T2T1, T2B1, T3B1, T3T1] steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - run: git checkout ${{ github.head_ref || github.ref_name }} - - run: ./build-docker.sh ${{ matrix.model == '1' && '--skip-core' || '--skip-legacy' }} --models ${{ matrix.model }} ${{ github.head_ref || github.ref_name }} + - run: ./build-docker.sh ${{ matrix.model == 'T1B1' && '--skip-core' || '--skip-legacy' }} --models ${{ matrix.model }} --targets bootloader,firmware,prodtest ${{ github.head_ref || github.ref_name }} - name: Show fingerprints run: | for file in build/*/*/*.fingerprint; do diff --git a/.github/workflows/core-hw.yml b/.github/workflows/core-hw.yml index ffd5ff48b3..fbe9e7d35d 100644 --- a/.github/workflows/core-hw.yml +++ b/.github/workflows/core-hw.yml @@ -31,7 +31,7 @@ jobs: model: [T2T1, T2B1] coins: [universal, btconly] env: - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || 'R' }} + TREZOR_MODEL: ${{ matrix.model }} TREZOR_PYTEST_SKIP_ALTCOINS: ${{ matrix.coins == 'btconly' && '1' || '0' }} PYTEST_TIMEOUT: 1200 PYOPT: 0 @@ -74,7 +74,7 @@ jobs: matrix: model: [T2T1, T2B1] env: - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || 'R' }} + TREZOR_MODEL: ${{ matrix.model }} PYTEST_TIMEOUT: 1200 PYOPT: 0 DISABLE_OPTIGA: 1 diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index 795c69332c..66187d01bf 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -65,7 +65,7 @@ jobs: - model: T3W1 type: production env: - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model == 'D001' && 'DISC1' || matrix.model }} + TREZOR_MODEL: ${{ matrix.model }} BITCOIN_ONLY: ${{ matrix.coins == 'universal' && '0' || '1' }} PYOPT: ${{ matrix.type == 'debuglink' && '0' || '1' }} PRODUCTION: ${{ matrix.type == 'production' && '1' || '0' }} @@ -116,7 +116,7 @@ jobs: - type: normal asan: asan env: - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }} + TREZOR_MODEL: ${{ matrix.model }} BITCOIN_ONLY: ${{ matrix.coins == 'universal' && '0' || '1' }} PYOPT: ${{ matrix.type == 'debuglink' && '0' || '1' }} ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }} @@ -154,7 +154,7 @@ jobs: - type: normal asan: asan env: - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }} + TREZOR_MODEL: ${{ matrix.model }} BITCOIN_ONLY: ${{ matrix.coins == 'universal' && '0' || '1' }} PYOPT: ${{ matrix.type == 'debuglink' && '0' || '1' }} ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }} @@ -186,7 +186,7 @@ jobs: model: [T2T1, T3B1, T3T1, T3W1] asan: ${{ fromJSON(needs.param.outputs.asan) }} env: - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }} + TREZOR_MODEL: ${{ matrix.model }} ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }} LSAN_OPTIONS: "suppressions=../../asan_suppressions.txt" steps: @@ -209,7 +209,7 @@ jobs: model: [T2T1, T3B1, T3T1, T3W1] asan: ${{ fromJSON(needs.param.outputs.asan) }} env: - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }} + TREZOR_MODEL: ${{ matrix.model }} ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }} RUSTC_BOOTSTRAP: ${{ matrix.asan == 'asan' && '1' || '0' }} RUSTFLAGS: ${{ matrix.asan == 'asan' && '-Z sanitizer=address' || '' }} @@ -262,7 +262,7 @@ jobs: lang: ${{ fromJSON(needs.param.outputs.test_lang) }} env: TREZOR_PROFILING: ${{ matrix.asan == 'noasan' && '1' || '0' }} - TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }} + TREZOR_MODEL: ${{ matrix.model }} TREZOR_PYTEST_SKIP_ALTCOINS: ${{ matrix.coins == 'btconly' && '1' || '0' }} ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }} PYTEST_TIMEOUT: ${{ matrix.asan == 'asan' && 600 || 400 }} @@ -451,7 +451,7 @@ jobs: if: false # NOTE manual job, comment out to run runs-on: ubuntu-latest env: - TREZOR_MODEL: T + TREZOR_MODEL: T2T1 TREZOR_MEMPERF: 1 PYOPT: 0 PYTEST_TIMEOUT: 900 diff --git a/build-docker.sh b/build-docker.sh index d9e2bec98c..e0c7338250 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -54,7 +54,7 @@ function help_and_die() { echo " --skip-legacy - do not build legacy" echo " --repository path/to/repo - checkout the repository from the given path/url" echo " --no-init - do not recreate docker environments" - echo " --models - comma-separated list of models. default: --models R,T" + echo " --models - comma-separated list of models. default: --models T2B1,T2T1,T3T1" echo " --targets - comma-separated list of targets for core build. default: --targets boardloader,bootloader,firmware" echo " --help" echo @@ -69,7 +69,7 @@ OPT_BUILD_LEGACY=1 OPT_BUILD_NORMAL=1 OPT_BUILD_BITCOINONLY=1 INIT=1 -MODELS=(R T T3T1) +MODELS=(T2B1 T2T1 T3T1) CORE_TARGETS=(boardloader bootloader firmware) REPOSITORY="file:///local" @@ -324,6 +324,7 @@ for BITCOIN_ONLY in ${VARIANTS_legacy[@]}; do DIRSUFFIX=${BITCOIN_ONLY/1/-bitcoinonly} DIRSUFFIX=${DIRSUFFIX/0/} + DIRSUFFIX="-T1B1${DIRSUFFIX}" SCRIPT_NAME=".build_legacy_$BITCOIN_ONLY.sh" cat < "build/$SCRIPT_NAME" diff --git a/core/Makefile b/core/Makefile index 90e428a9a9..84df1dbdb2 100644 --- a/core/Makefile +++ b/core/Makefile @@ -32,7 +32,7 @@ BITCOIN_ONLY ?= 0 BOOTLOADER_QA ?= 0 BOOTLOADER_DEVEL ?= 0 DISABLE_OPTIGA ?= 0 -TREZOR_MODEL ?= T +TREZOR_MODEL ?= T2T1 TREZOR_MEMPERF ?= 0 ADDRESS_SANITIZER ?= 0 CMAKELISTS ?= 0 @@ -50,11 +50,11 @@ OPENOCD_INTERFACE ?= stlink # OpenOCD transport default. Alternative: jtag OPENOCD_TRANSPORT ?= hla_swd -ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T)) +ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T2T1)) MCU = STM32F4 OPENOCD_TARGET = target/stm32f4x.cfg LAYOUT_FEATURE = layout_bolt -else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),R)) +else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T2B1)) MCU = STM32F4 OPENOCD_TARGET = target/stm32f4x.cfg LAYOUT_FEATURE = layout_samson @@ -70,10 +70,10 @@ else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T3W1)) MCU = STM32U5 OPENOCD_TARGET = target/stm32u5x.cfg LAYOUT_FEATURE = layout_bolt -else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC1)) +else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),D001)) MCU = STM32F4 OPENOCD_TARGET = target/stm32f4x.cfg -else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),DISC2)) +else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),D002)) MCU = STM32U5 OPENOCD_TARGET = target/stm32u5x.cfg else diff --git a/core/SConscript.boardloader b/core/SConscript.boardloader index 1e87eb20df..02ff325811 100644 --- a/core/SConscript.boardloader +++ b/core/SConscript.boardloader @@ -3,10 +3,9 @@ import os import tools, models -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) HW_REVISION = ARGUMENTS.get('HW_REVISION', None) -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) FEATURES_WANTED = ["sd_card"] @@ -163,7 +162,7 @@ obj_program += env.Object(source=SOURCE_HAL) linkerscript_gen = env.Command( target='memory.ld', - source=[f'embed/models/{MODEL_IDENTIFIER}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='boardloader')], + source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='boardloader')], action='$CAT $SOURCES > $TARGET', ) @@ -176,7 +175,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) -BINARY_NAME = f"build/boardloader/boardloader-{models.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME = f"build/boardloader/boardloader-{TREZOR_MODEL}" BINARY_NAME += "-" + tools.get_version('embed/projects/boardloader/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index cba4646a7b..2d7b133856 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -4,12 +4,11 @@ import os import shlex import tools, models, ui -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) BOOTLOADER_QA = ARGUMENTS.get('BOOTLOADER_QA', '0') == '1' PRODUCTION = 0 if BOOTLOADER_QA else ARGUMENTS.get('PRODUCTION', '0') == '1' HW_REVISION = ARGUMENTS.get('HW_REVISION', None) -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) FEATURES_WANTED = ["input", "rgb_led", "consumption_mask", "usb", "optiga", "dma2d"] @@ -246,7 +245,7 @@ obj_program += env.Object(source=SOURCE_HAL) linkerscript_gen = env.Command( target='memory.ld', - source=[f'embed/models/{MODEL_IDENTIFIER}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='bootloader')], + source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='bootloader')], action='$CAT $SOURCES > $TARGET', ) @@ -262,7 +261,7 @@ env.Depends(program_elf, rust) SUFFIX = '_qa' if BOOTLOADER_QA else '' -BINARY_NAME = f"build/bootloader/bootloader-{models.get_model_identifier(TREZOR_MODEL)}{SUFFIX}" +BINARY_NAME = f"build/bootloader/bootloader-{TREZOR_MODEL}{SUFFIX}" BINARY_NAME += "-" + tools.get_version('embed/projects/bootloader/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" diff --git a/core/SConscript.bootloader_ci b/core/SConscript.bootloader_ci index 7cb2d65baa..7df885fdfb 100644 --- a/core/SConscript.bootloader_ci +++ b/core/SConscript.bootloader_ci @@ -3,10 +3,9 @@ import os import tools, models, ui -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) HW_REVISION = ARGUMENTS.get('HW_REVISION', None) -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) FEATURES_WANTED = ["input", "rgb_led", "consumption_mask", "usb", "optiga"] @@ -190,7 +189,7 @@ obj_program += env.Object(source=SOURCE_HAL) linkerscript_gen = env.Command( target='memory.ld', - source=[f'embed/models/{MODEL_IDENTIFIER}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='bootloader')], + source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='bootloader')], action='$CAT $SOURCES > $TARGET', ) @@ -203,7 +202,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) -BINARY_NAME = f"build/bootloader_ci/bootloader_ci-{models.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME = f"build/bootloader_ci/bootloader_ci-{TREZOR_MODEL}" BINARY_NAME += "-" + tools.get_version('embed/projects/bootloader_ci/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu index c86949e8b4..80669a5d85 100644 --- a/core/SConscript.bootloader_emu +++ b/core/SConscript.bootloader_emu @@ -4,7 +4,7 @@ import os import shlex import tools, models, ui -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) HW_REVISION = 'emulator' @@ -151,8 +151,7 @@ env.Replace( PYTHON='python', MAKECMAKELISTS='$PYTHON tools/make_cmakelists.py', ) -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) -MODEL_AS_NUMBER = str(models.get_hw_model_as_number(MODEL_IDENTIFIER)) +MODEL_AS_NUMBER = str(models.get_hw_model_as_number(TREZOR_MODEL)) ALLPATHS = ['embed/rust', 'embed/projects/bootloader', diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 74c3073415..ce0b3bcdfa 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -11,14 +11,13 @@ PRODUCTION = ARGUMENTS.get('PRODUCTION', '0') == '1' BOOTLOADER_QA = ARGUMENTS.get('BOOTLOADER_QA', '0') == '1' BOOTLOADER_DEVEL = ARGUMENTS.get('BOOTLOADER_DEVEL', '0') == '1' EVERYTHING = BITCOIN_ONLY != '1' -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) PYOPT = ARGUMENTS.get('PYOPT', '1') DISABLE_OPTIGA = ARGUMENTS.get('DISABLE_OPTIGA', '0') == '1' HW_REVISION = ARGUMENTS.get('HW_REVISION', None) SCM_REVISION = ARGUMENTS.get('SCM_REVISION', None) THP = ARGUMENTS.get('THP', '0') == '1' # Trezor-Host Protocol -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) BENCHMARK = ARGUMENTS.get('BENCHMARK', '0') == '1' DISABLE_ANIMATION = ARGUMENTS.get('TREZOR_DISABLE_ANIMATION', '0') == '1' @@ -79,8 +78,8 @@ CPPDEFINES_MOD += [ ('USE_ETHEREUM', '1' if EVERYTHING else '0'), ('USE_MONERO', '1' if EVERYTHING else '0'), ('USE_CARDANO', '1' if EVERYTHING else '0'), - ('USE_NEM', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), - ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), + ('USE_NEM', '1' if (EVERYTHING and TREZOR_MODEL == "T2T1") else '0'), + ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T2T1") else '0'), ('DISABLE_ANIMATION', '1' if DISABLE_ANIMATION else '0'), ] SOURCE_MOD += [ @@ -647,7 +646,7 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Cardano*.py')) - if TREZOR_MODEL == "T": + if TREZOR_MODEL == "T2T1": SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Eos*.py')) @@ -661,7 +660,7 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/DebugMonero*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Monero*.py')) - if TREZOR_MODEL == "T": + if TREZOR_MODEL == "T2T1": SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/NEM*.py')) @@ -684,7 +683,7 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py')) - if TREZOR_MODEL == "T": + if TREZOR_MODEL == "T2T1": SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/decred.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/bitcoinlike.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash_v4.py')) @@ -807,8 +806,7 @@ env.Append(LINKFLAGS=f' -L{RUST_LIBDIR}') env.Append(LINKFLAGS=f' -l{RUST_LIB}') -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) -BOOTLOADER_SUFFIX = MODEL_IDENTIFIER +BOOTLOADER_SUFFIX = TREZOR_MODEL if BOOTLOADER_QA or BOOTLOADER_DEVEL: BOOTLOADER_SUFFIX += '_qa' @@ -818,14 +816,14 @@ if BOOTLOADER_QA or BOOTLOADER_DEVEL: elif not PRODUCTION: vendor = "unsafe_signed_prod" else: - if TREZOR_MODEL in ('T',): + if TREZOR_MODEL in ('T2T1',): vendor = "satoshilabs_signed_prod" elif BITCOIN_ONLY == '1': vendor = "trezor_btconly_signed_prod" else: vendor = "trezor_signed_prod" -VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/vendorheader_{vendor}.bin' +VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/vendorheader_{vendor}.bin' tools.embed_raw_binary( obj_program, @@ -849,7 +847,7 @@ env.Depends(obj_program, qstr_generated) linkerscript_gen = env.Command( target='memory.ld', - source=[f'embed/models/{MODEL_IDENTIFIER}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='firmware')], + source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='firmware')], action='$CAT $SOURCES > $TARGET', ) @@ -866,7 +864,7 @@ if CMAKELISTS != 0: env.Depends(program_elf, cmake_gen) env.Depends(program_elf, rust) -BINARY_NAME = f"build/firmware/firmware-{MODEL_IDENTIFIER}" +BINARY_NAME = f"build/firmware/firmware-{TREZOR_MODEL}" if not EVERYTHING: BINARY_NAME += "-btconly" BINARY_NAME += "-" + tools.get_version('embed/projects/firmware/version.h') diff --git a/core/SConscript.kernel b/core/SConscript.kernel index 232052785e..5681544943 100644 --- a/core/SConscript.kernel +++ b/core/SConscript.kernel @@ -9,7 +9,7 @@ PRODUCTION = ARGUMENTS.get('PRODUCTION', '0') == '1' BOOTLOADER_QA = ARGUMENTS.get('BOOTLOADER_QA', '0') == '1' BOOTLOADER_DEVEL = ARGUMENTS.get('BOOTLOADER_DEVEL', '0') == '1' EVERYTHING = BITCOIN_ONLY != '1' -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) PYOPT = ARGUMENTS.get('PYOPT', '1') DISABLE_OPTIGA = ARGUMENTS.get('DISABLE_OPTIGA', '0') == '1' @@ -77,8 +77,8 @@ CPPDEFINES_MOD += [ ('USE_ETHEREUM', '1' if EVERYTHING else '0'), ('USE_MONERO', '1' if EVERYTHING else '0'), ('USE_CARDANO', '1' if EVERYTHING else '0'), - ('USE_NEM', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), - ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), + ('USE_NEM', '1' if (EVERYTHING and TREZOR_MODEL == "T2T1") else '0'), + ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T2T1") else '0'), ] SOURCE_MOD_CRYPTO += [ 'vendor/trezor-crypto/address.c', @@ -354,8 +354,7 @@ cmake_gen = env.Command( action='$MAKECMAKELISTS --sources $ALLSOURCES --dirs $CPPPATH --defs $ALLDEFS', ) -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) -BOOTLOADER_SUFFIX = MODEL_IDENTIFIER +BOOTLOADER_SUFFIX = TREZOR_MODEL if BOOTLOADER_QA: BOOTLOADER_SUFFIX += '_qa' @@ -365,14 +364,14 @@ if BOOTLOADER_QA or BOOTLOADER_DEVEL: elif not PRODUCTION: vendor = "unsafe_signed_prod" else: - if TREZOR_MODEL in ('T',): + if TREZOR_MODEL in ('T2T1',): vendor = "satoshilabs_signed_prod" elif BITCOIN_ONLY == '1': vendor = "trezor_btconly_signed_prod" else: vendor = "trezor_signed_prod" -VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/vendorheader_{vendor}.bin' +VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/vendorheader_{vendor}.bin' obj_program.extend( @@ -388,14 +387,14 @@ tools.embed_compressed_binary( env, 'bootloader', 'embed/projects/bootloaders/bootloader.o', - f'embed/models/{MODEL_IDENTIFIER}/bootloaders/bootloader_{BOOTLOADER_SUFFIX}.bin', + f'embed/models/{TREZOR_MODEL}/bootloaders/bootloader_{BOOTLOADER_SUFFIX}.bin', 'kernel', 'bootloader', ) linkerscript_gen = env.Command( target='memory.ld', - source=[f'embed/models/{MODEL_IDENTIFIER}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='kernel')], + source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='kernel')], action='$CAT $SOURCES > $TARGET', ) @@ -411,7 +410,7 @@ env.Depends(program_elf, linkerscript_gen) if CMAKELISTS != 0: env.Depends(program_elf, cmake_gen) -BINARY_NAME = f"build/kernel/kernel-{models.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME = f"build/kernel/kernel-{TREZOR_MODEL}" if not EVERYTHING: BINARY_NAME += "-btconly" BINARY_NAME += "-" + tools.get_version('embed/projects/kernel/version.h') diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest index 0541d8178c..ddce05f152 100644 --- a/core/SConscript.prodtest +++ b/core/SConscript.prodtest @@ -3,7 +3,7 @@ import os import tools, models, ui -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) PRODUCTION = ARGUMENTS.get('PRODUCTION', '0') == '1' BOOTLOADER_DEVEL = ARGUMENTS.get('BOOTLOADER_DEVEL', '0') == '1' @@ -185,8 +185,6 @@ obj_program.extend(env.Object(source=SOURCE_MOD_CRYPTO, CCFLAGS='$CCFLAGS -ftriv obj_program.extend(env.Object(source=SOURCE_PRODTEST)) obj_program.extend(env.Object(source=SOURCE_HAL)) -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) - if (vh := ARGUMENTS.get("VENDOR_HEADER", None)): VENDORHEADER = vh @@ -195,13 +193,13 @@ elif (vh := os.environ.get("VENDOR_HEADER", None)): # of vendor header which does not affect reproducibility of the build. Nonetheless, # we should figure out a cleaner way to pass in this argument, without having to teach # the Makefile about it. - VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/{vh}' + VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/{vh}' elif PRODUCTION: - VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/vendorheader_prodtest_signed_prod.bin' + VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/vendorheader_prodtest_signed_prod.bin' elif BOOTLOADER_DEVEL: - VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/vendorheader_dev_DO_NOT_SIGN_signed_dev.bin' + VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/vendorheader_dev_DO_NOT_SIGN_signed_dev.bin' else: - VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/vendorheader_unsafe_signed_prod.bin' + VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/vendorheader_unsafe_signed_prod.bin' tools.embed_raw_binary( @@ -214,7 +212,7 @@ tools.embed_raw_binary( linkerscript_gen = env.Command( target='memory.ld', - source=[f'embed/models/{MODEL_IDENTIFIER}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='prodtest')], + source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='prodtest')], action='$CAT $SOURCES > $TARGET', ) @@ -227,7 +225,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) -BINARY_NAME = f"build/prodtest/prodtest-{models.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME = f"build/prodtest/prodtest-{TREZOR_MODEL}" BINARY_NAME += "-" + tools.get_version('embed/projects/prodtest/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" diff --git a/core/SConscript.reflash b/core/SConscript.reflash index 4d0ad53ff1..464bf18650 100644 --- a/core/SConscript.reflash +++ b/core/SConscript.reflash @@ -3,11 +3,11 @@ import os import tools, models, ui -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) HW_REVISION = ARGUMENTS.get('HW_REVISION', None) -if TREZOR_MODEL in ('DISC1', 'DISC2'): +if TREZOR_MODEL in ('D001', 'D002'): # skip reflash build env = Environment() def build_reflash(target,source,env): @@ -160,9 +160,7 @@ obj_program += env.Object(source=SOURCE_MOD_CRYPTO, CCFLAGS='$CCFLAGS -ftrivial- obj_program += env.Object(source=SOURCE_REFLASH) obj_program += env.Object(source=SOURCE_HAL) -MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL) - -VENDORHEADER = f'embed/models/{MODEL_IDENTIFIER}/vendorheader/vendorheader_' + ('unsafe_signed_dev.bin' if ARGUMENTS.get('PRODUCTION', '0') == '0' else 'satoshilabs_signed_prod.bin') +VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/vendorheader_' + ('unsafe_signed_dev.bin' if ARGUMENTS.get('PRODUCTION', '0') == '0' else 'satoshilabs_signed_prod.bin') tools.embed_raw_binary( obj_program, @@ -174,7 +172,7 @@ tools.embed_raw_binary( linkerscript_gen = env.Command( target='memory.ld', - source=[f'embed/models/{MODEL_IDENTIFIER}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='prodtest')], + source=[f'embed/models/{TREZOR_MODEL}/memory.ld', env.get('ENV')['LINKER_SCRIPT'].format(target='prodtest')], action='$CAT $SOURCES > $TARGET', ) @@ -187,7 +185,7 @@ program_elf = env.Command( env.Depends(program_elf, linkerscript_gen) -BINARY_NAME = f"build/reflash/reflash-{models.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME = f"build/reflash/reflash-{TREZOR_MODEL}" BINARY_NAME += "-" + tools.get_version('embed/projects/reflash/version.h') BINARY_NAME += "-" + tools.get_git_revision_short_hash() BINARY_NAME += "-dirty" if tools.get_git_modified() else "" diff --git a/core/SConscript.unix b/core/SConscript.unix index e4f1ca56b0..6b0fd17ff8 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -7,7 +7,7 @@ import tools, models, ui BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0') EVERYTHING = BITCOIN_ONLY != '1' -TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') +TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) HW_REVISION ='emulator' THP = ARGUMENTS.get('THP', '0') == '1' # Trezor-Host Protocol @@ -78,8 +78,8 @@ CPPDEFINES_MOD += [ ('USE_ETHEREUM', '1' if EVERYTHING else '0'), ('USE_MONERO', '1' if EVERYTHING else '0'), ('USE_CARDANO', '1' if EVERYTHING else '0'), - ('USE_NEM', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), - ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T") else '0'), + ('USE_NEM', '1' if (EVERYTHING and TREZOR_MODEL == "T2T1") else '0'), + ('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL == "T2T1") else '0'), ] SOURCE_MOD += [ 'embed/upymod/trezorobj.c', @@ -703,7 +703,7 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Cardano*.py')) - if TREZOR_MODEL == "T": + if TREZOR_MODEL == "T2T1": SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Eos*.py')) @@ -717,7 +717,7 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/DebugMonero*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Monero*.py')) - if TREZOR_MODEL == "T": + if TREZOR_MODEL == "T2T1": SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/NEM*.py')) @@ -741,7 +741,7 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py')) - if TREZOR_MODEL == "T": + if TREZOR_MODEL == "T2T1": SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/decred.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/bitcoinlike.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash_v4.py')) diff --git a/core/embed/io/display/backlight/stm32/backlight_pwm.c b/core/embed/io/display/backlight/stm32/backlight_pwm.c index 5670e5b432..8aeb40eb79 100644 --- a/core/embed/io/display/backlight/stm32/backlight_pwm.c +++ b/core/embed/io/display/backlight/stm32/backlight_pwm.c @@ -196,7 +196,7 @@ void backlight_pwm_deinit(backlight_action_t action) { return; } -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 // This code is for backward compatibility with the older // bootloader/firmware on model T that used different // PWM settings and relies on proper settings from the diff --git a/core/embed/io/display/st-7789/display_driver.c b/core/embed/io/display/st-7789/display_driver.c index c8165a727f..967e8d29b6 100644 --- a/core/embed/io/display/st-7789/display_driver.c +++ b/core/embed/io/display/st-7789/display_driver.c @@ -108,7 +108,7 @@ void display_deinit(display_content_mode_t mode) { backlight_pwm_deinit(mode == DISPLAY_RESET_CONTENT ? BACKLIGHT_RESET : BACKLIGHT_RETAIN); -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 // This ensures backward compatibility with legacy bootloader/firmware // that relies on this hardware settings from the previous boot stage if (mode == DISPLAY_RESET_CONTENT) { diff --git a/core/embed/io/display/st-7789/display_panel.c b/core/embed/io/display/st-7789/display_panel.c index 50466e8c2a..51dbfe9a56 100644 --- a/core/embed/io/display/st-7789/display_panel.c +++ b/core/embed/io/display/st-7789/display_panel.c @@ -25,7 +25,7 @@ #include "display_panel.h" #include "display_io.h" -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 #include "panels/154a.h" #include "panels/lx154a2411.h" #include "panels/lx154a2422.h" @@ -211,7 +211,7 @@ void display_panel_init(void) { HAL_Delay(120); // identify the controller we will communicate with -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 uint32_t id = display_panel_identify(); if (id == DISPLAY_ID_GC9307) { tf15411a_init_seq(); @@ -234,7 +234,7 @@ void display_panel_init(void) { void display_panel_reinit(void) { // reinitialization is needed due to original sequence is unchangable in // boardloader -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 // model TT has new gamma settings uint32_t id = display_panel_identify(); if (id == DISPLAY_ID_ST7789V && display_panel_is_inverted()) { @@ -243,14 +243,14 @@ void display_panel_reinit(void) { } else if (id == DISPLAY_ID_ST7789V) { lx154a2411_gamma(); } -#elif defined TREZOR_MODEL_T3T1 +#elif defined TREZOR_MODEL_T2T13T1 // reduced touch-display interference in T3T1 lx154a2482_init_seq(); #endif } void display_panel_rotate(int angle) { -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 uint32_t id = display_panel_identify(); if (id == DISPLAY_ID_GC9307) { tf15411a_rotate(angle, &g_window_padding); diff --git a/core/embed/models/model_version.h b/core/embed/models/model_version.h index 25c1552a0a..75836fa985 100644 --- a/core/embed/models/model_version.h +++ b/core/embed/models/model_version.h @@ -1,9 +1,9 @@ #ifndef MODELS_MODEL_H_ #define MODELS_MODEL_H_ -#if defined TREZOR_MODEL_T +#if defined TREZOR_MODEL_T2T1 #include "T2T1/versions.h" -#elif defined TREZOR_MODEL_R +#elif defined TREZOR_MODEL_T2B1 #include "T2B1/versions.h" #elif defined TREZOR_MODEL_T3T1 #include "T3T1/versions.h" @@ -11,9 +11,9 @@ #include "T3B1/versions.h" #elif defined TREZOR_MODEL_T3W1 #include "T3W1/versions.h" -#elif defined TREZOR_MODEL_DISC1 +#elif defined TREZOR_MODEL_D001 #include "D001/versions.h" -#elif defined TREZOR_MODEL_DISC2 +#elif defined TREZOR_MODEL_D002 #include "D002/versions.h" #else #error Unknown Trezor model diff --git a/core/embed/models/trezor_model.h b/core/embed/models/trezor_model.h index ac2ea0ea89..16c9c9b31d 100644 --- a/core/embed/models/trezor_model.h +++ b/core/embed/models/trezor_model.h @@ -4,9 +4,9 @@ #include #include "otp_layout.h" -#if defined TREZOR_MODEL_T +#if defined TREZOR_MODEL_T2T1 #include "T2T1/model_T2T1.h" -#elif defined TREZOR_MODEL_R +#elif defined TREZOR_MODEL_T2B1 #include "T2B1/model_T2B1.h" #elif defined TREZOR_MODEL_T3T1 #include "T3T1/model_T3T1.h" @@ -14,9 +14,9 @@ #include "T3B1/model_T3B1.h" #elif defined TREZOR_MODEL_T3W1 #include "T3W1/model_T3W1.h" -#elif defined TREZOR_MODEL_DISC1 +#elif defined TREZOR_MODEL_D001 #include "D001/model_D001.h" -#elif defined TREZOR_MODEL_DISC2 +#elif defined TREZOR_MODEL_D002 #include "D002/model_D002.h" #else #error Unknown Trezor model diff --git a/core/embed/projects/bootloader/bootui.c b/core/embed/projects/bootloader/bootui.c index 3ce2d26f72..45a71055d3 100644 --- a/core/embed/projects/bootloader/bootui.c +++ b/core/embed/projects/bootloader/bootui.c @@ -44,7 +44,7 @@ #define COLOR_BL_GRAY COLOR_BL_FG #endif -#if !defined TREZOR_MODEL_R && !defined TREZOR_MODEL_T3B1 +#if !defined TREZOR_MODEL_T2B1 && !defined TREZOR_MODEL_T3B1 #define BOOT_WAIT_HEIGHT 25 #define BOOT_WAIT_Y_TOP (DISPLAY_RESY - BOOT_WAIT_HEIGHT) #else diff --git a/core/embed/projects/bootloader/header.S b/core/embed/projects/bootloader/header.S index 8945f4cd29..29f9a9fde4 100644 --- a/core/embed/projects/bootloader/header.S +++ b/core/embed/projects/bootloader/header.S @@ -10,7 +10,7 @@ g_header: .byte 'T','R','Z','B' // magic .word g_header_end - g_header // hdrlen -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 .word 0 // expiry #else .word 1 // expiry diff --git a/core/embed/projects/bootloader_ci/header.S b/core/embed/projects/bootloader_ci/header.S index 8945f4cd29..29f9a9fde4 100644 --- a/core/embed/projects/bootloader_ci/header.S +++ b/core/embed/projects/bootloader_ci/header.S @@ -10,7 +10,7 @@ g_header: .byte 'T','R','Z','B' // magic .word g_header_end - g_header // hdrlen -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 .word 0 // expiry #else .word 1 // expiry diff --git a/core/embed/projects/firmware/header.S b/core/embed/projects/firmware/header.S index 03341ba6f9..18938da682 100644 --- a/core/embed/projects/firmware/header.S +++ b/core/embed/projects/firmware/header.S @@ -13,7 +13,7 @@ g_header: .byte 'T','R','Z','F' // magic .word g_header_end - g_header // hdrlen -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 .word 0 // expiry #else .word 1 // expiry diff --git a/core/embed/projects/prodtest/header.S b/core/embed/projects/prodtest/header.S index 2c101aa43c..e41f02e8d2 100644 --- a/core/embed/projects/prodtest/header.S +++ b/core/embed/projects/prodtest/header.S @@ -10,7 +10,7 @@ g_header: .byte 'T','R','Z','F' // magic .word g_header_end - g_header // hdrlen -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 .word 0 // expiry #else .word 1 // expiry diff --git a/core/embed/projects/prodtest/main.c b/core/embed/projects/prodtest/main.c index 55e5bacb9a..27f6d39e64 100644 --- a/core/embed/projects/prodtest/main.c +++ b/core/embed/projects/prodtest/main.c @@ -97,7 +97,7 @@ #include "stm32f4xx_ll_utils.h" #endif -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 #define MODEL_IDENTIFIER "TREZOR2-" #else #define MODEL_IDENTIFIER MODEL_INTERNAL_NAME "-" @@ -236,7 +236,7 @@ static void draw_border(int width, int padding) { } static void draw_welcome_screen(void) { -#if defined TREZOR_MODEL_R || defined TREZOR_MODEL_T3B1 +#if defined TREZOR_MODEL_T2B1 || defined TREZOR_MODEL_T3B1 gfx_draw_bar(gfx_rect_wh(0, 0, DISPLAY_RESX, DISPLAY_RESY), COLOR_WHITE); display_refresh(); #else diff --git a/core/embed/projects/reflash/header.S b/core/embed/projects/reflash/header.S index 2c101aa43c..e41f02e8d2 100644 --- a/core/embed/projects/reflash/header.S +++ b/core/embed/projects/reflash/header.S @@ -10,7 +10,7 @@ g_header: .byte 'T','R','Z','F' // magic .word g_header_end - g_header // hdrlen -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 .word 0 // expiry #else .word 1 // expiry diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index 6a5501861d..5e2f37585c 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -56,7 +56,7 @@ const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[ #[cfg(feature = "layout_bolt")] const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[ "-DSTM32F427", - "-DTREZOR_MODEL_T", + "-DTREZOR_MODEL_T2T1", "-DFLASH_BIT_ACCESS=1", "-DFLASH_BLOCK_WORDS=1", "-DDISPLAY_RESX=240", @@ -69,7 +69,7 @@ const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[]; #[cfg(feature = "layout_samson")] const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[ "-DSTM32F427", - "-DTREZOR_MODEL_R", + "-DTREZOR_MODEL_T2B1", "-DFLASH_BIT_ACCESS=1", "-DFLASH_BLOCK_WORDS=1", "-DDISPLAY_RESX=128", diff --git a/core/embed/sec/optiga/unix/optiga.c b/core/embed/sec/optiga/unix/optiga.c index 33ca8c2528..069c2a3e8f 100644 --- a/core/embed/sec/optiga/unix/optiga.c +++ b/core/embed/sec/optiga/unix/optiga.c @@ -26,7 +26,7 @@ #include "rand.h" #include "storage.h" -#if defined(TREZOR_MODEL_R) +#if defined(TREZOR_MODEL_T2B1) #include "certs/T2B1.h" #define DEVICE_CERT_CHAIN T2B1_der #elif defined(TREZOR_MODEL_T3T1) diff --git a/core/embed/sys/mpu/stm32f4/mpu.c b/core/embed/sys/mpu/stm32f4/mpu.c index 8eef94c661..1760054906 100644 --- a/core/embed/sys/mpu/stm32f4/mpu.c +++ b/core/embed/sys/mpu/stm32f4/mpu.c @@ -340,7 +340,7 @@ mpu_mode_t mpu_reconfig(mpu_mode_t mode) { // clang-format off switch (mode) { -#ifdef TREZOR_MODEL_DISC1 +#ifdef TREZOR_MODEL_D001 default: // All Peripherals (Unprivileged, Read-Write, Non-Executable) // SDRAM diff --git a/core/embed/sys/startup/stm32/bootutils.c b/core/embed/sys/startup/stm32/bootutils.c index ec1e85045b..1b69858749 100644 --- a/core/embed/sys/startup/stm32/bootutils.c +++ b/core/embed/sys/startup/stm32/bootutils.c @@ -28,7 +28,7 @@ #include #include -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 #include "../stm32f4/startup_init.h" #endif @@ -212,7 +212,7 @@ void __attribute__((noreturn)) secure_shutdown(void) { } void ensure_compatible_settings(void) { -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 // Early version of bootloader on T2T1 expects 168 MHz core clock. // So we need to set it here before handover to the bootloader. set_core_clock(CLOCK_168_MHZ); diff --git a/core/embed/sys/startup/stm32f4/startup_init.c b/core/embed/sys/startup/stm32f4/startup_init.c index c927df183e..52634a030f 100644 --- a/core/embed/sys/startup/stm32f4/startup_init.c +++ b/core/embed/sys/startup/stm32f4/startup_init.c @@ -52,7 +52,7 @@ typedef struct { #endif #if defined STM32F427xx || defined STM32F429xx -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 #define DEFAULT_FREQ 168U #define DEFAULT_PLLQ 7U #define DEFAULT_PLLP 0U // P = 2 (two bits, 00 means PLLP = 2) @@ -183,7 +183,7 @@ void SystemInit(void) { __HAL_RCC_GPIOD_CLK_ENABLE(); } -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 void set_core_clock(clock_settings_t settings) { /* Enable HSI clock */ RCC->CR |= RCC_CR_HSION; diff --git a/core/embed/sys/startup/stm32f4/startup_init.h b/core/embed/sys/startup/stm32f4/startup_init.h index 97d13a9760..bc5af73121 100644 --- a/core/embed/sys/startup/stm32f4/startup_init.h +++ b/core/embed/sys/startup/stm32f4/startup_init.h @@ -20,7 +20,7 @@ #ifndef TREZORHAL_STM32F4_STARTUP_INIT_H #define TREZORHAL_STM32F4_STARTUP_INIT_H -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 typedef enum { CLOCK_180_MHZ = 0, diff --git a/core/embed/sys/task/stm32/system.c b/core/embed/sys/task/stm32/system.c index 1bf6f4072b..a9a2b212c4 100644 --- a/core/embed/sys/task/stm32/system.c +++ b/core/embed/sys/task/stm32/system.c @@ -31,7 +31,7 @@ #include #endif -#if defined(TREZOR_MODEL_T) && (!defined(BOARDLOADER)) +#if defined(TREZOR_MODEL_T2T1) && (!defined(BOARDLOADER)) #include "../stm32f4/startup_init.h" #endif @@ -42,7 +42,7 @@ #ifdef KERNEL_MODE void system_init(systask_error_handler_t error_handler) { -#if defined(TREZOR_MODEL_T) && (!defined(BOARDLOADER)) +#if defined(TREZOR_MODEL_T2T1) && (!defined(BOARDLOADER)) // Early boardloader versions on Model T initialized the CPU clock to 168MHz. // We need to set it to the STM32F429's maximum - 180MHz. set_core_clock(CLOCK_180_MHZ); diff --git a/core/embed/util/image/image.c b/core/embed/util/image/image.c index df20fd4824..553d8ae256 100644 --- a/core/embed/util/image/image.c +++ b/core/embed/util/image/image.c @@ -96,7 +96,7 @@ const image_header *read_image_header(const uint8_t *const data, secbool check_image_model(const image_header *const hdr) { // abusing expiry field to break compatibility of non-TT images with existing // bootloaders/boardloaders -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 if (hdr->expiry == 0 && hdr->hw_model == 0 && hdr->hw_revision == 0) { // images for model TT older than this check return sectrue; @@ -195,7 +195,7 @@ secbool __wur read_vendor_header(const uint8_t *const data, } secbool check_vendor_header_model(const vendor_header *const vhdr) { -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 if (vhdr->hw_model == 0) { // vendor headers for model T have this field set to 0 return sectrue; diff --git a/core/embed/util/unit_properties/stm32/unit_properties.c b/core/embed/util/unit_properties/stm32/unit_properties.c index 527c48ce6b..6457267449 100644 --- a/core/embed/util/unit_properties/stm32/unit_properties.c +++ b/core/embed/util/unit_properties/stm32/unit_properties.c @@ -40,7 +40,7 @@ static unit_properties_driver_t g_unit_properties_driver = { .initialized = false, }; -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 // Parse two digit number from the string. // @@ -83,7 +83,7 @@ static bool get_production_date(int* year) { return true; } -#endif // TREZOR_MODEL_T +#endif // TREZOR_MODEL_T2T1 // Reads and parses the unit properties from the OTP block. // @@ -120,7 +120,7 @@ static bool detect_properties(unit_properties_t* props) { } props->sd_hotswap_enabled = true; -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 // Early produced TTs have a HW bug that prevents hotswapping of the SD card, // lets check the build data and decide based on that. int production_year; diff --git a/core/embed/util/unit_properties/unix/unit_properties.c b/core/embed/util/unit_properties/unix/unit_properties.c index c2de25732e..c6585d2b56 100644 --- a/core/embed/util/unit_properties/unix/unit_properties.c +++ b/core/embed/util/unit_properties/unix/unit_properties.c @@ -47,7 +47,7 @@ bool unit_properties_init(void) { memset(drv, 0, sizeof(unit_properties_driver_t)); drv->cache.sd_hotswap_enabled = true; -#ifdef TREZOR_MODEL_T +#ifdef TREZOR_MODEL_T2T1 drv->cache.sd_hotswap_enabled = false; #endif diff --git a/core/site_scons/models/__init__.py b/core/site_scons/models/__init__.py index c239f33638..5f4ec56043 100644 --- a/core/site_scons/models/__init__.py +++ b/core/site_scons/models/__init__.py @@ -17,39 +17,22 @@ def configure_board( sources: list[str], paths: list[str], ) -> list[str]: - imported_module = importlib.import_module("models." + get_model_identifier(model)) + imported_module = importlib.import_module(f"models.{model}") return imported_module.configure_board( revision, features_wanted, env, defines, sources, paths ) -def get_model_identifier(model: str) -> str: - if model == "T": - return "T2T1" - elif model == "R": - return "T2B1" - elif model == "T3T1": - return "T3T1" - elif model == "T3B1": - return "T3B1" - elif model == "DISC1": - return "D001" - elif model == "DISC2": - return "D002" - else: - return model - - def has_emulator(model: str) -> bool: - imported_module = importlib.import_module("models." + get_model_identifier(model)) + imported_module = importlib.import_module(f"models.{model}") return hasattr(imported_module, "emulator") def get_model_ui(model: str) -> str: - imported_module = importlib.import_module("models." + get_model_identifier(model)) + imported_module = importlib.import_module(f"models.{model}") return imported_module.get_model_ui() def get_model_ui_conf(model: str) -> str: - imported_module = importlib.import_module("models." + get_model_identifier(model)) + imported_module = importlib.import_module(f"models.{model}") return imported_module.get_model_ui_conf() diff --git a/core/site_scons/site_tools/micropython/__init__.py b/core/site_scons/site_tools/micropython/__init__.py index 7c3997b34a..dad5f0f260 100644 --- a/core/site_scons/site_tools/micropython/__init__.py +++ b/core/site_scons/site_tools/micropython/__init__.py @@ -67,14 +67,10 @@ def generate(env): r"-e 's/from typing import/# \0/'", ] - MODEL_SYMS = { - "T": "T2T1", - "R": "T2B1", - "T3T1": "T3T1", - } + MODELS = ["T2T1", "T2B1", "T3T1", "T3B1", "T3W1"] - for model_sym, internal_model in MODEL_SYMS.items(): - model_matches = env["TREZOR_MODEL"] == model_sym + for internal_model in MODELS: + model_matches = env["TREZOR_MODEL"] == internal_model sed_scripts.extend( ( rf"-e 's/utils\.INTERNAL_MODEL == \"{internal_model}\"/{model_matches}/g'", diff --git a/core/tests/test_trezor.utils.py b/core/tests/test_trezor.utils.py index ce3ff1c307..c5196efdf8 100644 --- a/core/tests/test_trezor.utils.py +++ b/core/tests/test_trezor.utils.py @@ -55,7 +55,7 @@ class TestUtils(unittest.TestCase): def test_firmware_hash(self): if utils.INTERNAL_MODEL in ( # pylint: disable=internal-model-tuple-comparison - "DISC2", + "D002", "T3W1", ): self.assertEqual( diff --git a/core/tools/trezor_core_tools/common.py b/core/tools/trezor_core_tools/common.py index 74fdb6f634..824d801d21 100644 --- a/core/tools/trezor_core_tools/common.py +++ b/core/tools/trezor_core_tools/common.py @@ -7,19 +7,9 @@ CORE = HERE.parent.parent MODELS_DIR = CORE / "embed" / "models" -MODELS_DICT = { - "1": "T1B1", - "T": "T2T1", - "R": "T2B1", - "DISC1": "D001", - "DISC2": "D002", -} - def get_layout_for_model(model: str) -> Path: - model = MODELS_DICT.get(model, model) return MODELS_DIR / model / f"model_{model}.h" def get_linkerscript_for_model(model: str) -> Path: - model = MODELS_DICT.get(model, model) return MODELS_DIR / model / f"memory.ld" diff --git a/docs/core/build/emulator.md b/docs/core/build/emulator.md index 8803daf028..28e04168f0 100644 --- a/docs/core/build/emulator.md +++ b/docs/core/build/emulator.md @@ -79,7 +79,7 @@ Run the build with: ```sh make build_unix # default -make build_unix TREZOR_MODEL=R # different model +make build_unix TREZOR_MODEL=T2B1 # different model ``` ## Run diff --git a/docs/core/embed_debug/index.md b/docs/core/embed_debug/index.md index 1091ccf691..b3a681f527 100644 --- a/docs/core/embed_debug/index.md +++ b/docs/core/embed_debug/index.md @@ -166,8 +166,8 @@ stm32lib): -DSTM32_HAL_H= - -DTREZOR_MODEL=T - -DTREZOR_MODEL_T=1 + -DTREZOR_MODEL=T2T1 + -DTREZOR_MODEL_T2T1=1 -DSTM32F427xx -DUSE_HAL_DRIVER -DSTM32_HAL_H="" diff --git a/storage/tests/c/Makefile b/storage/tests/c/Makefile index 8217c7ebb9..0349e9e91b 100644 --- a/storage/tests/c/Makefile +++ b/storage/tests/c/Makefile @@ -3,7 +3,7 @@ CC = cc CFLAGS = -Wall -Wshadow -Wextra -Wpedantic -Werror -Wno-missing-braces CFLAGS += -fPIC CFALGS += -fsanitize=address,undefined -CFLAGS += -DTREZOR_MODEL_T +CFLAGS += -DTREZOR_MODEL_T2T1 CFLAGS += -DTREZOR_EMULATOR CFLAGS += -DUSE_INSECURE_PRNG CFLAGS += -DCONFIDENTIAL="" diff --git a/storage/tests/c/norcow_config.h b/storage/tests/c/norcow_config.h index e850c8fdc9..04792c335d 100644 --- a/storage/tests/c/norcow_config.h +++ b/storage/tests/c/norcow_config.h @@ -30,7 +30,7 @@ * The length of the sector header in bytes. The header is preserved between * sector erasures. */ -#if defined TREZOR_MODEL_T +#if defined TREZOR_MODEL_T2T1 #define NORCOW_HEADER_LEN 0 #elif defined TREZOR_MODEL_1 #define NORCOW_HEADER_LEN (0x100) diff --git a/storage/tests/c3/Makefile b/storage/tests/c3/Makefile index 706a08b48e..0be336768b 100644 --- a/storage/tests/c3/Makefile +++ b/storage/tests/c3/Makefile @@ -3,7 +3,7 @@ CC = cc CFLAGS = -Wall -Wshadow -Wextra -Wpedantic -Werror -Wno-missing-braces CFLAGS += -fPIC CFALGS += -fsanitize=address,undefined -CFLAGS += -DTREZOR_MODEL_T +CFLAGS += -DTREZOR_MODEL_T2T1 CFLAGS += -DUSE_INSECURE_PRNG LIBS = diff --git a/storage/tests/c3/norcow_config.h b/storage/tests/c3/norcow_config.h index ea72a11157..2a00316fed 100644 --- a/storage/tests/c3/norcow_config.h +++ b/storage/tests/c3/norcow_config.h @@ -29,7 +29,7 @@ * The length of the sector header in bytes. The header is preserved between * sector erasures. */ -#if defined TREZOR_MODEL_T +#if defined TREZOR_MODEL_T2T1 #define NORCOW_HEADER_LEN 0 #elif defined TREZOR_MODEL_1 #define NORCOW_HEADER_LEN (0x100)