public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MinPlatformPkg: FSP Python script to python 3.x.
@ 2019-06-24 14:36 Chiu, Chasel
  2019-06-28  5:34 ` [edk2-devel] " Bob Feng
  2019-06-28 21:16 ` Nate DeSimone
  0 siblings, 2 replies; 3+ messages in thread
From: Chiu, Chasel @ 2019-06-24 14:36 UTC (permalink / raw)
  To: devel; +Cc: Michael Kubacki, Nate DeSimone, Liming Gao

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH] MinPlatformPkg: FSP Python script to python 3.x.
  2019-06-24 14:36 [PATCH] MinPlatformPkg: FSP Python script to python 3.x Chiu, Chasel
@ 2019-06-28  5:34 ` Bob Feng
  2019-06-28 21:16 ` Nate DeSimone
  1 sibling, 0 replies; 3+ messages in thread
From: Bob Feng @ 2019-06-28  5:34 UTC (permalink / raw)
  To: Chiu, Chasel, devel

[-- Attachment #1: Type: text/plain, Size: 67 bytes --]

Patch looks good.

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

[-- Attachment #2: Type: text/html, Size: 134 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] MinPlatformPkg: FSP Python script to python 3.x.
  2019-06-24 14:36 [PATCH] MinPlatformPkg: FSP Python script to python 3.x Chiu, Chasel
  2019-06-28  5:34 ` [edk2-devel] " Bob Feng
@ 2019-06-28 21:16 ` Nate DeSimone
  1 sibling, 0 replies; 3+ messages in thread
From: Nate DeSimone @ 2019-06-28 21:16 UTC (permalink / raw)
  To: Chiu, Chasel, devel@edk2.groups.io; +Cc: Kubacki, Michael A, Gao, Liming

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: Chiu, Chasel 
Sent: Monday, June 24, 2019 7:36 AM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH] MinPlatformPkg: FSP Python script to python 3.x.

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/RebaseAndPatchFspBinBaseAd
+++ dress.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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-28 21:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-24 14:36 [PATCH] MinPlatformPkg: FSP Python script to python 3.x Chiu, Chasel
2019-06-28  5:34 ` [edk2-devel] " Bob Feng
2019-06-28 21:16 ` Nate DeSimone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox