From 64f16118ad301ee505b3ef5fc10ef44146d805c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 28 Nov 2016 23:44:16 +0100 Subject: [PATCH] Added debug utility that uses littleyoda's EspStackTraceDecoder --- code/debug | 75 ++++++++++++++++++++++++++++++++++++ code/platformio.custom.ini | 36 ++++++++--------- code/platformio.official.ini | 50 ++++++++++++------------ 3 files changed, 118 insertions(+), 43 deletions(-) create mode 100755 code/debug diff --git a/code/debug b/code/debug new file mode 100755 index 00000000..b225b90e --- /dev/null +++ b/code/debug @@ -0,0 +1,75 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# CONFIGURATION +# ------------------------------------------------------------------------------ + +ENVIRONMENT="node-debug" +ADDR2LINE=$HOME/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-addr2line +DECODER=utils/EspStackTraceDecoder.jar +DECODER_ORIGIN=https://github.com/littleyoda/EspStackTraceDecoder/releases/download/untagged-83b6db3208da17a0f1fd/EspStackTraceDecoder.jar +FILE="/tmp/.trace" + +# ------------------------------------------------------------------------------ +# END CONFIGURATION - DO NOT EDIT FURTHER +# ------------------------------------------------------------------------------ + +# remove default trace file +rm -rf $FILE + +function help { + echo + echo "Syntax: $0 [-e ] [-d ]" + echo +} + +# get environment from command line +while [[ $# -gt 1 ]]; do + + key="$1" + + case $key in + -e) + ENVIRONMENT="$2" + shift + ;; + -d) + FILE="$2" + shift + ;; + esac + + shift # past argument or value + +done + +# check environment folder +if [ $ENVIRONMENT == "" ]; then + echo "No environment defined" + help + exit 1 +fi +ELF=.pioenvs/$ENVIRONMENT/firmware.elf +if [ ! -f $ELF ]; then + echo "Could not find ELF file for the selected environment: $ELF" + exit 2 +fi + +# get decode +if [ ! -f $DECODER ]; then + folder=$(dirname "$DECODER") + if [ $folder != "." ]; then + mkdir -p $folder + fi + echo "Downloading decoder..." + wget -q $DECODER_ORIGIN -O "$DECODER" +fi + +# get trace interactively +if [ ! -f $FILE ]; then + echo "Paste stack trace and end with a blank line:" + trace=$(sed '/^$/q') + echo $trace > $FILE +fi + +java -jar $DECODER $ADDR2LINE $ELF $FILE diff --git a/code/platformio.custom.ini b/code/platformio.custom.ini index 54b155e2..481f0c4b 100644 --- a/code/platformio.custom.ini +++ b/code/platformio.custom.ini @@ -15,16 +15,16 @@ framework = arduino extra_script = pio_hooks.py lib_ignore = FauxmoESP lib_deps = - 19 - 31 - 44 - 64 - 305 - 306 - 346 - 359 - 408 - 727 + DHT sensor library + Adafruit Unified Sensor + Time + ArduinoJson + ESPAsyncTCP + ESPAsyncWebServer@3e6e890808 + AsyncMqttClient + ESPAsyncUCP + Embedis + NtpClientLib https://bitbucket.org/xoseperez/justwifi.git https://bitbucket.org/xoseperez/nofuss.git https://bitbucket.org/xoseperez/hlw8012.git @@ -40,7 +40,7 @@ upload_flags = --auth=fibonacci --port 8266 [env:sonoff-debug] include = common board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF [env:sonoff-debug-ota] include = env:sonoff-debug,ota @@ -48,7 +48,7 @@ include = env:sonoff-debug,ota [env:sonoff-pow-debug] include = common board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW [env:sonoff-pow-debug-ota] include = env:sonoff-pow-debug,ota @@ -56,7 +56,7 @@ include = env:sonoff-pow-debug,ota [env:slampher-debug] include = common board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER [env:slampher-debug-ota] include = env:slampher-debug,ota @@ -64,7 +64,7 @@ include = env:slampher-debug,ota [env:s20-debug] include = common board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 [env:s20-debug-ota] include = env:s20-debug,ota @@ -73,7 +73,7 @@ include = env:s20-debug,ota include = common board = nodemcuv2 platform = espressif8266_stage -build_flags = -DNODEMCUV2 -DDEBUG_PORT=Serial -DENABLE_FAUXMO=1 +build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial -DENABLE_FAUXMO=1 lib_ignore = [env:node-debug-ota] @@ -86,18 +86,18 @@ include = env:node-debug,ota [env:washer-device] topic = /home/cellar/washer/ip include = env:sonoff-debug-ota -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 [env:studio-lamp-device] topic = /home/studio/lamp/ip include = env:sonoff-debug-ota platform = espressif8266_stage -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 lib_ignore = [env:living-lamp-device] topic = /home/living/lamp/ip include = env:s20-debug-ota platform = espressif8266_stage -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 -DENABLE_FAUXMO=1 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 -DENABLE_FAUXMO=1 lib_ignore = diff --git a/code/platformio.official.ini b/code/platformio.official.ini index 7499831a..b564dd83 100644 --- a/code/platformio.official.ini +++ b/code/platformio.official.ini @@ -3,21 +3,21 @@ env_default = node-debug [common] lib_deps = - 19 - 31 - 44 - 64 - 305 - 306 - 346 - 359 - 408 - 727 + DHT sensor library + Adafruit Unified Sensor + Time + ArduinoJson + ESPAsyncTCP + ESPAsyncWebServer@3e6e890808 + AsyncMqttClient + ESPAsyncUCP + Embedis + NtpClientLib https://bitbucket.org/xoseperez/justwifi.git https://bitbucket.org/xoseperez/nofuss.git https://bitbucket.org/xoseperez/hlw8012.git https://bitbucket.org/xoseperez/emonliteesp.git - https://bitbucket.org/xoseperez/fauxmoesp.git + https://bitbucket.org/xoseperez/fauxmoESP.git https://github.com/jccprj/RemoteSwitch-arduino-library [env:sonoff-debug] @@ -26,7 +26,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF lib_ignore = FauxmoESP [env:sonoff-debug-ota] @@ -35,7 +35,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -47,7 +47,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW lib_ignore = FauxmoESP [env:sonoff-pow-debug-ota] @@ -56,7 +56,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -68,7 +68,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER lib_ignore = FauxmoESP [env:slampher-debug-ota] @@ -77,7 +77,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -89,7 +89,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 lib_ignore = FauxmoESP [env:s20-debug-ota] @@ -98,7 +98,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 upload_speed = 115200 upload_port = "192.168.4.1" lib_ignore = FauxmoESP @@ -110,7 +110,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = nodemcuv2 -build_flags = -DNODEMCUV2 -DDEBUG_PORT=Serial -DENABLE_FAUXMO=1 +build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial -DENABLE_FAUXMO=1 [env:node-debug-ota] platform = espressif8266 @@ -118,7 +118,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = nodemcuv2 -build_flags = -DNODEMCUV2 -DDEBUG_PORT=Serial +build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -133,7 +133,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -149,7 +149,7 @@ board = esp01_1m upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 lib_ignore = FauxmoESP [env:studio-lamp-device] @@ -159,7 +159,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -172,7 +172,7 @@ framework = arduino lib_deps = ${common.lib_deps} extra_script = pio_hooks.py board = esp01_1m -build_flags = -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF +build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266