Skip to content

Commit

Permalink
add python script to check size of the compiled source
Browse files Browse the repository at this point in the history
  • Loading branch information
Portisch committed Feb 19, 2019
1 parent c108c01 commit d223605
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</storageModule>
<storageModule buildConfig.stockConfigId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" cppBuildConfig.builtinIncludes="studio:/sdk/Device/shared/si8051base/ studio:/sdk/Device/EFM8BB1/inc/ studio:/sdk/Device/EFM8BB1/peripheral_driver/inc/ studio:/sdk/Device/shared/si8051base/ studio:/sdk/Device/EFM8BB1/inc/ studio:/sdk/Device/EFM8BB1/peripheral_driver/inc/" cppBuildConfig.builtinLibraryFiles="" cppBuildConfig.builtinLibraryNames="" cppBuildConfig.builtinLibraryObjects="" cppBuildConfig.builtinLibraryPaths="" cppBuildConfig.builtinMacros="" moduleId="com.silabs.ss.framework.ide.project.core.cpp" projectCommon.referencedModules="[{&quot;builtinExcludes&quot;:[],&quot;builtinSources&quot;:[&quot;lib/efm8bb1/peripheralDrivers/inc/pca_0.h&quot;,&quot;lib/efm8bb1/peripheralDrivers/src/pca_0.c&quot;],&quot;builtin&quot;:false,&quot;module&quot;:&quot;&lt;project:MModule xmlns:project=\&quot;http://www.silabs.com/ss/Project.ecore\&quot; id=\&quot;com.silabs.sdk.si8051.external.efm8PeripheralDriver.pca0\&quot;/&gt;&quot;},{&quot;builtinExcludes&quot;:[],&quot;builtinSources&quot;:[&quot;lib/efm8bb1/peripheralDrivers/src/wdt_0.c&quot;,&quot;lib/efm8bb1/peripheralDrivers/inc/wdt_0.h&quot;],&quot;builtin&quot;:false,&quot;module&quot;:&quot;&lt;project:MModule xmlns:project=\&quot;http://www.silabs.com/ss/Project.ecore\&quot; id=\&quot;com.silabs.sdk.si8051.external.efm8PeripheralDriver.wdt0\&quot;/&gt;&quot;},{&quot;builtinExcludes&quot;:[],&quot;builtinSources&quot;:[&quot;lib/efm8bb1/peripheralDrivers/src/uart_0.c&quot;,&quot;lib/efm8bb1/peripheralDrivers/inc/uart_0.h&quot;],&quot;builtin&quot;:false,&quot;module&quot;:&quot;&lt;project:MModule xmlns:project=\&quot;http://www.silabs.com/ss/Project.ecore\&quot; id=\&quot;com.silabs.sdk.si8051.external.efm8PeripheralDriver.uart0\&quot;/&gt;&quot;},{&quot;builtinExcludes&quot;:[],&quot;builtinSources&quot;:[&quot;src/SILABS_STARTUP.A51&quot;],&quot;builtin&quot;:true,&quot;module&quot;:&quot;&lt;project:MModule xmlns:project=\&quot;http://www.silabs.com/ss/Project.ecore\&quot; builtin=\&quot;true\&quot; id=\&quot;com.silabs.sdk.si8051.shared\&quot;/&gt;&quot;}]" projectCommon.toolchainId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="omf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" name="Keil 8051 v9.53 - Release" parent="com.silabs.ide.si8051.keil.exe.default" postannouncebuildStep="">
<configuration artifactExtension="omf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" name="Keil 8051 v9.53 - Release" parent="com.silabs.ide.si8051.keil.exe.default" postannouncebuildStep="" postbuildStep="python ${workspace_loc:/${ProjName}}\Check_Size.py -s 8192 -p '${workspace_loc:/${ProjName}}\Keil 8051 v9.53 - Release\RF-Bridge-EFM8BB1.m51'">
<folderInfo id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0." name="/" resourcePath="">
<toolChain id="com.silabs.ide.si8051.keil.toolchain.exe.default.166809853" name="Keil 8051" superClass="com.silabs.ide.si8051.keil.toolchain.exe.default">
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.debug.1984276196" name="Generate debug information" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.debug" value="true" valueType="boolean"/>
Expand Down
46 changes: 46 additions & 0 deletions Check_Size.py
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)

0 comments on commit d223605

Please sign in to comment.