Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.

--sd-id param added to *pkg generate* #64

Merged
merged 7 commits into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion nordicsemi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,13 @@ 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|',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also 5.0.0-1.alpha and 5.0.0-3.alpha. Should those be added as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must also remember to update README.md with the new SD versions.

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',
Expand All @@ -399,6 +405,7 @@ def generate(zipfile,
bootloader_version,
hw_version,
sd_req,
sd_id,
softdevice,
key_file):
"""
Expand Down Expand Up @@ -461,6 +468,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.")
Expand Down Expand Up @@ -511,6 +528,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:
Expand All @@ -521,6 +550,7 @@ def generate(zipfile,
application_version_internal,
bootloader_version,
sd_req_list,
sd_id_list,
application,
bootloader,
softdevice,
Expand Down
10 changes: 8 additions & 2 deletions nordicsemi/dfu/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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 = {}

Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 148, init_packet_vars[PacketField.REQUIRED_SOFTDEVICES_ARRAY] might have already been set to sd_id. This would overwrite that.

If the same init packet field is being used for both --sd-req and --sd-id, then why do we need --sd-id? Couldn't we just use --sd-req?

Copy link
Contributor

@mrodem mrodem Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I thought init_packet_vars was the final init packet, but I see now that init_packet_vars is just a temporary variable. The init_packet_vars is mutated with different softdevice requirements between each call to __add_firmware_info(). Then it makes sense.


if bootloader_fw:
self.__add_firmware_info(firmware_type=HexType.BOOTLOADER,
firmware_version=bl_version,
Expand Down
2 changes: 1 addition & 1 deletion nordicsemi/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

""" Version definition for nrfutil. """

NRFUTIL_VERSION = "2.2.0"
NRFUTIL_VERSION = "2.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.3.0 has now been released, so this should be bumped to 2.4.0. There is also a merge conflict that needs to be resolved.