build: Make print statements in scripts python3 compatible.
Signed-off-by: Johannes Krampf <johannes.krampf@googlemail.com>
This commit is contained in:
parent
24ef4fd0d2
commit
064fd069ef
|
@ -40,11 +40,11 @@ def main():
|
||||||
if datasize > 128*1024:
|
if datasize > 128*1024:
|
||||||
finalsize = 256*1024
|
finalsize = 256*1024
|
||||||
if datasize > finalsize:
|
if datasize > finalsize:
|
||||||
print "Error! ROM doesn't fit (%d > %d)" % (datasize, finalsize)
|
print("Error! ROM doesn't fit (%d > %d)" % (datasize, finalsize))
|
||||||
print " You have to either increate the size (CONFIG_ROM_SIZE)"
|
print(" You have to either increate the size (CONFIG_ROM_SIZE)")
|
||||||
print " or turn off some features (such as hardware support not"
|
print(" or turn off some features (such as hardware support not")
|
||||||
print " needed) to make it fit. Trying a more recent gcc version"
|
print(" needed) to make it fit. Trying a more recent gcc version")
|
||||||
print " might work too."
|
print(" might work too.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
|
@ -52,17 +52,17 @@ def main():
|
||||||
end = symbols['code32flat_end'].offset
|
end = symbols['code32flat_end'].offset
|
||||||
expend = layoutrom.BUILD_BIOS_ADDR + layoutrom.BUILD_BIOS_SIZE
|
expend = layoutrom.BUILD_BIOS_ADDR + layoutrom.BUILD_BIOS_SIZE
|
||||||
if end != expend:
|
if end != expend:
|
||||||
print "Error! Code does not end at 0x%x (got 0x%x)" % (
|
print("Error! Code does not end at 0x%x (got 0x%x)" % (
|
||||||
expend, end)
|
expend, end))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if datasize > finalsize:
|
if datasize > finalsize:
|
||||||
print "Error! Code is too big (0x%x vs 0x%x)" % (
|
print("Error! Code is too big (0x%x vs 0x%x)" % (
|
||||||
datasize, finalsize)
|
datasize, finalsize))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
expdatasize = end - start
|
expdatasize = end - start
|
||||||
if datasize != expdatasize:
|
if datasize != expdatasize:
|
||||||
print "Error! Unknown extra data (0x%x vs 0x%x)" % (
|
print("Error! Unknown extra data (0x%x vs 0x%x)" % (
|
||||||
datasize, expdatasize)
|
datasize, expdatasize))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Fix up CSM Compatibility16 table
|
# Fix up CSM Compatibility16 table
|
||||||
|
@ -83,10 +83,10 @@ def main():
|
||||||
|
|
||||||
# Print statistics
|
# Print statistics
|
||||||
runtimesize = end - symbols['code32init_end'].offset
|
runtimesize = end - symbols['code32init_end'].offset
|
||||||
print "Total size: %d Fixed: %d Free: %d (used %.1f%% of %dKiB rom)" % (
|
print("Total size: %d Fixed: %d Free: %d (used %.1f%% of %dKiB rom)" % (
|
||||||
datasize, runtimesize, finalsize - datasize
|
datasize, runtimesize, finalsize - datasize
|
||||||
, (datasize / float(finalsize)) * 100.0
|
, (datasize / float(finalsize)) * 100.0
|
||||||
, finalsize / 1024)
|
, finalsize / 1024))
|
||||||
|
|
||||||
# Write final file
|
# Write final file
|
||||||
f = open(outfile, 'wb')
|
f = open(outfile, 'wb')
|
||||||
|
|
|
@ -182,12 +182,12 @@ def calc():
|
||||||
elif insn.startswith('calll'):
|
elif insn.startswith('calll'):
|
||||||
noteCall(cur, subfuncs, insnaddr, calladdr, stackusage + 4)
|
noteCall(cur, subfuncs, insnaddr, calladdr, stackusage + 4)
|
||||||
else:
|
else:
|
||||||
print "unknown call", ref
|
print("unknown call", ref)
|
||||||
noteCall(cur, subfuncs, insnaddr, calladdr, stackusage)
|
noteCall(cur, subfuncs, insnaddr, calladdr, stackusage)
|
||||||
# Reset stack usage to preamble usage
|
# Reset stack usage to preamble usage
|
||||||
stackusage = cur[1]
|
stackusage = cur[1]
|
||||||
|
|
||||||
#print "other", repr(line)
|
#print("other", repr(line))
|
||||||
|
|
||||||
# Calculate maxstackusage
|
# Calculate maxstackusage
|
||||||
for funcaddr, info in funcs.items():
|
for funcaddr, info in funcs.items():
|
||||||
|
@ -199,7 +199,7 @@ def calc():
|
||||||
funcaddrs = orderfuncs(funcs.keys(), funcs.copy())
|
funcaddrs = orderfuncs(funcs.keys(), funcs.copy())
|
||||||
|
|
||||||
# Show all functions
|
# Show all functions
|
||||||
print OUTPUTDESC
|
print(OUTPUTDESC)
|
||||||
for funcaddr in funcaddrs:
|
for funcaddr in funcaddrs:
|
||||||
name, basicusage, maxusage, yieldusage, maxyieldusage, count, calls = \
|
name, basicusage, maxusage, yieldusage, maxyieldusage, count, calls = \
|
||||||
funcs[funcaddr]
|
funcs[funcaddr]
|
||||||
|
@ -208,15 +208,15 @@ def calc():
|
||||||
yieldstr = ""
|
yieldstr = ""
|
||||||
if maxyieldusage is not None:
|
if maxyieldusage is not None:
|
||||||
yieldstr = ",%d" % maxyieldusage
|
yieldstr = ",%d" % maxyieldusage
|
||||||
print "\n%s[%d,%d%s]:" % (name, basicusage, maxusage, yieldstr)
|
print("\n%s[%d,%d%s]:" % (name, basicusage, maxusage, yieldstr))
|
||||||
for insnaddr, calladdr, stackusage in calls:
|
for insnaddr, calladdr, stackusage in calls:
|
||||||
callinfo = funcs.get(calladdr, ("<unknown>", 0, 0, 0, None))
|
callinfo = funcs.get(calladdr, ("<unknown>", 0, 0, 0, None))
|
||||||
yieldstr = ""
|
yieldstr = ""
|
||||||
if callinfo[4] is not None:
|
if callinfo[4] is not None:
|
||||||
yieldstr = ",%d" % (stackusage + callinfo[4])
|
yieldstr = ",%d" % (stackusage + callinfo[4])
|
||||||
print " %04s:%-40s [%d+%d,%d%s]" % (
|
print(" %04s:%-40s [%d+%d,%d%s]" % (
|
||||||
insnaddr, callinfo[0], stackusage, callinfo[1]
|
insnaddr, callinfo[0], stackusage, callinfo[1]
|
||||||
, stackusage+callinfo[2], yieldstr)
|
, stackusage+callinfo[2], yieldstr))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
calc()
|
calc()
|
||||||
|
|
|
@ -10,7 +10,7 @@ import sys
|
||||||
def main():
|
def main():
|
||||||
data = sys.stdin.read()
|
data = sys.stdin.read()
|
||||||
ords = map(ord, data)
|
ords = map(ord, data)
|
||||||
print "sum=%x\n" % sum(ords)
|
print("sum=%x\n" % sum(ords))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -76,8 +76,8 @@ def fitSections(sections, fillsections):
|
||||||
section.finalsegloc = addr
|
section.finalsegloc = addr
|
||||||
fixedsections.append((addr, section))
|
fixedsections.append((addr, section))
|
||||||
if section.align != 1:
|
if section.align != 1:
|
||||||
print "Error: Fixed section %s has non-zero alignment (%d)" % (
|
print("Error: Fixed section %s has non-zero alignment (%d)" % (
|
||||||
section.name, section.align)
|
section.name, section.align))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
fixedsections.sort()
|
fixedsections.sort()
|
||||||
firstfixed = fixedsections[0][0]
|
firstfixed = fixedsections[0][0]
|
||||||
|
@ -106,8 +106,8 @@ def fitSections(sections, fillsections):
|
||||||
addpos = fixedsection.finalsegloc + fixedsection.size
|
addpos = fixedsection.finalsegloc + fixedsection.size
|
||||||
totalused += fixedsection.size
|
totalused += fixedsection.size
|
||||||
nextfixedaddr = addpos + freespace
|
nextfixedaddr = addpos + freespace
|
||||||
# print "Filling section %x uses %d, next=%x, available=%d" % (
|
# print("Filling section %x uses %d, next=%x, available=%d" % (
|
||||||
# fixedsection.finalloc, fixedsection.size, nextfixedaddr, freespace)
|
# fixedsection.finalloc, fixedsection.size, nextfixedaddr, freespace))
|
||||||
while 1:
|
while 1:
|
||||||
canfit = None
|
canfit = None
|
||||||
for fitsection in canrelocate:
|
for fitsection in canrelocate:
|
||||||
|
@ -115,8 +115,8 @@ def fitSections(sections, fillsections):
|
||||||
# Can't fit and nothing else will fit.
|
# Can't fit and nothing else will fit.
|
||||||
break
|
break
|
||||||
fitnextaddr = alignpos(addpos, fitsection.align) + fitsection.size
|
fitnextaddr = alignpos(addpos, fitsection.align) + fitsection.size
|
||||||
# print "Test %s - %x vs %x" % (
|
# print("Test %s - %x vs %x" % (
|
||||||
# fitsection.name, fitnextaddr, nextfixedaddr)
|
# fitsection.name, fitnextaddr, nextfixedaddr))
|
||||||
if fitnextaddr > nextfixedaddr:
|
if fitnextaddr > nextfixedaddr:
|
||||||
# This item can't fit.
|
# This item can't fit.
|
||||||
continue
|
continue
|
||||||
|
@ -130,9 +130,9 @@ def fitSections(sections, fillsections):
|
||||||
fitsection.finalsegloc = addpos
|
fitsection.finalsegloc = addpos
|
||||||
addpos = fitnextaddr
|
addpos = fitnextaddr
|
||||||
totalused += fitsection.size
|
totalused += fitsection.size
|
||||||
# print " Adding %s (size %d align %d) pos=%x avail=%d" % (
|
# print(" Adding %s (size %d align %d) pos=%x avail=%d" % (
|
||||||
# fitsection[2], fitsection[0], fitsection[1]
|
# fitsection[2], fitsection[0], fitsection[1]
|
||||||
# , fitnextaddr, nextfixedaddr - fitnextaddr)
|
# , fitnextaddr, nextfixedaddr - fitnextaddr))
|
||||||
|
|
||||||
# Report stats
|
# Report stats
|
||||||
total = BUILD_BIOS_SIZE-firstfixed
|
total = BUILD_BIOS_SIZE-firstfixed
|
||||||
|
@ -273,12 +273,12 @@ def doLayout(sections, config, genreloc):
|
||||||
size32flat = li.sec32fseg_start - li.sec32flat_start
|
size32flat = li.sec32fseg_start - li.sec32flat_start
|
||||||
size32init = li.sec32flat_start - li.sec32init_start
|
size32init = li.sec32flat_start - li.sec32init_start
|
||||||
sizelow = sec32low_end - li.sec32low_start
|
sizelow = sec32low_end - li.sec32low_start
|
||||||
print "16bit size: %d" % size16
|
print("16bit size: %d" % size16)
|
||||||
print "32bit segmented size: %d" % size32seg
|
print("32bit segmented size: %d" % size32seg)
|
||||||
print "32bit flat size: %d" % size32flat
|
print("32bit flat size: %d" % size32flat)
|
||||||
print "32bit flat init size: %d" % size32init
|
print("32bit flat init size: %d" % size32init)
|
||||||
print "Lowmem size: %d" % sizelow
|
print("Lowmem size: %d" % sizelow)
|
||||||
print "f-segment var size: %d" % size32fseg
|
print("f-segment var size: %d" % size32fseg)
|
||||||
return li
|
return li
|
||||||
|
|
||||||
|
|
||||||
|
@ -458,8 +458,8 @@ def markRuntime(section, sections, chain=[]):
|
||||||
or '.init.' in section.name or section.fileid != '32flat'):
|
or '.init.' in section.name or section.fileid != '32flat'):
|
||||||
return
|
return
|
||||||
if '.data.varinit.' in section.name:
|
if '.data.varinit.' in section.name:
|
||||||
print "ERROR: %s is VARVERIFY32INIT but used from %s" % (
|
print("ERROR: %s is VARVERIFY32INIT but used from %s" % (
|
||||||
section.name, chain)
|
section.name, chain))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
section.category = '32flat'
|
section.category = '32flat'
|
||||||
# Recursively mark all sections this section points to
|
# Recursively mark all sections this section points to
|
||||||
|
|
|
@ -156,11 +156,11 @@ def main():
|
||||||
try:
|
try:
|
||||||
import serial
|
import serial
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print """
|
print("""
|
||||||
Unable to find pyserial package ( http://pyserial.sourceforge.net/ ).
|
Unable to find pyserial package ( http://pyserial.sourceforge.net/ ).
|
||||||
On Linux machines try: yum install pyserial
|
On Linux machines try: yum install pyserial
|
||||||
Or: apt-get install python-serial
|
Or: apt-get install python-serial
|
||||||
"""
|
""")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
ser = serial.Serial(serialport, baud, timeout=0)
|
ser = serial.Serial(serialport, baud, timeout=0)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue