STM32 Virtual COM Port USB-OTG driver

Bumanuu
Posts: 4
Joined: Tue Sep 05, 2023 8:12 am

STM32 Virtual COM Port USB-OTG driver

Postby Bumanuu » Tue Sep 05, 2023 8:56 am

Hello, all!
Any help to implement USB host driver for ESP32-S3 of that device:

Linux detects it as
  1. [ 4676.083396] usb 1-3.4: new full-speed USB device number 6 using xhci_hcd
  2. [ 4676.217745] usb 1-3.4: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
  3. [ 4676.217757] usb 1-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  4. [ 4676.217762] usb 1-3.4: Product: STM32 Virtual COM Port
  5. [ 4676.217766] usb 1-3.4: Manufacturer: STMicroelectronics
  6. [ 4676.217769] usb 1-3.4: SerialNumber: 56FF766A3231
  7. [ 4676.262120] cdc_acm 1-3.4:1.0: ttyACM0: USB ACM device
  8. [ 4676.262197] usbcore: registered new interface driver cdc_acm
  9. [ 4676.262201] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
I have tried to connect to it with modified
esp-idf/examples/peripherals/usb/host/cdc/cdc_acm_host/main/usb_cdc_example_main.c
code, but with no luck:
  1. I (1369) USB-CDC: Opening CDC ACM device 0x0483:0x5740...
  2. E (2369) cdc_acm: cdc_acm_host_open(757): USB device with VID: 0x0483, PID: 0x5740 not found
  3. I (2369) USB-CDC: Failed to open device
Any suggestions would be appreciated!

Bumanuu
Posts: 4
Joined: Tue Sep 05, 2023 8:12 am

Re: STM32 Virtual COM Port USB-OTG driver

Postby Bumanuu » Thu Sep 07, 2023 8:07 am

Actually, I need VCP driver for STM32 Virtual COM Port, like those:
esp-idf/examples/peripherals/usb/host/cdc/cdc_acm_vcp/managed_components/espressif__usb_host_ftdi_vcp
esp-idf/examples/peripherals/usb/host/cdc/cdc_acm_vcp/managed_components/espressif__usb_host_cp210x_vcp
esp-idf/examples/peripherals/usb/host/cdc/cdc_acm_vcp/managed_components/espressif__usb_host_ch34x_vcp


In attachment is capture of PC <-> STM32 VCP exchange (plug, open serial port, some data exchange, close, unplug).
Attachments
STM32-VCP.pcapng.zip
Wireshark capture of PC <-> STM32 VCP exchange
(5.04 KiB) Downloaded 202 times

Bumanuu
Posts: 4
Joined: Tue Sep 05, 2023 8:12 am

Re: STM32 Virtual COM Port USB-OTG driver

Postby Bumanuu » Fri Sep 08, 2023 8:18 am

monitor log:

Code: Select all

bumanuu@bumanuux:/media/2TB/DATA/DEV/cdc_acm_vcp$ export IDF_PATH=/home/bumanuu/DEV/GIT/esp-idf
/home/bumanuu/.espressif/python_env/idf5.2_py3.10_enbumanuu@bumanuux:/media/2TB/DATA/DEV/cdc_acm_vcp$ /home/bumanuu/.espressif/python_env/idf5.2_py3.10_env/bin/python /home/bumanuu/DEV/GIT/esp-idf/tools/idf_monitor.py -p /dev/ttyACM0 -b 115200 --toolchain-prefix xtensa-esp32s3-elf- --target esp32s3 /media/2TB/DATA/DEV/cdc_acm_vcp/build/cdc_acm_vcp.elf
--- idf_monitor on /dev/ttyACM0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3820,len:0x1718
load:0x403c9700,len:0x4
load:0x403c9704,len:0xc08
load:0x403cc700,len:0x2f20
entry 0x403c990c
I (27) boot: ESP-IDF v5.2-dev-1890-g28167ea5a3-dirty 2nd stage bootloader
I (27) boot: compile time Sep  7 2023 15:15:46
I (28) boot: Multicore bootloader
I (32) boot: chip revision: v0.1
I (36) boot.esp32s3: Boot SPI Speed : 80MHz
I (41) boot.esp32s3: SPI Mode       : DIO
I (45) boot.esp32s3: SPI Flash Size : 2MB
I (50) boot: Enabling RNG early entropy source...
I (56) boot: Partition Table:
I (59) boot: ## Label            Usage          Type ST Offset   Length
I (66) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (74) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (81) boot:  2 factory          factory app      00 00 00010000 00100000
I (89) boot: End of partition table
I (93) esp_image: segment 0: paddr=00010020 vaddr=3c040020 size=15bbch ( 89020) map
I (117) esp_image: segment 1: paddr=00025be4 vaddr=3fc93500 size=029e8h ( 10728) load
I (120) esp_image: segment 2: paddr=000285d4 vaddr=40374000 size=07a44h ( 31300) load
I (130) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=33ce4h (212196) map
I (170) esp_image: segment 4: paddr=00063d0c vaddr=4037ba44 size=079e4h ( 31204) load
I (183) boot: Loaded app from partition at offset 0x10000
I (183) boot: Disabling RNG early entropy source...
I (195) cpu_start: Multicore app
I (195) cpu_start: Pro cpu up.
I (195) cpu_start: Starting app cpu, entry point is 0x403752b0
0x403752b0: call_start_cpu1 at /media/2TB/DATA/DEV/GIT/esp-idf/components/esp_system/port/cpu_start.c:170

