establish-serial-connection.rst 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. Establish Serial Connection with {IDF_TARGET_NAME}
  2. ==================================================
  3. :link_to_translation:`zh_CN:[中文]`
  4. This section provides guidance how to establish serial connection between {IDF_TARGET_NAME} and PC.
  5. Connect {IDF_TARGET_NAME} to PC
  6. -------------------------------
  7. Connect the {IDF_TARGET_NAME} board to the PC using the USB cable. If device driver does not install automatically, identify USB to serial converter chip on your {IDF_TARGET_NAME} board (or external converter dongle), search for drivers in internet and install them.
  8. Below are the links to drivers for {IDF_TARGET_NAME} boards produced by Espressif:
  9. .. only:: esp32
  10. .. csv-table::
  11. :header: Development Board, USB Driver, Remarks
  12. :widths: 40, 20, 40
  13. :ref:`ESP32-DevKitC <esp-modules-and-boards-esp32-devkitc>`, `CP210x`_
  14. `ESP32-LyraT <https://www.espressif.com/en/products/hardware/esp32-lyrat>`_, `CP210x`_
  15. `ESP32-LyraTD-MSC <https://www.espressif.com/en/products/hardware/esp32-lyratd-msc>`_, `CP210x`_
  16. :ref:`ESP32-PICO-KIT <esp-modules-and-boards-esp32-pico-kit>`, `CP210x`_
  17. :ref:`ESP-WROVER-KIT <esp-modules-and-boards-esp-wrover-kit>`, `FTDI`_
  18. :ref:`ESP32 Demo Board <esp-modules-and-boards-esp32-demo-board>`, `FTDI`_
  19. `ESP-Prog`_, `FTDI`_, Programmer board (w/o ESP32)
  20. `ESP32-MeshKit-Sense <https://github.com/espressif/esp-iot-solution/blob/master/documents/evaluation_boards/ESP32-MeshKit-Sense_guide_en.md#esp32-meshkit-sense-hardware-design-guidelines>`_, n/a, Use with `ESP-Prog`_
  21. `ESP32-Sense Kit <https://github.com/espressif/esp-iot-solution/blob/master/documents/evaluation_boards/esp32_sense_kit_guide_en.md#guide-for-esp32-sense-development-kit>`_, n/a, Use with `ESP-Prog`_
  22. .. _CP210x: https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
  23. .. _FTDI: https://www.ftdichip.com/Drivers/VCP.htm
  24. .. _ESP-Prog: https://github.com/espressif/esp-iot-solution/blob/master/documents/evaluation_boards/ESP-Prog_guide_en.md#introduction-to-the-esp-prog-board
  25. * CP210x: `CP210x USB to UART Bridge VCP Drivers <https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers>`_
  26. * FTDI: `FTDI Virtual COM Port Drivers <https://www.ftdichip.com/Drivers/VCP.htm>`_
  27. The drivers above are primarily for reference. Under normal circumstances, the drivers should be bundled with and operating system and automatically installed upon connecting one of the listed boards to the PC.
  28. Check port on Windows
  29. ---------------------
  30. Check the list of identified COM ports in the Windows Device Manager. Disconnect {IDF_TARGET_NAME} and connect it back, to verify which port disappears from the list and then shows back again.
  31. Figures below show serial port for ESP32 DevKitC and ESP32 WROVER KIT
  32. .. figure:: ../../_static/esp32-devkitc-in-device-manager.png
  33. :align: center
  34. :alt: USB to UART bridge of ESP32-DevKitC in Windows Device Manager
  35. :figclass: align-center
  36. USB to UART bridge of ESP32-DevKitC in Windows Device Manager
  37. .. figure:: ../../_static/esp32-wrover-kit-in-device-manager.png
  38. :align: center
  39. :alt: Two USB Serial Ports of ESP-WROVER-KIT in Windows Device Manager
  40. :figclass: align-center
  41. Two USB Serial Ports of ESP-WROVER-KIT in Windows Device Manager
  42. Check port on Linux and MacOS
  43. -----------------------------
  44. To check the device name for the serial port of your {IDF_TARGET_NAME} board (or external converter dongle), run this command two times, first with the board / dongle unplugged, then with plugged in. The port which appears the second time is the one you need:
  45. Linux ::
  46. ls /dev/tty*
  47. MacOS ::
  48. ls /dev/cu.*
  49. .. note::
  50. MacOS users: if you don't see the serial port then check you have the USB/serial drivers installed as shown in the Getting Started guide for your particular development board. For MacOS High Sierra (10.13), you may also have to explicitly allow the drivers to load. Open System Preferences -> Security & Privacy -> General and check if there is a message shown here about "System Software from developer ..." where the developer name is Silicon Labs or FTDI.
  51. .. _linux-dialout-group:
  52. Adding user to ``dialout`` on Linux
  53. -----------------------------------
  54. The currently logged user should have read and write access the serial port over USB. On most Linux distributions, this is done by adding the user to ``dialout`` group with the following command::
  55. sudo usermod -a -G dialout $USER
  56. on Arch Linux this is done by adding the user to ``uucp`` group with the following command::
  57. sudo usermod -a -G uucp $USER
  58. Make sure you re-login to enable read and write permissions for the serial port.
  59. Verify serial connection
  60. ------------------------
  61. Now verify that the serial connection is operational. You can do this using a serial terminal program. In this example we will use `PuTTY SSH Client <http://www.putty.org/>`_ that is available for both Windows and Linux. You can use other serial program and set communication parameters like below.
  62. Run terminal, set identified serial port, baud rate = 115200, data bits = 8, stop bits = 1, and parity = N. Below are example screen shots of setting the port and such transmission parameters (in short described as 115200-8-1-N) on Windows and Linux. Remember to select exactly the same serial port you have identified in steps above.
  63. .. figure:: ../../_static/putty-settings-windows.png
  64. :align: center
  65. :alt: Setting Serial Communication in PuTTY on Windows
  66. :figclass: align-center
  67. Setting Serial Communication in PuTTY on Windows
  68. .. figure:: ../../_static/putty-settings-linux.png
  69. :align: center
  70. :alt: Setting Serial Communication in PuTTY on Linux
  71. :figclass: align-center
  72. Setting Serial Communication in PuTTY on Linux
  73. Then open serial port in terminal and check, if you see any log printed out by {IDF_TARGET_NAME}. The log contents will depend on application loaded to {IDF_TARGET_NAME}. An example log by {IDF_TARGET_NAME} is shown below.
  74. .. highlight:: none
  75. ::
  76. ets Jun 8 2016 00:22:57
  77. rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  78. ets Jun 8 2016 00:22:57
  79. rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  80. configsip: 0, SPIWP:0x00
  81. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  82. mode:DIO, clock div:2
  83. load:0x3fff0008,len:8
  84. load:0x3fff0010,len:3464
  85. load:0x40078000,len:7828
  86. load:0x40080000,len:252
  87. entry 0x40080034
  88. I (44) boot: ESP-IDF v2.0-rc1-401-gf9fba35 2nd stage bootloader
  89. I (45) boot: compile time 18:48:10
  90. ...
  91. If you can see readable log output, it means serial connection is working and you are ready to proceed with installation and finally upload of application to {IDF_TARGET_NAME}.
  92. .. note::
  93. For some serial port wiring configurations, the serial RTS & DTR pins need to be disabled in the terminal program before the {IDF_TARGET_NAME} will boot and produce serial output. This depends on the hardware itself, most development boards (including all Espressif boards) *do not* have this issue. The issue is present if RTS & DTR are wired directly to the EN & GPIO0 pins. See the `esptool documentation`_ for more details.
  94. .. note::
  95. Close serial terminal after verification that communication is working. In the next step we are going to use a different application to upload a new firmware to {IDF_TARGET_NAME}. This application will not be able to access serial port while it is open in terminal.
  96. If you got here from :ref:`get-started-connect` when installing s/w for {IDF_TARGET_NAME} development, then you can continue with :ref:`get-started-configure`.
  97. .. _esptool documentation: https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection#automatic-bootloader