1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-03 04:18:17 +00:00

support simplified nrfutil, more universal package update

This commit is contained in:
tychovrahe 2023-09-11 13:42:45 +02:00
parent f0ff6cbca9
commit b8ec994fe3
2 changed files with 23 additions and 17 deletions

View File

@ -463,14 +463,14 @@ program_pkg = env.Command(
target='ble_firmware.zip', target='ble_firmware.zip',
source=program_hex, source=program_hex,
action=[ 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( settings = env.Command(
target='settings.hex', target='settings.hex',
source=program_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( program_merge = env.Command(

View File

@ -14,6 +14,7 @@
# You should have received a copy of the License along with this library. # You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. # If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import json
import sys import sys
import zipfile import zipfile
from typing import TYPE_CHECKING, BinaryIO from typing import TYPE_CHECKING, BinaryIO
@ -45,22 +46,27 @@ def update(
"""Upload new BLE firmware to device.""" """Upload new BLE firmware to device."""
with zipfile.ZipFile(package) as archive: with zipfile.ZipFile(package) as archive:
binfile = archive.read("ble_firmware.bin") manifest = archive.read("manifest.json")
datfile = archive.read("ble_firmware.dat") mainfest_data = json.loads(manifest.decode("utf-8"))["manifest"]
"""Perform the final act of loading the firmware into Trezor.""" for k in mainfest_data.keys():
try:
click.echo("Uploading...\r", nl=False) binfile = archive.read(mainfest_data[k]["bin_file"])
with click.progressbar( datfile = archive.read(mainfest_data[k]["dat_file"])
label="Uploading", length=len(binfile), show_eta=False
) as bar: """Perform the final act of loading the firmware into Trezor."""
ble.update(client, datfile, binfile, bar.update) try:
click.echo("Update successful.") click.echo("Uploading...\r", nl=False)
except exceptions.Cancelled: with click.progressbar(
click.echo("Update aborted on device.") label="Uploading", length=len(binfile), show_eta=False
except exceptions.TrezorException as e: ) as bar:
click.echo(f"Update failed: {e}") ble.update(client, datfile, binfile, bar.update)
sys.exit(3) 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() @cli.command()