imgtool: change --max-align default value
The value of `--max-align` parameter passed to imgtool can never be
less than the value of `--align` parameter. At present the default
value of `--max-align` is fixed at 8. This forces user to pass the
parameter even when its value can be safely inferred.
Change the default value of the `--max-align` parameter to the larger
of the two values: `--align` or 8. Consequently, the user is required
to pass the parameter only if the flash alignment of the primary and
secondary slot differ.
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
diff --git a/scripts/imgtool/image.py b/scripts/imgtool/image.py
index d04333e..ef5d278 100644
--- a/scripts/imgtool/image.py
+++ b/scripts/imgtool/image.py
@@ -132,7 +132,7 @@
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=DEFAULT_MAX_ALIGN):
+ security_counter=None, max_align=None):
if load_addr and rom_fixed:
raise click.UsageError("Can not set rom_fixed and load_addr at the same time")
@@ -155,7 +155,7 @@
self.enckey = None
self.save_enctlv = save_enctlv
self.enctlv_len = 0
- self.max_align = DEFAULT_MAX_ALIGN if max_align is None else int(max_align)
+ self.max_align = max(DEFAULT_MAX_ALIGN, align) if max_align is None else int(max_align)
if self.max_align == DEFAULT_MAX_ALIGN:
self.boot_magic = bytes([