diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 08686cd8dc..297ffceba3 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -133,13 +133,13 @@ jobs: strategy: fail-fast: false matrix: - model: ["1", T2T1, T2B1, 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 }} --targets bootloader,firmware,prodtest ${{ 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: | echo "model **${{ matrix.model }}** commit \`${{ github.sha }}\` (fingerprint, sha256)" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index 01f75e5c76..1fa688c8c8 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 == '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' }} diff --git a/build-docker.sh b/build-docker.sh index eb1fce6f8e..7d095092e6 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -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 85536cb55c..b0446bea2e 100644 --- a/core/Makefile +++ b/core/Makefile @@ -70,10 +70,10 @@ else ifeq ($(TREZOR_MODEL),$(filter $(TREZOR_MODEL),T3W1)) MCU = STM32U5 OPENOCD_TARGET = target/stm32u5x.cfg MODEL_FEATURE = model_ford -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 01f23cdc67..fa6062f124 100644 --- a/core/SConscript.boardloader +++ b/core/SConscript.boardloader @@ -6,7 +6,6 @@ import tools, models 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', ) diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index b1e7792089..441e076918 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -9,7 +9,6 @@ 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', ) diff --git a/core/SConscript.bootloader_ci b/core/SConscript.bootloader_ci index 4246c78cff..8bec9cea29 100644 --- a/core/SConscript.bootloader_ci +++ b/core/SConscript.bootloader_ci @@ -6,7 +6,6 @@ import tools, models, ui 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', ) diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu index 5371e6e8d7..80669a5d85 100644 --- a/core/SConscript.bootloader_emu +++ b/core/SConscript.bootloader_emu @@ -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 c7aba98c7f..ce0b3bcdfa 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -18,7 +18,6 @@ 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) # TODO normalize always BENCHMARK = ARGUMENTS.get('BENCHMARK', '0') == '1' DISABLE_ANIMATION = ARGUMENTS.get('TREZOR_DISABLE_ANIMATION', '0') == '1' @@ -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' @@ -825,7 +823,7 @@ else: 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 fef19dc36c..130236cb65 100644 --- a/core/SConscript.kernel +++ b/core/SConscript.kernel @@ -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' @@ -372,7 +371,7 @@ else: 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', ) diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest index 70a005fb94..c398e6bb2c 100644 --- a/core/SConscript.prodtest +++ b/core/SConscript.prodtest @@ -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', ) diff --git a/core/SConscript.reflash b/core/SConscript.reflash index 2e2003c2b3..041221d203 100644 --- a/core/SConscript.reflash +++ b/core/SConscript.reflash @@ -7,7 +7,7 @@ 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', ) diff --git a/core/embed/models/model_version.h b/core/embed/models/model_version.h index 072e4e2ded..75836fa985 100644 --- a/core/embed/models/model_version.h +++ b/core/embed/models/model_version.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 f8e04cf6e8..16c9c9b31d 100644 --- a/core/embed/models/trezor_model.h +++ b/core/embed/models/trezor_model.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/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/site_scons/models/__init__.py b/core/site_scons/models/__init__.py index 32e5fa9f60..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" or model == "T2T1": - return "T2T1" - elif model == "R" or model == "T2B1": - 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 62971d1b03..f954b09aae 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/src/apps/common/coininfo.py b/core/src/apps/common/coininfo.py index 602f2ada3f..82fa6c70c5 100644 --- a/core/src/apps/common/coininfo.py +++ b/core/src/apps/common/coininfo.py @@ -7040,4 +7040,5 @@ def by_name(name: str) -> CoinInfo: None, # confidential_assets ) raise ValueError # Unknown coin name + print(f"unknown model {utils.INTERNAL_MODEL}") raise ValueError # Unknown model diff --git a/core/src/apps/common/coininfo.py.mako b/core/src/apps/common/coininfo.py.mako index 783e159289..138399b063 100644 --- a/core/src/apps/common/coininfo.py.mako +++ b/core/src/apps/common/coininfo.py.mako @@ -163,4 +163,5 @@ def by_name(name: str) -> CoinInfo: % endfor raise ValueError # Unknown coin name % endfor + print(f"unknown model {utils.INTERNAL_MODEL}") raise ValueError # Unknown model 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"