ginstall: add flash unlock support for gflt

sysvar and GFLT110 have flash locking behavior that can cause ginstall
to fail to install until the next reboot (in the new uboot we turn off
flash protection before boot) however flash can be locked from Linux.

If this is a FiberJack, make ginstall unlock the mtd partition we are
writing to using the flash_unlock tool.

Change-Id: I9ec8b3a04261e216f52f90632a0c2745f3471316
diff --git a/ginstall/ginstall.py b/ginstall/ginstall.py
index 983d76c..968a933 100755
--- a/ginstall/ginstall.py
+++ b/ginstall/ginstall.py
@@ -346,6 +346,13 @@
   return subprocess.call(cmd)
 
 
+def UnlockMtd(mtddevname):
+  """Unlocks an mtd partition."""
+  VerbosePrint('Unlocking flash partition %r\n', mtddevname)
+  cmd = ['flash_unlock', mtddevname]
+  return subprocess.call(cmd)
+
+
 def Nandwrite(f, mtddevname):
   """Write file to NAND flash using nandwrite."""
   cmd = ['nandwrite', '--quiet', '--markbad', mtddevname]
@@ -428,6 +435,9 @@
   if IsMtdNand(mtddevname) and GetPlatform().startswith('GFRG2'):
     return _CopyAndVerifyNand(f, mtddevname)
   else:
+    if GetPlatform().startswith('GFLT'):
+      if UnlockMtd(mtddevname):
+        raise IOError('Flash unlocking failed.')
     return _CopyAndVerify(mtddevname, f, open(mtddevname, 'r+b'))