From: "Chiu, Chasel" <chasel.chiu@intel.com>
To: devel@edk2.groups.io
Cc: Michael Kubacki <michael.a.kubacki@intel.com>,
Nate DeSimone <nathaniel.l.desimone@intel.com>,
Liming Gao <liming.gao@intel.com>
Subject: [PATCH v2] MinPlatformPkg: FSP Python script to python 3.x.
Date: Mon, 1 Jul 2019 14:20:32 +0800 [thread overview]
Message-ID: <20190701062032.16440-1-chasel.chiu@intel.com> (raw)
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 <michael.a.kubacki@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
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 <FlashMap file path> <FspBinPkg Folder> <Fsp.fd file name>\
- <Dsc file path to be patched> <pad_offset for Fsp-S Base Address> <OPTIONAL SplitFspBin.py tool path>"
+ print ("RebaseAndPatchFspBinBaseAddress.py - Error in number of arguments received")
+ print ("Usage - RebaseAndPatchFspBinBaseAddress.py <FlashMap file path> <FspBinPkg Folder> <Fsp.fd file name>\
+ <Dsc file path to be patched> <pad_offset for Fsp-S Base Address> <OPTIONAL SplitFspBin.py tool path>")
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
reply other threads:[~2019-07-01 6:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190701062032.16440-1-chasel.chiu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox