From: "Sinha, Ankit" <ankit.sinha@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"Chiu, Chasel" <chasel.chiu@intel.com>
Cc: "Kubacki, Michael A" <michael.a.kubacki@intel.com>,
"Desimone, Nathaniel L" <nathaniel.l.desimone@intel.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH 1/4] MinPlatformPkg: Auto configure Fsp*BaseAddress PCD
Date: Wed, 31 Jul 2019 18:58:43 +0000 [thread overview]
Message-ID: <972926FCCE2F9141BF8AD787AAA02EFF5128EA87@ORSMSX109.amr.corp.intel.com> (raw)
In-Reply-To: <20190729110715.2312-2-chasel.chiu@intel.com>
Reviewed-by: Ankit Sinha <ankit.sinha@intel.com>
-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Chiu, Chasel
Sent: Monday, July 29, 2019 4:07 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: [edk2-devel] [PATCH 1/4] MinPlatformPkg: Auto configure Fsp*BaseAddress PCD
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1863
Add python script which will rebase FSP binary without patching platform DSC for Fsp*BaseAddress PCDs.
Those base address PCD will be updated in FDF basing on flash map.
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/RebaseFspBinBaseAddress.py | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py
new file mode 100644
index 0000000000..a8165b08e6
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py
@@ -0,0 +1,96 @@
+## @ RebaseFspBinBaseAddress.py
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> #
+SPDX-License-Identifier: BSD-2-Clause-Patent #
+
+import os
+import sys
+import re
+import subprocess
+
+if len(sys.argv) not in [5,6]:
+ print ("RebaseFspBinBaseAddress.py - Error in number of arguments
+received")
+ print ("Usage - RebaseFspBinBaseAddress.py <FlashMap file path>
+<FspBinPkg Folder> <Fsp.fd file name>\
+ <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]
+fvOffset = int(sys.argv[4], 16)
+fspBinFileRebased = "Fsp_Rebased.fd"
+splitFspBinPath = os.path.join("edk2","IntelFsp2Pkg","Tools","SplitFspBin.py")
+
+if len(sys.argv) == 6:
+ splitFspBinPath = sys.argv[5]
+
+#
+# Make sure argument passed or valid
+#
+if not os.path.exists(flashMapName):
+ 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.")
+ 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 # file = open
+(flashMapName, "r") data = file.read ()
+
+# Get the Flash Base Address
+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
+
+# Get FSP-S & FSP-M & FSP-T offset & calculate the base for line in
+flashmap.split("\n"):
+ if "PcdFlashFvFspSOffset" in line:
+ fspSBaseOffset = int(line.split("=")[1].split()[0], 16)
+ if "PcdFlashFvFspMOffset" in line:
+ fspMBaseOffset = int(line.split("=")[1].split()[0], 16)
+ if "PcdFlashFvFspTOffset" in line:
+ fspTBaseOffset = int(line.split("=")[1].split()[0], 16)
+file.close()
+
+#
+# Get FSP-M Size, in order to calculate the FSP-T Base. Used
+SplitFspBin.py script # to dump the header, and get the ImageSize in
+FSP-M section # pythontool = 'python'
+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(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
+fspSBaseAddress = flashBase + fspSBaseOffset + fvOffset fspMBaseAddress
+= flashBase + fspMBaseOffset 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 + " " + splitFspBinPath + "
+rebase -f" + rebaseArguments)
+
+#
+# Split FSP bin to FSP-S/M/T segments
+#
+splitArguments = fspBinPath + os.sep + fspBinFileRebased + " -o " + fspBinPath + " -n Fsp_Rebased.fd"
+os.system(pythontool + " " + splitFspBinPath + " split -f" +
+splitArguments)
+
+exit(0)
--
2.13.3.windows.1
next prev parent reply other threads:[~2019-07-31 18:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 11:07 [PATCH 0/4] Auto configure Fsp*BaseAddress PCD Chiu, Chasel
2019-07-29 11:07 ` [PATCH 1/4] MinPlatformPkg: " Chiu, Chasel
2019-07-30 22:18 ` Nate DeSimone
2019-07-31 18:58 ` Sinha, Ankit [this message]
2019-07-29 11:07 ` [PATCH 2/4] Platform/Intel: " Chiu, Chasel
2019-07-30 22:18 ` [edk2-devel] " Nate DeSimone
2019-07-31 18:59 ` Sinha, Ankit
2019-07-29 11:07 ` [PATCH 3/4] KabylakeOpenBoardPkg: " Chiu, Chasel
2019-07-30 22:19 ` [edk2-devel] " Nate DeSimone
2019-07-31 18:59 ` Sinha, Ankit
2019-07-29 11:07 ` [PATCH 4/4] ClevoOpenBoardPkg: " Chiu, Chasel
2019-07-30 22:19 ` [edk2-devel] " Nate DeSimone
2019-07-31 19:00 ` Sinha, Ankit
2019-07-29 13:47 ` [edk2-devel] [PATCH 0/4] " Laszlo Ersek
2019-07-30 1:07 ` Chiu, Chasel
2019-07-30 3:46 ` Liming Gao
2019-07-30 3:49 ` Chiu, Chasel
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=972926FCCE2F9141BF8AD787AAA02EFF5128EA87@ORSMSX109.amr.corp.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