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.100, mailfrom: nathaniel.l.desimone@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Fri, 28 Jun 2019 14:16:56 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2019 14:16:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,429,1557212400"; d="scan'208";a="189575167" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga002.fm.intel.com with ESMTP; 28 Jun 2019 14:16:55 -0700 Received: from orsmsx116.amr.corp.intel.com (10.22.240.14) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 28 Jun 2019 14:16:55 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.32]) by ORSMSX116.amr.corp.intel.com ([169.254.7.109]) with mapi id 14.03.0439.000; Fri, 28 Jun 2019 14:16:54 -0700 From: "Nate DeSimone" To: "Chiu, Chasel" , "devel@edk2.groups.io" CC: "Kubacki, Michael A" , "Gao, Liming" Subject: Re: [PATCH] MinPlatformPkg: FSP Python script to python 3.x. Thread-Topic: [PATCH] MinPlatformPkg: FSP Python script to python 3.x. Thread-Index: AQHVKpo/uJMZQ2g7UkCkLq4SqXSO/KaxmFPQ Date: Fri, 28 Jun 2019 21:16:54 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AAEC9DCEB@ORSMSX114.amr.corp.intel.com> References: <20190624143617.16164-1-chasel.chiu@intel.com> In-Reply-To: <20190624143617.16164-1-chasel.chiu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDFmYjFiMGYtZTY0ZS00MWRmLWFiZjctNjU3N2M5M2M5MDVlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZnRzb2NlaW1wNXQ1SkdwMVBzSFd2b25od0hURHR3enU5UTVaTXMyWUoydWZjYVwvQVd4UlwvNU9nRXltajltYzZaIn0= x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nate DeSimone -----Original Message----- From: Chiu, Chasel=20 Sent: Monday, June 24, 2019 7:36 AM To: devel@edk2.groups.io Cc: Kubacki, Michael A ; Desimone, Nathaniel L= ; Gao, Liming Subject: [PATCH] MinPlatformPkg: FSP Python script to python 3.x. https://bugzilla.tianocore.org/show_bug.cgi?id=3D1930 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/RebaseAndPatchFspBinBa= seAddress.py b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBin= BaseAddress.py index 167a0e0a4c..406e5ec130 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddre= ss.py +++ b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAd +++ dress.py @@ -10,16 +10,16 @@ import re import subprocess =20 if len(sys.argv) not in [6,7]: - print "RebaseAndPatchFspBinBaseAddress.py - Error in number of arguments= received" - print "Usage - RebaseAndPatchFspBinBaseAddress.py <= FspBinPkg Folder> \ - " + print ("RebaseAndPatchFspBinBaseAddress.py - Error in number of=20 + arguments received") print ("Usage -=20 + RebaseAndPatchFspBinBaseAddress.py \ ") exit(1) =20 flashMapName =3D sys.argv[1] fspBinPath =3D sys.argv[2] fspBinFile =3D sys.argv[3] targetDscFile =3D sys.argv[4] -fvOffset =3D long(sys.argv[5], 16) +fvOffset =3D int(sys.argv[5], 16) fspBinFileRebased =3D "Fsp_Rebased.fd" splitFspBinPath =3D os.path.join("edk2","IntelFsp2Pkg","Tools","SplitFsp= Bin.py") =20 @@ -30,21 +30,21 @@ if len(sys.argv) =3D=3D 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 =3D 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 =3D str(os.path.splitext(targetDscFile)[-1]).lower() if ext_file !=3D ".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) =20 # @@ -54,7 +54,7 @@ file =3D open (flashMapName, "r") data =3D file.read () =20 # Get the Flash Base Address -flashBase =3D long(data.split("FLASH_BASE")[1].split("=3D")[1].split()[0],= 16) +flashBase =3D int(data.split("FLASH_BASE")[1].split("=3D")[1].split()[0],= =20 +16) =20 # Based on Build Target, select the section in the FlashMap file flashmap= =3D data @@ -62,11 +62,11 @@ flashmap =3D data # Get FSP-S & FSP-M & FSP-= T offset & calculate the base for line in flashmap.split("\n"): if "PcdFlashFvFspSOffset" in line: - fspSBaseOffset =3D long(line.split("=3D")[1].split()[0], 16) + fspSBaseOffset =3D int(line.split("=3D")[1].split()[0], 16) if "PcdFlashFvFspMOffset" in line: - fspMBaseOffset =3D long(line.split("=3D")[1].split()[0], 16) + fspMBaseOffset =3D int(line.split("=3D")[1].split()[0], 16) if "PcdFlashFvFspTOffset" in line: - fspTBaseOffset =3D long(line.split("=3D")[1].split()[0], 16) + fspTBaseOffset =3D int(line.split("=3D")[1].split()[0], 16) file.close() =20 # @@ -78,10 +78,10 @@ if 'PYTHON_HOME' in os.environ: pythontool =3D os.environ['PYTHON_HOME'] + os.sep + 'python' Process =3D subprocess.Popen([pythontool, splitFspBinPath, "info","-f",fsp= BinFilePath], stdout=3Dsubprocess.PIPE) Output =3D Process.communicate()[0= ] -FsptInfo =3D Output.rsplit("FSP_M", 1); -for line in FsptInfo[1].split("= \n"): - if "ImageSize" in line: - fspMSize =3D long(line.split("=3D")[1], 16) +FsptInfo =3D Output.rsplit(b"FSP_M", 1); +for line in FsptInfo[1].split(b"\n"): + if b"ImageSize" in line: + fspMSize =3D int(line.split(b"=3D")[1], 16) break =20 # Calculate FSP-S/M/T base address, to which re-base has to be done -- 2.13.3.windows.1