establish-serial-connection.rst 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 is the list of USB to serial converter chips installed on most of the {IDF_TARGET_NAME} boards produced by Espressif together with links to the drivers:
  9. * CP210x: `CP210x USB to UART Bridge VCP Drivers <https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers>`_
  10. * FTDI: `FTDI Virtual COM Port Drivers <https://www.ftdichip.com/Drivers/VCP.htm>`_
  11. Please check the board user guide for specific USB to serial converter chip used. The drivers above are primarily for reference. Under normal circumstances, the drivers should be bundled with an operating system and automatically installed upon connecting the board to the PC.
  12. Check port on Windows
  13. ---------------------
  14. 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.
  15. Figures below show serial port for ESP32 DevKitC and ESP32 WROVER KIT
  16. .. figure:: ../../_static/esp32-devkitc-in-device-manager.png
  17. :align: center
  18. :alt: USB to UART bridge of ESP32-DevKitC in Windows Device Manager
  19. :figclass: align-center
  20. USB to UART bridge of ESP32-DevKitC in Windows Device Manager
  21. .. figure:: ../../_static/esp32-wrover-kit-in-device-manager.png
  22. :align: center
  23. :alt: Two USB Serial Ports of ESP-WROVER-KIT in Windows Device Manager
  24. :figclass: align-center
  25. Two USB Serial Ports of ESP-WROVER-KIT in Windows Device Manager
  26. Check port on Linux and macOS
  27. -----------------------------
  28. 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:
  29. Linux ::
  30. ls /dev/tty*
  31. macOS ::
  32. ls /dev/cu.*
  33. .. note::
  34. 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.
  35. .. _linux-dialout-group:
  36. Adding user to ``dialout`` on Linux
  37. -----------------------------------
  38. 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::
  39. sudo usermod -a -G dialout $USER
  40. on Arch Linux this is done by adding the user to ``uucp`` group with the following command::
  41. sudo usermod -a -G uucp $USER
  42. Make sure you re-login to enable read and write permissions for the serial port.
  43. Verify serial connection
  44. ------------------------
  45. Now verify that the serial connection is operational. You can do this using a serial terminal program by checking if you get any output on the terminal after reseting {IDF_TARGET_NAME}.
  46. Windows and Linux
  47. ^^^^^^^^^^^^^^^^^
  48. 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.
  49. 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.
  50. .. figure:: ../../_static/putty-settings-windows.png
  51. :align: center
  52. :alt: Setting Serial Communication in PuTTY on Windows
  53. :figclass: align-center
  54. Setting Serial Communication in PuTTY on Windows
  55. .. figure:: ../../_static/putty-settings-linux.png
  56. :align: center
  57. :alt: Setting Serial Communication in PuTTY on Linux
  58. :figclass: align-center
  59. Setting Serial Communication in PuTTY on Linux
  60. 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}, see `Example Output`_.
  61. .. note::
  62. Close the serial terminal after verification that communication is working. If you keep the terminal session open, the serial port will be inaccessible for uploading firmware later.
  63. macOS
  64. ^^^^^^^^
  65. To spare you the trouble of installing a serial terminal program, macOS offers the **screen** command.
  66. - As discussed in `Check port on Linux and macOS`_, run::
  67. ls /dev/cu.*
  68. - You should see similar output::
  69. /dev/cu.Bluetooth-Incoming-Port /dev/cu.SLAB_USBtoUART /dev/cu.SLAB_USBtoUART7
  70. - The output will vary depending on the type and the number of boards connected to your PC. Then pick the device name of your board and run::
  71. screen /dev/cu.device_name 115200
  72. Replace ``device_name`` with the name found running ``ls /dev/cu.*``.
  73. - What you are looking for is some log displayed by the **screen**. The log contents will depend on application loaded to {IDF_TARGET_NAME}, see `Example Output`_. To exit the **screen** session type Ctrl-A + \\ .
  74. .. note::
  75. Do not forget to **exit the screen session** after verifying that the communication is working. If you fail to do it and just close the terminal window, the serial port will be inaccessible for uploading firmware later.
  76. Example Output
  77. ^^^^^^^^^^^^^^
  78. An example log by {IDF_TARGET_NAME} is shown below. Reset the board if you do not see anything.
  79. .. highlight:: none
  80. ::
  81. ets Jun 8 2016 00:22:57
  82. rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  83. ets Jun 8 2016 00:22:57
  84. rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  85. configsip: 0, SPIWP:0x00
  86. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  87. mode:DIO, clock div:2
  88. load:0x3fff0008,len:8
  89. load:0x3fff0010,len:3464
  90. load:0x40078000,len:7828
  91. load:0x40080000,len:252
  92. entry 0x40080034
  93. I (44) boot: ESP-IDF v2.0-rc1-401-gf9fba35 2nd stage bootloader
  94. I (45) boot: compile time 18:48:10
  95. ...
  96. 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}.
  97. .. note::
  98. 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.
  99. 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`.
  100. .. _esptool documentation: https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection#automatic-bootloader