Imported existing scripts
This commit is contained in:
parent
f60e12e7d1
commit
60f6cc6d99
39
hex_free_size.py
Normal file
39
hex_free_size.py
Normal file
@ -0,0 +1,39 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# hex_free_space
|
||||
# 02/05/2022
|
||||
# tool script used to estimate the free space left in a µP based on the number
|
||||
# of 0xFF bytes in the hex file. This methode only works for filled hex files.
|
||||
#
|
||||
# usage ex: python hex_free_size somehexfile.hex somemorehexfile.hex
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
import fileinput
|
||||
import re
|
||||
|
||||
free_space = 0
|
||||
free_threshold = 16
|
||||
|
||||
p = re.compile(r':[0-9A-F]{8,8}([0-9A-F]{32,32})')
|
||||
for line in fileinput.input():
|
||||
val = re.search(p, line)
|
||||
if val:
|
||||
data = val.group(0)
|
||||
count = 0
|
||||
for char in data:
|
||||
if char == 'F':
|
||||
count += 1
|
||||
if count <= free_threshold:
|
||||
continue
|
||||
|
||||
for char in data:
|
||||
if char == 'F':
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
first = True
|
||||
free_space += 1
|
||||
else:
|
||||
first = True
|
||||
|
||||
print("estimated free space: " + str(free_space))
|
||||
|
||||
49
lst_diff.py
Normal file
49
lst_diff.py
Normal file
@ -0,0 +1,49 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# lst_diff
|
||||
# 22/03/2022
|
||||
# tool script used to summarize the code size of a list of .lst, which display
|
||||
# the size of segment CODE in their last lines
|
||||
#
|
||||
# usage ex: find lst_folder -name *.lst | python lst_diff.py > output.txt
|
||||
# the output can then be compared using diff
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
import fileinput
|
||||
import re
|
||||
|
||||
code_size = 0
|
||||
|
||||
p_code = re.compile("CODE")
|
||||
# list of input lst files
|
||||
for lst_file in fileinput.input():
|
||||
|
||||
lst = lst_file.rstrip('\n')
|
||||
i = 0
|
||||
buff = []
|
||||
|
||||
# get 3 lines containing code size infos
|
||||
for line in reversed(list(open(lst, encoding="latin-1"))):
|
||||
i += 1
|
||||
if i > 3 and i < 7:
|
||||
buff.append(line)
|
||||
elif i >= 7:
|
||||
break
|
||||
|
||||
#parse lines
|
||||
for line in buff:
|
||||
if re.search(p_code, line):
|
||||
toks = line.split()
|
||||
size = 0
|
||||
try:
|
||||
size += int(toks[1])
|
||||
except:
|
||||
pass
|
||||
if size != 0:
|
||||
size += 1000 * int(toks[0])
|
||||
else:
|
||||
size += int(toks[0])
|
||||
code_size += size
|
||||
print(lst.split('/').pop() + ": " + str(size))
|
||||
|
||||
print("total: " + str(code_size))
|
||||
|
||||
32
map_diff.py
Normal file
32
map_diff.py
Normal file
@ -0,0 +1,32 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# map_diff
|
||||
# 22/03/2022
|
||||
# tool script used to easily compare diffs of (IAR) .map files
|
||||
#
|
||||
# usage ex: diff -hu file1.map file2.map | python map_diff.py
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
import fileinput
|
||||
import re
|
||||
|
||||
old_size = 0x0
|
||||
new_size = 0x0
|
||||
prev_line = ""
|
||||
total_diff = 0
|
||||
|
||||
p = re.compile('0x\w+ ')
|
||||
for line in fileinput.input():
|
||||
val = re.search(p, line)
|
||||
if val:
|
||||
if line[0] == '-':
|
||||
old_size = int(val.group(0), base=16)
|
||||
prev_line = line
|
||||
else:
|
||||
new_size = int(val.group(0), base=16)
|
||||
if new_size != old_size:
|
||||
diff = new_size-old_size
|
||||
total_diff += diff
|
||||
print(prev_line + line + "diff: " + str(diff))
|
||||
|
||||
print("total diff: " + str(total_diff))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user