From f4a810d7eb09b392544ec416435d88411874d9e3 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Fri, 31 Mar 2017 15:38:59 +0200 Subject: [PATCH 1/6] --sd-id param added to *pkg generate* --- nordicsemi/__main__.py | 29 +++++++++++++++++++++++++++++ nordicsemi/dfu/package.py | 10 ++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index 8f786dd..d5ce09e 100644 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -383,6 +383,11 @@ def pkg(): '\n|s132_nrf52_4.0.2|0x98|', type=click.STRING, multiple=True) +@click.option('--sd-id', + help='The new SoftDevice ID to be used as --sd-req for the Application update in case the ZIP ' + 'contains a SoftDevice and an Application.', + type=click.STRING, + multiple=True) @click.option('--softdevice', help='The SoftDevice firmware file.', type=click.STRING) @@ -399,6 +404,7 @@ def generate(zipfile, bootloader_version, hw_version, sd_req, + sd_id, softdevice, key_file): """ @@ -461,6 +467,16 @@ def generate(zipfile, if sd_req == 'none': sd_req = None + if len(sd_id) > 1: + click.echo("Please specify SoftDevice requirements as a comma-separated list: --sd-id 0xXXXX,0xYYYY,...") + return + elif len(sd_id) == 0: + sd_id = None + else: + sd_id = sd_id[0] + if sd_id == 'none': + sd_id = None + # Initial consistency checks if application_version_internal is not None and application is None: click.echo("Error: Application version with no image.") @@ -511,6 +527,18 @@ def generate(zipfile, raise NordicSemiException("Could not parse value for --sd-req. " "Hex values should be prefixed with 0x.") + sd_id_list = [] + if sd_id is not None: + try: + # This will parse any string starting with 0x as base 16. + sd_id_list = sd_id.split(',') + sd_id_list = map(int_as_text_to_int, sd_id_list) + except ValueError: + raise NordicSemiException("Could not parse value for --sd-id. " + "Hex values should be prefixed with 0x.") + else: + sd_id_list = sd_req_list + signer = Signing() default_key = signer.load_key(key_file) if default_key: @@ -521,6 +549,7 @@ def generate(zipfile, application_version_internal, bootloader_version, sd_req_list, + sd_id_list, application, bootloader, softdevice, diff --git a/nordicsemi/dfu/package.py b/nordicsemi/dfu/package.py index 2f6e6d0..f77aad5 100644 --- a/nordicsemi/dfu/package.py +++ b/nordicsemi/dfu/package.py @@ -106,6 +106,7 @@ class Package(object): DEFAULT_APP_VERSION = 0xFFFFFFFF DEFAULT_BL_VERSION = 0xFFFFFFFF DEFAULT_SD_REQ = [0xFFFE] + DEFAULT_SD_ID = [0xFFFE] DEFAULT_DFU_VER = 0.5 MANIFEST_FILENAME = "manifest.json" @@ -115,6 +116,7 @@ def __init__(self, app_version=DEFAULT_APP_VERSION, bl_version=DEFAULT_BL_VERSION, sd_req=DEFAULT_SD_REQ, + sd_id=DEFAULT_SD_ID, app_fw=None, bootloader_fw=None, softdevice_fw=None, @@ -127,6 +129,7 @@ def __init__(self, :param int app_version: App version init-packet field :param int bl_version: Bootloader version init-packet field :param list sd_req: Softdevice Requirement init-packet field + :param list sd_id: Softdevice Requirement init-packet field for the Application if softdevice_fw is set :param str app_fw: Path to application firmware file :param str bootloader_fw: Path to bootloader firmware file :param str softdevice_fw: Path to softdevice firmware file @@ -141,8 +144,8 @@ def __init__(self, if hw_version is not None: init_packet_vars[PacketField.HW_VERSION] = hw_version - if sd_req is not None: - init_packet_vars[PacketField.REQUIRED_SOFTDEVICES_ARRAY] = sd_req + if sd_id is not None: + init_packet_vars[PacketField.REQUIRED_SOFTDEVICES_ARRAY] = sd_id self.firmwares_data = {} @@ -152,6 +155,9 @@ def __init__(self, filename=app_fw, init_packet_data=init_packet_vars) + if sd_req is not None: + init_packet_vars[PacketField.REQUIRED_SOFTDEVICES_ARRAY] = sd_req + if bootloader_fw: self.__add_firmware_info(firmware_type=HexType.BOOTLOADER, firmware_version=bl_version, From 62cae3b2eec00f74bf7c73bfa38548fd284cccb4 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Fri, 31 Mar 2017 15:39:21 +0200 Subject: [PATCH 2/6] s140 5.0.0.2.alpha ID added --- nordicsemi/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index d5ce09e..4a7c480 100644 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -380,7 +380,8 @@ def pkg(): '\n|s132_nrf52_3.0.0|0x8C|' '\n|s132_nrf52_3.1.0|0x91|' '\n|s132_nrf52_4.0.0|0x95|' - '\n|s132_nrf52_4.0.2|0x98|', + '\n|s132_nrf52_4.0.2|0x98|' + '\n|s140_nrf52840_5.0.0-2.alpha|0x96|', type=click.STRING, multiple=True) @click.option('--sd-id', From 029f9fc7285f9ce1be92b9cd77dbb9a3faa3b254 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Fri, 31 Mar 2017 15:39:33 +0200 Subject: [PATCH 3/6] Version 2.3.0 --- nordicsemi/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nordicsemi/version.py b/nordicsemi/version.py index 7389537..5e92c79 100644 --- a/nordicsemi/version.py +++ b/nordicsemi/version.py @@ -37,4 +37,4 @@ """ Version definition for nrfutil. """ -NRFUTIL_VERSION = "2.2.0" +NRFUTIL_VERSION = "2.3.0" From aace5b4e1ea09dec72fdbb6dccc7a10b77a0e676 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Wed, 28 Jun 2017 14:55:22 +0200 Subject: [PATCH 4/6] SD s132 5.0 ID and SD-ID info added to README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0f545c..92e1d08 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ SoftDevice | FWID (sd-req) `s132_nrf52_4.0.0` | 0x95 `s132_nrf52_4.0.2` | 0x98 `s132_nrf52_4.0.3` | 0x99 +`s132_nrf52_5.0.0` | 0x9D **Note**: The Thread stack doesn't use a SoftDevice but --sd-req option is required for compatibility reasons. You can provide any value for the option as it is ignored during DFU. @@ -162,9 +163,11 @@ SD | Yes | **SD must be of the same Major Version** APP | Yes | BL + SD | Yes | BL + APP | No | Create two .zip packages instead -BL + SD + APP | Yes | +BL + SD + APP | Yes | **See not below** SD + APP | Yes | **SD must be of the same Major Version** +**Note:** When updating BL + SD + APP the update is done in 2 following connections, unless a custom bootloader is used. First the BL + SD is updated, then the bootloader will disconnect and the new BL will start advertising. Second connection to the new bootloader will update the APP. However, the two SDs may have different IDs. The first update requires --sd-req to be set to the ID of the old SD while update of the APP requires the ID of the new SD. In that case the new ID can be set using ```--sd-id``` parameter. + ##### display Use this option to display the contents of a DFU package in a .zip file. ``` From 216d6f050f077decd989a77fdd9a54fe264c9e7c Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Wed, 28 Jun 2017 15:13:45 +0200 Subject: [PATCH 5/6] README updated --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 92e1d08..8da3172 100644 --- a/README.md +++ b/README.md @@ -159,14 +159,16 @@ The following conventions are used on the table: Combination | Supported | Notes --------------| ----------|------- BL | Yes | -SD | Yes | **SD must be of the same Major Version** +SD | Yes | **See notes 1 and 2 below** APP | Yes | BL + SD | Yes | BL + APP | No | Create two .zip packages instead -BL + SD + APP | Yes | **See not below** -SD + APP | Yes | **SD must be of the same Major Version** +BL + SD + APP | Yes | **See note 1 below** +SD + APP | Yes | **See notes 1 and 2 below** -**Note:** When updating BL + SD + APP the update is done in 2 following connections, unless a custom bootloader is used. First the BL + SD is updated, then the bootloader will disconnect and the new BL will start advertising. Second connection to the new bootloader will update the APP. However, the two SDs may have different IDs. The first update requires --sd-req to be set to the ID of the old SD while update of the APP requires the ID of the new SD. In that case the new ID can be set using ```--sd-id``` parameter. +**Note 1:** SD must be of the same Major Version as the old BL may not be compatible with the new SD. + +**Note 2:** When updating BL + SD + APP the update is done in 2 following connections, unless a custom bootloader is used. First the BL + SD is updated, then the bootloader will disconnect and the new BL will start advertising. Second connection to the new bootloader will update the APP. However, the two SDs may have different IDs. The first update requires --sd-req to be set to the ID of the old SD while update of the APP requires the ID of the new SD. In that case the new ID can be set using ```--sd-id``` parameter. ##### display Use this option to display the contents of a DFU package in a .zip file. From fb2cc7ecbb4bca28857c7bd4c843bab39035d896 Mon Sep 17 00:00:00 2001 From: bencefr Date: Thu, 29 Jun 2017 08:24:00 +0200 Subject: [PATCH 6/6] fixed syntax error --- nordicsemi/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index 655393a..31b3fe9 100644 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -390,7 +390,7 @@ def pkg(): '\n|s132_nrf52_4.0.0|0x95|' '\n|s132_nrf52_4.0.2|0x98|' '\n|s132_nrf52_4.0.3|0x99|' - '\n|s132_nrf52_5.0.0|0x9D|' + '\n|s132_nrf52_5.0.0|0x9D|', type=click.STRING, multiple=True) @click.option('--sd-id',