From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: chasel.chiu@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Mon, 24 Jun 2019 07:36:35 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jun 2019 07:36:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,412,1557212400"; d="scan'208";a="161632138" Received: from elinachx-mobl.gar.corp.intel.com (HELO cchiu4-MOBL1.gar.corp.intel.com) ([10.252.191.119]) by fmsmga008.fm.intel.com with ESMTP; 24 Jun 2019 07:36:33 -0700 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: Michael Kubacki , Nate DeSimone , Liming Gao Subject: [PATCH] MinPlatformPkg: FSP Python script to python 3.x. Date: Mon, 24 Jun 2019 22:36:17 +0800 Message-Id: <20190624143617.16164-1-chasel.chiu@intel.com> X-Mailer: git-send-email 2.13.3.windows.1 https://bugzilla.tianocore.org/show_bug.cgi?id=1930 Updated FSP Python script to support both 2.x and 3.x. Test: . Verified with Python 2.7.12 and 3.6.6. . Verified tool result is the same before the change. . Both py -2 and py -3 built binary can boot. Cc: Michael Kubacki Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Chasel Chiu --- Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py index 167a0e0a4c..406e5ec130 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py +++ b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py @@ -10,16 +10,16 @@ import re import subprocess if len(sys.argv) not in [6,7]: - print "RebaseAndPatchFspBinBaseAddress.py - Error in number of arguments received" - print "Usage - RebaseAndPatchFspBinBaseAddress.py \ - " + print ("RebaseAndPatchFspBinBaseAddress.py - Error in number of arguments received") + print ("Usage - RebaseAndPatchFspBinBaseAddress.py \ + ") exit(1) flashMapName = sys.argv[1] fspBinPath = sys.argv[2] fspBinFile = sys.argv[3] targetDscFile = sys.argv[4] -fvOffset = long(sys.argv[5], 16) +fvOffset = int(sys.argv[5], 16) fspBinFileRebased = "Fsp_Rebased.fd" splitFspBinPath = os.path.join("edk2","IntelFsp2Pkg","Tools","SplitFspBin.py") @@ -30,21 +30,21 @@ if len(sys.argv) == 7: # Make sure argument passed or valid # if not os.path.exists(flashMapName): - print "WARNING! " + str(flashMapName) + " is not found." + print ("WARNING! " + str(flashMapName) + " is not found.") exit(1) fspBinFilePath = fspBinPath + os.sep + fspBinFile if not os.path.exists(fspBinFilePath): - print "WARNING! " + str(fspBinFilePath) + " is not found." + print ("WARNING! " + str(fspBinFilePath) + " is not found.") exit(1) if not os.path.exists(targetDscFile): - print "WARNING! " + str(targetDscFile) + " is not found." + print ("WARNING! " + str(targetDscFile) + " is not found.") exit(1) ext_file = str(os.path.splitext(targetDscFile)[-1]).lower() if ext_file != ".dsc": - print "WARNING! " + str(targetDscFile) + " is not a dsc file" + print ("WARNING! " + str(targetDscFile) + " is not a dsc file") exit(1) if not os.path.exists(splitFspBinPath): - print "WARNING! " + str(splitFspBinPath) + " is not found." + print ("WARNING! " + str(splitFspBinPath) + " is not found.") exit(1) # @@ -54,7 +54,7 @@ file = open (flashMapName, "r") data = file.read () # Get the Flash Base Address -flashBase = long(data.split("FLASH_BASE")[1].split("=")[1].split()[0], 16) +flashBase = int(data.split("FLASH_BASE")[1].split("=")[1].split()[0], 16) # Based on Build Target, select the section in the FlashMap file flashmap = data @@ -62,11 +62,11 @@ flashmap = data # Get FSP-S & FSP-M & FSP-T offset & calculate the base for line in flashmap.split("\n"): if "PcdFlashFvFspSOffset" in line: - fspSBaseOffset = long(line.split("=")[1].split()[0], 16) + fspSBaseOffset = int(line.split("=")[1].split()[0], 16) if "PcdFlashFvFspMOffset" in line: - fspMBaseOffset = long(line.split("=")[1].split()[0], 16) + fspMBaseOffset = int(line.split("=")[1].split()[0], 16) if "PcdFlashFvFspTOffset" in line: - fspTBaseOffset = long(line.split("=")[1].split()[0], 16) + fspTBaseOffset = int(line.split("=")[1].split()[0], 16) file.close() # @@ -78,10 +78,10 @@ if 'PYTHON_HOME' in os.environ: pythontool = os.environ['PYTHON_HOME'] + os.sep + 'python' Process = subprocess.Popen([pythontool, splitFspBinPath, "info","-f",fspBinFilePath], stdout=subprocess.PIPE) Output = Process.communicate()[0] -FsptInfo = Output.rsplit("FSP_M", 1); -for line in FsptInfo[1].split("\n"): - if "ImageSize" in line: - fspMSize = long(line.split("=")[1], 16) +FsptInfo = Output.rsplit(b"FSP_M", 1); +for line in FsptInfo[1].split(b"\n"): + if b"ImageSize" in line: + fspMSize = int(line.split(b"=")[1], 16) break # Calculate FSP-S/M/T base address, to which re-base has to be done -- 2.13.3.windows.1