summaryrefslogtreecommitdiff
path: root/util/qualcomm/mbncat.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/qualcomm/mbncat.py')
-rwxr-xr-xutil/qualcomm/mbncat.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/util/qualcomm/mbncat.py b/util/qualcomm/mbncat.py
index c4da265f80..622ed2dcbd 100755
--- a/util/qualcomm/mbncat.py
+++ b/util/qualcomm/mbncat.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# Copyright (c) 2014, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -75,27 +75,27 @@ class NorSbl:
self.verbose = verbose
self.mbn_file_names = []
if self.verbose:
- print 'Reading ' + sbl1
+ print('Reading ' + sbl1)
try:
self.sbl1 = open(sbl1, 'rb').read()
except IOError as e:
- print 'I/O error({0}): {1}'.format(e.errno, e.strerror)
+ print('I/O error({0}): {1}'.format(e.errno, e.strerror))
raise
(codeword, magic, _) = struct.unpack_from(
self.NOR_SBL1_HEADER, self.sbl1)
if codeword != self.NOR_CODE_WORD:
- print '\n\nError: Unexpected Codeword!'
- print 'Codeword : ' + ('0x%x' % self.NOR_CODE_WORD) + \
- ' != ' + ('0x%x' % codeword)
+ print('\n\nError: Unexpected Codeword!')
+ print('Codeword : ' + ('0x%x' % self.NOR_CODE_WORD) + \
+ ' != ' + ('0x%x' % codeword))
sys.exit(-1)
if magic != self.MAGIC_NUM:
- print '\n\nError: Unexpected Magic!'
- print 'Magic : ' + ('0x%x' % self.MAGIC_NUM) + \
- ' != ' + ('0x%x' % magic)
+ print('\n\nError: Unexpected Magic!')
+ print('Magic : ' + ('0x%x' % self.MAGIC_NUM) + \
+ ' != ' + ('0x%x' % magic))
sys.exit(-1)
def Append(self, src):
@@ -119,10 +119,10 @@ class NorSbl:
overflow = size % self.ALIGNMENT
if overflow:
pad_size = self.ALIGNMENT - overflow
- pad = '\377' * pad_size
+ pad = b'\377' * pad_size
outfile.write(pad)
if self.verbose:
- print 'Added %d byte padding' % pad_size
+ print('Added %d byte padding' % pad_size)
return pad_size
return 0
@@ -142,11 +142,11 @@ class NorSbl:
for mbn_file_name in self.mbn_file_names:
total_size += self.PadOutput(outfile, total_size)
- mbn_file_data = open(mbn_file_name, 'r').read()
+ mbn_file_data = open(mbn_file_name, 'rb').read()
outfile.write(mbn_file_data)
if self.verbose:
- print 'Added %s (%d bytes)' % (mbn_file_name,
- len(mbn_file_data))
+ print('Added %s (%d bytes)' % (mbn_file_name,
+ len(mbn_file_data)))
total_size += len(mbn_file_data)
outfile.seek(28)
@@ -155,13 +155,13 @@ class NorSbl:
def Usage(v):
- print '%s: [-v] [-h] [-o Output MBN] sbl1 sbl2 [bootblock]' % (
- os.path.basename(sys.argv[0]))
- print
- print 'Concatenates up to three mbn files: two SBLs and a coreboot bootblock'
- print ' -h This message'
- print ' -v verbose'
- print ' -o Output file name, (default: %s)\n' % DEFAULT_OUTPUT_FILE_NAME
+ print('%s: [-v] [-h] [-o Output MBN] sbl1 sbl2 [bootblock]' % (
+ os.path.basename(sys.argv[0])))
+ print()
+ print('Concatenates up to three mbn files: two SBLs and a coreboot bootblock')
+ print(' -h This message')
+ print(' -v verbose')
+ print(' -o Output file name, (default: %s)\n' % DEFAULT_OUTPUT_FILE_NAME)
sys.exit(v)
def main():