[edk2-devel] [edk2-platforms/devel-MinPlatform] [PATCH] Added an optional SplitFspBin.py path argument

Agyeman, Prince posted 1 patch 5 years ago
Failed in applying to current master (apply log)
.../Fsp/RebaseAndPatchFspBinBaseAddress.py    | 34 ++++++++++---------
1 file changed, 18 insertions(+), 16 deletions(-)
[edk2-devel] [edk2-platforms/devel-MinPlatform] [PATCH] Added an optional SplitFspBin.py path argument
Posted by Agyeman, Prince 5 years ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1691

What was done:
- an optional 7th argument was added to RebaseAndPatchFspBinBaseAddress.py
- updated lincense on RebaseAndPatchFspBinBaseAddress.py
- replace \\ with os independent os.sep

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Ankit Sinha <ankit.sinha@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>

Contributed-under: TianoCore Contribution Agreement 0.1
Signed-off-by: Agyeman <prince.agyeman@intel.com>
---
 .../Fsp/RebaseAndPatchFspBinBaseAddress.py    | 34 ++++++++++---------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py
index 4cdbe017e9..496b977c1f 100644
--- a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py
+++ b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py
@@ -1,23 +1,18 @@
 ## @ RebaseAndPatchFspBinBaseAddress.py
 #
-# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials are licensed and made available under
-# the terms and conditions of the BSD License that accompanies this distribution.
-# The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
+# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
 #
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
+
 import os
 import sys
 import re
 import subprocess
 
-if len(sys.argv) != 6:
+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>"
+  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]
@@ -26,6 +21,10 @@ fspBinFile        = sys.argv[3]
 targetDscFile     = sys.argv[4]
 fvOffset          = long(sys.argv[5], 16)
 fspBinFileRebased = "Fsp_Rebased.fd"
+splitFspBinPath   = os.path.join("edk2","IntelFsp2Pkg","Tools","SplitFspBin.py")
+
+if len(sys.argv) == 7:
+  splitFspBinPath   = sys.argv[6]
 
 #
 # Make sure argument passed or valid
@@ -33,7 +32,7 @@ fspBinFileRebased = "Fsp_Rebased.fd"
 if not os.path.exists(flashMapName):
   print "WARNING!  " + str(flashMapName) + " is not found."
   exit(1)
-fspBinFilePath = fspBinPath + "\\" + fspBinFile
+fspBinFilePath = fspBinPath + os.sep + fspBinFile
 if not os.path.exists(fspBinFilePath):
   print "WARNING!  " + str(fspBinFilePath) + " is not found."
   exit(1)
@@ -44,6 +43,9 @@ ext_file = str(os.path.splitext(targetDscFile)[-1]).lower()
 if ext_file != ".dsc":
   print "WARNING!  " + str(targetDscFile) + " is not a dsc file"
   exit(1)
+if not os.path.exists(splitFspBinPath):
+  print "WARNING!  " + str(splitFspBinPath) + " is not found."
+  exit(1)
 
 #
 # Get the FSP-S / FSP-M-T FV Base Address from Flash Map
@@ -74,7 +76,7 @@ file.close()
 pythontool = 'python'
 if 'PYTHON_HOME' in os.environ:
     pythontool = os.environ['PYTHON_HOME'] + os.sep + 'python'
-Process = subprocess.Popen(pythontool + " edk2\IntelFsp2Pkg\Tools\SplitFspBin.py info -f" + fspBinFilePath, stdout=subprocess.PIPE)
+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"):
@@ -91,13 +93,13 @@ fspTBaseAddress = flashBase + fspTBaseOffset
 # Re-base FSP bin file to new address and save it as fspBinFileRebased using SplitFspBin.py
 #
 rebaseArguments = fspBinFilePath + " -c s m t -b " + str(hex(fspSBaseAddress).rstrip("L")) + " " + str(hex(fspMBaseAddress).rstrip("L")) + " " + str(hex(fspTBaseAddress).rstrip("L")) + " -o" + fspBinPath + " -n " + fspBinFileRebased
-os.system(pythontool + " edk2\IntelFsp2Pkg\Tools\SplitFspBin.py rebase -f" + rebaseArguments)
+os.system(pythontool + " " + splitFspBinPath + " rebase -f" + rebaseArguments)
 
 #
 # Split FSP bin to FSP-S/M/T segments
 #
-splitArguments = fspBinPath +"\\" + fspBinFileRebased + " -o " + fspBinPath + " -n Fsp_Rebased.fd"
-os.system(pythontool + " edk2\IntelFsp2Pkg\Tools\SplitFspBin.py split -f" + splitArguments)
+splitArguments = fspBinPath + os.sep + fspBinFileRebased + " -o " + fspBinPath + " -n Fsp_Rebased.fd"
+os.system(pythontool + " " + splitFspBinPath + " split -f" + splitArguments)
 
 #
 # Patch dsc file with the re-based FSP-S/M/T address, so internally build will use the same.
