public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chiu, Chasel" <chasel.chiu@intel.com>
To: devel@edk2.groups.io
Cc: Maurice Ma <maurice.ma@intel.com>,
	Nate DeSimone <nathaniel.l.desimone@intel.com>,
	Star Zeng <star.zeng@intel.com>
Subject: [PATCH v2] IntelFsp2Pkg/SplitFspBin.py: Support rebasing 1.x binary.
Date: Thu, 30 May 2019 12:57:50 +0800	[thread overview]
Message-ID: <20190530045750.5600-1-chasel.chiu@intel.com> (raw)

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1308

Support rebasing FSP 1.x binary.
FSP 1.x has single component in binary so not supported
by split command and rebase can be done with the same
command for rebasing FSP-T component in FSP 2.x image.

Test: both FSP 2.x (Kabylake) and FSP 1.x (BroadwellDE) binary
      can be rebased successfully.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 IntelFsp2Pkg/Tools/SplitFspBin.py                       | 21 +++++++++++++--------
 IntelFsp2Pkg/Tools/UserManuals/SplitFspBinUserManual.md | 47 +++++++++++++++++++++++++----------------------
 2 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitFspBin.py
index 2458231d09..15c8bebee2 100644
--- a/IntelFsp2Pkg/Tools/SplitFspBin.py
+++ b/IntelFsp2Pkg/Tools/SplitFspBin.py
@@ -1,6 +1,6 @@
 ## @ FspTool.py
 #
-# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -14,12 +14,12 @@ import argparse
 from   ctypes import *
 
 """
-This utility supports some operations for Intel FSP 2.0 image.
+This utility supports some operations for Intel FSP 1.x/2.x image.
 It supports:
-    - Display FSP 2.0 information header
-    - Split FSP 2.0 image into individual FSP-T/M/S/O component
-    - Rebase FSP 2.0 components to a different base address
-    - Generate FSP mapping C header file
+    - Display FSP 1.x/2.x information header
+    - Split FSP 2.x image into individual FSP-T/M/S/O component
+    - Rebase FSP 1.x/2.x components to a different base address
+    - Generate FSP 1.x/2.x mapping C header file
 """
 
 CopyRightHeaderFile = """/*
@@ -500,8 +500,6 @@ class FirmwareDevice:
 
         fih = None
         for fsp in self.FspList:
-            if fsp.Fih.HeaderRevision < 3:
-                raise Exception("ERROR: FSP 1.x is not supported by this tool !")
             if not fih:
                 fih = fsp.Fih
             else:
@@ -713,6 +711,8 @@ def SplitFspBin (fspfile, outdir, nametemplate):
     fd.ParseFsp ()
 
     for fsp in fd.FspList:
+        if fsp.Fih.HeaderRevision < 3:
+            raise Exception("ERROR: FSP 1.x is not supported by the split command !")
         ftype = fsp.Type
         if not nametemplate:
             nametemplate = fspfile
@@ -742,6 +742,11 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile):
 
         found = False
         for fsp in fd.FspList:
+            # Is this FSP 1.x single binary?
+            if fsp.Fih.HeaderRevision < 3:
+                found = True
+                ftype = 'X'
+                break
             ftype = fsp.Type.lower()
             if ftype == fspcomp:
                 found = True
diff --git a/IntelFsp2Pkg/Tools/UserManuals/SplitFspBinUserManual.md b/IntelFsp2Pkg/Tools/UserManuals/SplitFspBinUserManual.md
index 064e0ac845..06d87bbb2e 100644
--- a/IntelFsp2Pkg/Tools/UserManuals/SplitFspBinUserManual.md
+++ b/IntelFsp2Pkg/Tools/UserManuals/SplitFspBinUserManual.md
@@ -1,68 +1,71 @@
-# SplitFspBin.py is a python script to support some operations on Intel FSP 2.0 image.
+# SplitFspBin.py is a python script to support some operations on Intel FSP 1.x/2.x image.
 
 It supports:
 
-- Split Intel FSP 2.0 image into individual FSP-T/M/S/O component
+- Split Intel FSP 2.x image into individual FSP-T/M/S/O component
 
-- Rebase Intel FSP 2.0 components to different base addresses
+- Rebase Intel FSP 1.x/2.x components to different base addresses
 
-- Generate Intel FSP 2.0 C header file
+- Generate Intel FSP 1.x/2.x C header file
 
-- Display Intel FSP 2.0 information header for each FSP component
+- Display Intel FSP 1.x/2.x information header for each FSP component
 
-## Split Intel FSP 2.0 image
+## Split Intel FSP 2.x image
 
-To split individual FSP component in Intel FSP 2.0 image, the following
+FSP 1.x image is not supported by split command.
+To split individual FSP component in Intel FSP 2.x image, the following
 command can be used:
 
    **python SplitFspBin.py split [-h] -f FSPBINARY [-o OUTPUTDIR] [-n NAMETEMPLATE]**
 
-For example:  
+For example:
 
    `python SplitFspBin.py split -f FSP.bin`
 
    It will create FSP_T.bin, FSP_M.bin and FSP_S.bin in current directory.
 
-## Rebase Intel FSP 2.0 components
+## Rebase Intel FSP 1.x/2.x components
 
-To rebase one or multiple FSP components in Intel FSP 2.0 image, the following
+To rebase one or multiple FSP components in Intel FSP 1.x/2.x image, the following
 command can be used:
 
    **python SplitFspBin.py rebase [-h] -f FSPBINARY -c {t,m,s,o} [{t,m,s,o} ...] -b FSPBASE [FSPBASE ...] [-o OUTPUTDIR] [-n OUTPUTFILE]**
 
-For example:  
+For example:
 
-   `python SplitFspBin.py rebase -f FSP.bin –c t –b 0xFFF00000 –n FSP_new.bin`
+   `python SplitFspBin.py rebase -f FSP.bin -c t -b 0xFFF00000 -n FSP_new.bin`
 
    It will rebase FSP-T component inside FSP.bin to new base 0xFFF00000 and save the
-   rebased Intel FSP 2.0 image into file FSP_new.bin.
+   rebased Intel FSP 2.x image into file FSP_new.bin.
+   For FSP 1.x image there is only one component in binary so above command also
+   works for FSP 1.x image.
 
-   `python SplitFspBin.py rebase -f FSP.bin –c t m –b 0xFFF00000 0xFEF80000 –n FSP_new.bin`
+   `python SplitFspBin.py rebase -f FSP.bin -c t m -b 0xFFF00000 0xFEF80000 -n FSP_new.bin`
 
    It will rebase FSP-T and FSP-M components inside FSP.bin to new base 0xFFF00000
-   and 0xFEF80000 respectively, and save the rebased Intel FSP 2.0 image into file 
+   and 0xFEF80000 respectively, and save the rebased Intel FSP 2.x image into file
    FSP_new.bin file.
 
-## Generate Intel FSP 2.0 C header file
+## Generate Intel FSP 1.x/2.x C header file
 
-To generate Intel FSP 2.0 C header file, the following command can be used:
+To generate Intel FSP 1.x/2.x C header file, the following command can be used:
 
    **Python SplitFspBin.py genhdr [-h] -f FSPBINARY [-o OUTPUTDIR] [-n HFILENAME]**
 
-For example:  
+For example:
 
-   `python SplitFspBin.py genhdr -f FSP.bin –n FSP.h`
+   `python SplitFspBin.py genhdr -f FSP.bin -n FSP.h`
 
    It will create the C header file FSP.h containing the image ID, revision, offset
    and size for each individual FSP component.
 
-## Display Intel FSP 2.0 information header
+## Display Intel FSP 1.x/2.x information header
 
-To display Intel FSP 2.0 information headers, the following command can be used:
+To display Intel FSP 1.x/2.x information headers, the following command can be used:
 
    **Python SplitFspBin.py info [-h] -f FSPBINARY**
 
-For example:  
+For example:
 
    `python SplitFspBin.py info -f FSP.bin`
 
-- 
2.13.3.windows.1


             reply	other threads:[~2019-05-30  4:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30  4:57 Chiu, Chasel [this message]
2019-05-30 15:03 ` [PATCH v2] IntelFsp2Pkg/SplitFspBin.py: Support rebasing 1.x binary Zeng, Star
2019-05-31  5:37 ` Nate DeSimone

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=20190530045750.5600-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