USB HID Implementation for ESP32S3 has problems !
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Domain
- embedded-iot
Research direction
Start with the usb.device examples on an ESP32S3 board and compare the host-visible HID report with the logs from usb_device_submit_xfer and dcd_edpt_xfer. Trace where the nonzero keyboard buffer changes after those entry points, using the provided debug output to narrow the transfer path. Done means keypress reports arrive at the host with their expected bytes instead of eight zero bytes.
Written by the indexing model from the issue text.
Description
I tried to run the different usb.device examples on different ESP32S3 board all with the same results.
Since version 1.26.1 and also in version 1.27.x receiving the LED information from the host works fine.
Sending keypress information to the host is working (as I confirmed with wireshark) but the report "arrives"
at the host always with only 8 bytes of "0" ! Regardless what has been send by the python code.
I recompiled the micropython image and added debug information in:
static mp_obj_t usb_device_submit_xfer(mp_obj_t self, mp_obj_t ep, mp_obj_t buffer) {
mp_obj_usb_device_t *usbd = (mp_obj_usb_device_t *)MP_OBJ_TO_PTR(self);
int ep_addr;
mp_buffer_info_t buf_info = { 0 };
bool result;
usb_device_check_active(usbd);
// Unmarshal arguments, raises TypeError if invalid
ep_addr = mp_obj_get_int(ep);
mp_get_buffer_raise(buffer, &buf_info, ep_addr & TUSB_DIR_IN_MASK ? MP_BUFFER_READ : MP_BUFFER_RW);
uint8_t ep_num = tu_edpt_number(ep_addr);
uint8_t ep_dir = tu_edpt_dir(ep_addr);
if (ep_num == 0 || ep_num >= CFG_TUD_ENDPPOINT_MAX) {
// TinyUSB usbd API doesn't range check arguments, so this check avoids
// out of bounds array access, or submitting transfers on the control endpoint.
//
// This C layer doesn't otherwise keep track of which endpoints the host
// is aware of (or not).
mp_raise_ValueError(MP_ERROR_TEXT("ep"));
}
if (!usbd_edpt_claim(USBD_RHPORT, ep_addr)) {
mp_raise_OSError(MP_EBUSY);
}
size_t len = buf_info.len;
const byte *data = buf_info.buf;
mp_printf(&mp_plat_print, "----Debug: (len=%d): ", len);
for (size_t i = 0; i < len; i++) {
mp_printf(&mp_plat_print, "%02x ", data[i]);
}
mp_printf(&mp_plat_print, "\n");
And also in :
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
uint8_t const epnum = tu_edpt_number(ep_addr);
uint8_t const dir = tu_edpt_dir(ep_addr);
if (ep_addr == 0x83) {
esp_rom_printf("DCD: xfer ep=%02X len=%u : ", ep_addr, (unsigned)total_bytes);
// Print a limited number of bytes to stay ISR-friendly
const uint8_t *data = (const uint8_t *)buffer;
uint16_t limit = total_bytes;
if (limit > 32) limit = 32; // cap output (optional)
for (uint16_t i = 0; i < limit; i++) {
esp_rom_printf("%02X ", data[i]);
}
if (limit < total_bytes) esp_rom_printf("... ");
esp_rom_printf("\n");
}
DCD_ENTER_CRITICAL();
```and both logs shows that the keyboard buffer bytes are fine until these log-points.
But nonetheless at the host side only "zeros" are arriving .
Can anyone using a ESP32S3 create a working USB HID keyboard from the sample code provided ?
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from micropython/micropython-lib
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficulty 1/5 Under an hour Newbie friendliness 72/100
micropython/micropython-lib#943 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
micropython/micropython-lib#931 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
micropython/micropython-lib#795 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#762 ·
All issues in micropython/micropython-lib
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Openarea: ci bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-connect#1057 ·