when the FV contents come from the filesystem instead of from a named FDF section, the build tool missed to generate alignment for this FV. The fix is get the alignment value from FV header and use this value to generate alignment.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong....@intel.com> --- BaseTools/Source/Python/GenFds/FvImageSection.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py index caf8de1..b577de2 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -1,9 +1,9 @@ ## @file # process FV image section generation # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR> # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php @@ -81,10 +81,28 @@ class FvImageSection(FvImageSectionClassObject): if GenFdsGlobalVariable.GetAlignment (Fv.FvAlignment) > GenFdsGlobalVariable.GetAlignment (self.Alignment): self.Alignment = Fv.FvAlignment else: if self.FvFileName != None: FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName) + if os.path.isfile(FvFileName): + FvFileObj = open (FvFileName,'r+b') + FvFileObj.seek(0) + # PI FvHeader is 0x48 byte + FvHeaderBuffer = FvFileObj.read(0x48) + # FV alignment position. + FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F) + # FvAlignmentValue is larger than or equal to 1K + if FvAlignmentValue >= 0x400: + if FvAlignmentValue >= 0x10000: + #The max alignment supported by FFS is 64K. + self.Alignment = "64K" + else: + self.Alignment = str (FvAlignmentValue / 0x400) + "K" + else: + # FvAlignmentValue is less than 1K + self.Alignment = str (FvAlignmentValue) + FvFileObj.close() else: EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSection Failed! %s NOT found in FDF" % self.FvName) # # Prepare the parameter of GenSection -- 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel