Browse Source

Add binary size to memanalyzer report

i18n
Xose Pérez 7 years ago
parent
commit
98adb88f12
4 changed files with 56 additions and 33 deletions
  1. +1
    -1
      code/build.sh
  2. +52
    -29
      code/memanalyzer.py
  3. +1
    -1
      code/ota_flash.sh
  4. +2
    -2
      code/platformio.ini

+ 1
- 1
code/build.sh View File

@ -45,7 +45,7 @@ echo "Building firmware images..."
mkdir -p firmware/espurna-$version
for environment in $environments; do
echo "* espurna-$version-$environment.bin"
platformio run -s -e $environment || exit
platformio run --silent --environment $environment || exit
mv .pioenvs/$environment/firmware.bin firmware/espurna-$version/espurna-$version-$environment.bin
done
echo "--------------------------------------------------------------"

+ 52
- 29
code/memanalyzer.py View File

@ -19,6 +19,7 @@ import shlex
import commands
import subprocess
import sys
import os
import re
import argparse
@ -39,6 +40,12 @@ description = "ESPurna Memory Analyzer v0.1"
#-------------------------------------------------------------------------------
def file_size(file):
try:
return os.stat(file).st_size
except:
return 0
def analyse_memory(elf_file):
command = "%s -t '%s' " % (objdump_binary, elf_file)
@ -107,7 +114,7 @@ try:
# Parse command line options
parser = argparse.ArgumentParser(description=description)
parser.add_argument("modules", nargs='*', help="Modules to test")
parser.add_argument("modules", nargs='*', help="Modules to test (use ALL to test them all)")
parser.add_argument("-c", "--core", help="use core as base configuration instead of default", default=0, action='count')
parser.add_argument("-l", "--list", help="list available modules", default=0, action='count')
args = parser.parse_args()
@ -133,10 +140,12 @@ try:
sys.exit(0)
# Which modules to test?
test_modules = []
if len(args.modules) > 0:
test_modules = args.modules
else:
test_modules = available_modules.keys()
if "ALL" in args.modules:
test_modules = available_modules.keys()
else:
test_modules = args.modules
# Check test modules exist
for module in test_modules:
@ -153,20 +162,26 @@ try:
modules = available_modules
# Show init message
print "Analyzing module(s) %s on top of %s configuration\n" % (", ".join(test_modules), "CORE" if args.core > 0 else "DEFAULT")
output_format="{:<20}|{:<11}|{:<11}|{:<11}|{:<11}|{:<11}"
if len(test_modules) > 0:
print "Analyzing module(s) %s on top of %s configuration\n" % (", ".join(test_modules), "CORE" if args.core > 0 else "DEFAULT")
else:
print "Analyzing %s configuration\n" % ("CORE" if args.core > 0 else "DEFAULT")
output_format="{:<20}|{:<11}|{:<11}|{:<11}|{:<11}|{:<11}|{:<12}"
print(output_format.format(
"Module",
"Cache IRAM",
"Init RAM",
"R.O. RAM",
"Uninit RAM",
"Flash ROM"
"Flash ROM",
"Binary size"
))
# Build the core without modules to get base memory usage
run(env, modules)
base = analyse_memory(".pioenvs/"+env+"/firmware.elf")
base = analyse_memory(".pioenvs/%s/firmware.elf" % env)
base['size'] = file_size(".pioenvs/%s/firmware.bin" % env)
print(output_format.format(
"CORE" if args.core == 1 else "DEFAULT",
base['text'],
@ -174,6 +189,7 @@ try:
base['rodata'],
base['bss'],
base['irom0_text'],
base['size'],
))
# Test each module
@ -182,7 +198,8 @@ try:
modules[module] = 1
run(env, modules)
results[module]=analyse_memory(".pioenvs/"+env+"/firmware.elf")
results[module]=analyse_memory(".pioenvs/%s/firmware.elf" % env)
results[module]['size'] = file_size(".pioenvs/%s/firmware.bin" % env)
modules[module] = 0
print(output_format.format(
@ -192,33 +209,39 @@ try:
results[module]['rodata'] - base['rodata'],
results[module]['bss'] - base['bss'],
results[module]['irom0_text'] - base['irom0_text'],
results[module]['size'] - base['size'],
))
# Test all modules
for module in test_modules:
modules[module] = 1
run(env, modules)
total = analyse_memory(".pioenvs/"+env+"/firmware.elf")
if len(test_modules) > 0:
for module in test_modules:
modules[module] = 1
run(env, modules)
total = analyse_memory(".pioenvs/%s/firmware.elf" % env)
total['size'] = file_size(".pioenvs/%s/firmware.bin" % env)
if len(test_modules) > 1:
print(output_format.format(
"ALL MODULES",
total['text'] - base['text'],
total['data'] - base['data'],
total['rodata'] - base['rodata'],
total['bss'] - base['bss'],
total['irom0_text'] - base['irom0_text'],
total['size'] - base['size'],
))
if len(test_modules) > 1:
print(output_format.format(
"ALL MODULES",
total['text'] - base['text'],
total['data'] - base['data'],
total['rodata'] - base['rodata'],
total['bss'] - base['bss'],
total['irom0_text'] - base['irom0_text'],
"TOTAL",
total['text'],
total['data'],
total['rodata'],
total['bss'],
total['irom0_text'],
total['size'],
))
print(output_format.format(
"TOTAL",
total['text'],
total['data'],
total['rodata'],
total['bss'],
total['irom0_text'],
))
except:
raise


+ 1
- 1
code/ota_flash.sh View File

@ -222,4 +222,4 @@ export ESPURNA_BOARD=$board
export ESPURNA_AUTH=$auth
export ESPURNA_FLAGS=$flags
pio run -e $env -t upload
platformio run --silent --environment $env -t upload

+ 2
- 2
code/platformio.ini View File

@ -4,8 +4,8 @@ src_dir = espurna
data_dir = espurna/data
[common]
platform = espressif8266
#platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
#platform = espressif8266
platform = https://github.com/platformio/platform-espressif8266.git#v1.5.0
build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS}
debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM
build_flags_512k = ${common.build_flags} -Wl,-Tesp8266.flash.512k0.ld


Loading…
Cancel
Save