public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Bob Feng" <bob.c.feng@intel.com>
To: "Chen, Christine" <yuwei.chen@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Rebecca Cran <rebecca@bsdio.com>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>
Subject: Re: [Patch V2 1/4] BaseTools: fixing FMMT ShrinkFv issue
Date: Thu, 29 Jun 2023 06:54:05 +0000	[thread overview]
Message-ID: <PH7PR11MB58636F908E47A68B538B9560C925A@PH7PR11MB5863.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230629033420.872-1-yuwei.chen@intel.com>

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: Chen, Christine <yuwei.chen@intel.com> 
Sent: Thursday, June 29, 2023 11:34 AM
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@bsdio.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>
Subject: [Patch V2 1/4] BaseTools: fixing FMMT ShrinkFv issue

1. FvLength not change issue;
2. FileSystemGuid align with File Size;

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
---
 BaseTools/Source/Python/FMMT/core/FMMTOperation.py |  2 +-
 BaseTools/Source/Python/FMMT/core/FvHandler.py     | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/FMMT/core/FMMTOperation.py b/BaseTools/Source/Python/FMMT/core/FMMTOperation.py
index a86f8dda9a1a..d4aa3397036d 100644
--- a/BaseTools/Source/Python/FMMT/core/FMMTOperation.py
+++ b/BaseTools/Source/Python/FMMT/core/FMMTOperation.py
@@ -188,7 +188,7 @@ def ExtractFfs(inputfile: str, Ffs_name: str, outputfile: str, Fv_name: str=None
                 FmmtParser.WholeFvTree.Findlist.remove(FmmtParser.WholeFvTree.Findlist[index])
     if FmmtParser.WholeFvTree.Findlist != []:
         TargetNode = FmmtParser.WholeFvTree.Findlist[0]
-        if TargetNode.type == FV_TREE or SEC_FV_TREE or DATA_FV_TREE:
+        if TargetNode.type == FV_TREE or TargetNode.type == SEC_FV_TREE or TargetNode.type == DATA_FV_TREE:
             FinalData = struct2stream(TargetNode.Data.Header) + TargetNode.Data.Data
             with open(outputfile, "wb") as f:
                 f.write(FinalData)
diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Source/Python/FMMT/core/FvHandler.py
index ff3d637623f8..b0cc1951a1c6 100644
--- a/BaseTools/Source/Python/FMMT/core/FvHandler.py
+++ b/BaseTools/Source/Python/FMMT/core/FvHandler.py
@@ -279,7 +279,7 @@ class FvHandler:
                             ParTree.Child.remove(ParTree.Child[-1])
                             ParTree.Data.Free_Space = 0
                         ParTree.Data.Size += Needed_Space
-                        ParTree.Data.Header.Fvlength = ParTree.Data.Size
+                        ParTree.Data.Header.FvLength = ParTree.Data.Size
                 ModifyFvSystemGuid(ParTree)
                 for item in ParTree.Child:
                     if item.type == FFS_FREE_SPACE:
@@ -650,8 +650,12 @@ class FvHandler:
             Removed_Space = TargetFv.Data.Free_Space - New_Free_Space
             TargetFv.Child[-1].Data.Data = b'\xff' * New_Free_Space
             TargetFv.Data.Size -= Removed_Space
-            TargetFv.Data.Header.Fvlength = TargetFv.Data.Size
-            ModifyFvSystemGuid(TargetFv)
+            TargetFv.Data.Header.FvLength = TargetFv.Data.Size
+            if struct2stream(TargetFv.Data.Header.FileSystemGuid) == EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE:
+                if TargetFv.Data.Size <= 0xFFFFFF:
+                    TargetFv.Data.Header.FileSystemGuid = ModifyGuidFormat(
+                        "8c8ce578-8a3d-4f1c-9935-896185c32dd3")
+
             for item in TargetFv.Child:
                 if item.type == FFS_FREE_SPACE:
                     TargetFv.Data.Data += item.Data.Data + item.Data.PadData
-- 
2.27.0.windows.1


  reply	other threads:[~2023-06-29  6:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29  3:34 [Patch V2 1/4] BaseTools: fixing FMMT ShrinkFv issue Yuwei Chen
2023-06-29  6:54 ` Bob Feng [this message]
2023-08-30  8:43   ` 回复: [edk2-devel] " gaoliming via groups.io
2023-09-11  1:23     ` Yuwei Chen
     [not found]     ` <1783B3A3A09571FB.23877@groups.io>
2023-11-29  8:25       ` Yuwei Chen
2023-11-29 15:53         ` 回复: " gaoliming via groups.io
2023-12-04  2:58           ` Yuwei Chen
2023-12-11  9:04             ` 回复: " gaoliming via groups.io
2023-12-11  9:34               ` Yuwei Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH7PR11MB58636F908E47A68B538B9560C925A@PH7PR11MB5863.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox