forked from Portisch/RF-Bridge-EFM8BB1
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add python script to check size of the compiled source
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/python3 | ||
|
||
#------------------------------------------------------------------------------- | ||
# Name: Check_Size.py | ||
# Purpose: Check if compiled data fits into the EFM8BB1 flash | ||
# | ||
# Author: Portisch | ||
# | ||
# Created: 19/02/2019 | ||
#------------------------------------------------------------------------------- | ||
|
||
from optparse import OptionParser | ||
|
||
def parse_file(fn): | ||
with open(fn) as f: | ||
for line in f: | ||
if 'Program Size: data=' in line: | ||
data = line.split() | ||
if len(data) == 6: | ||
const = data[4].split('=')[1] | ||
code = data[5].split('=')[1] | ||
if (int(const, 10) + int(code, 10)) > options.size: | ||
print 'Check_Size: Error!' | ||
print 'Check_Size: Data of ' + str(int(const, 10) + int(code, 10)) + ' will not fit into ' + str(options.size) + ' byte' | ||
exit(1) | ||
print 'Check_Size: Data of ' + str(int(const, 10) + int(code, 10)) + ' will fit into ' + str(options.size) + ' byte' | ||
print 'Check_Size: ' + str(options.size - (int(const, 10) + int(code, 10))) + ' bytes are left' | ||
exit(0) | ||
|
||
usage = "usage: %prog [options]" | ||
parser = OptionParser(usage=usage, version="%prog 0.0") | ||
parser.add_option("-s", "--size", action="store", type="int", | ||
dest="size", default=8192, help="maximum of flash storage") | ||
parser.add_option("-p", "--path", action="store", | ||
dest="path", help="path where this script is located") | ||
(options, args) = parser.parse_args() | ||
|
||
if __name__ == '__main__': | ||
''' | ||
print(len(args)) | ||
if len(args) < 1: | ||
#parser.error("incorrect number of arguments. Use -h or --help") | ||
print(parser.print_help()) | ||
exit(1) | ||
''' | ||
parse_file(options.path) |