ESP32-S3 USB Host CDC Generic

antunesls
Posts: 3
Joined: Fri Aug 09, 2024 10:00 pm

ESP32-S3 USB Host CDC Generic

Postby antunesls » Fri Aug 09, 2024 10:01 pm

Hi,

I have tried all available examples in ESP-IDF related to USB communication, including both the Host CDC and Host USB libraries, but I am unable to establish communication with my UPS device.

I can successfully communicate with other devices using known drivers like CP210x, but I am struggling with my Ragtech Easy Pro 1200 UPS, which uses a generic driver.

Here is the output of the dmesg | tail command from Linux with my UPS connected:

[ 7855.208112] usb 1-1.3: new full-speed USB device number 3 using xhci_hcd
[ 7855.320032] usb 1-1.3: New USB device found, idVendor=04d8, idProduct=000a, bcdDevice= 1.00
[ 7855.320049] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7855.320055] usb 1-1.3: Product: USB Serial Port
[ 7855.320059] usb 1-1.3: Manufacturer: Ragtech Sistemas de Energia
[ 7855.419658] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device
[ 7855.419897] usbcore: registered new interface driver cdc_acm
[ 7855.419902] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Despite this, I am unable to establish serial communication with the UPS from the ESP32-S3.

I have been attempting to resolve this issue for a month without success. I have also tried using MicroPython and TinyUSB with no results.

Any assistance or guidance on how to resolve this issue would be greatly appreciated.

Thank you.

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 USB Host CDC Generic

Postby ESP_Sprite » Fri Aug 09, 2024 11:55 pm

Given that it's unlikely that someone else here has this exact UPS, it's probably useful if you post what you tried and how it failed.

antunesls
Posts: 3
Joined: Fri Aug 09, 2024 10:00 pm

Re: ESP32-S3 USB Host CDC Generic

Postby antunesls » Sat Aug 10, 2024 2:36 am

Ok,

I'm trying to open a serial communication via USB with this device (CDC-RS233), but I could not not make its works with the host library examples.

https://github.com/espressif/esp-idf/tr ... c_acm_host

I understand that my device should expose the output like the example, but the is no communication. When I use an device with the driver CP210X I can communicate normally.

So I guess that could be some related about the driver, but I have no idea to go further.

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 USB Host CDC Generic

Postby ESP_Sprite » Sat Aug 10, 2024 2:53 pm

Did you change EXAMPLE_USB_DEVICE_[P|V]ID to the one of your UPS? Generally, can you post the output the program generates?

antunesls
Posts: 3
Joined: Fri Aug 09, 2024 10:00 pm

Re: ESP32-S3 USB Host CDC Generic

Postby antunesls » Sat Aug 10, 2024 6:57 pm

For some reason the device take a few seconds more than others to connect, I just have to wait :? .

Now its connecting but shows up a buffer error.


