1**********************************
2USB Serial/JTAG Controller Console
3**********************************
4
5On chips with an integrated USB Serial/JTAG Controller, it is possible to use the part of this controller that implements a serial port (CDC) to implement the serial console, instead of using UART with an external USB-UART bridge chip. {IDF_TARGET_NAME} contains this controller, providing the following functions:
6
7* Bidirectional serial console, which can be used with :doc:`IDF Monitor <tools/idf-monitor>` or another serial monitor
8* Flashing using ``esptool.py`` and ``idf.py flash``.
9* JTAG debugging using e.g. OpenOCD, simultaneous with serial operations
10
11Note that, in contrast with the USB OTG peripheral found in some Espressif chips, the USB Serial/JTAG Controller is a fixed function device, implemented entirely in hardware. This means it cannot be reconfigured to perform any function other than to provide a serial channel and JTAG debugging functionality.
12
13Hardware Requirements
14=====================
15
16Connect {IDF_TARGET_NAME} to the USB port as follows:
17
18+------+-------------+
19| GPIO | USB         |
20+======+=============+
21| 19   | D+ (green)  |
22+------+-------------+
23| 18   | D- (white)  |
24+------+-------------+
25| GND  | GND (black) |
26+------+-------------+
27|      | +5V (red)   |
28+------+-------------+
29
30Some development boards may offer a USB connector for the USB Serial/JTAG Controller — in that case, no extra connections are required.
31
32Software Configuration
33======================
34
35USB console feature can be enabled using ``CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG`` option in menuconfig tool (see :ref:`CONFIG_ESP_CONSOLE_UART`).
36
37Once the option is enabled, build the project as usual.
38
39Uploading the Application
40=========================
41
42The USB Serial/JTAG Controller is able to put the {IDF_TARGET_NAME} into download mode automatically. Simply flash as usual, but specify the USB Serial/JTAG Controller port on your system: ``idf.py flash -p PORT`` where ``PORT`` is the name of the proper port.
43
44Limitations
45===========
46
47There are several limitations to the USB console feature. These may or may not be significant, depending on the type of application being developed, and the development workflow.
48
49{IDF_TARGET_BOOT_PIN:default = "Not Updated!", esp32c3 = "GPIO9", esp32s3 = "GPIO0"}
50
511. If the application accidentally reconfigures the USB peripheral pins, or disables the USB Serial/JTAG Controller, the device will disappear from the system. After fixing the issue in the application, you will need to manually put the {IDF_TARGET_NAME} into download mode by pulling low {IDF_TARGET_BOOT_PIN} and resetting the chip.
52
532. If the application enters deep sleep mode, USB CDC device will disappear from the system.
54
553. The behaviour between an actual USB-to-serial bridge chip and the USB Serial/JTAG Controller is slightly different if the ESP-IDF application does not listen for incoming bytes. An USB-to-serial bridge chip will just send the bytes to a (not listening) chip, while the USB Serial/JTAG Controller will block until the application reads the bytes. This can lead to a non-responsive looking terminal program.
56
574. If the application enters light-sleep (including automatic light-sleep) or software reset, etc. The USB CDC device will still work on the system. But be aware that this might increase the power consumption, if you don't need USB CDC in sleep and want to keep low power consumption, please disable the menuconfig ``CONFIG_RTC_CLOCK_BBPLL_POWER_ON_WITH_USB``. Moreover, the power consumption will only increase when your USB CDC port is really in use (like data transaction), therefore, if your USB CDC just connects with power bank or battery, rather than something like computer, you don't need to care about the increasing power consumption mentioned above.
58