diff --git a/core/SConscript.ble_firmware b/core/SConscript.ble_firmware index 3143013c7c..0bc9153319 100644 --- a/core/SConscript.ble_firmware +++ b/core/SConscript.ble_firmware @@ -463,14 +463,14 @@ program_pkg = env.Command( target='ble_firmware.zip', source=program_hex, action=[ - f'python ../../pc-nrfutil/nordicsemi/ pkg generate --hw-version 52 --sd-req=0x100 --application $SOURCE --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --key-file ./embed/ble_bootloader/priv.pem $TARGET --application-version-string {tools.get_version("embed/ble_firmware/version.h")}' + f'python ../../pc-nrfutil/nordicsemi/ pkg generate --hw-version 52 --sd-req=0x100 --application $SOURCE --key-file ./embed/ble_bootloader/priv.pem $TARGET --application-version-string {tools.get_version("embed/ble_firmware/version.h")} --sd-id=0x100 --softdevice ./embed/sdk/nrf52/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex ' ], ) settings = env.Command( target='settings.hex', source=program_hex, - action=f'python ../../pc-nrfutil/nordicsemi/ settings generate --family NRF52 --application $SOURCE --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --application-version-string {tools.get_version("embed/ble_firmware/version.h")} --bootloader-version {tools.get_version_int("embed/ble_bootloader/version.h")} --bl-settings-version 2 --sd-boot-validation VALIDATE_ECDSA_P256_SHA256 --softdevice ./embed/sdk/nrf52/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --key-file ./embed/ble_bootloader/priv.pem $TARGET', + action=f'python ../../pc-nrfutil/nordicsemi/ settings generate --family NRF52 --application $SOURCE --application-version-string {tools.get_version("embed/ble_firmware/version.h")} --bootloader-version {tools.get_version_int("embed/ble_bootloader/version.h")} --softdevice ./embed/sdk/nrf52/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --key-file ./embed/ble_bootloader/priv.pem $TARGET', ) program_merge = env.Command( diff --git a/python/src/trezorlib/cli/ble.py b/python/src/trezorlib/cli/ble.py index bef455f90f..c4ecf8fba6 100644 --- a/python/src/trezorlib/cli/ble.py +++ b/python/src/trezorlib/cli/ble.py @@ -14,6 +14,7 @@ # You should have received a copy of the License along with this library. # If not, see . +import json import sys import zipfile from typing import TYPE_CHECKING, BinaryIO @@ -45,22 +46,27 @@ def update( """Upload new BLE firmware to device.""" with zipfile.ZipFile(package) as archive: - binfile = archive.read("ble_firmware.bin") - datfile = archive.read("ble_firmware.dat") + manifest = archive.read("manifest.json") + mainfest_data = json.loads(manifest.decode("utf-8"))["manifest"] - """Perform the final act of loading the firmware into Trezor.""" - try: - click.echo("Uploading...\r", nl=False) - with click.progressbar( - label="Uploading", length=len(binfile), show_eta=False - ) as bar: - ble.update(client, datfile, binfile, bar.update) - click.echo("Update successful.") - except exceptions.Cancelled: - click.echo("Update aborted on device.") - except exceptions.TrezorException as e: - click.echo(f"Update failed: {e}") - sys.exit(3) + for k in mainfest_data.keys(): + + binfile = archive.read(mainfest_data[k]["bin_file"]) + datfile = archive.read(mainfest_data[k]["dat_file"]) + + """Perform the final act of loading the firmware into Trezor.""" + try: + click.echo("Uploading...\r", nl=False) + with click.progressbar( + label="Uploading", length=len(binfile), show_eta=False + ) as bar: + ble.update(client, datfile, binfile, bar.update) + click.echo("Update successful.") + except exceptions.Cancelled: + click.echo("Update aborted on device.") + except exceptions.TrezorException as e: + click.echo(f"Update failed: {e}") + sys.exit(3) @cli.command()