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.

76 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>] [-f <elf_file>] [-d <dumpfile>]"
  18. echo
  19. }
  20. # get environment from command line
  21. while [[ $# -gt 1 ]]; do
  22. key="$1"
  23. case $key in
  24. -f)
  25. ELF="$2"
  26. shift
  27. ;;
  28. -e)
  29. ENVIRONMENT="$2"
  30. shift
  31. ;;
  32. -d)
  33. FILE="$2"
  34. shift
  35. ;;
  36. esac
  37. shift # past argument or value
  38. done
  39. # check environment folder
  40. if [ ! -f $ELF ]; then
  41. ELF=.pio/build/$ENVIRONMENT/firmware.elf
  42. fi
  43. if [ ! -f $ELF ]; then
  44. echo "Could not find ELF file for the selected environment: $ELF"
  45. exit 2
  46. fi
  47. # get decode
  48. if [ ! -f $DECODER ]; then
  49. folder=$(dirname "$DECODER")
  50. if [ $folder != "." ]; then
  51. mkdir -p $folder
  52. fi
  53. echo "Downloading decoder..."
  54. wget -q $DECODER_ORIGIN -O "$DECODER"
  55. fi
  56. # get trace interactively
  57. if [ ! -f $FILE ]; then
  58. echo "Paste stack trace and end with a blank line:"
  59. trace=$(sed '/^$/q')
  60. echo $trace > $FILE
  61. fi
  62. java -jar $DECODER $ADDR2LINE $ELF $FILE