|
| 1 | +Troubleshooting |
| 2 | +=============== |
| 3 | + |
| 4 | +.. seo:: |
| 5 | + :description: Guide for troubleshooting ESPHome issues, debugging crashes, and obtaining decoded stack traces from device failures. |
| 6 | + :image: bug-report.svg |
| 7 | + |
| 8 | +This guide helps you diagnose and debug ESPHome device issues, particularly crashes and boot failures. Whether you're experiencing random resets, watchdog timeouts, or need to analyze stack traces, this guide provides step-by-step instructions for capturing and understanding crash data. |
| 9 | + |
| 10 | +.. note:: |
| 11 | + |
| 12 | + This guide assumes you have ESPHome installed and basic familiarity with the command line. For installation instructions, see :doc:`/guides/installing_esphome`. |
| 13 | + |
| 14 | +Getting a Stack Trace from Crashes |
| 15 | +----------------------------------- |
| 16 | + |
| 17 | +When your ESPHome device crashes, you can obtain a decoded stack trace to help identify the cause. This requires: |
| 18 | + |
| 19 | +1. Compiling the firmware locally (to have matching debug symbols) |
| 20 | +2. Connecting the device via USB cable for serial console access |
| 21 | +3. Running the logs command to capture and decode the crash |
| 22 | + |
| 23 | +Steps to Get a Stack Trace |
| 24 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 25 | + |
| 26 | +1. **Compile locally**: Build your configuration on your local machine to ensure you have matching debug symbols. |
| 27 | + |
| 28 | + If you're using the ESPHome Device Builder web interface: |
| 29 | + |
| 30 | + - Click the overflow menu (three dots) next to your device |
| 31 | + - Select "Download YAML" to get your configuration file |
| 32 | + - Save it to a local directory |
| 33 | + |
| 34 | + Then use the command line interface (see the :doc:`/guides/cli` guide for full details): |
| 35 | + |
| 36 | + .. code-block:: bash |
| 37 | +
|
| 38 | + esphome compile your-device.yaml |
| 39 | + esphome upload your-device.yaml |
| 40 | +
|
| 41 | + .. note:: |
| 42 | + |
| 43 | + While you can use OTA for the upload, you'll need a USB connection anyway to capture the crash output in the next steps, so uploading via USB is usually more convenient. |
| 44 | + |
| 45 | +2. **Connect via USB**: Connect your device to your computer using a USB cable. The device must be connected via serial console (not over WiFi/OTA) to capture the crash output. |
| 46 | + |
| 47 | +3. **Monitor logs**: Run the logs command to monitor the device output: |
| 48 | + |
| 49 | + .. code-block:: bash |
| 50 | +
|
| 51 | + esphome logs your-device.yaml |
| 52 | +
|
| 53 | +4. **Wait for crash**: When the device crashes, ESPHome will automatically detect and decode the stack trace. You'll see output similar to this: |
| 54 | + |
| 55 | + .. code-block:: text |
| 56 | +
|
| 57 | + [08:17:06]E (5906) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time: |
| 58 | + [08:17:06]E (5906) task_wdt: - loopTask (CPU 0) |
| 59 | + [08:17:06]E (5906) task_wdt: Tasks currently running: |
| 60 | + [08:17:06]E (5906) task_wdt: CPU 0: esp_timer |
| 61 | + [08:17:06]E (5906) task_wdt: CPU 1: IDLE1 |
| 62 | + [08:17:06]E (5906) task_wdt: Aborting. |
| 63 | + [08:17:06]E (5906) task_wdt: Print CPU 0 (current core) backtrace |
| 64 | + |
| 65 | + [08:17:06]Backtrace: 0x4013d30e:0x3ffbac20 0x4013d383:0x3ffbac40 0x4014b23e:0x3ffbac70 |
| 66 | + WARNING Found stack trace! Trying to decode it |
| 67 | + WARNING Decoded 0x4013d30e: touch_ll_is_measure_done at /Users/bdraco/.platformio/packages/framework-espidf/components/hal/esp32/include/hal/touch_sensor_ll.h:505 |
| 68 | + (inlined by) _touch_pad_read at /Users/bdraco/.platformio/packages/framework-espidf/components/driver/touch_sensor/esp32/touch_sensor.c:365 |
| 69 | + WARNING Decoded 0x4013d383: touch_pad_filter_cb at /Users/bdraco/.platformio/packages/framework-espidf/components/driver/touch_sensor/esp32/touch_sensor.c:108 |
| 70 | + (inlined by) touch_pad_filter_cb at /Users/bdraco/.platformio/packages/framework-espidf/components/driver/touch_sensor/esp32/touch_sensor.c:98 |
| 71 | + WARNING Decoded 0x4014b23e: timer_process_alarm at /Users/bdraco/.platformio/packages/framework-espidf/components/esp_timer/src/esp_timer.c:456 |
| 72 | + (inlined by) timer_task at /Users/bdraco/.platformio/packages/framework-espidf/components/esp_timer/src/esp_timer.c:482 |
| 73 | +
|
| 74 | +The decoded stack trace shows: |
| 75 | + |
| 76 | +- The exact function names and source files where the crash occurred |
| 77 | +- Line numbers in the source code |
| 78 | +- The call stack leading to the crash |
| 79 | + |
| 80 | +.. note:: |
| 81 | + |
| 82 | + **Important**: You must compile locally and upload the firmware before capturing the crash. The debug symbols must match the running firmware for the stack trace to be decoded correctly. |
| 83 | + |
| 84 | +Common Issues |
| 85 | +~~~~~~~~~~~~~ |
| 86 | + |
| 87 | +- **No decoded output**: Ensure you compiled and uploaded the firmware locally before capturing the crash |
| 88 | +- **Cannot connect**: Make sure you're using a USB data cable (not just a charging cable) and the correct serial port |
| 89 | + |
| 90 | +Alternative: Web-Based Stack Trace Decoder |
| 91 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 92 | + |
| 93 | +If you already have a stack trace but need to decode it, you can use the `ESP Stack Trace Decoder <https://esphome.github.io/esp-stacktrace-decoder/>`__ web tool: |
| 94 | + |
| 95 | +1. **Download the .elf file**: From the ESPHome dashboard, click the overflow menu (three dots) on your device card and select "Download .elf file" |
| 96 | + |
| 97 | + .. note:: |
| 98 | + |
| 99 | + The .elf file must be from the same compilation that produced the firmware currently running on your device. If you've recompiled since flashing, the debug symbols won't match. |
| 100 | + |
| 101 | +2. **Open the decoder**: Navigate to https://esphome.github.io/esp-stacktrace-decoder/ |
| 102 | + |
| 103 | +3. **Upload files**: |
| 104 | + |
| 105 | + - Click "Choose File" under "ELF File" and select your downloaded .elf file |
| 106 | + - Paste your stack trace into the text area |
| 107 | + - Click "Decode Stack Trace" |
| 108 | + |
| 109 | +4. **View results**: The tool will decode the addresses and show you the function names, file paths, and line numbers |
| 110 | + |
| 111 | +.. note:: |
| 112 | + |
| 113 | + This tool runs entirely in your browser - no data is sent to any server, ensuring your firmware and debug information remain private. |
| 114 | + |
| 115 | +See Also |
| 116 | +-------- |
| 117 | + |
| 118 | +- :doc:`/components/logger` - Configure logging levels and outputs |
| 119 | +- :doc:`/components/debug` - Debug component for additional diagnostics |
| 120 | +- :doc:`/components/safe_mode` - Safe Mode recovery guide |
| 121 | +- :doc:`/guides/faq` - Frequently asked questions |
0 commit comments