From dfd4444a33b1c06f550a9b0fefc20aa7be31c4c4 Mon Sep 17 00:00:00 2001 From: Subash Lakkimsetti Date: Mon, 17 May 2021 16:30:48 -0700 Subject: [PATCH] Generate signed slimboot binary to output path Currently final IFWI gets generated output path. Copy the signed slimboot binary to out path. Added option for outpath. Signed-off-by: Subash Lakkimsetti --- Platform/CoffeelakeBoardPkg/Script/StitchIfwi.py | 14 +++++++++++--- Platform/CometlakeBoardPkg/Script/StitchIfwi.py | 7 ++++++- Platform/CometlakevBoardPkg/Script/StitchIfwi.py | 8 +++++++- Platform/ElkhartlakeBoardPkg/Script/StitchIfwi.py | 9 +++++++-- Platform/TigerlakeBoardPkg/Script/StitchIfwi.py | 8 ++++++-- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Platform/CoffeelakeBoardPkg/Script/StitchIfwi.py b/Platform/CoffeelakeBoardPkg/Script/StitchIfwi.py index 4a808cc6..c5176a53 100644 --- a/Platform/CoffeelakeBoardPkg/Script/StitchIfwi.py +++ b/Platform/CoffeelakeBoardPkg/Script/StitchIfwi.py @@ -501,6 +501,11 @@ def main(): type=str, required=True, help='specify the platform specific stitch config file') + ap.add_argument('-op', + dest='outpath', + default = '', + help = "Specify path to write output IFIW and signed bin files") + args = ap.parse_args() stitch_cfg_file = load_source('StitchIfwiConfig', args.config_file) @@ -539,11 +544,14 @@ def main(): raise Exception ('Stitching process failed !') os.chdir(curr_dir) - generated_ifwi_file = os.path.join(stitch_dir, 'Temp', 'Ifwi.bin') - - ifwi_file_name = 'sbl_ifwi_%s.bin' % (args.platform) + generated_ifwi_file = os.path.join(work_dir, 'Temp', 'Ifwi.bin') + ifwi_file_name = os.path.join(args.outpath,'sbl_ifwi_%s.bin' % (args.platform)) shutil.copy(generated_ifwi_file, ifwi_file_name) + generated_signed_sbl = os.path.join(work_dir, 'Temp', 'SlimBootloader.bin') + sbl_file_name = os.path.join(args.outpath,'SlimBootloader_%s.bin' % (args.platform)) + shutil.copy(generated_signed_sbl, sbl_file_name) + print ("\nIFWI Stitching completed successfully !") print ("Boot Guard Profile: %s" % args.btg_profile.upper()) print ("IFWI image: %s\n" % ifwi_file_name) diff --git a/Platform/CometlakeBoardPkg/Script/StitchIfwi.py b/Platform/CometlakeBoardPkg/Script/StitchIfwi.py index dde7be08..ae98b094 100644 --- a/Platform/CometlakeBoardPkg/Script/StitchIfwi.py +++ b/Platform/CometlakeBoardPkg/Script/StitchIfwi.py @@ -435,6 +435,7 @@ def main(): ap.add_argument('-r', dest='remove', action = "store_true", default = False, help = "delete temporary files after stitch") ap.add_argument('-t', dest='tpm', default = 'ptt', choices=['ptt', 'dtpm', 'none'], help='specify TPM type') ap.add_argument('-fusa', dest='fusa', action = "store_true", default = False, help = "Patch IFWI to generate Fusa ifwi") + ap.add_argument('-op', dest='outpath', default = '', help = "Specify path to write output IFIW and signed bin files") args = ap.parse_args() stitch_cfg_file = load_source('StitchIfwiConfig', args.config_file) @@ -460,9 +461,13 @@ def main(): os.chdir(curr_dir) generated_ifwi_file = os.path.join(work_dir, 'Temp', 'Ifwi.bin') - ifwi_file_name = 'sbl_ifwi_%s.bin' % (args.platform) + ifwi_file_name = os.path.join(args.outpath,'sbl_ifwi_%s.bin' % (args.platform)) shutil.copy(generated_ifwi_file, ifwi_file_name) + generated_signed_sbl = os.path.join(work_dir, 'Temp', 'SlimBootloader.bin') + sbl_file_name = os.path.join(args.outpath,'SlimBootloader_%s.bin' % (args.platform)) + shutil.copy(generated_signed_sbl, sbl_file_name) + if args.fusa: print ("patch IFWI to generate Fusa ifwi") with open(ifwi_file_name, "r+b") as fh: diff --git a/Platform/CometlakevBoardPkg/Script/StitchIfwi.py b/Platform/CometlakevBoardPkg/Script/StitchIfwi.py index 60eee20e..866c73ec 100644 --- a/Platform/CometlakevBoardPkg/Script/StitchIfwi.py +++ b/Platform/CometlakevBoardPkg/Script/StitchIfwi.py @@ -435,6 +435,8 @@ def main(): ap.add_argument('-r', dest='remove', action = "store_true", default = False, help = "delete temporary files after stitch") ap.add_argument('-t', dest='tpm', default = 'ptt', choices=['ptt', 'dtpm', 'none'], help='specify TPM type') ap.add_argument('-fusa', dest='fusa', action = "store_true", default = False, help = "Patch IFWI to generate Fusa ifwi") + ap.add_argument('-op', dest='outpath', default = '', help = "Specify path to write output IFIW and signed bin files") + args = ap.parse_args() stitch_cfg_file = load_source('StitchIfwiConfig', args.config_file) @@ -460,9 +462,13 @@ def main(): os.chdir(curr_dir) generated_ifwi_file = os.path.join(work_dir, 'Temp', 'Ifwi.bin') - ifwi_file_name = 'sbl_ifwi_%s.bin' % (args.platform) + ifwi_file_name = os.path.join(args.outpath,'sbl_ifwi_%s.bin' % (args.platform)) shutil.copy(generated_ifwi_file, ifwi_file_name) + generated_signed_sbl = os.path.join(work_dir, 'Temp', 'SlimBootloader.bin') + sbl_file_name = os.path.join(args.outpath,'SlimBootloader_%s.bin' % (args.platform)) + shutil.copy(generated_signed_sbl, sbl_file_name) + if args.fusa: print ("patch IFWI to generate Fusa ifwi") with open(ifwi_file_name, "r+b") as fh: diff --git a/Platform/ElkhartlakeBoardPkg/Script/StitchIfwi.py b/Platform/ElkhartlakeBoardPkg/Script/StitchIfwi.py index c1c90d54..dc7c4c26 100644 --- a/Platform/ElkhartlakeBoardPkg/Script/StitchIfwi.py +++ b/Platform/ElkhartlakeBoardPkg/Script/StitchIfwi.py @@ -195,6 +195,7 @@ def main(): ap.add_argument('-t', dest='tpm', default = 'ptt', choices=['ptt', 'dtpm', 'none'], help='specify TPM type') ap.add_argument('-k', dest='key_dir', type=str, required=True, help='specify the path to Sbl Keys directory') ap.add_argument('-o', dest='option', default = '', help = "Platform specific stitch option. Format: '-o option1;option2;...' For each option its format is 'parameter:data'. Try -o help for more information") + ap.add_argument('-op', dest='outpath', default = '', help = "Specify path to write output IFIW and signed bin files") args = ap.parse_args() @@ -235,9 +236,13 @@ def main(): os.chdir(curr_dir) generated_ifwi_file = os.path.join(work_dir, 'Temp', 'Ifwi.bin') - - ifwi_file_name = 'sbl_ifwi_%s.bin' % (args.platform) + ifwi_file_name = os.path.join(args.outpath,'sbl_ifwi_%s.bin' % (args.platform)) shutil.copy(generated_ifwi_file, ifwi_file_name) + + generated_signed_sbl = os.path.join(work_dir, 'Temp', 'SlimBootloader.bin') + sbl_file_name = os.path.join(args.outpath,'SlimBootloader_%s.bin' % (args.platform)) + shutil.copy(generated_signed_sbl, sbl_file_name) + list_val = [1,0,2,4,16,249,15] #List of values to override softstrap_write(ifwi_file_name,0xc18,list_val[0],1) #FUSA SOFTSTRAP due to CSME 2041 update ################################################################################### diff --git a/Platform/TigerlakeBoardPkg/Script/StitchIfwi.py b/Platform/TigerlakeBoardPkg/Script/StitchIfwi.py index 643281a0..54310d5d 100644 --- a/Platform/TigerlakeBoardPkg/Script/StitchIfwi.py +++ b/Platform/TigerlakeBoardPkg/Script/StitchIfwi.py @@ -172,6 +172,7 @@ def main(): ap.add_argument('-r', dest='remove', action = "store_true", default = False, help = "delete temporary files after stitch") ap.add_argument('-t', dest='tpm', default = 'ptt', choices=['ptt', 'dtpm', 'none'], help='specify TPM type') ap.add_argument('-o', dest='option', default = '', help = "Platform specific stitch option. Format: '-o option1;option2;...' For each option its format is 'parameter:data'. Try -o help for more information") + ap.add_argument('-op', dest='outpath', default = '', help = "Specify path to write output IFIW and signed bin files") args = ap.parse_args() @@ -211,10 +212,13 @@ def main(): os.chdir(curr_dir) generated_ifwi_file = os.path.join(work_dir, 'Temp', 'Ifwi.bin') - - ifwi_file_name = 'sbl_ifwi_%s.bin' % (args.platform) + ifwi_file_name = os.path.join(args.outpath,'sbl_ifwi_%s.bin' % (args.platform)) shutil.copy(generated_ifwi_file, ifwi_file_name) + generated_signed_sbl = os.path.join(work_dir, 'Temp', 'SlimBootloader.bin') + sbl_file_name = os.path.join(args.outpath,'SlimBootloader_%s.bin' % (args.platform)) + shutil.copy(generated_signed_sbl, sbl_file_name) + print ("\nIFWI Stitching completed successfully !") print ("Boot Guard Profile: %s" % args.btg_profile.upper()) print ("IFWI image: %s\n" % ifwi_file_name)