Browse Source

west/sign: Move from using partition label property

MCUmgr no longer uses DTS node property label to identify
slots for image upload and running application. It now uses DTS node
labels for that purpose.
This commit moves `west sign` from using label properties
to DTS node labels, same way the MCUmgr does.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
pull/55099/head
Dominik Ermel 3 years ago committed by Marti Bolivar
parent
commit
86c4b4caa9
  1. 41
      scripts/west_commands/sign.py

41
scripts/west_commands/sign.py

@ -333,34 +333,35 @@ class ImgtoolSigner(Signer):
flash = edt.chosen_node('zephyr,flash') flash = edt.chosen_node('zephyr,flash')
if not flash: if not flash:
log.die('devicetree has no chosen zephyr,flash node;', log.die('devicetree has no chosen zephyr,flash node;',
"can't infer flash write block or image-0 slot sizes") "can't infer flash write block or slot0_partition slot sizes")
return flash return flash
@staticmethod @staticmethod
def edt_flash_params(flash): def edt_flash_params(flash):
# Get the flash device's write alignment and offset from the # Get the flash device's write alignment and offset from the
# image-0 partition and the size from image-1 partition, out of the # slot0_partition and the size from slot1_partition , out of the
# build directory's devicetree. image-1 partition size is used, # build directory's devicetree. slot1_partition size is used,
# when available, because in swap-move mode it can be one sector # when available, because in swap-move mode it can be one sector
# smaller. When not available, fallback to image-0 (single image dfu). # smaller. When not available, fallback to slot0_partition (single slot dfu).
# The node must have a "partitions" child node, which in turn # The node must have a "partitions" child node, which in turn
# must have child node labeled "image-0" and may have a child node # must have child nodes with label slot0_partition and may have a child node
# named "image-1". By convention, the slots for consumption by # with label slot1_partition. By convention, the slots for consumption by
# imgtool are linked into these partitions. # imgtool are linked into these partitions.
if 'partitions' not in flash.children: if 'partitions' not in flash.children:
log.die("DT zephyr,flash chosen node has no partitions,", log.die("DT zephyr,flash chosen node has no partitions,",
"can't find partitions for MCUboot slots") "can't find partitions for MCUboot slots")
partitions = flash.children['partitions'] partitions = flash.children['partitions']
images = { slots = {
node.label: node for node in partitions.children.values() label: node for node in partitions.children.values()
if node.label in set(['image-0', 'image-1']) for label in node.labels
if label in set(['slot0_partition', 'slot1_partition'])
} }
if 'image-0' not in images: if 'slot0_partition' not in slots:
log.die("DT zephyr,flash chosen node has no image-0 partition,", log.die("DT zephyr,flash chosen node has no slot0_partition partition,",
"can't determine its address") "can't determine its address")
# Die on missing or zero alignment or slot_size. # Die on missing or zero alignment or slot_size.
@ -373,18 +374,18 @@ class ImgtoolSigner(Signer):
'DT flash device write-block-size {}'.format(align)) 'DT flash device write-block-size {}'.format(align))
# The partitions node, and its subnode, must provide # The partitions node, and its subnode, must provide
# the size of image-1 or image-0 partition via the regs property. # the size of slot1_partition or slot0_partition partition via the regs property.
image_key = 'image-1' if 'image-1' in images else 'image-0' slot_key = 'slot0_partition' if 'slot1_partition' in slots else 'slot0_partition'
if not images[image_key].regs: if not slots[slot_key].regs:
log.die(f'{image_key} flash partition has no regs property;', log.die(f'{slot_key} flash partition has no regs property;',
"can't determine size of image") "can't determine size of slot")
# always use addr of image-0, which is where images are run # always use addr of slot0_partition, which is where slots are run
addr = images['image-0'].regs[0].addr addr = slots['slot0_partition'].regs[0].addr
size = images[image_key].regs[0].size size = slots[slot_key].regs[0].size
if size == 0: if size == 0:
log.die('expected nonzero slot size for {}'.format(image_key)) log.die('expected nonzero slot size for {}'.format(slot_key))
return (align, addr, size) return (align, addr, size)

Loading…
Cancel
Save