usb_serial_jtag: support usb_serial_jtag on esp32c3

USB serial/jtag controller: Add vfs (logging/printf), panic handler, gdb support.

See merge request espressif/esp-idf!12925
This commit is contained in:
Jeroen Domburg
2021-04-28 08:38:31 +00:00
committed by Cao Sen Miao
parent ba15ac8634
commit d6cdb3e0ae
29 changed files with 2099 additions and 51 deletions

View File

@@ -163,12 +163,13 @@ LEGACY_DOCS = ['api-guides/build-system-legacy.rst',
'get-started-legacy/**']
USB_DOCS = ['api-reference/peripherals/usb.rst',
'api-guides/usb-console.rst',
'api-guides/usb-otg-console.rst',
'api-guides/dfu.rst']
FTDI_JTAG_DOCS = ['api-guides/jtag-debugging/configure-ft2232h-jtag.rst']
BUILTIN_JTAG_DOCS = ['api-guides/jtag-debugging/configure-builtin-jtag.rst']
USB_SERIAL_JTAG_DOCS = ['api-guides/jtag-debugging/configure-builtin-jtag.rst',
'api-guides/usb-serial-jtag-console.rst']
ULP_DOCS = ['api-guides/ulp.rst', 'api-guides/ulp_macros.rst']
@@ -199,7 +200,8 @@ ESP32S2_DOCS = ['hw-reference/esp32s2/**',
'api-reference/peripherals/touch_element.rst',
'api-reference/peripherals/dac.rst'] + FTDI_JTAG_DOCS
ESP32C3_DOCS = ['hw-reference/esp32c3/**'] + BUILTIN_JTAG_DOCS
# No JTAG docs for this one as it gets gated on SOC_USB_SERIAL_JTAG_SUPPORTED down below.
ESP32C3_DOCS = ['hw-reference/esp32c3/**']
# format: {tag needed to include: documents to included}, tags are parsed from sdkconfig and peripheral_caps.h headers
conditional_include_dict = {'SOC_BT_SUPPORTED':BT_DOCS,
@@ -207,6 +209,7 @@ conditional_include_dict = {'SOC_BT_SUPPORTED':BT_DOCS,
'SOC_SDIO_SLAVE_SUPPORTED':SDIO_SLAVE_DOCS,
'SOC_MCPWM_SUPPORTED':MCPWM_DOCS,
'SOC_USB_SUPPORTED':USB_DOCS,
'SOC_USB_SERIAL_JTAG_SUPPORTED':USB_SERIAL_JTAG_DOCS,
'SOC_DEDICATED_GPIO_SUPPORTED':DEDIC_GPIO_DOCS,
'SOC_SPIRAM_SUPPORTED':SPIRAM_DOCS,
'SOC_PCNT_SUPPORTED':PCNT_DOCS,

View File

@@ -40,5 +40,6 @@ API Guides
:SOC_RISCV_COPROC_SUPPORTED: ULP-RISC-V Coprocessor <ulp-risc-v>
Unit Testing <unit-tests>
:esp32: Unit Testing (Legacy GNU Make) <unit-tests-legacy>
:SOC_USB_SUPPORTED: USB Console <usb-console>
:SOC_USB_SUPPORTED: USB OTG Console <usb-otg-console>
:SOC_USB_SERIAL_JTAG_SUPPORTED: USB Serial/JTAG Controller Console <usb-serial-jtag-console>
WiFi Driver <wifi>

View File

@@ -1,6 +1,6 @@
***********
USB Console
***********
***************
USB OTG Console
***************
On chips with an integrated USB peripheral, it is possible to use USB Communication Device Class (CDC) to implement the serial console, instead of using UART with an external USB-UART bridge chip. {IDF_TARGET_NAME} ROM code contains a USB CDC implementation, which supports for some basic functionality without requiring the application to include the USB stack:
@@ -15,7 +15,7 @@ On chips with an integrated USB peripheral, it is possible to use USB Communicat
Hardware Requirements
=====================
Connect ESP32-S2 to the USB port as follows
Connect {IDF_TARGET_NAME} to the USB port as follows
+------+-------------+
| GPIO | USB |

View File

@@ -0,0 +1,54 @@
**********************************
USB Serial/JTAG Controller Console
**********************************
On 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:
* Bidirectional serial console, which can be used with :doc:`IDF Monitor <tools/idf-monitor>` or another serial monitor
* Flashing using ``esptool.py`` and ``idf.py flash``.
* JTAG debugging using e.g. OpenOCD, simultaneous with serial operations
Note 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.
Hardware Requirements
=====================
Connect {IDF_TARGET_NAME} to the USB port as follows:
+------+-------------+
| GPIO | USB |
+======+=============+
| 19 | D+ (green) |
+------+-------------+
| 18 | D- (white) |
+------+-------------+
| GND | GND (black) |
+------+-------------+
| | +5V (red) |
+------+-------------+
Some development boards may offer a USB connector for the USB Serial/JTAG Controller — in that case, no extra connections are required.
Software Configuration
======================
USB console feature can be enabled using ``CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG`` option in menuconfig tool (see :ref:`CONFIG_ESP_CONSOLE_UART`).
Once the option is enabled, build the project as usual.
Uploading the Application
=========================
The 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.
Limitations
===========
There 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.
1. 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 GPIO0 and resetting the chip.
2. If the application enters light sleep (including automatic light sleep) or deep sleep mode, USB CDC device will disappear from the system.
3. 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.

View File

@@ -40,5 +40,6 @@ API 指南
:esp32s2: ULP-RISC-V 协处理器 <ulp-risc-v>
单元测试 <unit-tests>
:esp32: 单元测试 (传统 GNU Make) <unit-tests-legacy>
:esp32s2: USB 控制台 <usb-console>
:SOC_USB_SUPPORTED: USB 控制台 <usb-otg-console>
:SOC_USB_SERIAL_JTAG_SUPPORTED: USB Serial/JTAG Controller Console <usb-serial-jtag-console>
Wi-Fi 驱动 <wifi>

View File

@@ -1 +0,0 @@
.. include:: ../../en/api-guides/usb-console.rst

View File

@@ -0,0 +1 @@
.. include:: ../../en/api-guides/usb-otg-console.rst

View File

@@ -0,0 +1 @@
.. include:: ../../en/api-guides/usb-serial-jtag-console.rst