update_kernel: Use fixed partition numbers as fallback

When updating kernel on a device with a R57 image, update_kernel
succeeds without any error, but the kernel is mysteriously not
updated.

The issue is that older images built before
https://chromium-review.googlesource.com/c/439508/
has no PARTITION_NUM_* in /usr/sbin/write_gpt.sh which is
read by update_kernel since
https://chromium-review.googlesource.com/c/451543/

So new_kern.bin is dd-ed to /dev/mmcblk0p instead of
/dev/mmcblk0p2 or /dev/mmcblk0p4.

This patch adds the fixed partition numbers as fallback
in case the target image provides none.

BUG=chromium:733028
TEST=update_kernel to a R57 image on Kip and see local
kernel changes are applied on device.

Change-Id: I3931ef447e3e0f4314ba2b295b32dd4b531b37bd
Signed-off-by: Ben Zhang <benzh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/540741
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/update_kernel.sh b/update_kernel.sh
index b00b0c5..5025aea 100755
--- a/update_kernel.sh
+++ b/update_kernel.sh
@@ -47,6 +47,14 @@
   info "Target reports root device is ${FLAGS_device}"
 }
 
+# Delete the fixed numbers after R65 when we don't care about <R57 upgrades.
+load_default_partition_numbers() {
+  PARTITION_NUM_KERN_A=2
+  PARTITION_NUM_ROOT_A=3
+  PARTITION_NUM_KERN_B=4
+  PARTITION_NUM_EFI_SYSTEM=12
+}
+
 # Ask the target what the kernel partition is
 learn_partition_and_ro() {
   ! remote_sh rootdev
@@ -223,6 +231,10 @@
   learn_device
 
   learn_partition_layout
+  if [[ -z "${PARTITION_NUM_KERN_A}" ]]; then
+    info "Target has no partition number info, use default instead"
+    load_default_partition_numbers
+  fi
 
   learn_partition_and_ro