espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.33k stars 7.2k forks source link

ESP32 USB Host CDC-ACM driver for CH34x (IDFGH-7370) #8951

Closed AristarchosOfSamos closed 2 years ago

AristarchosOfSamos commented 2 years ago

Hi,

Seen CDC USB host drivers for FTDI and SiLabs chips in new S3/S2/C3 ESP32 variants.

Although these do work, it seems that the CH34x USB serial chip brand is quite widespread and in use by really almost anything nowadays in many devices and gadgets. So, it could be a good idea if such a driver could be implemented. Eg. now we cannot use one of the abundant arduino clones as a device attached on a ESP32-S3, having this driver though it could open lots of prospects.

Is there any hint if this has been done already ?

Thanks in advance,

tore-espressif commented 2 years ago

Hi @AristarchosOfSamos , thank you for your interest in esp-idf USB drivers.

Indeed, CH340 needs a custom driver. The RX and TX paths work, but functions for setting of linecoding, baudrate etc need to be implemented. I'll keep you updated.

Just a side note to your post: ESP32C3 does not contain USB On-the-Go peripheral (only USB-serial-JTAG)

AristarchosOfSamos commented 2 years ago

Hi, Thanks for considering this request, a CH34x driver is definitively required nowadays! Waiting to read any news on it, got some ESP32-S3-Devkits here to test that. Regards,

tore-espressif commented 2 years ago

Update: we are waiting for CH340 manufacturer to provide complete documentation EDIT: Upate2: They can't provide any useful documentation. We will have to reverse engineer from its linux driver: https://github.com/WCHSoftGroup/ch341ser_linux

sramrajkar commented 2 years ago

Hi, Sorry to bug on this topic, but even I am using ESP32-S2 (or S3 in future) for an ELM327 USB OBD adaptor and it uses CH340T. Currently I would also need this feature to set line parameters as the baud rate of the OBD IC and the default baud of CH340 dont match. Any luck on this front? I dont mind applying any patches myself. But please note I am super new to USB. Also any idea when would CH34x be supported in the IDF? Thank you

tore-espressif commented 2 years ago

Hello @sramrajkar @AristarchosOfSamos

I uploaded an early version of CH340 driver into my esp-idf fork, feel free to have a look: https://github.com/tore-espressif/esp-idf/tree/feature/usb_host/cdc_ch340/examples/peripherals/usb/host/cdc/cdc_acm_vcp

It covers only the basics: RX/TX, setting of baudrate, linecoding and DTR/RTS control.

Note: Please note that there are two commits in the linked branch:

  1. CDC-ACM driver bug fix https://github.com/tore-espressif/esp-idf/commit/438234ad702fcd8ddc9781dcb2782f15a014d235
  2. CH340 driver https://github.com/tore-espressif/esp-idf/commit/93e9c72534975243e0b7b4e09a1e5e818ba3a3e7

Please let me know whether this solution works for you

AristarchosOfSamos commented 2 years ago

Hi @tore-espressif , first test looks ok. Got it compiled and after flashed on a esp32-s3-devkitc it can open an attached CH34x on its USB port {an arduino nano clone) via the provided test/example.

Output I (277) sleep: Configure to isolate all GPIO pins in sleep state I (283) sleep: Enable automatic switching of GPIO sleep configuration I (291) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (311) VCP example: Installing USB Host I (341) VCP example: Installing CDC-ACM driver I (341) VCP example: Opening CH340 device I (741) VCP example: Setting up line coding

I'll run some tests and see how the comms are, I'll report back with any remarks.

Either way, thanks for your effort.

Aristarchos

AristarchosOfSamos commented 2 years ago

Ok @tore-espressif Done more tests, speed, disconnection/reconnection, full duplex and it looks just fine! For me it is ready to be commited on main esp-idf repo in v5.0 branch (I guess).

Thanks for an excellent work. Aristarchos

ghost commented 2 years ago

Hi, i got some problems when trying to build this to an esp32-S2. In menuconfig i set the esp system settings - channel for console output to usb cdc and the example configuration to ch340. Can someone help me with this?

[98/100] Linking C executable bootloader.elf
[99/100] Generating binary image from built executable
esptool.py v3.2-dev
Merged 1 ELF section
Generated C:/Espressif/frameworks/esp-idf-v4.4/examples/peripherals/usb/host/cdc/cdc_acm_vcp/build/bootloader/bootloader.bin
[100/100] cmd.exe /C "cd /D C:\Espressif\frameworks\esp-idf-v4.4\examples\peripherals\usb\host\cdc\cdc_acm_vcp\build\bootloader\esp-idf\esptool_py && C:\Espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe C:/Espressif/frameworks/esp-idf-v4.4/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 C:/Espressif/frameworks/esp-idf-v4.4/examples/peripherals/usb/host/cdc/cdc_acm_vcp/build/bootloader/bootloader.bin"
Bootloader binary size 0x51c0 bytes. 0x1e40 bytes (27%) free.
[1028/1037] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/ch34x_usb.cpp.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/ch34x_usb.cpp.obj

ccache C:\Espressif\tools\xtensa-esp32s2-elf\esp-2021r2-patch2-8.4.0\xtensa-esp32s2-elf\bin\xtensa-esp32s2-elf-g++.exe -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -Iconfig -I../main -I../../../../../../../components/newlib/platform_include -I../../../../../../../components/freertos/include -I../../../../../../../components/freertos/include/esp_additions/freertos -I../../../../../../../components/freertos/port/xtensa/include -I../../../../../../../components/freertos/include/esp_additions -I../../../../../../../components/esp_hw_support/include -I../../../../../../../components/esp_hw_support/include/soc -I../../../../../../../components/esp_hw_support/include/soc/esp32s2 -I../../../../../../../components/esp_hw_support/port/esp32s2/. -I../../../../../../../components/esp_hw_support/port/esp32s2/private_include -I../../../../../../../components/heap/include -I../../../../../../../components/log/include -I../../../../../../../components/lwip/include/apps -I../../../../../../../components/lwip/include/apps/sntp -I../../../../../../../components/lwip/lwip/src/include -I../../../../../../../components/lwip/port/esp32/include -I../../../../../../../components/lwip/port/esp32/include/arch -I../../../../../../../components/soc/include -I../../../../../../../components/soc/esp32s2/. -I../../../../../../../components/soc/esp32s2/include -I../../../../../../../components/hal/esp32s2/include -I../../../../../../../components/hal/include -I../../../../../../../components/hal/platform_port/include -I../../../../../../../components/esp_rom/include -I../../../../../../../components/esp_rom/include/esp32s2 -I../../../../../../../components/esp_rom/esp32s2 -I../../../../../../../components/esp_common/include -I../../../../../../../components/esp_system/include -I../../../../../../../components/esp_system/port/soc -I../../../../../../../components/esp_system/port/public_compat -I../../../../../../../components/xtensa/include -I../../../../../../../components/xtensa/esp32s2/include -I../../../../../../../components/driver/include -I../../../../../../../components/driver/esp32s2/include -I../../../../../../../components/esp_pm/include -I../../../../../../../components/esp_ringbuf/include -I../../../../../../../components/efuse/include -I../../../../../../../components/efuse/esp32s2/include -I../../../../../../../components/vfs/include -I../../../../../../../components/esp_wifi/include -I../../../../../../../components/esp_event/include -I../../../../../../../components/esp_netif/include -I../../../../../../../components/esp_eth/include -I../../../../../../../components/tcpip_adapter/include -I../../../../../../../components/esp_phy/include -I../../../../../../../components/esp_phy/esp32s2/include -I../../../../../../../components/esp_ipc/include -I../../../../../../../components/app_trace/include -I../../../../../../../components/esp_timer/include -I../../../../../../../components/mbedtls/port/include -I../../../../../../../components/mbedtls/mbedtls/include -I../../../../../../../components/mbedtls/esp_crt_bundle/include -I../../../../../../../components/app_update/include -I../../../../../../../components/spi_flash/include -I../../../../../../../components/bootloader_support/include -I../../../../../../../components/nvs_flash/include -I../../../../../../../components/pthread/include -I../../../../../../../components/esp_gdbstub/include -I../../../../../../../components/esp_gdbstub/xtensa -I../../../../../../../components/esp_gdbstub/esp32s2 -I../../../../../../../components/espcoredump/include -I../../../../../../../components/espcoredump/include/port/xtensa -I../../../../../../../components/wpa_supplicant/include -I../../../../../../../components/wpa_supplicant/port/include -I../../../../../../../components/wpa_supplicant/esp_supplicant/include -I../../../../../../../components/ieee802154/include -I../../../../../../../components/console -I../../../../../../../components/asio/asio/asio/include -I../../../../../../../components/asio/port/include -I../../../../../../../components/cbor/port/include -I../../../../../../../components/unity/include -I../../../../../../../components/unity/unity/src -I../../../../../../../components/cmock/CMock/src -I../../../../../../../components/coap/port/include -I../../../../../../../components/coap/libcoap/include -I../../../../../../../components/nghttp/port/include -I../../../../../../../components/nghttp/nghttp2/lib/includes -I../../../../../../../components/esp-tls -I../../../../../../../components/esp-tls/esp-tls-crypto -I../../../../../../../components/esp_adc_cal/include -I../../../../../../../components/esp_hid/include -I../../../../../../../components/tcp_transport/include -I../../../../../../../components/esp_http_client/include -I../../../../../../../components/esp_http_server/include -I../../../../../../../components/esp_https_ota/include -I../../../../../../../components/esp_lcd/include -I../../../../../../../components/esp_lcd/interface -I../../../../../../../components/protobuf-c/protobuf-c -I../../../../../../../components/protocomm/include/common -I../../../../../../../components/protocomm/include/security -I../../../../../../../components/protocomm/include/transports -I../../../../../../../components/mdns/include -I../../../../../../../components/esp_local_ctrl/include -I../../../../../../../components/sdmmc/include -I../../../../../../../components/esp_serial_slave_link/include -I../../../../../../../components/esp_websocket_client/include -I../../../../../../../components/expat/expat/expat/lib -I../../../../../../../components/expat/port/include -I../../../../../../../components/wear_levelling/include -I../../../../../../../components/fatfs/diskio -I../../../../../../../components/fatfs/vfs -I../../../../../../../components/fatfs/src -I../../../../../../../components/freemodbus/common/include -I../../../../../../../components/idf_test/include -I../../../../../../../components/idf_test/include/esp32s2 -I../../../../../../../components/jsmn/include -I../../../../../../../components/json/cJSON -I../../../../../../../components/libsodium/libsodium/src/libsodium/include -I../../../../../../../components/libsodium/port_include -I../../../../../../../components/mqtt/esp-mqtt/include -I../../../../../../../components/openssl/include -I../../../../../../../components/perfmon/include -I../../../../../../../components/spiffs/include -I../../../../../../../components/usb/include -I../../../../../../../components/touch_element/include -I../../../../../../../components/ulp/include -I../../../../../../../components/wifi_provisioning/include -I../../common/cdc_acm_host/include -mlongcalls -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4/examples/peripherals/usb/host/cdc/cdc_acm_vcp=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4=IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.4\" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/ch34x_usb.cpp.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\ch34x_usb.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/ch34x_usb.cpp.obj -c ../main/ch34x_usb.cpp
In file included from ../main/ch34x_usb.cpp:10:
../main/ch34x_usb.cpp: In member function 'esp_err_t esp_usb::CH34x::line_coding_set(cdc_acm_line_coding_t*)':
../main/ch34x_usb.cpp:89:35: error: 'class esp_usb::CH34x' has no member named 'send_custom_request'
         ESP_RETURN_ON_ERROR(this->send_custom_request(CH34X_WRITE_REQ, CH34X_CMD_WRITE, 0x1312, baud_reg_val, 0, NULL), TAG, "Set baudrate failed");
                                   ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/ch34x_usb.cpp:119:31: error: 'class esp_usb::CH34x' has no member named 'send_custom_request'
     ESP_RETURN_ON_ERROR(this->send_custom_request(CH34X_WRITE_REQ, CH34X_CMD_WRITE, 0x2518, lcr, 0, NULL), TAG, "Set line coding failed");
                               ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/ch34x_usb.cpp: In member function 'esp_err_t esp_usb::CH34x::set_control_line_state(bool, bool)':
../main/ch34x_usb.cpp:134:18: error: 'class esp_usb::CH34x' has no member named 'send_custom_request'
     return this->send_custom_request(CH34X_WRITE_REQ, CH34X_CMD_MODEM_OUT, wValue, this->intf, 0, NULL);
                  ^~~~~~~~~~~~~~~~~~~
[1029/1037] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/ftdi_usb.cpp.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/ftdi_usb.cpp.obj
ccache C:\Espressif\tools\xtensa-esp32s2-elf\esp-2021r2-patch2-8.4.0\xtensa-esp32s2-elf\bin\xtensa-esp32s2-elf-g++.exe -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -Iconfig -I../main -I../../../../../../../components/newlib/platform_include -I../../../../../../../components/freertos/include -I../../../../../../../components/freertos/include/esp_additions/freertos -I../../../../../../../components/freertos/port/xtensa/include -I../../../../../../../components/freertos/include/esp_additions -I../../../../../../../components/esp_hw_support/include -I../../../../../../../components/esp_hw_support/include/soc -I../../../../../../../components/esp_hw_support/include/soc/esp32s2 -I../../../../../../../components/esp_hw_support/port/esp32s2/. -I../../../../../../../components/esp_hw_support/port/esp32s2/private_include -I../../../../../../../components/heap/include -I../../../../../../../components/log/include -I../../../../../../../components/lwip/include/apps -I../../../../../../../components/lwip/include/apps/sntp -I../../../../../../../components/lwip/lwip/src/include -I../../../../../../../components/lwip/port/esp32/include -I../../../../../../../components/lwip/port/esp32/include/arch -I../../../../../../../components/soc/include -I../../../../../../../components/soc/esp32s2/. -I../../../../../../../components/soc/esp32s2/include -I../../../../../../../components/hal/esp32s2/include -I../../../../../../../components/hal/include -I../../../../../../../components/hal/platform_port/include -I../../../../../../../components/esp_rom/include -I../../../../../../../components/esp_rom/include/esp32s2 -I../../../../../../../components/esp_rom/esp32s2 -I../../../../../../../components/esp_common/include -I../../../../../../../components/esp_system/include -I../../../../../../../components/esp_system/port/soc -I../../../../../../../components/esp_system/port/public_compat -I../../../../../../../components/xtensa/include -I../../../../../../../components/xtensa/esp32s2/include -I../../../../../../../components/driver/include -I../../../../../../../components/driver/esp32s2/include -I../../../../../../../components/esp_pm/include -I../../../../../../../components/esp_ringbuf/include -I../../../../../../../components/efuse/include -I../../../../../../../components/efuse/esp32s2/include -I../../../../../../../components/vfs/include -I../../../../../../../components/esp_wifi/include -I../../../../../../../components/esp_event/include -I../../../../../../../components/esp_netif/include -I../../../../../../../components/esp_eth/include -I../../../../../../../components/tcpip_adapter/include -I../../../../../../../components/esp_phy/include -I../../../../../../../components/esp_phy/esp32s2/include -I../../../../../../../components/esp_ipc/include -I../../../../../../../components/app_trace/include -I../../../../../../../components/esp_timer/include -I../../../../../../../components/mbedtls/port/include -I../../../../../../../components/mbedtls/mbedtls/include -I../../../../../../../components/mbedtls/esp_crt_bundle/include -I../../../../../../../components/app_update/include -I../../../../../../../components/spi_flash/include -I../../../../../../../components/bootloader_support/include -I../../../../../../../components/nvs_flash/include -I../../../../../../../components/pthread/include -I../../../../../../../components/esp_gdbstub/include -I../../../../../../../components/esp_gdbstub/xtensa -I../../../../../../../components/esp_gdbstub/esp32s2 -I../../../../../../../components/espcoredump/include -I../../../../../../../components/espcoredump/include/port/xtensa -I../../../../../../../components/wpa_supplicant/include -I../../../../../../../components/wpa_supplicant/port/include -I../../../../../../../components/wpa_supplicant/esp_supplicant/include -I../../../../../../../components/ieee802154/include -I../../../../../../../components/console -I../../../../../../../components/asio/asio/asio/include -I../../../../../../../components/asio/port/include -I../../../../../../../components/cbor/port/include -I../../../../../../../components/unity/include -I../../../../../../../components/unity/unity/src -I../../../../../../../components/cmock/CMock/src -I../../../../../../../components/coap/port/include -I../../../../../../../components/coap/libcoap/include -I../../../../../../../components/nghttp/port/include -I../../../../../../../components/nghttp/nghttp2/lib/includes -I../../../../../../../components/esp-tls -I../../../../../../../components/esp-tls/esp-tls-crypto -I../../../../../../../components/esp_adc_cal/include -I../../../../../../../components/esp_hid/include -I../../../../../../../components/tcp_transport/include -I../../../../../../../components/esp_http_client/include -I../../../../../../../components/esp_http_server/include -I../../../../../../../components/esp_https_ota/include -I../../../../../../../components/esp_lcd/include -I../../../../../../../components/esp_lcd/interface -I../../../../../../../components/protobuf-c/protobuf-c -I../../../../../../../components/protocomm/include/common -I../../../../../../../components/protocomm/include/security -I../../../../../../../components/protocomm/include/transports -I../../../../../../../components/mdns/include -I../../../../../../../components/esp_local_ctrl/include -I../../../../../../../components/sdmmc/include -I../../../../../../../components/esp_serial_slave_link/include -I../../../../../../../components/esp_websocket_client/include -I../../../../../../../components/expat/expat/expat/lib -I../../../../../../../components/expat/port/include -I../../../../../../../components/wear_levelling/include -I../../../../../../../components/fatfs/diskio -I../../../../../../../components/fatfs/vfs -I../../../../../../../components/fatfs/src -I../../../../../../../components/freemodbus/common/include -I../../../../../../../components/idf_test/include -I../../../../../../../components/idf_test/include/esp32s2 -I../../../../../../../components/jsmn/include -I../../../../../../../components/json/cJSON -I../../../../../../../components/libsodium/libsodium/src/libsodium/include -I../../../../../../../components/libsodium/port_include -I../../../../../../../components/mqtt/esp-mqtt/include -I../../../../../../../components/openssl/include -I../../../../../../../components/perfmon/include -I../../../../../../../components/spiffs/include -I../../../../../../../components/usb/include -I../../../../../../../components/touch_element/include -I../../../../../../../components/ulp/include -I../../../../../../../components/wifi_provisioning/include -I../../common/cdc_acm_host/include -mlongcalls -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4/examples/peripherals/usb/host/cdc/cdc_acm_vcp=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4=IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.4\" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/ftdi_usb.cpp.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\ftdi_usb.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/ftdi_usb.cpp.obj -c ../main/ftdi_usb.cpp
../main/ftdi_usb.cpp: In constructor 'esp_usb::FT23x::FT23x(uint16_t, const cdc_acm_host_device_config_t*, uint8_t)':
../main/ftdi_usb.cpp:38:32: error: invalid conversion from 'void (*)(const cdc_acm_host_dev_event_data_t*, void*)' to 'cdc_acm_host_dev_callback_t' {aka 'void (*)(cdc_dev_s*, const cdc_acm_host_dev_event_data_t*, void*)'} [-fpermissive]
         ftdi_config.event_cb = ftdi_event;
                                ^~~~~~~~~~
../main/ftdi_usb.cpp:49:17: error: 'class esp_usb::FT23x' has no member named 'send_custom_request'
     err = this->send_custom_request(FTDI_WRITE_REQ, FTDI_CMD_RESET, 0, this->intf + 1, 0, NULL);
                 ^~~~~~~~~~~~~~~~~~~
In file included from ../main/ftdi_usb.cpp:11:
../main/ftdi_usb.cpp: In member function 'esp_err_t esp_usb::FT23x::line_coding_set(cdc_acm_line_coding_t*)':
../main/ftdi_usb.cpp:73:35: error: 'class esp_usb::FT23x' has no member named 'send_custom_request'
         ESP_RETURN_ON_ERROR(this->send_custom_request(FTDI_WRITE_REQ, FTDI_CMD_SET_BAUDRATE, wValue, wIndex, 0, NULL), "FT23x",);
                                   ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/ftdi_usb.cpp:78:22: error: 'class esp_usb::FT23x' has no member named 'send_custom_request'
         return this->send_custom_request(FTDI_WRITE_REQ, FTDI_CMD_SET_LINE_CTL, wValue, this->intf, 0, NULL);
                      ^~~~~~~~~~~~~~~~~~~
In file included from ../main/ftdi_usb.cpp:11:
../main/ftdi_usb.cpp: In member function 'esp_err_t esp_usb::FT23x::set_control_line_state(bool, bool)':
../main/ftdi_usb.cpp:85:31: error: 'class esp_usb::FT23x' has no member named 'send_custom_request'
     ESP_RETURN_ON_ERROR(this->send_custom_request(FTDI_WRITE_REQ, FTDI_CMD_SET_MHS, dtr ? 0x11 : 0x10, this->intf, 0, NULL), "FT23x",); // DTR
                               ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/ftdi_usb.cpp:86:18: error: 'class esp_usb::FT23x' has no member named 'send_custom_request'
     return this->send_custom_request(FTDI_WRITE_REQ, FTDI_CMD_SET_MHS, rts ? 0x21 : 0x20, this->intf, 0, NULL); // RTS
                  ^~~~~~~~~~~~~~~~~~~
../main/ftdi_usb.cpp: In static member function 'static void esp_usb::FT23x::ftdi_rx(uint8_t*, size_t, void*)':
../main/ftdi_usb.cpp:109:72: error: cannot convert 'cdc_acm_host_dev_event_data_t*' to 'cdc_acm_dev_hdl_t' {aka 'cdc_dev_s*'} in argument passing
             this_ftdi->user_event_cb(&serial_event, this_ftdi->user_arg);
                                                                        ^
../main/ftdi_usb.cpp: In static member function 'static void esp_usb::FT23x::ftdi_event(const cdc_acm_host_dev_event_data_t*, void*)':
../main/ftdi_usb.cpp:123:56: error: cannot convert 'const cdc_acm_host_dev_event_data_t*' to 'cdc_acm_dev_hdl_t' {aka 'cdc_dev_s*'} in argument passing
     this_ftdi->user_event_cb(event, this_ftdi->user_arg);
                                                        ^
