imgtool: add erased-val cli option

Add `-R`/`--erased-val` CLI option when creating images, which accepts
a value to be used for padding. This is useful when creating images
that run in devices that have flash erased to some value different
from 0xff (like STM32L0x and STM32L1x that have 0s).

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py
index 48bbd74..2b0d4fe 100755
--- a/scripts/imgtool/main.py
+++ b/scripts/imgtool/main.py
@@ -182,6 +182,9 @@
 
 @click.argument('outfile')
 @click.argument('infile')
+@click.option('-R', '--erased-val', type=click.Choice(['0', '0xff']),
+              required=False,
+              help='The value that is read back from erased flash.')
 @click.option('-x', '--hex-addr', type=BasedIntParamType(), required=False,
               help='Adjust address in hex output file.')
 @click.option('-L', '--load-addr', type=BasedIntParamType(), required=False,
@@ -214,12 +217,12 @@
                .hex extension, otherwise binary format is used''')
 def sign(key, align, version, header_size, pad_header, slot_size, pad,
          max_sectors, overwrite_only, endian, encrypt, infile, outfile,
-         dependencies, load_addr, hex_addr):
+         dependencies, load_addr, hex_addr, erased_val):
     img = image.Image(version=decode_version(version), header_size=header_size,
                       pad_header=pad_header, pad=pad, align=int(align),
                       slot_size=slot_size, max_sectors=max_sectors,
                       overwrite_only=overwrite_only, endian=endian,
-                      load_addr=load_addr)
+                      load_addr=load_addr, erased_val=erased_val)
     img.load(infile)
     key = load_key(key) if key else None
     enckey = load_key(encrypt) if encrypt else None