Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
dpgeorge wants to merge1 commit intomicropython:master
base:master
Choose a base branch
Loading
fromdpgeorge:esp32-change-usb-to-non-dma

Conversation

@dpgeorge
Copy link
Member

Summary

With MicroPython 1.26.0 and 1.26.1 on ESP32-S3 with PSRAM,machine.USBDevice is 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 theespressif__esp_tinyusb managed 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:

importtimeimportusb.devicefromusb.device.keyboardimportKeyboardInterface,KeyCodekb=KeyboardInterface()usb.device.get().init(kb,builtin_driver=True)whilenotkb.is_open():time.sleep(0.1)for_inrange(10):print("send key")kb.send_keys([KeyCode.M])time.sleep(0.15)kb.send_keys([])time.sleep(2)

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.

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>
Copy link
Contributor

@projectgusprojectgus left a 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.

@projectgus
Copy link
Contributor

An odd side effect of this PR, if you disable the UART REPL thentest_serial.py in the OUT direction is as much as 50% faster with this change. No idea how to explain that...

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@projectgusprojectgusprojectgus approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@dpgeorge@projectgus

[8]ページ先頭

©2009-2025 Movatter.jp