Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.8 KiB

  1. #!/bin/bash
  2. # ------------------------------------------------------------------------------
  3. # CONFIGURATION
  4. # ------------------------------------------------------------------------------
  5. ENVIRONMENT="nodemcu-lolin"
  6. ADDR2LINE=$HOME/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-addr2line
  7. DECODER=utils/EspStackTraceDecoder.jar
  8. DECODER_ORIGIN=https://github.com/littleyoda/EspStackTraceDecoder/releases/download/untagged-83b6db3208da17a0f1fd/EspStackTraceDecoder.jar
  9. FILE="/tmp/.trace"
  10. # ------------------------------------------------------------------------------
  11. # END CONFIGURATION - DO NOT EDIT FURTHER
  12. # ------------------------------------------------------------------------------
  13. # remove default trace file
  14. rm -rf $FILE
  15. function help {
  16. echo
  17. echo "Syntax: $0 [-e <environment>] [-d <dumpfile>]"
  18. echo
  19. }
  20. # get environment from command line
  21. while [[ $# -gt 1 ]]; do
  22. key="$1"
  23. case $key in
  24. -e)
  25. ENVIRONMENT="$2"
  26. shift
  27. ;;
  28. -d)
  29. FILE="$2"
  30. shift
  31. ;;
  32. esac
  33. shift # past argument or value
  34. done
  35. # check environment folder
  36. if [ $ENVIRONMENT == "" ]; then
  37. echo "No environment defined"
  38. help
  39. exit 1
  40. fi
  41. ELF=.pioenvs/$ENVIRONMENT/firmware.elf
  42. if [ ! -f $ELF ]; then
  43. echo "Could not find ELF file for the selected environment: $ELF"
  44. exit 2
  45. fi
  46. # get decode
  47. if [ ! -f $DECODER ]; then
  48. folder=$(dirname "$DECODER")
  49. if [ $folder != "." ]; then
  50. mkdir -p $folder
  51. fi
  52. echo "Downloading decoder..."
  53. wget -q $DECODER_ORIGIN -O "$DECODER"
  54. fi
  55. # get trace interactively
  56. if [ ! -f $FILE ]; then
  57. echo "Paste stack trace and end with a blank line:"
  58. trace=$(sed '/^$/q')
  59. echo $trace > $FILE
  60. fi
  61. java -jar $DECODER $ADDR2LINE $ELF $FILE