Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imgtool: Add --non-bootable flag #1908

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion scripts/imgtool/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ def __init__(self, version=None, header_size=IMAGE_HEADER_SIZE,
slot_size=0, max_sectors=DEFAULT_MAX_SECTORS,
overwrite_only=False, endian="little", load_addr=0,
rom_fixed=None, erased_val=None, save_enctlv=False,
security_counter=None, max_align=None):
security_counter=None, max_align=None,
non_bootable=False):

if load_addr and rom_fixed:
raise click.UsageError("Can not set rom_fixed and load_addr at the same time")
Expand All @@ -166,6 +167,7 @@ def __init__(self, version=None, header_size=IMAGE_HEADER_SIZE,
self.save_enctlv = save_enctlv
self.enctlv_len = 0
self.max_align = max(DEFAULT_MAX_ALIGN, align) if max_align is None else int(max_align)
self.non_bootable = non_bootable

if self.max_align == DEFAULT_MAX_ALIGN:
self.boot_magic = bytes([
Expand Down Expand Up @@ -551,6 +553,8 @@ def add_header(self, enckey, protected_tlv_size, aes_length=128):
flags |= IMAGE_F['RAM_LOAD']
if self.rom_fixed:
flags |= IMAGE_F['ROM_FIXED']
if self.non_bootable:
flags |= IMAGE_F['NON_BOOTABLE']

e = STRUCT_ENDIAN_DICT[self.endian]
fmt = (e +
Expand Down
7 changes: 5 additions & 2 deletions scripts/imgtool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ def convert(self, value, param, ctx):

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

if confirm:
# Confirmed but non-padded images don't make much sense, because
Expand All @@ -421,7 +423,8 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
max_sectors=max_sectors, overwrite_only=overwrite_only,
endian=endian, load_addr=load_addr, rom_fixed=rom_fixed,
erased_val=erased_val, save_enctlv=save_enctlv,
security_counter=security_counter, max_align=max_align)
security_counter=security_counter, max_align=max_align,
non_bootable=non_bootable)
img.load(infile)
key = load_key(key) if key else None
enckey = load_key(encrypt) if encrypt else None
Expand Down