[1030/1037] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/cdc_acm_vcp.cpp.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/cdc_acm_vcp.cpp.obj
ccache C:\Espressif\tools\xtensa-esp32s2-elf\esp-2021r2-patch2-8.4.0\xtensa-esp32s2-elf\bin\xtensa-esp32s2-elf-g++.exe -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -Iconfig -I../main -I../../../../../../../components/newlib/platform_include -I../../../../../../../components/freertos/include -I../../../../../../../components/freertos/include/esp_additions/freertos -I../../../../../../../components/freertos/port/xtensa/include -I../../../../../../../components/freertos/include/esp_additions -I../../../../../../../components/esp_hw_support/include -I../../../../../../../components/esp_hw_support/include/soc -I../../../../../../../components/esp_hw_support/include/soc/esp32s2 -I../../../../../../../components/esp_hw_support/port/esp32s2/. -I../../../../../../../components/esp_hw_support/port/esp32s2/private_include -I../../../../../../../components/heap/include -I../../../../../../../components/log/include -I../../../../../../../components/lwip/include/apps -I../../../../../../../components/lwip/include/apps/sntp -I../../../../../../../components/lwip/lwip/src/include -I../../../../../../../components/lwip/port/esp32/include -I../../../../../../../components/lwip/port/esp32/include/arch -I../../../../../../../components/soc/include -I../../../../../../../components/soc/esp32s2/. -I../../../../../../../components/soc/esp32s2/include -I../../../../../../../components/hal/esp32s2/include -I../../../../../../../components/hal/include -I../../../../../../../components/hal/platform_port/include -I../../../../../../../components/esp_rom/include -I../../../../../../../components/esp_rom/include/esp32s2 -I../../../../../../../components/esp_rom/esp32s2 -I../../../../../../../components/esp_common/include -I../../../../../../../components/esp_system/include -I../../../../../../../components/esp_system/port/soc -I../../../../../../../components/esp_system/port/public_compat -I../../../../../../../components/xtensa/include -I../../../../../../../components/xtensa/esp32s2/include -I../../../../../../../components/driver/include -I../../../../../../../components/driver/esp32s2/include -I../../../../../../../components/esp_pm/include -I../../../../../../../components/esp_ringbuf/include -I../../../../../../../components/efuse/include -I../../../../../../../components/efuse/esp32s2/include -I../../../../../../../components/vfs/include -I../../../../../../../components/esp_wifi/include -I../../../../../../../components/esp_event/include -I../../../../../../../components/esp_netif/include -I../../../../../../../components/esp_eth/include -I../../../../../../../components/tcpip_adapter/include -I../../../../../../../components/esp_phy/include -I../../../../../../../components/esp_phy/esp32s2/include -I../../../../../../../components/esp_ipc/include -I../../../../../../../components/app_trace/include -I../../../../../../../components/esp_timer/include -I../../../../../../../components/mbedtls/port/include -I../../../../../../../components/mbedtls/mbedtls/include -I../../../../../../../components/mbedtls/esp_crt_bundle/include -I../../../../../../../components/app_update/include -I../../../../../../../components/spi_flash/include -I../../../../../../../components/bootloader_support/include -I../../../../../../../components/nvs_flash/include -I../../../../../../../components/pthread/include -I../../../../../../../components/esp_gdbstub/include -I../../../../../../../components/esp_gdbstub/xtensa -I../../../../../../../components/esp_gdbstub/esp32s2 -I../../../../../../../components/espcoredump/include -I../../../../../../../components/espcoredump/include/port/xtensa -I../../../../../../../components/wpa_supplicant/include -I../../../../../../../components/wpa_supplicant/port/include -I../../../../../../../components/wpa_supplicant/esp_supplicant/include -I../../../../../../../components/ieee802154/include -I../../../../../../../components/console -I../../../../../../../components/asio/asio/asio/include -I../../../../../../../components/asio/port/include -I../../../../../../../components/cbor/port/include -I../../../../../../../components/unity/include -I../../../../../../../components/unity/unity/src -I../../../../../../../components/cmock/CMock/src -I../../../../../../../components/coap/port/include -I../../../../../../../components/coap/libcoap/include -I../../../../../../../components/nghttp/port/include -I../../../../../../../components/nghttp/nghttp2/lib/includes -I../../../../../../../components/esp-tls -I../../../../../../../components/esp-tls/esp-tls-crypto -I../../../../../../../components/esp_adc_cal/include -I../../../../../../../components/esp_hid/include -I../../../../../../../components/tcp_transport/include -I../../../../../../../components/esp_http_client/include -I../../../../../../../components/esp_http_server/include -I../../../../../../../components/esp_https_ota/include -I../../../../../../../components/esp_lcd/include -I../../../../../../../components/esp_lcd/interface -I../../../../../../../components/protobuf-c/protobuf-c -I../../../../../../../components/protocomm/include/common -I../../../../../../../components/protocomm/include/security -I../../../../../../../components/protocomm/include/transports -I../../../../../../../components/mdns/include -I../../../../../../../components/esp_local_ctrl/include -I../../../../../../../components/sdmmc/include -I../../../../../../../components/esp_serial_slave_link/include -I../../../../../../../components/esp_websocket_client/include -I../../../../../../../components/expat/expat/expat/lib -I../../../../../../../components/expat/port/include -I../../../../../../../components/wear_levelling/include -I../../../../../../../components/fatfs/diskio -I../../../../../../../components/fatfs/vfs -I../../../../../../../components/fatfs/src -I../../../../../../../components/freemodbus/common/include -I../../../../../../../components/idf_test/include -I../../../../../../../components/idf_test/include/esp32s2 -I../../../../../../../components/jsmn/include -I../../../../../../../components/json/cJSON -I../../../../../../../components/libsodium/libsodium/src/libsodium/include -I../../../../../../../components/libsodium/port_include -I../../../../../../../components/mqtt/esp-mqtt/include -I../../../../../../../components/openssl/include -I../../../../../../../components/perfmon/include -I../../../../../../../components/spiffs/include -I../../../../../../../components/usb/include -I../../../../../../../components/touch_element/include -I../../../../../../../components/ulp/include -I../../../../../../../components/wifi_provisioning/include -I../../common/cdc_acm_host/include -mlongcalls -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4/examples/peripherals/usb/host/cdc/cdc_acm_vcp=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4=IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.4\" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/cdc_acm_vcp.cpp.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\cdc_acm_vcp.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/cdc_acm_vcp.cpp.obj -c ../main/cdc_acm_vcp.cpp
../main/cdc_acm_vcp.cpp: In function 'void app_main()':
../main/cdc_acm_vcp.cpp:80:5: error: 'const usb_host_config_t' has no non-static data member named 'skip_phy_setup'
     };
     ^
../main/cdc_acm_vcp.cpp:96:9: error: invalid conversion from 'void (*)(const cdc_acm_host_dev_event_data_t*, void*)' to 'cdc_acm_host_dev_callback_t' {aka 'void (*)(cdc_dev_s*, const cdc_acm_host_dev_event_data_t*, void*)'} [-fpermissive]
         };
         ^
