REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2527 One BIOS image may have more than FVs with SEC module. FCE tool should find the latest FV with SEC module as BFV image. Cc: Bob Feng Cc: Liming Gao Signed-off-by: Yunhua Feng --- BaseTools/Source/C/BfmLib/BinFileManager.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/BaseTools/Source/C/BfmLib/BinFileManager.c b/BaseTools/Source/C/BfmLib/BinFileManager.c index 9b4e0929f5..69521044b8 100644 --- a/BaseTools/Source/C/BfmLib/BinFileManager.c +++ b/BaseTools/Source/C/BfmLib/BinFileManager.c @@ -251,10 +251,11 @@ BfmImageAdd ( BOOLEAN FfsLevelFoundFlag; CHAR8 *OutputFileName; CHAR8 *FvId; BOOLEAN FirstInFlag; BOOLEAN FvGuidExisted; + FV_INFORMATION *FvInFdTmp; NewFvLength = 0; FvEncapLevel = 0; NewAddedFfsLevel = 0; @@ -269,10 +270,11 @@ BfmImageAdd ( TemDir = NULL; LocalEncapDataTemp = NULL; OutputFileName = NULL; FvId = NULL; FvGuidExisted = FALSE; + FvInFdTmp = NULL; // // Get the size of ffs file to be inserted. // NewFfsLength = GetFileSize(NewFile); @@ -306,10 +308,19 @@ BfmImageAdd ( // FvInFd = FdData->Fv; do { if ((FvGuidExisted && mFvGuidIsSet && FvInFd->IsInputFvFlag) || ((!FvGuidExisted || (!mFvGuidIsSet)) && FvInFd->IsBfvFlag)) { + if (FvInFd->IsBfvFlag) { + FvInFdTmp = FdData->Fv; + while (FvInFdTmp != NULL) { + if (FvInFdTmp->IsBfvFlag) { + FvInFd = FvInFdTmp; + } + FvInFdTmp = FvInFdTmp->FvNext; + } + } Status = LibLocateBfv (FdData, &FvId, &FvInFd); if (EFI_ERROR (Status)) { printf("Error while locate BFV from FD.\n"); LibBfmFreeFd(FdData); -- 2.12.2.windows.2