diff options
Diffstat (limited to 'src/boot')
-rwxr-xr-x | src/boot/sbeCompression.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/boot/sbeCompression.py b/src/boot/sbeCompression.py index 510b2cc3..74988e26 100755 --- a/src/boot/sbeCompression.py +++ b/src/boot/sbeCompression.py @@ -6,7 +6,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2017 +# Contributors Listed Below - COPYRIGHT 2017,2019 # [+] International Business Machines Corp. # # @@ -41,17 +41,17 @@ def compress(inputFile, compressedFile): f = open(inputFile, "rb") except IOError as e : print "I/O error File for File to be compressed." - sys.exit() + sys.exit(1) try: fW = open(compressedFile, "wb") except IOError as e : print "I/O error File for compressed file." - sys.exit() + sys.exit(1) if os.stat(inputFile).st_size < 4 : print "File is less than four bytes." - sys.exit() + sys.exit(1) instDict = dict() for i in range(0, os.stat(inputFile).st_size / 4 ): @@ -135,12 +135,13 @@ def usage(): print "-h, --help\t\tshow this help message and exit" print "-l, --imageLoc\t\tSeeprom Binary Location" print "-i, --image\t\tSeeprom Binary" + print "-p, --p9_xip_tool\t\tp9_xip_tool path" return 1 def main( argv ): try: - opts, args = getopt.getopt(argv[1:], "l:i:h", ['imageLoc=', 'image=', 'help']) + opts, args = getopt.getopt(argv[1:], "l:i:p:h", ['imageLoc=', 'image=', 'p9_xip_tool=', 'help']) except getopt.GetoptError as err: print str(err) usage() @@ -148,12 +149,15 @@ def main( argv ): imagePath = '' image = '' + p9_xip_tool = '' for opt, arg in opts: if opt in ('-l', '--imageLoc'): imagePath = arg elif opt in ('-i', '--image'): image = arg + elif opt in ('-p', '--p9_xip_tool'): + p9_xip_tool = arg else: usage() exit(1) @@ -163,31 +167,31 @@ def main( argv ): rc = os.system(cmd1) if rc: print "Unable to make copy of seeprom binary" - sys.exit() + sys.exit(1) #Extract base from SEEPROM binary. - cmd2 = imagePath + "/p9_xip_tool " + imagePath + "/" + image + " extract .base " + imagePath + "/" + image + ".base" + cmd2 = p9_xip_tool + " " + imagePath + "/" + image + " extract .base " + imagePath + "/" + image + ".base" rc = os.system(cmd2) if rc: print "Unable to extract the base from seeprom binary" - sys.exit() + sys.exit(1) #Compress the base section compress(imagePath + "/" + image + ".base", imagePath + "/" + image + ".base.compressed") #Delete the base section from SEEPEOM binary. - cmd3 = imagePath + "/p9_xip_tool " + imagePath + "/" + image + " delete .base" + cmd3 = p9_xip_tool + " " + imagePath + "/" + image + " delete .base" rc = os.system(cmd3) if rc: print "Unable to delete base section from seeprom binary" - sys.exit() + sys.exit(1) #Append the base section from SEEPEOM binary. - cmd4 = imagePath + "/p9_xip_tool " + imagePath + "/" + image + " append .base " + imagePath + "/" + image + ".base.compressed" + cmd4 = p9_xip_tool + " " + imagePath + "/" + image + " append .base " + imagePath + "/" + image + ".base.compressed" rc = os.system(cmd4) if rc: print "Unable to append the base section" - sys.exit() + sys.exit(1) if __name__ == "__main__": main( sys.argv ) |