[1031/1037] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/cp210x_usb.cpp.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/cp210x_usb.cpp.obj
ccache C:\Espressif\tools\xtensa-esp32s2-elf\esp-2021r2-patch2-8.4.0\xtensa-esp32s2-elf\bin\xtensa-esp32s2-elf-g++.exe -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -Iconfig -I../main -I../../../../../../../components/newlib/platform_include -I../../../../../../../components/freertos/include -I../../../../../../../components/freertos/include/esp_additions/freertos -I../../../../../../../components/freertos/port/xtensa/include -I../../../../../../../components/freertos/include/esp_additions -I../../../../../../../components/esp_hw_support/include -I../../../../../../../components/esp_hw_support/include/soc -I../../../../../../../components/esp_hw_support/include/soc/esp32s2 -I../../../../../../../components/esp_hw_support/port/esp32s2/. -I../../../../../../../components/esp_hw_support/port/esp32s2/private_include -I../../../../../../../components/heap/include -I../../../../../../../components/log/include -I../../../../../../../components/lwip/include/apps -I../../../../../../../components/lwip/include/apps/sntp -I../../../../../../../components/lwip/lwip/src/include -I../../../../../../../components/lwip/port/esp32/include -I../../../../../../../components/lwip/port/esp32/include/arch -I../../../../../../../components/soc/include -I../../../../../../../components/soc/esp32s2/. -I../../../../../../../components/soc/esp32s2/include -I../../../../../../../components/hal/esp32s2/include -I../../../../../../../components/hal/include -I../../../../../../../components/hal/platform_port/include -I../../../../../../../components/esp_rom/include -I../../../../../../../components/esp_rom/include/esp32s2 -I../../../../../../../components/esp_rom/esp32s2 -I../../../../../../../components/esp_common/include -I../../../../../../../components/esp_system/include -I../../../../../../../components/esp_system/port/soc -I../../../../../../../components/esp_system/port/public_compat -I../../../../../../../components/xtensa/include -I../../../../../../../components/xtensa/esp32s2/include -I../../../../../../../components/driver/include -I../../../../../../../components/driver/esp32s2/include -I../../../../../../../components/esp_pm/include -I../../../../../../../components/esp_ringbuf/include -I../../../../../../../components/efuse/include -I../../../../../../../components/efuse/esp32s2/include -I../../../../../../../components/vfs/include -I../../../../../../../components/esp_wifi/include -I../../../../../../../components/esp_event/include -I../../../../../../../components/esp_netif/include -I../../../../../../../components/esp_eth/include -I../../../../../../../components/tcpip_adapter/include -I../../../../../../../components/esp_phy/include -I../../../../../../../components/esp_phy/esp32s2/include -I../../../../../../../components/esp_ipc/include -I../../../../../../../components/app_trace/include -I../../../../../../../components/esp_timer/include -I../../../../../../../components/mbedtls/port/include -I../../../../../../../components/mbedtls/mbedtls/include -I../../../../../../../components/mbedtls/esp_crt_bundle/include -I../../../../../../../components/app_update/include -I../../../../../../../components/spi_flash/include -I../../../../../../../components/bootloader_support/include -I../../../../../../../components/nvs_flash/include -I../../../../../../../components/pthread/include -I../../../../../../../components/esp_gdbstub/include -I../../../../../../../components/esp_gdbstub/xtensa -I../../../../../../../components/esp_gdbstub/esp32s2 -I../../../../../../../components/espcoredump/include -I../../../../../../../components/espcoredump/include/port/xtensa -I../../../../../../../components/wpa_supplicant/include -I../../../../../../../components/wpa_supplicant/port/include -I../../../../../../../components/wpa_supplicant/esp_supplicant/include -I../../../../../../../components/ieee802154/include -I../../../../../../../components/console -I../../../../../../../components/asio/asio/asio/include -I../../../../../../../components/asio/port/include -I../../../../../../../components/cbor/port/include -I../../../../../../../components/unity/include -I../../../../../../../components/unity/unity/src -I../../../../../../../components/cmock/CMock/src -I../../../../../../../components/coap/port/include -I../../../../../../../components/coap/libcoap/include -I../../../../../../../components/nghttp/port/include -I../../../../../../../components/nghttp/nghttp2/lib/includes -I../../../../../../../components/esp-tls -I../../../../../../../components/esp-tls/esp-tls-crypto -I../../../../../../../components/esp_adc_cal/include -I../../../../../../../components/esp_hid/include -I../../../../../../../components/tcp_transport/include -I../../../../../../../components/esp_http_client/include -I../../../../../../../components/esp_http_server/include -I../../../../../../../components/esp_https_ota/include -I../../../../../../../components/esp_lcd/include -I../../../../../../../components/esp_lcd/interface -I../../../../../../../components/protobuf-c/protobuf-c -I../../../../../../../components/protocomm/include/common -I../../../../../../../components/protocomm/include/security -I../../../../../../../components/protocomm/include/transports -I../../../../../../../components/mdns/include -I../../../../../../../components/esp_local_ctrl/include -I../../../../../../../components/sdmmc/include -I../../../../../../../components/esp_serial_slave_link/include -I../../../../../../../components/esp_websocket_client/include -I../../../../../../../components/expat/expat/expat/lib -I../../../../../../../components/expat/port/include -I../../../../../../../components/wear_levelling/include -I../../../../../../../components/fatfs/diskio -I../../../../../../../components/fatfs/vfs -I../../../../../../../components/fatfs/src -I../../../../../../../components/freemodbus/common/include -I../../../../../../../components/idf_test/include -I../../../../../../../components/idf_test/include/esp32s2 -I../../../../../../../components/jsmn/include -I../../../../../../../components/json/cJSON -I../../../../../../../components/libsodium/libsodium/src/libsodium/include -I../../../../../../../components/libsodium/port_include -I../../../../../../../components/mqtt/esp-mqtt/include -I../../../../../../../components/openssl/include -I../../../../../../../components/perfmon/include -I../../../../../../../components/spiffs/include -I../../../../../../../components/usb/include -I../../../../../../../components/touch_element/include -I../../../../../../../components/ulp/include -I../../../../../../../components/wifi_provisioning/include -I../../common/cdc_acm_host/include -mlongcalls -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4/examples/peripherals/usb/host/cdc/cdc_acm_vcp=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v4.4=IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.4\" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/cp210x_usb.cpp.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\cp210x_usb.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/cp210x_usb.cpp.obj -c ../main/cp210x_usb.cpp
../main/cp210x_usb.cpp: In constructor 'esp_usb::CP210x::CP210x(uint16_t, const cdc_acm_host_device_config_t*, uint8_t)':
../main/cp210x_usb.cpp:34:17: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
     err = this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_IFC_ENABLE, 1, this->intf, 0, NULL);
                 ^~~~~~~~~~~~~~~~~~~
In file included from ../main/cp210x_usb.cpp:10:
../main/cp210x_usb.cpp: In member function 'esp_err_t esp_usb::CP210x::line_coding_get(cdc_acm_line_coding_t*)':
../main/cp210x_usb.cpp:44:31: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
     ESP_RETURN_ON_ERROR(this->send_custom_request(CP210X_READ_REQ, CP210X_CMD_GET_BAUDRATE, 0, this->intf, sizeof(line_coding->dwDTERate), (uint8_t *)&line_coding->dwDTERate), "CP210X",);
                               ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/cp210x_usb.cpp:47:31: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
     ESP_RETURN_ON_ERROR(this->send_custom_request(CP210X_READ_REQ, CP210X_CMD_GET_LINE_CTL, 0, this->intf, 2, temp_data), "CP210X",);
                               ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/cp210x_usb.cpp: In member function 'esp_err_t esp_usb::CP210x::line_coding_set(cdc_acm_line_coding_t*)':
../main/cp210x_usb.cpp:60:35: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
         ESP_RETURN_ON_ERROR(this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_SET_BAUDRATE, 0, this->intf, sizeof(line_coding->dwDTERate), (uint8_t *)&line_coding->dwDTERate), "CP210X",);
                                   ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/cp210x_usb.cpp:65:22: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
         return this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_SET_LINE_CTL, wValue, this->intf, 0, NULL);
                      ^~~~~~~~~~~~~~~~~~~
../main/cp210x_usb.cpp: In member function 'esp_err_t esp_usb::CP210x::set_control_line_state(bool, bool)':
../main/cp210x_usb.cpp:73:18: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
     return this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_SET_MHS, wValue, this->intf, 0, NULL);
                  ^~~~~~~~~~~~~~~~~~~
In file included from ../main/cp210x_usb.cpp:10:
../main/cp210x_usb.cpp: In member function 'esp_err_t esp_usb::CP210x::send_break(uint16_t)':
../main/cp210x_usb.cpp:78:31: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
     ESP_RETURN_ON_ERROR(this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_SET_BREAK, 1, this->intf, 0, NULL), "CP210x",);
                               ^~~~~~~~~~~~~~~~~~~
../../../../../../../components/esp_common/include/esp_check.h:215:30: note: in definition of macro 'ESP_RETURN_ON_ERROR'
         esp_err_t err_rc_ = (x);                                                                \
                              ^
../main/cp210x_usb.cpp:80:18: error: 'class esp_usb::CP210x' has no member named 'send_custom_request'
     return this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_SET_BREAK, 0, this->intf, 0, NULL);
                  ^~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

C:\Espressif\frameworks\esp-idf-v4.4\examples\peripherals\usb\host\cdc\cdc_acm_vcp>
AristarchosOfSamos commented 2 years ago

@tore-espressif Hope you will soon get this commited in the main repo. Thanks again. Aristarchos

tore-espressif commented 2 years ago

@AristarchosOfSamos I'm happy it works for you.