I (0) cpu_start: App cpu up.
I (213) cpu_start: Pro cpu start user code
I (214) cpu_start: cpu freq: 160000000 Hz
I (214) cpu_start: Application information:
I (217) cpu_start: Project name:     cdc_acm_vcp
I (222) cpu_start: App version:      1
I (226) cpu_start: Compile time:     Sep  8 2023 10:45:32
I (232) cpu_start: ELF file SHA256:  c9c6d100a...
I (238) cpu_start: ESP-IDF:          v5.2-dev-1890-g28167ea5a3-dirty
I (245) cpu_start: Min chip rev:     v0.0
I (249) cpu_start: Max chip rev:     v0.99 
I (254) cpu_start: Chip rev:         v0.1
I (259) heap_init: Initializing. RAM available for dynamic allocation:
I (266) heap_init: At 3FC96950 len 00052DC0 (331 KiB): DRAM
I (272) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
I (279) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (285) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
I (292) spi_flash: detected chip: gd
I (296) spi_flash: flash io: dio
W (300) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (314) gpio: GPIO[48]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (323) gpio: GPIO[44]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (332) gpio: GPIO[6]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (341) sleep: Configure to isolate all GPIO pins in sleep state
I (348) sleep: Enable automatic switching of GPIO sleep configuration
I (355) app_start: Starting scheduler on CPU0
I (360) app_start: Starting scheduler on CPU1
I (360) main_task: Started on CPU0
I (370) main_task: Calling app_main()
I (370) VCP example: Installing USB Host
I (410) VCP example: Installing CDC-ACM driver
I (410) VCP example: Opening any VCP device...
I (5660) VCP example: Failed to open VCP device
I (5660) VCP example: Opening any VCP device...
I (10910) VCP example: Failed to open VCP device
I (10910) VCP example: Opening any VCP device...
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x4200c274  PS      : 0x00060d30  A0      : 0x8200c836  A1      : 0x3fc9a730  
0x4200c274: cdc_acm_transfers_allocate at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_cdc_acm/cdc_acm_host.c:625

A2      : 0x3fc9e650  A3      : 0x3fc9eae8  A4      : 0x00000000  A5      : 0x00000200  
A6      : 0x00000000  A7      : 0x00000200  A8      : 0x4200bf04  A9      : 0x3fc9a710  
0x4200bf04: in_xfer_cb at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_cdc_acm/cdc_acm_host.c:1009

A10     : 0x00000000  A11     : 0x00000000  A12     : 0x3fc9e65c  A13     : 0x3fc9ea1c  
A14     : 0xb33fffff  A15     : 0xb33fffff  SAR     : 0x0000001b  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000002  LBEG    : 0x400570e8  LEND    : 0x400570f3  LCOUNT  : 0x00000000  
0x400570e8: memset in ROM

0x400570f3: memset in ROM



Backtrace: 0x4200c271:0x3fc9a730 0x4200c833:0x3fc9a790 0x42009a6e:0x3fc9a7e0 0x4200a575:0x3fc9a800 0x4200a5a1:0x3fc9a820 0x4200bae6:0x3fc9a840 0x4200ab5f:0x3fc9a8b0 0x42032dd3:0x3fc9a910 0x4037d23d:0x3fc9a940
0x4200c271: cdc_acm_transfers_allocate at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_cdc_acm/cdc_acm_host.c:624

