]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Enhance GenFv Tool to report error message
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 7 Dec 2015 09:04:39 +0000 (09:04 +0000)
committeryzhu52 <yzhu52@Edk2>
Mon, 7 Dec 2015 09:04:39 +0000 (09:04 +0000)
When two vtf files in one FV image, no FV file can be generated, but it
report the stack trace info. so we enhance the tool to report error
message directly but not the stack trace info.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19141 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/C/GenFv/GenFvInternalLib.c
BaseTools/Source/Python/GenFds/Fv.py

index 6d2d5d1f8c6710fd92d60619788afd4b9364b029..10bb88b0a88c3625b7aaa5b7c9a7669bd938fe1e 100644 (file)
@@ -2854,17 +2854,18 @@ Returns:
     fclose (fpin);\r
     \r
     if (FvInfoPtr->IsPiFvImage) {\r
     fclose (fpin);\r
     \r
     if (FvInfoPtr->IsPiFvImage) {\r
-           //\r
-           // Check whether this ffs file is vtf file\r
-           //\r
-           if (IsVtfFile (&FfsHeader)) {\r
-             if (VtfFileFlag) {\r
-               //\r
-               // One Fv image can't have two vtf files.\r
-               //\r
-               return EFI_ABORTED;\r
-             }\r
-             VtfFileFlag = TRUE;\r
+        //\r
+        // Check whether this ffs file is vtf file\r
+        //\r
+        if (IsVtfFile (&FfsHeader)) {\r
+          if (VtfFileFlag) {\r
+            //\r
+            // One Fv image can't have two vtf files.\r
+            //\r
+            Error (NULL, 0, 3000,"Invalid", "One Fv image can't have two vtf files.");\r
+            return EFI_ABORTED;\r
+          }\r
+          VtfFileFlag = TRUE;\r
         VtfFileSize = FfsFileSize;\r
         continue;\r
       }\r
         VtfFileSize = FfsFileSize;\r
         continue;\r
       }\r
index 163ccd37f1582a03a3056bae04e587801dfa51a7..df97ccbab6484fd74d85b09c8429d11d26bd5055 100644 (file)
@@ -181,30 +181,33 @@ class FV (FvClassObject):
         #\r
         # Write the Fv contents to Buffer\r
         #\r
         #\r
         # Write the Fv contents to Buffer\r
         #\r
-        FvFileObj = open ( FvOutputFile,'r+b')\r
+        if os.path.isfile(FvOutputFile):\r
+            FvFileObj = open ( FvOutputFile,'r+b')\r
 \r
 \r
-        GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName)\r
-        GenFdsGlobalVariable.SharpCounter = 0\r
+            GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName)\r
+            GenFdsGlobalVariable.SharpCounter = 0\r
 \r
 \r
-        Buffer.write(FvFileObj.read())\r
-        FvFileObj.seek(0)\r
-        # PI FvHeader is 0x48 byte\r
-        FvHeaderBuffer = FvFileObj.read(0x48)\r
-        # FV alignment position.\r
-        FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
-        # FvAlignmentValue is larger than or equal to 1K\r
-        if FvAlignmentValue >= 0x400:\r
-            if FvAlignmentValue >= 0x10000:\r
-                #The max alignment supported by FFS is 64K.\r
-                self.FvAlignment = "64K"\r
+            Buffer.write(FvFileObj.read())\r
+            FvFileObj.seek(0)\r
+            # PI FvHeader is 0x48 byte\r
+            FvHeaderBuffer = FvFileObj.read(0x48)\r
+            # FV alignment position.\r
+            FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
+            # FvAlignmentValue is larger than or equal to 1K\r
+            if FvAlignmentValue >= 0x400:\r
+                if FvAlignmentValue >= 0x10000:\r
+                    #The max alignment supported by FFS is 64K.\r
+                    self.FvAlignment = "64K"\r
+                else:\r
+                    self.FvAlignment = str (FvAlignmentValue / 0x400) + "K"\r
             else:\r
             else:\r
-                self.FvAlignment = str (FvAlignmentValue / 0x400) + "K"\r
+                # FvAlignmentValue is less than 1K\r
+                self.FvAlignment = str (FvAlignmentValue)\r
+            FvFileObj.close()\r
+            GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile\r
+            GenFdsGlobalVariable.LargeFileInFvFlags.pop()\r
         else:\r
         else:\r
-            # FvAlignmentValue is less than 1K\r
-            self.FvAlignment = str (FvAlignmentValue)\r
-        FvFileObj.close()\r
-        GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile\r
-        GenFdsGlobalVariable.LargeFileInFvFlags.pop()\r
+            GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName)\r
         return FvOutputFile\r
 \r
     ## _GetBlockSize()\r
         return FvOutputFile\r
 \r
     ## _GetBlockSize()\r