nand_disk_layout.json: Reserve space for BBT in NAND

The MTD bad block table (BBT) code doesn't need to be told where to
store the bad block table. However, it'll reserve a block for itself
towards the end of the device. This patch makes nand_disk_layout.json
include a BBT partition with four blocks for the BBT. It also makes a
minor update to cgpt.py so that it doesn't choke on an empty partition
with reserved erase blocks.

BUG=none
TEST=builds Storm image

Change-Id: Id42d0232aaa77fe045a916910eefcfcde6d6d234
Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/243383
diff --git a/build_library/cgpt.py b/build_library/cgpt.py
index e612f93..925cf8b 100755
--- a/build_library/cgpt.py
+++ b/build_library/cgpt.py
@@ -1166,6 +1166,8 @@
   for partition in partitions:
     if ('reserved_erase_blocks' in partition or
         partition.get('format') == 'ubi'):
+      if partition.get('bytes', 0) == 0:
+        continue
       metadata = GetMetadataPartition(partitions)
       if (not _HasBadEraseBlocks(partitions)
           or 'reserved_erase_blocks' not in partition
diff --git a/build_library/nand_disk_layout.json b/build_library/nand_disk_layout.json
index b16bb69..b8bb3a7 100644
--- a/build_library/nand_disk_layout.json
+++ b/build_library/nand_disk_layout.json
@@ -80,6 +80,15 @@
       {
         "num": 3,
         "format":"ubi"
+      },
+      # BBT partition exists just to hold a few blocks open for
+      # the bad block table.
+      {
+        "num": 13,
+        "label": "BBT",
+        "size": 0,
+        "type": "blank",
+        "reserved_erase_blocks": 4
       }
     ],
     "usb": [