hikey: Program serialno only once in flash-all.sh am: e9b656f63b am: a60251f498 am: 03449132ac
am: df9476a6c8

Change-Id: I0e3e9d5a1c741b1a886158ee229773748e36b42d
diff --git a/installer/flash-all.sh b/installer/flash-all.sh
index 7476db3..0fd401f 100755
--- a/installer/flash-all.sh
+++ b/installer/flash-all.sh
@@ -61,8 +61,16 @@
 echo "android out dir:${OUT_IMGDIR}"
 
 sudo python "${INSTALLER_DIR}"/hisi-idt.py --img1="${FIRMWARE_DIR}"/l-loader.bin -d "${DEVICE_PORT}"
+sleep 3
 # set a unique serial number
-fastboot oem serialno
+serialno=`fastboot getvar serialno 2>&1 > /dev/null`
+if [ "${serialno:10:6}" == "(null)" ]; then
+    fastboot oem serialno
+else
+    if [ "${serialno:10:15}" == "0123456789abcde" ]; then
+        fastboot oem serialno
+    fi
+fi
 fastboot flash ptable "${INSTALLER_DIR}"/"${PTABLE}"
 fastboot flash fastboot "${FIRMWARE_DIR}"/fip.bin
 fastboot flash nvme "${INSTALLER_DIR}"/nvme.img