2017-03-26 22:01:52 +00:00
***** ***** *
2017-03-07 22:15:19 +00:00
IDF Monitor
***** ***** *
2018-04-27 06:46:13 +00:00
:link_to_translation:`zh_CN:[中文]`
2017-03-07 22:15:19 +00:00
2018-05-03 04:22:35 +00:00
The idf_monitor tool is a Python program which runs when the `` idf.py monitor `` target is invoked in IDF.
2017-03-07 22:15:19 +00:00
2018-03-29 06:21:15 +00:00
It is mainly a serial terminal program which relays serial data to and from the target device's serial port, but it has some other IDF-specific features.
2017-03-07 22:15:19 +00:00
2018-03-29 06:21:15 +00:00
Interacting With IDF Monitor
2017-03-07 22:15:19 +00:00
============================
- `` Ctrl-] `` will exit the monitor.
- `` Ctrl-T Ctrl-H `` will display a help menu with all other keyboard shortcuts.
- Any other key apart from `` Ctrl-] `` and `` Ctrl-T `` is sent through the serial port.
Automatically Decoding Addresses
================================
2018-03-29 06:21:15 +00:00
Any time esp-idf prints a hexadecimal code address of the form `` 0x4_______ `` , IDF Monitor will use addr2line_ to look up the source code location and function name.
2017-03-07 22:15:19 +00:00
2017-03-26 22:01:52 +00:00
.. highlight :: none
2017-03-07 22:15:19 +00:00
When an esp-idf app crashes and panics a register dump and backtrace such as this is produced::
Guru Meditation Error of type StoreProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x400f360d PS : 0x00060330 A0 : 0x800dbf56 A1 : 0x3ffb7e00
A2 : 0x3ffb136c A3 : 0x00000005 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000080 A8 : 0x00000000 A9 : 0x3ffb7dd0
A10 : 0x00000003 A11 : 0x00060f23 A12 : 0x00060f20 A13 : 0x3ffba6d0
A14 : 0x00000047 A15 : 0x0000000f SAR : 0x00000019 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x400f360d:0x3ffb7e00 0x400dbf56:0x3ffb7e20 0x400dbf5e:0x3ffb7e40 0x400dbf82:0x3ffb7e60 0x400d071d:0x3ffb7e90
2018-03-29 06:21:15 +00:00
IDF Monitor will augment the dump::
2017-03-07 22:15:19 +00:00
Guru Meditation Error of type StoreProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x400f360d PS : 0x00060330 A0 : 0x800dbf56 A1 : 0x3ffb7e00
0x400f360d: do_something_to_crash at /home/gus/esp/32/idf/examples/get-started/hello_world/main/./hello_world_main.c:57
(inlined by) inner_dont_crash at /home/gus/esp/32/idf/examples/get-started/hello_world/main/./hello_world_main.c:52
A2 : 0x3ffb136c A3 : 0x00000005 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000080 A8 : 0x00000000 A9 : 0x3ffb7dd0
A10 : 0x00000003 A11 : 0x00060f23 A12 : 0x00060f20 A13 : 0x3ffba6d0
A14 : 0x00000047 A15 : 0x0000000f SAR : 0x00000019 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x400f360d:0x3ffb7e00 0x400dbf56:0x3ffb7e20 0x400dbf5e:0x3ffb7e40 0x400dbf82:0x3ffb7e60 0x400d071d:0x3ffb7e90
0x400f360d: do_something_to_crash at /home/gus/esp/32/idf/examples/get-started/hello_world/main/./hello_world_main.c:57
(inlined by) inner_dont_crash at /home/gus/esp/32/idf/examples/get-started/hello_world/main/./hello_world_main.c:52
0x400dbf56: still_dont_crash at /home/gus/esp/32/idf/examples/get-started/hello_world/main/./hello_world_main.c:47
0x400dbf5e: dont_crash at /home/gus/esp/32/idf/examples/get-started/hello_world/main/./hello_world_main.c:42
0x400dbf82: app_main at /home/gus/esp/32/idf/examples/get-started/hello_world/main/./hello_world_main.c:33
0x400d071d: main_task at /home/gus/esp/32/idf/components/esp32/./cpu_start.c:254
2018-03-29 06:21:15 +00:00
Behind the scenes, the command IDF Monitor runs to decode each address is::
2017-03-07 22:15:19 +00:00
2017-10-04 05:00:28 +00:00
xtensa-esp32-elf-addr2line -pfiaC -e build/PROJECT.elf ADDRESS
2017-03-07 22:15:19 +00:00
Launch GDB for GDBStub
======================
By default, if an esp-idf app crashes then the panic handler prints registers and a stack dump as shown above, and then resets.
Optionally, the panic handler can be configured to run a serial "gdb stub" which can communicate with a gdb_ debugger program and allow memory to be read, variables and stack frames examined, etc. This is not as versatile as JTAG debugging, but no special hardware is required.
2018-05-03 04:22:35 +00:00
To enable the gdbstub, run `` idf.py menuconfig `` and set :ref: `CONFIG_ESP32_PANIC` option to `` Invoke GDBStub `` .
2017-03-07 22:15:19 +00:00
2018-03-29 06:21:15 +00:00
If this option is enabled and IDF Monitor sees the gdb stub has loaded, it will automatically pause serial monitoring and run GDB with the correct arguments. After GDB exits, the board will be reset via the RTS serial line (if this is connected.)
2017-03-07 22:15:19 +00:00
2018-03-29 06:21:15 +00:00
Behind the scenes, the command IDF Monitor runs is::
2017-03-07 22:15:19 +00:00
xtensa-esp32-elf-gdb -ex "set serial baud BAUD" -ex "target remote PORT" -ex interrupt build/PROJECT.elf
Quick Compile and Flash
=======================
2018-05-03 04:22:35 +00:00
The keyboard shortcut `` Ctrl-T Ctrl-F `` will pause idf_monitor, run the `` idf.py flash `` target, then resume idf_monitor. Any changed source files will be recompiled before re-flashing.
2017-03-07 22:15:19 +00:00
2018-05-03 04:22:35 +00:00
The keyboard shortcut `` Ctrl-T Ctrl-A `` will pause idf-monitor, run the `` idf.py app-flash `` target, then resume idf_monitor. This is similar to `` idf.py flash `` , but only the main app is compiled and reflashed.
2017-03-07 22:15:19 +00:00
Quick Reset
===========
The keyboard shortcut `` Ctrl-T Ctrl-R `` will reset the target board via the RTS line (if it is connected.)
2017-11-30 04:46:08 +00:00
Pause the Application
=====================
The keyboard shortcut `` Ctrl-T Ctrl-P `` will reset the target into bootloader, so that the board will run nothing. This is
useful when you want to wait for another device to startup. Then shortcut `` Ctrl-T Ctrl-R `` can be used to restart the
application.
2017-11-16 06:39:57 +00:00
Toggle Output Display
=====================
Sometimes you may want to stop new output printed to screen, to see the log before. The keyboard shortcut `` Ctrl-T Ctrl-Y `` will
toggle the display (discard all serial data when the display is off) so that you can stop to see the log, and revert
again quickly without quitting the monitor.
2017-03-07 22:15:19 +00:00
Simple Monitor
==============
Earlier versions of ESP-IDF used the pySerial_ command line program miniterm_ as a serial console program.
This program can still be run, via `` make simple_monitor `` .
2018-03-29 06:21:15 +00:00
IDF Monitor is based on miniterm and shares the same basic keyboard shortcuts.
2017-03-07 22:15:19 +00:00
2018-05-03 04:22:35 +00:00
.. note :: This target only works in the GNU Make based build system, not the CMake-based build system preview.
2017-03-07 22:15:19 +00:00
2018-03-29 06:21:15 +00:00
Known Issues with IDF Monitor
2017-03-07 22:15:19 +00:00
=============================
Issues Observed on Windows
~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-03-17 10:41:18 +00:00
- If you are using the supported Windows environment and receive the error "winpty: command not found" then run `` pacman -S winpty `` to fix.
2017-03-07 22:15:19 +00:00
- Arrow keys and some other special keys in gdb don't work, due to Windows Console limitations.
- Occasionally when "make" exits, it may stall for up to 30 seconds before idf_monitor resumes.
- Occasionally when "gdb" is run, it may stall for a short time before it begins communicating with the gdbstub.
.. _addr2line: https://sourceware.org/binutils/docs/binutils/addr2line.html
.. _gdb: https://sourceware.org/gdb/download/onlinedocs/
.. _pySerial: https://github.com/pyserial/pyserial
2017-09-05 19:58:31 +00:00
.. _miniterm: https://pyserial.readthedocs.org/en/latest/tools.html#module-serial.tools.miniterm