[PATCH] [edk2-staging] [PATCH] BaseTools/Bfm: Fix "-g" input FV is not BFV issue

Yang Jie

FCE tool provides "-g" parameter to indicate which FV to insert
binaries. Current code logic has some defects when this FV is
not the last BFV, this patch is to fix this issue and enhance
this tool.

Signed-off-by: jie.yang <jie.yang@...>

Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
BaseTools/Source/C/BfmLib/BinFileManager.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/BfmLib/BinFileManager.c b/BaseTools/Source/=
index 69521044b8..42953bfce5 100644
--- a/BaseTools/Source/C/BfmLib/BinFileManager.c
+++ b/BaseTools/Source/C/BfmLib/BinFileManager.c
@@ -2,7 +2,7 @@
The main entry of BFM tool.=0D
- Copyright (c) 2011-2019, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2011-2022, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
@@ -310,7 +310,10 @@ BfmImageAdd (
do {=0D
if ((FvGuidExisted && mFvGuidIsSet && FvInFd->IsInputFvFlag) || ((!FvG=
uidExisted || (!mFvGuidIsSet)) && FvInFd->IsBfvFlag)) {=0D
- if (FvInFd->IsBfvFlag) {=0D
+ if (FvInFd->IsBfvFlag && !FvGuidExisted) {=0D
+ //=0D
+ // No target FV is set, find the last BFV to insert Binary=0D
+ //=0D
FvInFdTmp =3D FdData->Fv;=0D
while (FvInFdTmp !=3D NULL) {=0D
if (FvInFdTmp->IsBfvFlag) {=0D

Join {devel@edk2.groups.io to automatically receive all group messages.