@alexandru98765 It seems that your esp-idf is out-dated. We added support for custom commands only in April (so it isn't included in any official release yet). Please update esp-idf and try again. If you keep having problems, please open another issue, thanks!

sramrajkar commented 2 years ago

@tore-espressif Thank you for this feature addition. It works very well for me.

THEDSP commented 2 years ago

Hello I got the following error Linking .pio\build\esp32-s3-devkitc-1\firmware.elf c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\cdc_acm_vpc.o:(.literal.app_main+0x54): undefined reference to cdc_acm_host_install' c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\cdc_acm_vpc.o:(.literal.app_main+0x60): undefined reference tocdc_acm_host_close'
c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\cdc_acm_vpc.o: in function app_main': C:\Users\Dvimaya\Documents\PlatformIO\Projects\ESP32ch34/src/cdc_acm_vpc.cpp:79: undefined reference tocdc_acm_host_install'
c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\cdc_acm_vpc.o: in function CdcAcmDevice::close()': C:/Users/Dvimaya/.platformio/packages/framework-espidf/components/usb/include/usb/cdc_acm_host.h:298: undefined reference tocdc_acm_host_close' c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\ch34.o:(.literal._ZN7esp_usb5CH34xC2EtPK28cdc_acm_host_device_config_th+0x8): undefined reference to cdc_acm_host_open_vendor_specific' c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\ch34.o:(.literal._ZN7esp_usb5CH34x15line_coding_setEP21cdc_acm_line_coding_t+0x24): undefined reference tocdc_acm_host_send_custom_request' c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\ch34.o: in function CdcAcmDevice::open_vendor_specific(unsigned short, unsigned short, unsigned char, cdc_acm_host_device_config_t const*)': C:/Users/Dvimaya/.platformio/packages/framework-espidf/components/usb/include/usb/cdc_acm_host.h:293: undefined reference tocdc_acm_host_open_vendor_specific' c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\ch34.o: in function CdcAcmDevice::close()': C:/Users/Dvimaya/.platformio/packages/framework-espidf/components/usb/include/usb/cdc_acm_host.h:298: undefined reference tocdc_acm_host_close' c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio\build\esp32-s3-devkitc-1\src\ch34.o: in function CdcAcmDevice::send_custom_request(unsigned char, unsigned char, unsigned short, unsigned short, unsigned short, unsigned char*)': C:/Users/Dvimaya/.platformio/packages/framework-espidf/components/usb/include/usb/cdc_acm_host.h:327: undefined reference tocdc_acm_host_send_custom_request' c:/users/dvimaya/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:/Users/Dvimaya/.platformio/packages/framework-espidf/components/usb/include/usb/cdc_acm_host.h:327: undefined reference to `cdc_acm_host_send_custom_request' collect2.exe: error: ld returned 1 exit status *** [.pio\build\esp32-s3-devkitc-1\firmware.elf] Error 1

THEDSP commented 2 years ago

@tore-espressif Thank you for this feature addition. It works very well for me.

can you help me to successful compilations ?

sramrajkar commented 2 years ago

Hey, Did you include the patched component in your build system? What IDF version are you using?

On Tue, Aug 30, 2022 at 7:58 AM THEDSP @.***> wrote:

@tore-espressif https://github.com/tore-espressif Thank you for this feature addition. It works very well for me.

can you help me to successful compilations ?

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/8951#issuecomment-1231567082, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANH7FFJ6I7SQTABVZMBIV3DV3XZQFANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.***>

THEDSP commented 2 years ago

Hey, Did you include the patched component in your build system? What IDF version are you using? On Tue, Aug 30, 2022 at 7:58 AM THEDSP @.> wrote: @tore-espressif https://github.com/tore-espressif Thank you for this feature addition. It works very well for me. can you help me to successful compilations ? — Reply to this email directly, view it on GitHub <#8951 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANH7FFJ6I7SQTABVZMBIV3DV3XZQFANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.>

i used 4.4 master in main branch of idf

sramrajkar commented 2 years ago

Where did you put the CDC code? And did you modify make files? Also I am building this with 5.x dev branch of idf.

On Thu, Sep 1, 2022, 1:33 AM THEDSP @.***> wrote:

Hey, Did you include the patched component in your build system? What IDF version are you using? … <#m-138107727130066277> On Tue, Aug 30, 2022 at 7:58 AM THEDSP @.> wrote: @tore-espressif https://github.com/tore-espressif https://github.com/tore-espressif https://github.com/tore-espressif Thank you for this feature addition. It works very well for me. can you help me to successful compilations ? — Reply to this email directly, view it on GitHub <#8951 (comment) https://github.com/espressif/esp-idf/issues/8951#issuecomment-1231567082>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANH7FFJ6I7SQTABVZMBIV3DV3XZQFANCNFSM5V5UHA2A https://github.com/notifications/unsubscribe-auth/ANH7FFJ6I7SQTABVZMBIV3DV3XZQFANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.>

i used 4.4 master in main branch of idf

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/8951#issuecomment-1233761569, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANH7FFN7HZCPEVHZHWRXGOTV4A53BANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.***>

tore-espressif commented 2 years ago

@sramrajkar thank you for following this up.

The discussion continues in https://github.com/espressif/esp-idf/issues/9652

This is not about CH340 for UART, but for I2C, which has different PID and requires different driver

THEDSP commented 2 years ago

i found linux driver for ch341 for epp i2c mode so how can we port them in to the esp. https://github.com/zoobab/ch341-parport/tree/master/CH341PAR_LINUX where to start any hint ?

sramrajkar commented 2 years ago

I am just guessing at this point. If you know what custom commands are needed for I2C to work, then this patch from expressif shows how to send those commands over the USB interface. You may have to replicated that for the I2C commands yourself after enumeration is successful.

On Thu, Sep 1, 2022 at 9:46 AM THEDSP @.***> wrote:

i found linux driver for ch341 for epp i2c mode so how can we port them in to the esp. https://github.com/zoobab/ch341-parport/tree/master/CH341PAR_LINUX where to start any hint ?

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/8951#issuecomment-1234305004, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANH7FFIRF4QSJMSAUJEC5P3V4CXTJANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.***>

THEDSP commented 2 years ago

Which patch

THEDSP commented 2 years ago

I am just guessing at this point. If you know what custom commands are needed for I2C to work, then this patch from expressif shows how to send those commands over the USB interface. You may have to replicated that for the I2C commands yourself after enumeration is successful. On Thu, Sep 1, 2022 at 9:46 AM THEDSP @.> wrote: i found linux driver for ch341 for epp i2c mode so how can we port them in to the esp. https://github.com/zoobab/ch341-parport/tree/master/CH341PAR_LINUX where to start any hint ? — Reply to this email directly, view it on GitHub <#8951 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANH7FFIRF4QSJMSAUJEC5P3V4CXTJANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.>

hello @sramrajkar which patch do you talking about would you tell me the bare mettle api for usb communication i am confused ?

tore-espressif commented 2 years ago

To everyone seeing this in the future: Please open new issues for new problems, if no other issue describes the problem you see, rather than replying here, we've locked this not because we don't care about issues but because we do care about them, and tracking a number of discussions in a long thread makes it hard for us to address them all.

THEDSP commented 2 years ago

sorry sir @tore-espressif hello @sramrajkar we can continued our diction in #9652

a1exwang commented 1 year ago

Hello @sramrajkar @AristarchosOfSamos

I uploaded an early version of CH340 driver into my esp-idf fork, feel free to have a look: https://github.com/tore-espressif/esp-idf/tree/feature/usb_host/cdc_ch340/examples/peripherals/usb/host/cdc/cdc_acm_vcp

It covers only the basics: RX/TX, setting of baudrate, linecoding and DTR/RTS control.

Note: Please note that there are two commits in the linked branch:

  1. CDC-ACM driver bug fix tore-espressif@438234a
  2. CH340 driver tore-espressif@93e9c72

Please let me know whether this solution works for you

Works on my side with CH340. Looking to changing this to a serial port over Wifi solution.

sramrajkar commented 1 year ago

@tore-espressif Would this driver work for all the 4 channels of CH344 with RS485 support?

ChanSeongKim commented 1 year ago

Hello @sramrajkar @AristarchosOfSamos

I uploaded an early version of CH340 driver into my esp-idf fork, feel free to have a look: https://github.com/tore-espressif/esp-idf/tree/feature/usb_host/cdc_ch340/examples/peripherals/usb/host/cdc/cdc_acm_vcp

It covers only the basics: RX/TX, setting of baudrate, linecoding and DTR/RTS control.

Note: Please note that there are two commits in the linked branch:

1. CDC-ACM driver bug fix [tore-espressif@438234a](https://github.com/tore-espressif/esp-idf/commit/438234ad702fcd8ddc9781dcb2782f15a014d235)

2. CH340 driver [tore-espressif@93e9c72](https://github.com/tore-espressif/esp-idf/commit/93e9c72534975243e0b7b4e09a1e5e818ba3a3e7)

Please let me know whether this solution works for you

I am trying to make PL2303 driver for host mode for making legacy device connectable through wireless using ESP32S3. This legacy device has PL2303 IC for USB port.

(Legacy Device[voltage Logger] built-in PL2303HX for USB port)--->(ESP32S3 using USB Host mode)......(WiFi connect for SmartPhone)......>(SmartPhone)

Can you guide how to make driver PL2303 ?
I started from cp210 driver. But datasheet of pl2303 is not enough to code. So I am stuck in how to modify this function.

Following is part of my code.
//pl2303_usb.hpp

define PL230X_CMD_SET_LINE_CTL (0x03) // Set the line control

...

define PL230X_CMD_SET_BAUDRATE (0x1E) // Set the baud rate

// my working on for PL2303.cpp , modifed from other driver source.
esp_err_t PL230x::line_coding_set(cdc_acm_line_coding_t *line_coding) { assert(line_coding);

if (line_coding->dwDTERate != 0) {
    ESP_RETURN_ON_ERROR(this->send_custom_request(PL230X_WRITE_REQ, PL230X_CMD_SET_BAUDRATE, 0, this->intf, sizeof(line_coding->dwDTERate), (uint8_t *)&line_coding->dwDTERate), "PL230X",);
}

if (line_coding->bDataBits != 0) {
    const uint16_t wValue = line_coding->bCharFormat | (line_coding->bParityType << 4) | (line_coding->bDataBits << 8);
    return this->send_custom_request(PL230X_WRITE_REQ, PL230X_CMD_SET_LINE_CTL, wValue, this->intf, 0, NULL);
}
return ESP_OK;

}

// reference code of cp210x_usb.cpp esp_err_t CP210x::line_coding_set(cdc_acm_line_coding_t *line_coding) { assert(line_coding);

if (line_coding->dwDTERate != 0) {
    ESP_RETURN_ON_ERROR(this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_SET_BAUDRATE, 0, this->intf, sizeof(line_coding->dwDTERate), (uint8_t *)&line_coding->dwDTERate), "CP210X",);
}

if (line_coding->bDataBits != 0) {
    const uint16_t wValue = line_coding->bCharFormat | (line_coding->bParityType << 4) | (line_coding->bDataBits << 8);
    return this->send_custom_request(CP210X_WRITE_REQ, CP210X_CMD_SET_LINE_CTL, wValue, this->intf, 0, NULL);
}
return ESP_OK;

}

Thank you in advance.

tore-espressif commented 1 year ago

Hello @ChanSeongKim , the vendor claims that PL-2303 is CDC compatible, so you can try your luck with the base CDC-ACM driver.

If it does not work, you willhave to reverse engineer from linux driver https://github.com/torvalds/linux/blob/master/drivers/usb/serial/pl2303.c

ChanSeongKim commented 1 year ago

Thank you for your email. I will check your information.

Since I didn't succeed with PL2303 until now, So I am trying with ch340 USB IC. I succeeded in connection with ch34x_usb.cpp which is for Arduino Nano(built with CH340 USB IC). Following is the connection message with ch34x. (Hello:0 is the message sent from arduino nano with 57600bps.)

I (307) VCP example: Enabling USB_HOST interface through USB_SEL---

I (307) VCP example: Example configure_usb_sel ==== !

I (317) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0

I (1327) VCP example: Installing USB Host

I (1357) VCP example: Installing CDC-ACM driver

I (1357) VCP example: Opening CH340 device

I (1757) VCP example: Setting up line coding

I (1757) VCP example: baudrate:57600(d)

rx=>Hello: 0

rx=>Hello: 1

rx=>Hello: 2

rx=>Hello: 3

Thank you for your interest.

2023년 5월 12일 (금) 오후 5:43, Tomas Rezucha @.***>님이 작성:

Hello @ChanSeongKim https://github.com/ChanSeongKim , the vendor claims that PL-2303 is CDC compatible, so you can try your luck with the base CDC-ACM driver https://components.espressif.com/components/espressif/usb_host_cdc_acm.

If it does not work, you willhave to reverse engineer from linux driver https://components.espressif.com/components/espressif/usb_host_cdc_acm

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/8951#issuecomment-1545392881, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4F4JQPAHMQNMRJCGFBO7DXFXZ2RANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.***>

ChanSeongKim commented 1 year ago

Thank you for your email. I will check your information. Since I didn't succeed with PL2303 until now, So I am trying with ch340 USB IC. I succeeded in connection with ch34x_usb.cpp which is for Arduino Nano(built with CH340 USB IC). Following is the connection message with ch34x. (Hello:0 is the message sent from arduino nano with 57600bps.) I (307) VCP example: Enabling USB_HOST interface through USB_SEL--- I (307) VCP example: Example configure_usb_sel ==== ! I (317) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (1327) VCP example: Installing USB Host I (1357) VCP example: Installing CDC-ACM driver I (1357) VCP example: Opening CH340 device I (1757) VCP example: Setting up line coding I (1757) VCP example: baudrate:57600(d) rx=>Hello: 0 rx=>Hello: 1 rx=>Hello: 2 rx=>Hello: 3 Thank you for your interest. 2023년 5월 12일 (금) 오후 5:43, Tomas Rezucha @.>님이 작성: Hello @ChanSeongKim https://github.com/ChanSeongKim , the vendor claims that PL-2303 is CDC compatible, so you can try your luck with the base CDC-ACM driver https://components.espressif.com/components/espressif/usb_host_cdc_acm. If it does not work, you willhave to reverse engineer from linux driver https://components.espressif.com/components/espressif/usb_host_cdc_acm — Reply to this email directly, view it on GitHub <#8951 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4F4JQPAHMQNMRJCGFBO7DXFXZ2RANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.>

I managed to test PL2303HX USB ic driver under ESP32 usb host mode. Although handle_rx() should be revised again. I could see data send and receiving log.

Following is the log output:

(269) spi_flash: flash io: dio W (273) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (287) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (307) VCP example: Enabling USB_HOST interface through USB_SEL--- I (307) VCP example: Example configure_usb_sel ==== ! I (317) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (1327) VCP example: Installing USB Host I (1357) VCP example: Installing CDC-ACM driver I (1357) VCP example: starting next loop=======, 0 I (1357) VCP example: Opening PL2303 device I (1757) VCP example: PL230x::open_pl230x: 1070179776 I (1757) VCP example: Setting up line coding I (1757) VCP example: Opening device baudrate: 57600 I (1757) PL230x: line_coding->dwDTERate: 57600, line_coding->bDataBits: 8, sizeof(*line_coding)=7 0x2 0x30 0x30 0x30 0x39 0x52 0x38 0x34 0x3 I (1777) VCP example: Sending sample data to PL2303HX(DigitalRecorder): len=9

0009R84003Cr:2030.3678.3289:23.05.17-18.37.01:000.0v:000.0v:000.0v:32I (2777) VCP example: vTaskDelay() finished. portTICK_PERIOD_MS=10

tore-espressif commented 1 year ago

looks good! is your code publicly available? would you be interested in creating an ESP-IDF component for PL2303?

ChanSeongKim commented 1 year ago

I think it will be avaliable soon. I think it would be ready nextweek. Because it is now some spaghetti code. I need time to arrange it. Let me know if you can introduce process of creating ESP-IDF component for PL2303HX.

tore-espressif commented 1 year ago

An esp-idf component should follow our standard conventions such as containing CMakeLists.txt and README.md (more details in our Build System docs.

For the PL2303 component, it would be good to follow the design that is outlined in similar components such as CH34x or CP210x. If you wanted to contribute the PL2303 component to our esp-idf registry (such as here), you 'd have to add also an idf_compnent.yaml file, described in Component Manager docs

Please, let me know, if you needed any help

sxs777 commented 1 year ago

Hi,

I've tried running cdc_acm_vcp example to communicate between esp32s3 usb host and CH340, however I could not build the code. I ve run 2 commands to add dependencies: 1- idf.py add-dependency "espressif/usb_host_cdc_acm^2.0.0" 2 - idf.py add-dependency "espressif/usb_host_ch34x_vcp^2.0.0"

When building the code I get the following errors. In file included from C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/main/usb_cdc_acm_vcp.c:10: C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/include/usb/vcp_ch34x.hpp:10:10: fatal error: array: No such file or directory 10 | #include | ^~~ compilation terminated. [3/10] ccache C:\Espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin\xtensa-esp32s3-elf-g++.exe -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/build/config -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/newlib/platform_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include/freertos -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/private_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/heap/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/log/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/platform_port/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_common/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/include/private -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps/sntp -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/lwip/src/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include/arch -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_cdc_acm/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/usb/include -mlongcalls -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v5.0.1=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -Wno-format-nonliteral -Wno-format-security -Wformat=0 -std=gnu++20 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v5.0.1-dirty\" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/espressif__usb_host_ch34x_vcp/CMakeFiles/idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -MF esp-idf\espressifusb_host_ch34x_vcp\CMakeFiles__idf_espressifusb_host_ch34x_vcp.dir\usb_host_ch34x_vcp.cpp.obj.d -o esp-idf/espressifusb_host_ch34x_vcp/CMakeFiles/idf_espressif__usb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -c C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp FAILED: esp-idf/espressifusb_host_ch34x_vcp/CMakeFiles/__idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj ccache C:\Espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin\xtensa-esp32s3-elf-g++.exe -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/build/config -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/newlib/platform_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include/freertos -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/private_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/heap/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/log/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/platform_port/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_common/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/include/private -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps/sntp -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/lwip/src/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include/arch -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_cdc_acm/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/usb/include -mlongcalls -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v5.0.1=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -Wno-format-nonliteral -Wno-format-security -Wformat=0 -std=gnu++20 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v5.0.1-dirty\" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/espressifusb_host_ch34x_vcp/CMakeFiles/__idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -MF esp-idf\espressifusb_host_ch34x_vcp\CMakeFiles__idf_espressifusb_host_ch34x_vcp.dir\usb_host_ch34x_vcp.cpp.obj.d -o esp-idf/espressifusb_host_ch34x_vcp/CMakeFiles/__idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -c C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressif__usb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp:17:2: error: #error This component requires C++ exceptions 17 | #error This component requires C++ exceptions | ^~~~~ C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp: In constructor 'esp_usb::CH34x::CH34x(uint16_t, const cdc_acm_host_device_config_t*, uint8_t)': C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressif__usb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp:73:19: error: exception handling disabled, use '-fexceptions' to enable 73 | throw (err); | ^ ninja: build stopped: subcommand failed.

My understanding is that array.h is missing but how to add it? Also not sure about how solve C++ exception related errors. It says use -fexceptions to enable them but where?

ChanSeongKim commented 1 year ago

Hi~ Please have a look at this following site.

https://github.com/tore-espressif/esp-idf/tree/feature/usb_host/cdc_ch340/examples/peripherals/usb/host/cdc/cdc_acm_vcp/main

2023년 7월 14일 (금) 오전 2:48, sxs777 @.***>님이 작성:

Hi,

I've tried running cdc_acm_vcp example to communicate between esp32s3 usb host and CH340, however I could not build the code. I ve run 2 commands to add dependencies: 1- idf.py add-dependency "espressif/usb_host_cdc_acm^2.0.0" 2 - idf.py add-dependency "espressif/usb_host_ch34x_vcp^2.0.0"

When building the code I get the following errors. In file included from C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/main/usb_cdc_acm_vcp.c:10: C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/include/usb/vcp_ch34x.hpp:10:10: fatal error: array: No such file or directory 10 | #include | ^~~ compilation terminated. [3/10] ccache C:\Espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin\xtensa-esp32s3-elf-g++.exe -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/build/config -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/newlib/platform_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include/freertos -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/private_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/heap/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/log/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/platform_port/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_common/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/include/private -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps/sntp -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/lwip/src/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include/arch -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_cdc_acm/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/usb/include -mlongcalls -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v5.0.1=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -Wno-format-nonliteral -Wno-format-security -Wformat=0 -std=gnu++20 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER="v5.0.1-dirty" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/espressif__usb_host_ch34x_vcp/CMakeFiles/idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -MF esp-idf\espressifusb_host_ch34x_vcp\CMakeFilesidf_espressifusb_host_ch34x_vcp.dir\usb_host_ch34x_vcp.cpp.obj.d -o esp-idf/espressifusb_host_ch34x_vcp/CMakeFiles/idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -c C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp FAILED: esp-idf/espressifusb_host_ch34x_vcp/CMakeFiles/idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj ccache C:\Espressif\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin\xtensa-esp32s3-elf-g++.exe -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/build/config -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/newlib/platform_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include/freertos -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/esp_additions/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/include/soc/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_hw_support/port/esp32s3/private_include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/heap/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/log/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/. -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/soc/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/hal/platform_port/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/include/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_rom/esp32s3 -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_common/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/soc -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/include/private -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/xtensa/esp32s3/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/include/apps/sntp -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/lwip/src/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/lwip/port/esp32/include/arch -IC:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_cdc_acm/include -IC:/Espressif/frameworks/esp-idf-v5.0.1/components/usb/include -mlongcalls -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx=. -fmacro-prefix-map=C:/Espressif/frameworks/esp-idf-v5.0.1=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -Wno-format-nonliteral -Wno-format-security -Wformat=0 -std=gnu++20 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER="v5.0.1-dirty" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -MD -MT esp-idf/espressif__usb_host_ch34x_vcp/CMakeFiles/idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -MF esp-idf\espressifusb_host_ch34x_vcp\CMakeFilesidf_espressifusb_host_ch34x_vcp.dir\usb_host_ch34x_vcp.cpp.obj.d -o esp-idf/espressifusb_host_ch34x_vcp/CMakeFiles/idf_espressifusb_host_ch34x_vcp.dir/usb_host_ch34x_vcp.cpp.obj -c C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressif__usb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressifusb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp:17:2: error: #error This component requires C++ exceptions 17 | #error This component requires C++ exceptions | ^~~~~ C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressif__usb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp: In constructor 'esp_usb::CH34x::CH34x(uint16_t, const cdc_acm_host_device_config_t*, uint8_t)': C:/Users/serge/OneDrive/Desktop/Firmware_Projects/ESP32_Projects/blinx/managed_components/espressif__usb_host_ch34x_vcp/usb_host_ch34x_vcp.cpp:73:19: error: exception handling disabled, use '-fexceptions' to enable 73 | throw (err); | ^ ninja: build stopped: subcommand failed.

My understanding is that array.h is missing but how to add it? Also not sure about how solve C++ exception related errors. It says use -fexceptions to enable them but where?

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/8951#issuecomment-1634655230, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4F4JXAVVBYOYVFHSRC62TXQAYFDANCNFSM5V5UHA2A . You are receiving this because you were mentioned.Message ID: @.***>

sxs777 commented 1 year ago

Thank you very much for the provided link

tore-espressif commented 1 year ago
  1. This code requires C++ exceptions. You can enable them in menuconfig-> compiler settings
  2. This code requires c++14, which should be enabled in IDF v5.0.1

Can you enable the exceptions and try again?

Berserker2229 commented 7 months ago

![Uploading 17075051569343209727204131013946.jpg…]()