From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 05D4681912 for ; Tue, 3 Jan 2017 21:14:58 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 03 Jan 2017 21:14:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,458,1477983600"; d="scan'208";a="25894713" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.121]) by orsmga002.jf.intel.com with ESMTP; 03 Jan 2017 21:14:57 -0800 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Liming Gao Date: Wed, 4 Jan 2017 13:14:57 +0800 Message-Id: <1483506897-109600-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: not report error for the optional items in the FmpTokens X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2017 05:14:59 -0000 in the FDF spec defined some optional items, eg: IMAGE_INDEX, HARDWARE_INSTANCE. but current tool report error if no such item is exist in the FDF file. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=293 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/GenFds/CapsuleData.py | 8 ++++++-- BaseTools/Source/Python/GenFds/FdfParser.py | 13 +++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py index d7a6d54..24c210d 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -1,9 +1,9 @@ ## @file # generate capsule # -# Copyright (c) 2007-2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007-2017, Intel Corporation. All rights reserved.
# # 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 @@ -184,11 +184,15 @@ class CapsulePayload(CapsuleData): self.Certificate_Guid = None self.MonotonicCount = None def GenCapsuleSubItem(self, AuthData=[]): if not self.Version: - self.Version = 0x00000002 + self.Version = '0x00000002' + if not self.ImageIndex: + self.ImageIndex = '0x1' + if not self.HardwareInstance: + self.HardwareInstance = '0x0' ImageFileSize = os.path.getsize(self.ImageFile) if AuthData: # the ImageFileSize need include the full authenticated info size. From first bytes of MonotonicCount to last bytes of certificate. # the 32 bit is the MonotonicCount, dwLength, wRevision, wCertificateType and CertType ImageFileSize += 32 diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 2900283..e1295f2 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -1,9 +1,9 @@ ## @file # parse FDF file # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.
# # 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 @@ -3237,17 +3237,14 @@ class FdfParser: else: self.__UndoToken() if (FmpData.MonotonicCount and not FmpData.Certificate_Guid) or (not FmpData.MonotonicCount and FmpData.Certificate_Guid): EdkLogger.error("FdfParser", FORMAT_INVALID, "CERTIFICATE_GUID and MONOTONIC_COUNT must be work as a pair.") - # remove CERTIFICATE_GUID and MONOTONIC_COUNT from FmpKeyList, since these keys are optional - if 'CERTIFICATE_GUID' in FmpKeyList: - FmpKeyList.remove('CERTIFICATE_GUID') - if 'MONOTONIC_COUNT' in FmpKeyList: - FmpKeyList.remove('MONOTONIC_COUNT') - if FmpKeyList: - raise Warning("Missing keywords %s in FMP payload section." % ', '.join(FmpKeyList), self.FileName, self.CurrentLineNumber) + + # Only the IMAGE_TYPE_ID is required item + if FmpKeyList and 'IMAGE_TYPE_ID' in FmpKeyList: + raise Warning("Missing keywords IMAGE_TYPE_ID in FMP payload section.", self.FileName, self.CurrentLineNumber) # get the Image file and Vendor code file self.__GetFMPCapsuleData(FmpData) if not FmpData.ImageFile: raise Warning("Missing image file in FMP payload section.", self.FileName, self.CurrentLineNumber) # check whether more than one Vendor code file -- 2.6.1.windows.1