cgpt: Enable images to be built with auto detected block sizes.

Do not assume all images use 512 block sizes. Use new common
blocksize function to auto detect block size. Removed 'blocks'
label from partition and let them default to a minimum size
and removed 'blocks' field from default JSON file.

BUG=chromium:832160
BRANCH=none
CQ-DEPEND=CL:*657734
TEST=manual
./build_image --board=bob
installed on device and booted

Output of 'cgpt show /dev/mmcblk0' with my changes:
start        size    part  contents
           0           1          PMBR (Boot GUID: F3E1F680-95B0-054E-A82B-BD3F017DE459)
           1           1          Pri GPT header
           2          32          Pri GPT table
     8704000    52367312       1  Label: "STATE"
                                  Type: Linux data
                                  UUID: 3DFED94B-D9AE-B744-BD9F-BF0834938B33
       20480       32768       2  Label: "KERN-A"
                                  Type: ChromeOS kernel
                                  UUID: 0165168D-FA3F-E54F-8707-0AAEEF4D41EF
                                  Attr: priority=1 tries=0 successful=1
     4509696     4194304       3  Label: "ROOT-A"
                                  Type: ChromeOS rootfs
                                  UUID: C74D9CF6-152E-6B4E-964B-D4531A1268D1
       53248       32768       4  Label: "KERN-B"
                                  Type: ChromeOS kernel
                                  UUID: A0448FB5-D631-6C41-A5DA-18D8242735BC
                                  Attr: priority=0 tries=15 successful=0
      315392     4194304       5  Label: "ROOT-B"
                                  Type: ChromeOS rootfs
                                  UUID: DA8A4C29-EBCC-994C-ACD3-93C4F58A77DF
       16448           1       6  Label: "KERN-C"
                                  Type: ChromeOS kernel
                                  UUID: 36BA8C58-B600-3A4B-8B55-C32EB0164BBC
                                  Attr: priority=0 tries=15 successful=0
       16449           1       7  Label: "ROOT-C"
                                  Type: ChromeOS rootfs
                                  UUID: 56CE49CE-1DBD-F146-89E4-25B06C8B62C4
       86016       32768       8  Label: "OEM"
                                  Type: Linux data
                                  UUID: FA935D09-E726-E042-9B10-AA4C03AFB2EE
       16450           1       9  Label: "reserved"
                                  Type: ChromeOS reserved
                                  UUID: 2B982238-8E22-FA49-86C7-38734C5B33DE
       16451           1      10  Label: "reserved"
                                  Type: ChromeOS reserved
                                  UUID: 3B81F9CA-1BBA-164D-BEE9-0BCB1FA26F19
          64       16384      11  Label: "RWFW"
                                  Type: ChromeOS firmware
                                  UUID: E6944883-005E-AE4A-B3A8-B55AFCE94C42
      249856       65536      12  Label: "EFI-SYSTEM"
                                  Type: EFI System Partition
                                  UUID: F3E1F680-95B0-054E-A82B-BD3F017DE459
                                  Attr: legacy_boot=1
    61071327          32          Sec GPT table
    61071359           1          Sec GPT header

Output without changes:
start        size    part  contents
           0           1          PMBR (Boot GUID: 9DA82550-D83E-6A4C-BA78-054E98F12006)
           1           1          Pri GPT header
           2          32          Pri GPT table
     8704000    52363264       1  Label: "STATE"
                                  Type: Linux data
                                  UUID: 3F35D00C-8097-D54C-B480-CF48872FA474
       20480       32768       2  Label: "KERN-A"
                                  Type: ChromeOS kernel
                                  UUID: 920D89C0-F1A6-924D-9EE9-A30FD8FEC247
                                  Attr: priority=1 tries=6 successful=1
     4509696     4194304       3  Label: "ROOT-A"
                                  Type: ChromeOS rootfs
                                  UUID: BA717C2B-83EC-0944-B24D-CD3ED88BC9C4
       53248       32768       4  Label: "KERN-B"
                                  Type: ChromeOS kernel
                                  UUID: 3DD0DBA3-0525-0B4E-9327-9FCDBAAB6580
                                  Attr: priority=0 tries=15 successful=0
      315392     4194304       5  Label: "ROOT-B"
                                  Type: ChromeOS rootfs
                                  UUID: F88EBFC4-A004-B348-ACFB-539E3AA93575
       16448           1       6  Label: "KERN-C"
                                  Type: ChromeOS kernel
                                  UUID: 82A9EF93-5DAA-5F45-9FFE-8A3A5C8DAE7F
                                  Attr: priority=0 tries=15 successful=0
       16449           1       7  Label: "ROOT-C"
                                  Type: ChromeOS rootfs
                                  UUID: D92CE030-3113-AF4E-AFD8-5E7AA302B35A
       86016       32768       8  Label: "OEM"
                                  Type: Linux data
                                  UUID: 27D59369-75CA-3946-B9A5-B6F091E4908A
       16450           1       9  Label: "reserved"
                                  Type: ChromeOS reserved
                                  UUID: E234C4E2-3F61-7147-B281-06B90047CE75
       16451           1      10  Label: "reserved"
                                  Type: ChromeOS reserved
                                  UUID: F3961050-D6A0-3A43-BC2D-0E1DB18EBF3D
          64       16384      11  Label: "RWFW"
                                  Type: ChromeOS firmware
                                  UUID: BA21F542-9AD9-FD49-9CA9-7E7C472EDA78
      249856       65536      12  Label: "EFI-SYSTEM"
                                  Type: EFI System Partition
                                  UUID: 9DA82550-D83E-6A4C-BA78-054E98F12006
                                  Attr: legacy_boot=1
    61071327          32          Sec GPT table
    61071359           1          Sec GPT header

CQ-DEPEND=CL:1091293, CL:1091299, CL:1121781

Change-Id: I9494a3a5f6d277c61a369e32e47ef1a17f95e8ad
Reviewed-on: https://chromium-review.googlesource.com/1091308
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
4 files changed