0x4200c833: cdc_acm_host_open_vendor_specific at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_cdc_acm/cdc_acm_host.c:859 (discriminator 6)

0x42009a6e: CdcAcmDevice::open_vendor_specific(unsigned short, unsigned short, unsigned char, cdc_acm_host_device_config_t const*) at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_cdc_acm/include/usb/cdc_acm_host.h:317
 (inlined by) esp_usb::STM32::STM32(unsigned short, cdc_acm_host_device_config_t const*, unsigned char) at /media/2TB/DATA/DEV/cdc_acm_vcp/main/stm32_vcp.hpp:140

0x4200a575: esp_usb::VCP::register_driver<esp_usb::STM32>()::{lambda(unsigned short, cdc_acm_host_device_config_t const*, unsigned char)#1}::operator()(unsigned short, cdc_acm_host_device_config_t const*, unsigned char) const at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_vcp/include/usb/vcp.hpp:52

0x4200a5a1: esp_usb::VCP::register_driver<esp_usb::STM32>()::{lambda(unsigned short, cdc_acm_host_device_config_t const*, unsigned char)#1}::_FUN(unsigned short, cdc_acm_host_device_config_t const*, unsigned char) at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_vcp/include/usb/vcp.hpp:51

0x4200bae6: esp_usb::VCP::open(cdc_acm_host_device_config_t const*, unsigned char) at /media/2TB/DATA/DEV/cdc_acm_vcp/managed_components/espressif__usb_host_vcp/usb_host_vcp.cpp:72

0x4200ab5f: app_main at /media/2TB/DATA/DEV/cdc_acm_vcp/main/cdc_acm_vcp_example_main.cpp:227

0x42032dd3: main_task at /media/2TB/DATA/DEV/GIT/esp-idf/components/freertos/app_startup.c:217 (discriminator 13)

0x4037d23d: vPortTaskWrapper at /media/2TB/DATA/DEV/GIT/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162





ELF file SHA256: c9c6d100a

Rebooting...
esp-idf/examples/peripherals/usb/host/usb_host_lib with CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE=768 reports following about plugged device:

Code: Select all

*** Device descriptor ***
bLength 18
bDescriptorType 1
bcdUSB 2.00                        --!!!!!
bDeviceClass 0x2
bDeviceSubClass 0x0
bDeviceProtocol 0x0
bMaxPacketSize0 64                 --!!!!!
idVendor 0x483
idProduct 0x5740
bcdDevice 2.00
iManufacturer 1
iProduct 2
iSerialNumber 3
bNumConfigurations 1
I (6208) CLASS: Getting config descriptor
*** Configuration descriptor ***
bLength 9
bDescriptorType 2
wTotalLength 67
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
bMaxPower 100mA
        *** Interface descriptor ***
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 0
        bAlternateSetting 0
        bNumEndpoints 1
        bInterfaceClass 0x2
        bInterfaceSubClass 0x2
        bInterfaceProtocol 0x1
        iInterface 0
                *** Endpoint descriptor ***
                bLength 7
                bDescriptorType 5
                bEndpointAddress 0x82   EP 2 IN
                bmAttributes 0x3        INT
                wMaxPacketSize 8
                bInterval 255
        *** Interface descriptor ***
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 1
        bAlternateSetting 0
        bNumEndpoints 2
        bInterfaceClass 0xa
        bInterfaceSubClass 0x0
        bInterfaceProtocol 0x0
        iInterface 0
                *** Endpoint descriptor ***
                bLength 7
                bDescriptorType 5
                bEndpointAddress 0x3    EP 3 OUT
                bmAttributes 0x2        BULK
                wMaxPacketSize 64
                bInterval 0
                *** Endpoint descriptor ***
                bLength 7
                bDescriptorType 5
                bEndpointAddress 0x81   EP 1 IN
                bmAttributes 0x2        BULK
                wMaxPacketSize 64
                bInterval 0
I (6308) CLASS: Getting Manufacturer string descriptor
STMicroelectronics
I (6318) CLASS: Getting Product string descriptor
STM32 Virtual COM Port  
I (6328) CLASS: Getting Serial Number string descriptor
56FF766A3231

Bumanuu
Posts: 4
Joined: Tue Sep 05, 2023 8:12 am

Re: STM32 Virtual COM Port USB-OTG driver

Postby Bumanuu » Mon Oct 16, 2023 9:50 am


Who is online

Users browsing this forum: Bing [Bot] and 78 guests