Skip to content

Commit

Permalink
assemble: add an opportunity to assemble without image-1 partition
Browse files Browse the repository at this point in the history
  • Loading branch information
toshbi4 committed Jun 6, 2024
1 parent 45d379e commit 45efffb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ def same_keys(a, b):
size_re = re.compile(r"^#define DT_FLASH_AREA_([0-9A-Z_]+)_SIZE(_0)?\s+(0x[0-9a-fA-F]+|[0-9]+)$")

class Assembly():
def __init__(self, output, bootdir, edt):
self.find_slots(edt)
def __init__(self, output, bootdir, edt, is_secondary=True):
self.find_slots(edt, is_secondary)
try:
os.unlink(output)
except OSError as e:
if e.errno != errno.ENOENT:
raise
self.output = output

def find_slots(self, edt):
def find_slots(self, edt, is_secondary):
offsets = {}
sizes = {}

Expand All @@ -74,7 +74,7 @@ def find_slots(self, edt):
if 'image-0' not in offsets:
raise Exception("Board partition table does not have image-0 partition")

if 'image-1' not in offsets:
if ('image-1' not in offsets) and is_secondary:
raise Exception("Board partition table does not have image-1 partition")

self.offsets = offsets
Expand Down Expand Up @@ -137,11 +137,12 @@ def main():
edt = pickle.load(f)
assert isinstance(edt, devicetree.edtlib.EDT)

output = Assembly(args.output, args.bootdir, edt)
is_secondary = args.secondary is not None
output = Assembly(args.output, args.bootdir, edt, is_secondary)

output.add_image(os.path.join(args.bootdir, 'zephyr', 'zephyr.bin'), 'mcuboot')
output.add_image(args.primary, "image-0")
if args.secondary is not None:
if is_secondary:
output.add_image(args.secondary, "image-1")

if __name__ == '__main__':
Expand Down

0 comments on commit 45efffb

Please sign in to comment.