avbtool: Generate forward-error-correcting codes for hashtree by default.

The overhead of FEC is tiny and data shows that it help a lot. So just
enable it by default to avoid everybody having to manually turn it on.

Technically this is a breaking change (insofar hashtree images will
now have FEC on when avbtool is updated) but since we haven't actually
released 1.0.0 and it's still early days for AVB, do it anyway. Do
warn on stderr that the --generate_fec option is now deprecated.

Bug: None
Test: All unit tests pass
Test: Manually tested on UEFI-based bootloader.
Change-Id: Ife5038b8d2f4b4ebc88138bb38048ad50094fd2a
diff --git a/avbtool b/avbtool
index 08876a2..7c18d46 100755
--- a/avbtool
+++ b/avbtool
@@ -3279,8 +3279,16 @@
                             help='Block size (default: 4096)',
                             type=parse_number,
                             default=4096)
+    # TODO(zeuthen): The --generate_fec option was removed when we
+    # moved to generating FEC by default. To avoid breaking existing
+    # users needing to transition we simply just print a warning below
+    # in add_hashtree_footer(). Remove this option and the warning at
+    # some point in the future.
     sub_parser.add_argument('--generate_fec',
-                            help='Add forward-error-correction codes',
+                            help=argparse.SUPPRESS,
+                            action='store_true')
+    sub_parser.add_argument('--do_not_generate_fec',
+                            help='Do not generate forward-error-correction codes',
                             action='store_true')
     sub_parser.add_argument('--fec_num_roots',
                             help='Number of roots for FEC (default: 2)',
@@ -3485,10 +3493,16 @@
   def add_hashtree_footer(self, args):
     """Implements the 'add_hashtree_footer' sub-command."""
     args = self._fixup_common_args(args)
+    # TODO(zeuthen): Remove when removing support for the
+    # '--generate_fec' option above.
+    if args.generate_fec:
+      sys.stderr.write('The --generate_fec option is deprecated since FEC '
+                       'is now generated by default. Use the option '
+                       '--do_not_generate_fec to not generate FEC.\n')
     self.avb.add_hashtree_footer(args.image.name if args.image else None,
                                  args.partition_size,
                                  args.partition_name,
-                                 args.generate_fec, args.fec_num_roots,
+                                 not args.do_not_generate_fec, args.fec_num_roots,
                                  args.hash_algorithm, args.block_size,
                                  args.salt, args.chain_partition, args.algorithm,
                                  args.key, args.public_key_metadata,