Compute sketch binary size after build
This commit is contained in:
parent
35840c56d0
commit
ff1092da43
|
@ -54,6 +54,7 @@ class ASBuilder {
|
||||||
args.append("board="+board)
|
args.append("board="+board)
|
||||||
args.append("mcu="+boardProp["build.mcu"])
|
args.append("mcu="+boardProp["build.mcu"])
|
||||||
args.append("f_cpu="+boardProp["build.f_cpu"])
|
args.append("f_cpu="+boardProp["build.f_cpu"])
|
||||||
|
args.append("max_size"+boardProp["upload.maximum_size"])
|
||||||
args.append("core="+boardProp["build.core"])
|
args.append("core="+boardProp["build.core"])
|
||||||
args.append("variant="+boardProp["build.variant"])
|
args.append("variant="+boardProp["build.variant"])
|
||||||
args.append("libs="+libPath)
|
args.append("libs="+libPath)
|
||||||
|
|
|
@ -17,6 +17,7 @@ BUILD = {
|
||||||
'f_cpu' => 16000000,
|
'f_cpu' => 16000000,
|
||||||
'core' => 'arduino',
|
'core' => 'arduino',
|
||||||
'variant' => 'standard',
|
'variant' => 'standard',
|
||||||
|
'max_size'=> 32256
|
||||||
}
|
}
|
||||||
|
|
||||||
def parseArguments
|
def parseArguments
|
||||||
|
@ -128,9 +129,10 @@ File.open("Rakefile", 'w') do |rakeFile|
|
||||||
rakeFile.print <<END_RAKE
|
rakeFile.print <<END_RAKE
|
||||||
CC = '/usr/local/CrossPack-AVR/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=#{BUILD['mcu']} -DF_CPU=#{BUILD['f_cpu']} -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I ../..'#{INCLUDES}
|
CC = '/usr/local/CrossPack-AVR/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=#{BUILD['mcu']} -DF_CPU=#{BUILD['f_cpu']} -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I ../..'#{INCLUDES}
|
||||||
LD = '/usr/local/CrossPack-AVR/bin/avr-g++ -Os -Wl,--gc-sections -mmcu=#{BUILD['mcu']}'
|
LD = '/usr/local/CrossPack-AVR/bin/avr-g++ -Os -Wl,--gc-sections -mmcu=#{BUILD['mcu']}'
|
||||||
AR = '/usr/local/CrossPack-AVR/bin/avr-ar crsv'
|
AR = '/usr/local/CrossPack-AVR/bin/avr-ar crs'
|
||||||
EEP = '/usr/local/CrossPack-AVR/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0'
|
EEP = '/usr/local/CrossPack-AVR/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0'
|
||||||
HEX = '/usr/local/CrossPack-AVR/bin/avr-objcopy -O ihex -R .eeprom'
|
HEX = '/usr/local/CrossPack-AVR/bin/avr-objcopy -O ihex -R .eeprom'
|
||||||
|
SIZE = '/usr/local/CrossPack-AVR/bin/avr-size'
|
||||||
|
|
||||||
def compile(dest, extrainc, *src)
|
def compile(dest, extrainc, *src)
|
||||||
directory dest
|
directory dest
|
||||||
|
@ -174,7 +176,11 @@ end
|
||||||
file '#{BUILD['project']}.hex' => '#{BUILD['project']}.elf' do |task|
|
file '#{BUILD['project']}.hex' => '#{BUILD['project']}.elf' do |task|
|
||||||
sh "%s '%s' '%s'" % [HEX, task.prerequisites[0], task.name]
|
sh "%s '%s' '%s'" % [HEX, task.prerequisites[0], task.name]
|
||||||
end
|
end
|
||||||
task :default => ['#{BUILD['project']}.eep', '#{BUILD['project']}.hex']
|
task :default => ['#{BUILD['project']}.eep', '#{BUILD['project']}.hex'] do
|
||||||
|
szCmd = "%s '%s' | tail -1 | awk '{print $4}'" % [SIZE, '#{BUILD['project']}.hex']
|
||||||
|
sz = %x{#{'#'}{szCmd}}.chomp
|
||||||
|
puts "Binary sketch size: "+sz+" bytes (of a #{BUILD['max_size']} byte maximum)"
|
||||||
|
end
|
||||||
|
|
||||||
END_RAKE
|
END_RAKE
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user