-- 
2.19.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#39884): https://edk2.groups.io/g/devel/message/39884
Mute This Topic: https://groups.io/mt/31426546/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-platforms/devel-MinPlatform] [PATCH] Added an optional SplitFspBin.py path argument
Posted by Kubacki, Michael A 4 years, 12 months ago
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
Tested-by: Michael Kubacki <michael.a.kubacki@intel.com> 

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Agyeman, Prince
> Sent: Tuesday, April 30, 2019 4:29 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Desimone,
> Nathaniel L <nathaniel.l.desimone@intel.com>; Sinha, Ankit
> <ankit.sinha@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [edk2-platforms/devel-MinPlatform] [PATCH] Added an
> optional SplitFspBin.py path argument
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1691
> 
> What was done:
> - an optional 7th argument was added to
> RebaseAndPatchFspBinBaseAddress.py
> - updated lincense on RebaseAndPatchFspBinBaseAddress.py
> - replace \\ with os independent os.sep
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Ankit Sinha <ankit.sinha@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> 
> Contributed-under: TianoCore Contribution Agreement 0.1
> Signed-off-by: Agyeman <prince.agyeman@intel.com>
> ---
>  .../Fsp/RebaseAndPatchFspBinBaseAddress.py    | 34 ++++++++++---------
>  1 file changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git
> a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAdd
> ress.py
> b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAdd
> ress.py
> index 4cdbe017e9..496b977c1f 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAdd
> ress.py
> +++
> b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAd
> +++ dress.py
> @@ -1,23 +1,18 @@
>  ## @ RebaseAndPatchFspBinBaseAddress.py
>  #
> -# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> -# This
> program and the accompanying materials are licensed and made available
> under -# the terms and conditions of the BSD License that accompanies this
> distribution.
> -# The full text of the license may be found at -#
> http://opensource.org/licenses/bsd-license.php.
> +# Copyright (c) 2017 - 2019, Intel Corporation. All rights
> +reserved.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
> EITHER EXPRESS OR IMPLIED.
> -#
> -##
> +
>  import os
>  import sys
>  import re
>  import subprocess
> 
> -if len(sys.argv) != 6:
> +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>"
> +  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]
> @@ -26,6 +21,10 @@ fspBinFile        = sys.argv[3]
>  targetDscFile     = sys.argv[4]
>  fvOffset          = long(sys.argv[5], 16)
>  fspBinFileRebased = "Fsp_Rebased.fd"
> +splitFspBinPath   =
> os.path.join("edk2","IntelFsp2Pkg","Tools","SplitFspBin.py")
> +
> +if len(sys.argv) == 7:
> +  splitFspBinPath   = sys.argv[6]
> 
>  #
>  # Make sure argument passed or valid
> @@ -33,7 +32,7 @@ fspBinFileRebased = "Fsp_Rebased.fd"
>  if not os.path.exists(flashMapName):
>    print "WARNING!  " + str(flashMapName) + " is not found."
>    exit(1)
> -fspBinFilePath = fspBinPath + "\\" + fspBinFile
> +fspBinFilePath = fspBinPath + os.sep + fspBinFile
>  if not os.path.exists(fspBinFilePath):
>    print "WARNING!  " + str(fspBinFilePath) + " is not found."
>    exit(1)
> @@ -44,6 +43,9 @@ ext_file = str(os.path.splitext(targetDscFile)[-1]).lower()
>  if ext_file != ".dsc":
>    print "WARNING!  " + str(targetDscFile) + " is not a dsc file"
>    exit(1)
> +if not os.path.exists(splitFspBinPath):
> +  print "WARNING!  " + str(splitFspBinPath) + " is not found."
> +  exit(1)
> 
>  #
>  # Get the FSP-S / FSP-M-T FV Base Address from Flash Map @@ -74,7 +76,7
> @@ file.close()  pythontool = 'python'
>  if 'PYTHON_HOME' in os.environ:
>      pythontool = os.environ['PYTHON_HOME'] + os.sep + 'python'
> -Process = subprocess.Popen(pythontool + "
> edk2\IntelFsp2Pkg\Tools\SplitFspBin.py info -f" + fspBinFilePath,
> stdout=subprocess.PIPE)
> +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"):
> @@ -91,13 +93,13 @@ fspTBaseAddress = flashBase + fspTBaseOffset  # Re-
> base FSP bin file to new address and save it as fspBinFileRebased using
> SplitFspBin.py  #  rebaseArguments = fspBinFilePath + " -c s m t -b " +
> str(hex(fspSBaseAddress).rstrip("L")) + " " +
> str(hex(fspMBaseAddress).rstrip("L")) + " " +
> str(hex(fspTBaseAddress).rstrip("L")) + " -o" + fspBinPath + " -n " +
> fspBinFileRebased -os.system(pythontool + "
> edk2\IntelFsp2Pkg\Tools\SplitFspBin.py rebase -f" + rebaseArguments)
> +os.system(pythontool + " " + splitFspBinPath + " rebase -f" +
> +rebaseArguments)
> 
>  #
>  # Split FSP bin to FSP-S/M/T segments
>  #
> -splitArguments = fspBinPath +"\\" + fspBinFileRebased + " -o " + fspBinPath +
> " -n Fsp_Rebased.fd"
> -os.system(pythontool + " edk2\IntelFsp2Pkg\Tools\SplitFspBin.py split -f" +
> splitArguments)
> +splitArguments = fspBinPath + os.sep + fspBinFileRebased + " -o " +
> fspBinPath + " -n Fsp_Rebased.fd"
> +os.system(pythontool + " " + splitFspBinPath + " split -f" +
> +splitArguments)
> 
>  #
>  # Patch dsc file with the re-based FSP-S/M/T address, so internally build will
> use the same.
> --
> 2.19.1.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#40371): https://edk2.groups.io/g/devel/message/40371
Mute This Topic: https://groups.io/mt/31426546/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-