Skip to content

ESP32S3 - HID USBHID SendReport error and USB Replug #6922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
RichardsATcn opened this issue Jun 28, 2022 · 8 comments
Closed
1 task done

ESP32S3 - HID USBHID SendReport error and USB Replug #6922

RichardsATcn opened this issue Jun 28, 2022 · 8 comments
Assignees
Labels
Chip: ESP32-S3 Issue is related to support of ESP32-S3 Chip Resolution: Awaiting response Waiting for response of author Status: Needs investigation We need to do some research before taking next steps on this issue

Comments

@RichardsATcn
Copy link

RichardsATcn commented Jun 28, 2022

Board

ESP32-S3-WROOM-1 Moudle

Device Description

ESP32-S3-WROOM-1

Hardware Configuration

image
only use USB ;

Version

v2.0.3

IDE Name

Arduino 1.8.19

Operating System

Windows 10

Flash frequency

QIO 80

PSRAM enabled

no

Upload speed

115200

Description

ESP32-S3-USB.zip

src.zip

USB device will appear error after using for a while.

If the CDC serial port is enabled, it will be easier to send at fixed time.

Devices will be re enumerated repeatedly

The error code segment is as follows

` bool res = ready();
if (!res)
{
log_e("not ready");
}
else
{
res = tud_hid_n_report(0, id, data, len);
if (!res)
{
log_e("report %u failed", id);
}
else
{
xSemaphoreTake(tinyusb_hid_device_input_sem, 0);
if (xSemaphoreTake(tinyusb_hid_device_input_sem, timeout_ms / portTICK_PERIOD_MS) != pdTRUE)
{
log_e("report %u wait failed", id);
res = false;
}
}
}
xSemaphoreGive(tinyusb_hid_device_input_mutex);

//Added code snippet
if (tinyusb_hid_device_input_sem)
{
xSemaphoreGive(tinyusb_hid_device_input_sem);
}
log_d("report %u wait over %s", id, res == true ? "true" : "false");
//Added code snippet

return res;`

usb设备使用一会儿会出现错误。
如果cdc串口开启定时发送时候会更容易出现。
设备会反复的 重新枚举

Sketch

//Added code snippet
    if (tinyusb_hid_device_input_sem)
    {
        xSemaphoreGive(tinyusb_hid_device_input_sem);
    }
    log_d("report %u wait over %s", id, res == true ? "true" : "false");
//Added code snippet

Debug Message

17:27:54.138 -> [ 34283][E][USBHID.cpp:410] SendReport(): report 3 wait failed
17:27:54.138 -> [ 34284][D][USBHID.cpp:420] SendReport(): report 3 wait over false
17:27:54.234 -> USB PLUGGED
17:27:54.330 -> [ 34475][E][USBHID.cpp:410] SendReport(): report 3 wait failed

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@RichardsATcn RichardsATcn added the Status: Awaiting triage Issue is waiting for triage label Jun 28, 2022
@VojtechBartoska VojtechBartoska added the Status: Needs investigation We need to do some research before taking next steps on this issue label Jul 13, 2022
@VojtechBartoska VojtechBartoska added this to the 2.0.5 milestone Jul 13, 2022
@VojtechBartoska
Copy link
Contributor

This will be triage by @SuGlider, in next 2 weeks we will specify next steps.

@SuGlider
Copy link
Collaborator

SuGlider commented Aug 10, 2022

@RichardsATcn - It seems that the code you posted is some modified version of "official" USBHID.cpp - Not sure how to help you. Please confirm.

Can you try the sketch using Arduino Core 2.0.4?
Could you please post a Arduino Sketch that reproduces the issue, using only official Arduino Core?

Thanks.

@SuGlider SuGlider added Resolution: Awaiting response Waiting for response of author and removed Status: Needs investigation We need to do some research before taking next steps on this issue labels Aug 10, 2022
@SuGlider SuGlider moved this from Todo to Under investigation in Arduino ESP32 Core Project Roadmap Aug 10, 2022
@SuGlider SuGlider moved this from Under investigation to In Progress in Arduino ESP32 Core Project Roadmap Aug 12, 2022
@SuGlider SuGlider added Chip: ESP32-S3 Issue is related to support of ESP32-S3 Chip and removed Status: Awaiting triage Issue is waiting for triage labels Aug 12, 2022
@VojtechBartoska
Copy link
Contributor

@RichardsATcn any updates?

@VojtechBartoska VojtechBartoska removed this from the 2.0.5 milestone Aug 24, 2022
@VojtechBartoska VojtechBartoska moved this from In Progress to Under investigation in Arduino ESP32 Core Project Roadmap Aug 24, 2022
@VojtechBartoska VojtechBartoska added the Status: Needs investigation We need to do some research before taking next steps on this issue label Sep 21, 2022
@VojtechBartoska VojtechBartoska added this to the 2.0.6 milestone Sep 21, 2022
@VojtechBartoska VojtechBartoska removed this from the 2.0.6 milestone Nov 30, 2022
@RichardsATcn
Copy link
Author

