summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorYuwei Chen <yuwei.chen@intel.com>2023-06-29 11:34:20 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-12-11 10:12:52 +0000
commit5b5481526fc9b89e5f3843d9bb3d6c4f5ce41060 (patch)
tree5621ea2372c5c97e634d0f938436fb4d82bdf983 /BaseTools
parent59f0d350a9f39fdb1d26295457eaf14306703afb (diff)
downloadedk2-5b5481526fc9b89e5f3843d9bb3d6c4f5ce41060.tar.gz
edk2-5b5481526fc9b89e5f3843d9bb3d6c4f5ce41060.tar.bz2
edk2-5b5481526fc9b89e5f3843d9bb3d6c4f5ce41060.zip
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> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/FMMT/core/FMMTOperation.py2
-rw-r--r--BaseTools/Source/Python/FMMT/core/FvHandler.py10
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 a86f8dda9a..d4aa339703 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 c7aca95bf2..7a60760336 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:
@@ -663,8 +663,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