Browse Source

Add binary size to memanalyzer report

i18n
Xose Pérez 6 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 mkdir -p firmware/espurna-$version
for environment in $environments; do for environment in $environments; do
echo "* espurna-$version-$environment.bin" 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 mv .pioenvs/$environment/firmware.bin firmware/espurna-$version/espurna-$version-$environment.bin
done done
echo "--------------------------------------------------------------" echo "--------------------------------------------------------------"

+ 52
- 29
code/memanalyzer.py View File

@ -19,6 +19,7 @@ import shlex
import commands import commands
import subprocess import subprocess
import sys import sys
import os
import re import re
import argparse 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): def analyse_memory(elf_file):
command = "%s -t '%s' " % (objdump_binary, elf_file) command = "%s -t '%s' " % (objdump_binary, elf_file)
@ -107,7 +114,7 @@ try:
# Parse command line options # Parse command line options
parser = argparse.ArgumentParser(description=description) 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("-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') parser.add_argument("-l", "--list", help="list available modules", default=0, action='count')
args = parser.parse_args() args = parser.parse_args()
@ -133,10 +140,12 @@ try:
sys.exit(0) sys.exit(0)
# Which modules to test? # Which modules to test?
test_modules = []
if len(args.modules) > 0: 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 # Check test modules exist
for module in test_modules: for module in test_modules:
@ -153,20 +162,26 @@ try:
modules = available_modules modules = available_modules
# Show init message # 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( print(output_format.format(
"Module", "Module",
"Cache IRAM", "Cache IRAM",
"Init RAM", "Init RAM",
"R.O. RAM", "R.O. RAM",
"Uninit RAM", "Uninit RAM",
"Flash ROM"
"Flash ROM",
"Binary size"
)) ))
# Build the core without modules to get base memory usage # Build the core without modules to get base memory usage
run(env, modules) 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( print(output_format.format(
"CORE" if args.core == 1 else "DEFAULT", "CORE" if args.core == 1 else "DEFAULT",
base['text'], base['text'],
@ -174,6 +189,7 @@ try:
base['rodata'], base['rodata'],
base['bss'], base['bss'],
base['irom0_text'], base['irom0_text'],
base['size'],
)) ))
# Test each module # Test each module
@ -182,7 +198,8 @@ try:
modules[module] = 1 modules[module] = 1
run(env, modules) 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 modules[module] = 0
print(output_format.format( print(output_format.format(
@ -192,33 +209,39 @@ try:
results[module]['rodata'] - base['rodata'], results[module]['rodata'] - base['rodata'],
results[module]['bss'] - base['bss'], results[module]['bss'] - base['bss'],
results[module]['irom0_text'] - base['irom0_text'], results[module]['irom0_text'] - base['irom0_text'],
results[module]['size'] - base['size'],
)) ))
# Test all modules # 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( 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: except:
raise raise


+ 1
- 1
code/ota_flash.sh View File

@ -222,4 +222,4 @@ export ESPURNA_BOARD=$board
export ESPURNA_AUTH=$auth export ESPURNA_AUTH=$auth
export ESPURNA_FLAGS=$flags 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 data_dir = espurna/data
[common] [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} 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 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 build_flags_512k = ${common.build_flags} -Wl,-Tesp8266.flash.512k0.ld


Loading…
Cancel
Save