I will try with sdk 2.0.6,thank you。

@hoantv
Copy link

hoantv commented Apr 8, 2023

same issue with esps3 wroom 1U. Use lastest version 2.0.7
Just use gamepad example, PC doesnt recognize gamepad after sendReport command

[ 7621][E][USBHID.cpp�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:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbe4
load:0x403cc700,len:0x2a38
entry 0x403c98d4
[ 93][D][esp32-hal-tinyusb.c:675] tinyusb_enable_interface(): Interface CDC enabled
[ 94][D][esp32-hal-tinyusb.c:675] tinyusb_enable_interface(): Interface MSC enabled
[ 98][D][esp32-hal-tinyusb.c:675] tinyusb_enable_interface(): Interface HID enabled
[ 105][D][USBHID.cpp:61] tinyusb_enable_hid_device(): Device[0] len: 68
[ 160][D][FirmwareMSC.cpp:94] msc_update_get_required_disk_sectors(): APP size: 336928 (659 sectors)
[ 160][D][FirmwareMSC.cpp:100] msc_update_get_required_disk_sectors(): OTA size: 1310720 (2560 sectors)
[ 167][D][FirmwareMSC.cpp:113] msc_update_get_required_disk_sectors(): USING FAT12
[ 174][D][FirmwareMSC.cpp:116] msc_update_get_required_disk_sectors(): FAT sector size: 512
[ 183][D][FirmwareMSC.cpp:117] msc_update_get_required_disk_sectors(): FAT data sectors: 3235
[ 191][D][FirmwareMSC.cpp:118] msc_update_get_required_disk_sectors(): FAT table sectors: 10
[ 199][D][FirmwareMSC.cpp:119] msc_update_get_required_disk_sectors(): FAT total sectors: 3247 (1623KB)
[ 209][D][esp32-hal-tinyusb.c:564] tinyusb_load_enabled_interfaces(): Load Done: if_num: 4, descr_len: 130, if_mask: 0x15
[ 220][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 3 = 160 Mhz, APB: 80000000 Hz
[ 236][E][USBHID.cpp:346] SendReport(): not ready
[ 236][E][USBHID.cpp:346] SendReport(): not ready
[ 237][E][USBHID.cpp:346] SendReport(): not ready
[ 242][E][USBHID.cpp:346] SendReport(): not ready
[ 246][E][USBHID.cpp:346] SendReport(): not ready
[ 251][E][USBHID.cpp:346] SendReport(): not ready
[ 256][E][USBHID.cpp:346] SendReport(): not ready
[ 260][E][USBHID.cpp:346] SendReport(): not ready
[ 265][E][USBHID.cpp:346] SendReport(): not ready

@SuGlider
Copy link
Collaborator

SuGlider commented Apr 10, 2023

@hoantv - I have tested it with Win11. The problem is that Win doesn't know what is BUTTON_START.

I tested it with an ESP32-S3 and when pressing the BOOT button on the board, the Joystick moves to the right bottom corner and returns back to the center.

This is the code that I have tested:

#if ARDUINO_USB_MODE
#warning This sketch should be used when USB is in OTG mode
void setup() {}
void loop() {}
#else
#include "USB.h"
#include "USBHIDGamepad.h"
USBHIDGamepad Gamepad;

const int buttonPin = 0;
int previousButtonState = HIGH;

void setup() {
  Serial.begin(115200);
  pinMode(buttonPin, INPUT_PULLUP);
  Gamepad.begin();
  USB.begin();
}

void loop() {
  int buttonState = digitalRead(buttonPin);
  if ((buttonState != previousButtonState) && (buttonState == LOW)) {
    Gamepad.leftStick(100, 100);
    delay(500);
    Gamepad.leftStick(0, 0);
    Serial.println("Button Pressed - gamePad should have sent event.");
  }
  previousButtonState = buttonState;
}
#endif /* ARDUINO_USB_MODE */

@SuGlider
Copy link
Collaborator

@RichardsATcn - I used Arduino Core 2.0.7 and it works fine also when USB is unplugged and plugged back.

This issue is solved.

@SuGlider
Copy link
Collaborator

SuGlider commented Apr 10, 2023

@hoantv - Check PR #8058

One problem I had with the "TinyUSB HID Properties" Window was that it had to be Active/Selected (by clicking it), otherwise no gamepad information was displayed. The example of the PR #8058 works perfectly fine with Win10/11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chip: ESP32-S3 Issue is related to support of ESP32-S3 Chip Resolution: Awaiting response Waiting for response of author Status: Needs investigation We need to do some research before taking next steps on this issue
Projects
Development

No branches or pull requests

4 participants