My buffer is set to 4096 in the code and in the menuconfig.


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:0x3fce2810,len:0x178c
load:0x403c8700,len:0x4
load:0x403c8704,len:0xcb8
load:0x403cb700,len:0x2db0
entry 0x403c8914
I (27) boot: ESP-IDF v5.3 2nd stage bootloader
I (27) boot: compile time Aug 10 2024 12:23:54
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (57) boot: ## Label Usage Type ST Offset Length
I (64) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (71) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (79) boot: 2 factory factory app 00 00 00010000 00100000
I (86) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c030020 size=0c954h ( 51540) map
I (108) esp_image: segment 1: paddr=0001c97c vaddr=3fc92b00 size=02904h ( 10500) load
I (111) esp_image: segment 2: paddr=0001f288 vaddr=40374000 size=00d90h ( 3472) load
I (117) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=21c44h (138308) map
I (149) esp_image: segment 4: paddr=00041c6c vaddr=40374d90 size=0dca8h ( 56488) load
I (168) boot: Loaded app from partition at offset 0x10000
I (168) boot: Disabling RNG early entropy source...
I (180) cpu_start: Multicore app
I (189) cpu_start: Pro cpu start user code
I (189) cpu_start: cpu freq: 160000000 Hz
I (189) app_init: Application information:
I (192) app_init: Project name: cdc-host-example
I (198) app_init: App version: 1
I (202) app_init: Compile time: Aug 10 2024 14:04:58
I (208) app_init: ELF file SHA256: 4454c768a...
I (213) app_init: ESP-IDF: v5.3
I (218) efuse_init: Min chip rev: v0.0
I (223) efuse_init: Max chip rev: v0.99
I (228) efuse_init: Chip rev: v0.2
I (232) heap_init: Initializing. RAM available for dynamic allocation:
I (240) heap_init: At 3FC95C78 len 00053A98 (334 KiB): RAM
I (246) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (252) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (258) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM
I (265) spi_flash: detected chip: winbond
I (269) spi_flash: flash io: dio
W (273) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (286) sleep: Configure to isolate all GPIO pins in sleep state
I (293) sleep: Enable automatic switching of GPIO sleep configuration
I (300) main_task: Started on CPU0
I (310) main_task: Calling app_main()
I (310) USB-CDC: Instalando USB Host
I (340) USB-CDC: Instalando driver CDC-ACM
I (340) USB-CDC: Abrindo dispositivo CDC ACM 0x04D8:0x000A...
E (440) cdc_acm: cdc_acm_host_open(731): USB device with VID: 0x04D8, PID: 0x000A not found
I (440) USB-CDC: Falha ao abrir dispositivo
I (440) USB-CDC: Abrindo dispositivo CDC ACM 0x04D8:0x000A...
E (540) cdc_acm: cdc_acm_host_open(731): USB device with VID: 0x04D8, PID: 0x000A not found
I (540) USB-CDC: Falha ao abrir dispositivo
I (540) USB-CDC: Abrindo dispositivo CDC ACM 0x04D8:0x000A...
E (640) cdc_acm: cdc_acm_host_open(731): USB device with VID: 0x04D8, PID: 0x000A not found
I (640) USB-CDC: Falha ao abrir dispositivo
I (640) USB-CDC: Abrindo dispositivo CDC ACM 0x04D8:0x000A...
E (740) cdc_acm: cdc_acm_host_open(731): USB device with VID: 0x04D8, PID: 0x000A not found
I (740) USB-CDC: Falha ao abrir dispositivo
I (740) USB-CDC: Abrindo dispositivo CDC ACM 0x04D8:0x000A...
E (750) USBH: usb_transfer_t num_bytes > data_buffer_size
E (750) cdc_acm: cdc_acm_host_send_custom_request(1257): CTRL transfer failed
E (760) cdc_acm: cdc_acm_host_line_coding_set(1196):
ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x4200752a
0x4200752a: app_main at C:/Users/lukss/cdc-host-example/main/usb_cdc_example_main.c:218 (discriminator 1)

file: "./main/usb_cdc_example_main.c" line 218
func: app_main
expression: cdc_acm_host_line_coding_set(cdc_dev, &line_coding)

abort() was called at PC 0x40379bd7 on core 0
0x40379bd7: _esp_error_check_failed at C:/Users/lukss/esp/v5.3/esp-idf/components/esp_system/esp_err.c:49



Backtrace: 0x40375abe:0x3fc98010 0x40379be1:0x3fc98030 0x4038092d:0x3fc98050 0x40379bd7:0x3fc980c0 0x4200752a:0x3fc980f0 0x420213bb:0x3fc98150 0x4037a571:0x3fc98180
0x40375abe: panic_abort at C:/Users/lukss/esp/v5.3/esp-idf/components/esp_system/panic.c:463
0x40379be1: esp_system_abort at C:/Users/lukss/esp/v5.3/esp-idf/components/esp_system/port/esp_system_chip.c:92
0x4038092d: abort at C:/Users/lukss/esp/v5.3/esp-idf/components/newlib/abort.c:38
0x40379bd7: _esp_error_check_failed at C:/Users/lukss/esp/v5.3/esp-idf/components/esp_system/esp_err.c:49
0x4200752a: app_main at C:/Users/lukss/cdc-host-example/main/usb_cdc_example_main.c:218 (discriminator 1)
0x420213bb: main_task at C:/Users/lukss/esp/v5.3/esp-idf/components/freertos/app_startup.c:208
0x4037a571: vPortTaskWrapper at C:/Users/lukss/esp/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134





ELF file SHA256: 4454c768a
Attachments
usb_cdc_example_main.c
(8.82 KiB) Downloaded 42 times

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 USB Host CDC Generic

Postby ESP_Sprite » Sun Aug 11, 2024 1:37 pm

No clue. You could try to leave out the cdc_acm_host_line_coding_[get|set] calls; if the device indeed is native CDC-ACM, they should not be needed.

Who is online

Users browsing this forum: ShinyGlossy and 226 guests