Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.5k
esp32/boards: Configure S2/S3 PSRAM boards to use USB in IRQ mode.#18332
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Commitespressif/esp-usb@1b18558in the `espressif__esp_tinyusb` managed component switched USB to use DMAby default. But DMA cannot read from PSRAM. So force USB to use IRQ modewhen building with PSRAM enabled.Fixes issuemicropython/micropython-lib#1044.Signed-off-by: Damien George <damien@micropython.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for picking this up,@dpgeorge!
I'm not sure if it counts as a regression either (probably does), but good it has an easy fix.
An odd side effect of this PR, if you disable the UART REPL then |
Summary
With MicroPython 1.26.0 and 1.26.1 on ESP32-S3 with PSRAM,
machine.USBDeviceis broken. Eg making a custom keyboard, keypresses sent to the host arrive as a packet of all zeros.The root cause is commitespressif/esp-usb@1b18558 in the
espressif__esp_tinyusbmanaged component, which switched USB to use DMA by default. But DMA cannot read from PSRAM. So HID (and other USB) packets that live in PSRAM end up as all zeros when sent to the host.To fix that, force USB to use IRQ mode when building with PSRAM enabled.
Fixes issuemicropython/micropython-lib#1044.
Testing
Tested with ESP32_GENERIC_S3 firmware, on a UM TinyS3, and the following code:
Without the fix in this PR, that code doesn't send any keys. With the fix, it does.
Trade-offs and Alternatives
I'm not sure if this is technically a bug/regression in the IDF, because they did provide an easy option to disable DMA. So this seems the best way to workaround the issue for us.
Alternatively we could allocate a temporary buffer in internal SRAM, and copy the PSRAM buffer into that before passing it to the DMA engine. But it's hard to know when the DMA has finished with the buffer so it can be reused for the next transfer.