diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest index da2bcaebb7..ebbf395b03 100644 --- a/core/SConscript.prodtest +++ b/core/SConscript.prodtest @@ -6,6 +6,7 @@ import tools, models, ui TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T2T1') CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0)) PRODUCTION = ARGUMENTS.get('PRODUCTION', '0') == '1' +BOOTLOADER_QA = ARGUMENTS.get('BOOTLOADER_QA', '0') == '1' BOOTLOADER_DEVEL = ARGUMENTS.get('BOOTLOADER_DEVEL', '0') == '1' HW_REVISION = ARGUMENTS.get('HW_REVISION', None) UI_DEBUG_OVERLAY = ARGUMENTS.get('UI_DEBUG_OVERLAY', '0') == '1' @@ -41,6 +42,7 @@ SOURCE_MOD_CRYPTO += [ 'vendor/trezor-crypto/aes/aeskey.c', 'vendor/trezor-crypto/aes/aestab.c', 'vendor/trezor-crypto/bignum.c', + 'vendor/trezor-crypto/blake2s.c', 'vendor/trezor-crypto/buffer.c', 'vendor/trezor-crypto/chacha_drbg.c', 'vendor/trezor-crypto/chacha20poly1305/chacha_merged.c', @@ -72,6 +74,7 @@ SOURCE_MOD += [ 'embed/gfx/gfx_draw.c', 'embed/gfx/terminal.c', 'embed/io/display/display_utils.c', + 'embed/util/bl_check/bl_check.c', 'embed/util/image/image.c', 'embed/util/rsod/rsod.c', 'embed/util/scm_revision/scm_revision.c', @@ -88,7 +91,7 @@ ui.init_ui(TREZOR_MODEL, "prodtest", RUST_UI_FEATURES) env = Environment( ENV=os.environ, - CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')), + CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={ARGUMENTS.get('PRODUCTION', '0')} -DBOOTLOADER_QA={int(BOOTLOADER_QA)}", CPPDEFINES_IMPLICIT=[], CPPDEFPREFIX="-D'", CPPDEFSUFFIX="'", @@ -150,6 +153,7 @@ ALLPATHS = [ 'embed/models', 'embed/gfx/inc', 'embed/sys/bsp/inc', + 'embed/util/bl_check/inc', 'embed/util/image/inc', 'embed/util/rsod/inc', 'embed/util/scm_revision/inc', @@ -243,6 +247,20 @@ else: VENDORHEADER = f'embed/models/{TREZOR_MODEL}/vendorheader/vendorheader_unsafe_signed_prod.bin' +BOOTLOADER_SUFFIX = TREZOR_MODEL +if BOOTLOADER_QA or BOOTLOADER_DEVEL: + BOOTLOADER_SUFFIX += '_qa' + +tools.embed_compressed_binary( + obj_program, + env, + 'bootloader', + 'embed/projects/bootloaders/bootloader.o', + f'embed/models/{TREZOR_MODEL}/bootloaders/bootloader_{BOOTLOADER_SUFFIX}.bin', + 'prodtest', + 'bootloader', + ) + tools.embed_raw_binary( obj_program, env, diff --git a/core/embed/models/T3W1/bootloaders/bootloader_T3W1_qa.bin b/core/embed/models/T3W1/bootloaders/bootloader_T3W1_qa.bin index 3befe07768..14c3ada86c 100755 Binary files a/core/embed/models/T3W1/bootloaders/bootloader_T3W1_qa.bin and b/core/embed/models/T3W1/bootloaders/bootloader_T3W1_qa.bin differ diff --git a/core/embed/models/T3W1/bootloaders/bootloader_hashes.h b/core/embed/models/T3W1/bootloaders/bootloader_hashes.h index c81bf5a304..6a82aa675d 100644 --- a/core/embed/models/T3W1/bootloaders/bootloader_hashes.h +++ b/core/embed/models/T3W1/bootloaders/bootloader_hashes.h @@ -5,12 +5,12 @@ // clang-format off // bootloader_T3W1.bin version 2.1.10.0 -#define BOOTLOADER_T3W1_00 {0x33, 0x7b, 0xe4, 0xc8, 0x54, 0x54, 0x4e, 0x0d, 0xf7, 0xd0, 0x29, 0xed, 0x5b, 0x6d, 0x35, 0x0f, 0xf4, 0x77, 0x87, 0x3f, 0xa2, 0xd1, 0x21, 0xca, 0x99, 0xd0, 0xfc, 0x94, 0xc1, 0xa8, 0xac, 0x78} -#define BOOTLOADER_T3W1_FF {0xa0, 0x71, 0xd4, 0xea, 0x0a, 0xab, 0xce, 0x92, 0x8d, 0xf2, 0xce, 0xff, 0xe2, 0xd2, 0x12, 0x31, 0x47, 0xd0, 0xbb, 0x25, 0x01, 0xd2, 0x1a, 0xa4, 0x21, 0xff, 0xb0, 0xc8, 0x2a, 0x23, 0x41, 0x3d} +#define BOOTLOADER_T3W1_00 {0xa6, 0xf0, 0xd1, 0xa0, 0xdc, 0xdd, 0xa7, 0x1e, 0xd8, 0x1e, 0x3a, 0x6c, 0x55, 0x9a, 0xb2, 0xf0, 0xc7, 0xdf, 0xe8, 0xd8, 0x6d, 0xfb, 0x4e, 0xb8, 0xb4, 0xb9, 0x13, 0x8d, 0x8d, 0xa7, 0x5f, 0xaa} +#define BOOTLOADER_T3W1_FF {0xb9, 0x41, 0x87, 0x7b, 0xec, 0x55, 0x1a, 0xfb, 0xab, 0xa6, 0xa8, 0x5d, 0xce, 0x34, 0x3b, 0x4f, 0x4d, 0xfc, 0x26, 0x8b, 0x24, 0x68, 0x8b, 0x3d, 0x76, 0xee, 0xd0, 0xf8, 0x66, 0xd6, 0x64, 0x5a} -// bootloader_T3W1_qa.bin version 2.1.11.0 -#define BOOTLOADER_T3W1_QA_00 {0x70, 0xd0, 0xcb, 0xe3, 0xb9, 0x9a, 0x6b, 0x5f, 0xe5, 0x38, 0xf9, 0xb3, 0x80, 0x49, 0x80, 0xe8, 0xbb, 0xb4, 0xda, 0xf6, 0x4d, 0xab, 0xe9, 0x31, 0xa9, 0xdf, 0x90, 0x69, 0x07, 0xc7, 0x3f, 0x06} -#define BOOTLOADER_T3W1_QA_FF {0xa9, 0xd7, 0x74, 0x24, 0x0d, 0xb9, 0x75, 0x11, 0x2d, 0xff, 0xbf, 0x64, 0x83, 0xe1, 0xe3, 0xe5, 0xb5, 0x91, 0x95, 0xc6, 0x97, 0x55, 0x1e, 0xcc, 0x86, 0x45, 0xde, 0x99, 0x23, 0xaf, 0xc9, 0xfe} +// bootloader_T3W1_qa.bin version 2.1.12.0 +#define BOOTLOADER_T3W1_QA_00 {0xed, 0xd9, 0x03, 0x09, 0x3a, 0x4c, 0x6f, 0x3c, 0xce, 0xe8, 0x75, 0xce, 0xa7, 0xdf, 0x04, 0xa8, 0x9e, 0x73, 0x58, 0x09, 0x1d, 0x00, 0x13, 0x17, 0x87, 0xb8, 0x2b, 0x4a, 0x48, 0xf5, 0xce, 0x03} +#define BOOTLOADER_T3W1_QA_FF {0x97, 0xa1, 0x7e, 0x04, 0x8b, 0x7b, 0xf2, 0x07, 0x73, 0x2c, 0xcb, 0x39, 0x3f, 0xbe, 0x07, 0xa6, 0x98, 0x38, 0xa0, 0x4b, 0xbe, 0xb1, 0x91, 0x27, 0x4d, 0xc1, 0xa5, 0x2e, 0xa0, 0xe3, 0x18, 0xee} // clang-format on diff --git a/core/embed/models/T3W1/model_T3W1.h b/core/embed/models/T3W1/model_T3W1.h index 83bf16f7a6..63cb4b1073 100644 --- a/core/embed/models/T3W1/model_T3W1.h +++ b/core/embed/models/T3W1/model_T3W1.h @@ -1,7 +1,7 @@ #ifndef MODELS_MODEL_T3W1_H_ #define MODELS_MODEL_T3W1_H_ -// #include "bootloaders/bootloader_hashes.h" +#include "bootloaders/bootloader_hashes.h" #include diff --git a/core/embed/projects/prodtest/main.c b/core/embed/projects/prodtest/main.c index 8bbdc97673..9e20580610 100644 --- a/core/embed/projects/prodtest/main.c +++ b/core/embed/projects/prodtest/main.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -228,6 +230,11 @@ static void drivers_init(void) { #ifdef USE_HW_REVISION hw_revision_init(); #endif + +#if BOOTLOADER_QA + parse_boardloader_capabilities(); + check_and_replace_bootloader(); +#endif } #define BACKLIGHT_NORMAL 150 diff --git a/core/embed/sys/linker/stm32u5g/prodtest.ld b/core/embed/sys/linker/stm32u5g/prodtest.ld index 3da2123298..96ba222f76 100644 --- a/core/embed/sys/linker/stm32u5g/prodtest.ld +++ b/core/embed/sys/linker/stm32u5g/prodtest.ld @@ -61,6 +61,9 @@ SECTIONS { . = ALIGN(4); *(.rodata*); . = ALIGN(4); + KEEP(*(.bootloader)); + *(.bootloader*); + . = ALIGN(4); _prodtest_cli_cmd_section_start = .; KEEP(*(.prodtest_cli_cmd)) diff --git a/core/tools/bootloader_hashes.py b/core/tools/bootloader_hashes.py index 6683d87908..a410d63be4 100755 --- a/core/tools/bootloader_hashes.py +++ b/core/tools/bootloader_hashes.py @@ -7,7 +7,7 @@ from hashlib import blake2s from trezorlib.firmware.core import FirmwareImage, Model -ALIGNED_SIZE = 128 * 1024 +ALIGNED_SIZE = 192 * 1024 HERE = Path(__file__).parent BOOTLOADERS = HERE / ".." / "embed" / "models"