diff --git a/ci/build.yml b/ci/build.yml index d15929d747..4097f5c157 100644 --- a/ci/build.yml +++ b/ci/build.yml @@ -28,11 +28,11 @@ core fw regular build: - nix-shell --run "poetry run make -C core build_prodtest" - nix-shell --run "poetry run make -C core build_firmware" - nix-shell --run "poetry run make -C core sizecheck" - - cp core/build/firmware/firmware.bin trezor-fw-regular-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin + - cp core/build/firmware/firmware.bin firmware-T2T1-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-regular-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T2T1-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week # Build of Core into firmware with enabled _debug_ mode. In debug mode you can @@ -44,11 +44,11 @@ core fw regular debug build: needs: [] script: - nix-shell --run "PYOPT=0 poetry run make -C core build_firmware" - - cp core/build/firmware/firmware.bin trezor-fw-regular-debug-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin + - cp core/build/firmware/firmware.bin firmware-T2T1-debug-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-regular-debug-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T2T1-debug-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week core fw regular production build: @@ -66,11 +66,11 @@ core fw regular production build: - nix-shell --run "poetry run make -C core build_prodtest" - nix-shell --run "poetry run make -C core build_firmware" - nix-shell --run "poetry run make -C core sizecheck" - - cp core/build/firmware/firmware.bin trezor-fw-regular-production-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin + - cp core/build/firmware/firmware.bin firmware-T2T1-production-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-regular-production-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T2T1-production-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week # Build of Core into firmware. Bitcoin-only version. @@ -84,11 +84,11 @@ core fw btconly build: - nix-shell --run "poetry run make -C core build_firmware" - mv core/build/firmware/firmware.bin core/build/firmware/firmware-bitcoinonly.bin - nix-shell --run "poetry run ./tools/check-bitcoin-only core/build/firmware/firmware-bitcoinonly.bin" - - cp core/build/firmware/firmware-bitcoinonly.bin trezor-fw-btconly-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin + - cp core/build/firmware/firmware-bitcoinonly.bin firmware-T2T1-btconly-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-btconly-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T2T1-btconly-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week core fw btconly debug build: @@ -100,7 +100,7 @@ core fw btconly debug build: PYOPT: "0" script: - nix-shell --run "poetry run make -C core build_firmware" - - cp core/build/firmware/firmware.bin trezor-fw-btconly-debug-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin + - cp core/build/firmware/firmware.bin firmware-T2T1-btconly-debug-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin only: # currently used only for HW tests and deploys - schedules # nightly build - /^legacy\// @@ -111,7 +111,7 @@ core fw btconly debug build: artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-btconly-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T2T1-btconly-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week core fw btconly production build: @@ -126,11 +126,11 @@ core fw btconly production build: script: - nix-shell --run "poetry run make -C core build_firmware" - nix-shell --run "poetry run ./tools/check-bitcoin-only core/build/firmware/firmware.bin" - - cp core/build/firmware/firmware.bin trezor-fw-btconly-production-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin + - cp core/build/firmware/firmware.bin firmware-T2T1-btconly-production-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-btconly-production-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T2T1-btconly-production-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week core fw btconly t1 build: @@ -142,11 +142,11 @@ core fw btconly t1 build: TREZOR_MODEL: "1" script: - nix-shell --run "poetry run make -C core build_firmware" - - cp core/build/firmware/firmware.bin trezor-fw-btconly-t1-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin + - cp core/build/firmware/firmware.bin firmware-T1B1-btconly-t1-$CORE_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-btconly-t1-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T1B1-btconly-t1-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week # Non-frozen emulator build. This means you still need Python files @@ -368,11 +368,11 @@ legacy fw regular build: - nix-shell --run "poetry run legacy/script/setup" - nix-shell --run "export PRODUCTION=0 && poetry run legacy/script/cibuild" - nix-shell --run "poetry run make -C legacy/demo" - - mv legacy/firmware/trezor.bin trezor-fw-regular-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin + - mv legacy/firmware/trezor.bin firmware-T1B1-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-regular-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T1B1-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week legacy fw regular debug build: @@ -385,11 +385,11 @@ legacy fw regular debug build: - nix-shell --run "export PRODUCTION=1 && poetry run legacy/script/cibuild" - nix-shell --run "poetry run legacy/script/setup" - nix-shell --run "export PRODUCTION=0 && poetry run legacy/script/cibuild" - - mv legacy/firmware/trezor.bin trezor-fw-regular-debug-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin + - mv legacy/firmware/trezor.bin firmware-T1B1-debug-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-regular-debug-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T1B1-debug-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week legacy fw btconly build: @@ -404,11 +404,11 @@ legacy fw btconly build: - nix-shell --run "export PRODUCTION=0 && poetry run legacy/script/cibuild" - mv legacy/firmware/trezor.bin legacy/firmware/trezor-bitcoinonly.bin - nix-shell --run "poetry run ./tools/check-bitcoin-only legacy/firmware/trezor-bitcoinonly.bin" - - mv legacy/firmware/trezor-bitcoinonly.bin trezor-fw-btconly-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin + - mv legacy/firmware/trezor-bitcoinonly.bin firmware-T1B1-btconly-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-btconly-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T1B1-btconly-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week legacy fw btconly debug build: @@ -423,11 +423,11 @@ legacy fw btconly debug build: - nix-shell --run "poetry run legacy/script/setup" - nix-shell --run "export PRODUCTION=0 && poetry run legacy/script/cibuild" - nix-shell --run "poetry run ./tools/check-bitcoin-only legacy/firmware/trezor.bin" - - mv legacy/firmware/trezor.bin trezor-fw-btconly-debug-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin + - mv legacy/firmware/trezor.bin firmware-T1B1-btconly-debug-$LEGACY_VERSION-$CI_COMMIT_SHORT_SHA.bin artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - trezor-fw-btconly-*.*.*-$CI_COMMIT_SHORT_SHA.bin + - firmware-T1B1-btconly-debug-*.*.*-$CI_COMMIT_SHORT_SHA.bin expire_in: 1 week # Regular version (not only Bitcoin) of above. diff --git a/ci/deploy.yml b/ci/deploy.yml index b34e76f267..669f4c820e 100644 --- a/ci/deploy.yml +++ b/ci/deploy.yml @@ -12,7 +12,7 @@ release core fw regular deploy: - core fw regular build script: - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) - - export NAME="trezor-fw-regular-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T2T1-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" @@ -33,7 +33,7 @@ release core fw btconly deploy: - core fw btconly build script: - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) - - export NAME="trezor-fw-btconly-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T2T1-btconly-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" @@ -54,7 +54,7 @@ release core fw regular debug deploy: - core fw regular debug build script: - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) - - export NAME="trezor-fw-regular-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T2T1-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" @@ -75,7 +75,7 @@ release core fw btconly debug deploy: - core fw btconly debug build script: - export VERSION=$(./tools/version.sh core/embed/firmware/version.h) - - export NAME="trezor-fw-btconly-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T2T1-btconly-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" @@ -98,7 +98,7 @@ release legacy fw regular deploy: - legacy fw regular build script: - export VERSION=$(./tools/version.sh legacy/firmware/version.h) - - export NAME="trezor-fw-regular-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T1B1-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" @@ -119,7 +119,7 @@ release legacy fw btconly deploy: - legacy fw btconly build script: - export VERSION=$(./tools/version.sh legacy/firmware/version.h) - - export NAME="trezor-fw-btconly-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T1B1-btconly-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" @@ -140,7 +140,7 @@ release legacy fw regular debug deploy: - legacy fw regular debug build script: - export VERSION=$(./tools/version.sh legacy/firmware/version.h) - - export NAME="trezor-fw-regular-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T1B1-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" @@ -161,7 +161,7 @@ release legacy fw btconly debug deploy: - legacy fw btconly debug build script: - export VERSION=$(./tools/version.sh legacy/firmware/version.h) - - export NAME="trezor-fw-btconly-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" + - export NAME="firmware-T1B1-btconly-debug-$VERSION-$CI_COMMIT_SHORT_SHA.bin" - echo "Deploying to ${DEPLOY_DIRECTORY}/$NAME" - mkdir -p "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}" - rsync --delete -va $NAME "${DEPLOY_BASE_DIR}/${DEPLOY_DIRECTORY}/$NAME" diff --git a/core/SConscript.boardloader b/core/SConscript.boardloader index 2b86a1d6b5..1391a55d6d 100644 --- a/core/SConscript.boardloader +++ b/core/SConscript.boardloader @@ -104,6 +104,7 @@ env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get(' tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL) env.Replace( + CP='cp', AS='arm-none-eabi-as', AR='arm-none-eabi-ar', CC='arm-none-eabi-gcc', @@ -170,8 +171,17 @@ program_elf = env.Command( '$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES -lc_nano -lgcc', ) +BINARY_NAME = f"build/boardloader/boardloader-{tools.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME += "-" + tools.get_version('embed/boardloader/version.h') +BINARY_NAME += "-" + tools.get_git_revision_short_hash() +BINARY_NAME += "-dirty" if tools.get_git_modified() else "" +BINARY_NAME += ".bin" + program_bin = env.Command( target='boardloader.bin', source=program_elf, - action='$OBJCOPY -O binary $SOURCE $TARGET', + action=[ + '$OBJCOPY -O binary $SOURCE $TARGET', + '$CP $TARGET ' + BINARY_NAME, + ], ) diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index 7a30b274d1..383b91eed2 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -157,6 +157,7 @@ env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get(' tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL) env.Replace( + CP='cp', AS='arm-none-eabi-as', AR='arm-none-eabi-ar', CC='arm-none-eabi-gcc', @@ -240,10 +241,17 @@ program_elf = env.Command( '$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES -lc_nano -lgcc', ) +BINARY_NAME = f"build/bootloader/bootloader-{tools.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME += "-" + tools.get_version('embed/bootloader/version.h') +BINARY_NAME += "-" + tools.get_git_revision_short_hash() +BINARY_NAME += "-dirty" if tools.get_git_modified() else "" +BINARY_NAME += ".bin" + program_bin = env.Command( target='bootloader.bin', source=program_elf, action=[ '$OBJCOPY -O binary -j .header -j .flash -j .data $SOURCE $TARGET', '$HEADERTOOL $TARGET ' + ('-D' if ARGUMENTS.get('PRODUCTION', '0') == '0' else ''), + '$CP $TARGET ' + BINARY_NAME, ], ) diff --git a/core/SConscript.bootloader_ci b/core/SConscript.bootloader_ci index f7b99791d9..2ae15aba17 100644 --- a/core/SConscript.bootloader_ci +++ b/core/SConscript.bootloader_ci @@ -140,6 +140,7 @@ env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get(' tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL) env.Replace( + CP='cp', AS='arm-none-eabi-as', AR='arm-none-eabi-ar', CC='arm-none-eabi-gcc', @@ -215,10 +216,17 @@ program_elf = env.Command( '$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES -lc_nano -lgcc', ) +BINARY_NAME = f"build/bootloader_ci/bootloader_ci-{tools.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME += "-" + tools.get_version('embed/bootloader_ci/version.h') +BINARY_NAME += "-" + tools.get_git_revision_short_hash() +BINARY_NAME += "-dirty" if tools.get_git_modified() else "" +BINARY_NAME += ".bin" + program_bin = env.Command( target='bootloader.bin', source=program_elf, action=[ '$OBJCOPY -O binary -j .header -j .flash -j .data $SOURCE $TARGET', '$HEADERTOOL $TARGET ' + ('-D' if ARGUMENTS.get('PRODUCTION', '0') == '0' else ''), + '$CP $TARGET ' + BINARY_NAME, ], ) diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 822ee218f9..36b6d9e5cd 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -441,6 +441,7 @@ env.Tool('micropython') env.Replace( CAT='cat', DD='dd', + CP='cp', SED='sed', AS='arm-none-eabi-as', AR='arm-none-eabi-ar', @@ -797,6 +798,15 @@ program_elf = env.Command( env.Depends(program_elf, rust) +BINARY_NAME = f"build/firmware/firmware-{tools.get_model_identifier(TREZOR_MODEL)}" +if BITCOIN_ONLY != 0: + BINARY_NAME += "-btconly" +BINARY_NAME += "-" + tools.get_version('embed/firmware/version.h') +BINARY_NAME += "-" + tools.get_git_revision_short_hash() +BINARY_NAME += "-dirty" if tools.get_git_modified() else "" +BINARY_NAME += ".bin" + + if TREZOR_MODEL in ('T', 'R'): action_bin=[ '$OBJCOPY -O binary -j .vendorheader -j .header -j .flash -j .data --pad-to 0x08100000 $SOURCE ${TARGET}.p1', @@ -804,11 +814,13 @@ if TREZOR_MODEL in ('T', 'R'): '$CAT ${TARGET}.p1 ${TARGET}.p2 > $TARGET', '$HEADERTOOL -h $TARGET ' + ('-D' if ARGUMENTS.get('PRODUCTION', '0') == '0' else ''), '$DD if=$TARGET of=${TARGET}.p1 skip=0 bs=128k count=6', + '$CP $TARGET ' + BINARY_NAME, ] elif TREZOR_MODEL in ('1',): action_bin=[ '$OBJCOPY -O binary -j .header -j .flash -j .data $SOURCE $TARGET', '../legacy/bootloader/firmware_sign.py -f $TARGET', + '$CP $TARGET ' + BINARY_NAME, ] else: raise ValueError('Unknown Trezor model') diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest index ba19d4dd19..a42e53d305 100644 --- a/core/SConscript.prodtest +++ b/core/SConscript.prodtest @@ -109,6 +109,7 @@ env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get(' tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL) env.Replace( + CP='cp', AS='arm-none-eabi-as', AR='arm-none-eabi-ar', CC='arm-none-eabi-gcc', @@ -191,10 +192,17 @@ program_elf = env.Command( '$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES -lc_nano -lgcc', ) +BINARY_NAME = f"build/prodtest/prodtest-{tools.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME += "-" + tools.get_version('embed/prodtest/version.h') +BINARY_NAME += "-" + tools.get_git_revision_short_hash() +BINARY_NAME += "-dirty" if tools.get_git_modified() else "" +BINARY_NAME += ".bin" + program_bin = env.Command( target='prodtest.bin', source=program_elf, action=[ '$OBJCOPY -O binary -j .vendorheader -j .header -j .flash -j .data $SOURCE $TARGET', '$HEADERTOOL $TARGET ' + ('-D' if ARGUMENTS.get('PRODUCTION', '0') == '0' else ''), + '$CP $TARGET ' + BINARY_NAME, ], ) diff --git a/core/SConscript.reflash b/core/SConscript.reflash index e10b523115..2785517ff5 100644 --- a/core/SConscript.reflash +++ b/core/SConscript.reflash @@ -37,7 +37,7 @@ SOURCE_MOD += [ 'embed/extmod/modtrezorui/display.c', 'embed/extmod/modtrezorui/colors.c', 'embed/extmod/modtrezorui/fonts/fonts.c', - 'embed/extmod/modtrezorui/font_bitmap.c', + 'embed/extmod/modtrezorui/fonts/font_bitmap.c', 'vendor/micropython/lib/uzlib/adler32.c', 'vendor/micropython/lib/uzlib/crc32.c', 'vendor/micropython/lib/uzlib/tinflate.c', @@ -102,6 +102,7 @@ env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get(' tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL) env.Replace( + CP='cp', AS='arm-none-eabi-as', AR='arm-none-eabi-ar', CC='arm-none-eabi-gcc', @@ -184,10 +185,17 @@ program_elf = env.Command( '$LINK -o $TARGET $CCFLAGS $CFLAGS $LINKFLAGS $SOURCES -lc_nano -lgcc', ) +BINARY_NAME = f"build/reflash/reflash-{tools.get_model_identifier(TREZOR_MODEL)}" +BINARY_NAME += "-" + tools.get_version('embed/reflash/version.h') +BINARY_NAME += "-" + tools.get_git_revision_short_hash() +BINARY_NAME += "-dirty" if tools.get_git_modified() else "" +BINARY_NAME += ".bin" + program_bin = env.Command( target='reflash.bin', source=program_elf, action=[ '$OBJCOPY -O binary -j .vendorheader -j .header -j .flash -j .data $SOURCE $TARGET', '$HEADERTOOL $TARGET ' + ('-D' if ARGUMENTS.get('PRODUCTION', '0') == '0' else ''), + '$CP $TARGET ' + BINARY_NAME, ], ) diff --git a/core/site_scons/tools.py b/core/site_scons/tools.py index 2e4e558794..e6fb500b9b 100644 --- a/core/site_scons/tools.py +++ b/core/site_scons/tools.py @@ -1,3 +1,8 @@ +import os.path + +import subprocess + + def add_font(font_name, font, defines, sources): if font is not None: defines += [ @@ -55,3 +60,34 @@ def get_model_identifier(model): return "T2B1" else: raise Exception("Unknown model") + + +def get_version(file): + major = 0 + minor = 0 + patch = 0 + + if not os.path.exists(file): + file = os.path.join("..", "..", file) + + with open(file, 'r') as f: + for line in f: + if line.startswith('#define VERSION_MAJOR '): + major = line.split('VERSION_MAJOR')[1].strip() + if line.startswith('#define VERSION_MINOR '): + minor = line.split('VERSION_MINOR')[1].strip() + if line.startswith('#define VERSION_PATCH '): + patch = line.split('VERSION_PATCH')[1].strip() + return f'{major}.{minor}.{patch}' + + +def get_git_revision_hash() -> str: + return subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() + + +def get_git_revision_short_hash() -> str: + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() + + +def get_git_modified() -> bool: + return subprocess.check_output(['git', 'diff', '--name-status']).decode('ascii').strip() != ''