Skip to content

Commit dc03055

Browse files
mateusz-nordicjm
authored andcommitted
imgtool: Add --non-bootable flag
Defaults to false. Signed-off-by: Mateusz Wielgos <[email protected]>
1 parent aa1f956 commit dc03055

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

scripts/imgtool/image.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ def __init__(self, version=None, header_size=IMAGE_HEADER_SIZE,
159159
slot_size=0, max_sectors=DEFAULT_MAX_SECTORS,
160160
overwrite_only=False, endian="little", load_addr=0,
161161
rom_fixed=None, erased_val=None, save_enctlv=False,
162-
security_counter=None, max_align=None):
162+
security_counter=None, max_align=None,
163+
non_bootable=False):
163164

164165
if load_addr and rom_fixed:
165166
raise click.UsageError("Can not set rom_fixed and load_addr at the same time")
@@ -183,6 +184,7 @@ def __init__(self, version=None, header_size=IMAGE_HEADER_SIZE,
183184
self.save_enctlv = save_enctlv
184185
self.enctlv_len = 0
185186
self.max_align = max(DEFAULT_MAX_ALIGN, align) if max_align is None else int(max_align)
187+
self.non_bootable = non_bootable
186188

187189
if self.max_align == DEFAULT_MAX_ALIGN:
188190
self.boot_magic = bytes([
@@ -567,6 +569,8 @@ def add_header(self, enckey, protected_tlv_size, aes_length=128):
567569
flags |= IMAGE_F['RAM_LOAD']
568570
if self.rom_fixed:
569571
flags |= IMAGE_F['ROM_FIXED']
572+
if self.non_bootable:
573+
flags |= IMAGE_F['NON_BOOTABLE']
570574

571575
e = STRUCT_ENDIAN_DICT[self.endian]
572576
fmt = (e +

scripts/imgtool/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ def convert(self, value, param, ctx):
314314

315315
@click.argument('outfile')
316316
@click.argument('infile')
317+
@click.option('--non-bootable', default=False, is_flag=True,
318+
help='Mark the image as non-bootable.')
317319
@click.option('--custom-tlv', required=False, nargs=2, default=[],
318320
multiple=True, metavar='[tag] [value]',
319321
help='Custom TLV that will be placed into protected area. '
@@ -411,7 +413,7 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
411413
endian, encrypt_keylen, encrypt, infile, outfile, dependencies,
412414
load_addr, hex_addr, erased_val, save_enctlv, security_counter,
413415
boot_record, custom_tlv, rom_fixed, max_align, clear, fix_sig,
414-
fix_sig_pubkey, sig_out, vector_to_sign):
416+
fix_sig_pubkey, sig_out, vector_to_sign, non_bootable):
415417

416418
if confirm:
417419
# Confirmed but non-padded images don't make much sense, because
@@ -423,7 +425,8 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
423425
max_sectors=max_sectors, overwrite_only=overwrite_only,
424426
endian=endian, load_addr=load_addr, rom_fixed=rom_fixed,
425427
erased_val=erased_val, save_enctlv=save_enctlv,
426-
security_counter=security_counter, max_align=max_align)
428+
security_counter=security_counter, max_align=max_align,
429+
non_bootable=non_bootable)
427430
img.load(infile)
428431
key = load_key(key) if key else None
429432
enckey = load_key(encrypt) if encrypt else None

0 commit comments

Comments
 (0)