qca: Modify pack.py script

Add print statements to display the failure reason for flashing.

Change-Id: Ib355271bdef307f6a981b32738a1a4195dc979ec
Signed-off-by: Pavithra Palanisamy <pavip@codeaurora.org>
diff --git a/tools/pack.py b/tools/pack.py
index 14b7e92..ba304de 100755
--- a/tools/pack.py
+++ b/tools/pack.py
@@ -328,9 +328,21 @@
         """
 
         if fatal:
+            """Check cmd strings to display reason for failure."""
+
+            if "imxtract" in cmd:
+                self.script.append("failreason='error: failed on image extraction'\n")
+            elif "erase" in cmd:
+                self.script.append("failreason='error: failed on partition erase'\n")
+            elif "write" in cmd:
+                self.script.append("failreason='error: failed on partition write'\n")
+            else:
+                pass
+
             self.script.append(cmd
                                + ' || setenv stdout serial'
                                + ' && echo "$failedmsg"'
+                               + ' && echo "$failreason"'
                                + ' && exit 1\n')
         else:
             self.script.append(cmd + "\n")