-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Implement machine.USBDevice for ESP32-S3 #15564
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
Comments
For this to be possible we need to stop using the Espressif provided USB support and instead use the USB support code in micropython. I've submitted such a change here, but it's a large change that will need more testing: #15108 Once that's complete then testing builds with the dynamic usb device support should be possible. |
I'd also like to see this supported! I realised that we might be able to do it another way, but locking the GIL for each of the USB callbacks. But that's also a lot of work, and I like the approach in your PR better. |
@andrewleech I noticed that your commits were merged last week, and so took the opportunity to compile a couple of micropython images for the Arduino Nano ESP32 and a Waveshare Pico S2. I've only tested the use of basic USB CDC instantiation (using the Fantastic job and thank you very much for you efforts here! |
That's really interesting to hear @TomFahey did you just enable the runtime build config?
|
Pretty much - I also had to add list(APPEND MICROPY_SOURCE_TINYUSB
${TINYUSB_SRC}/tusb.c
${TINYUSB_SRC}/common/tusb_fifo.c
${TINYUSB_SRC}/device/usbd.c
${TINYUSB_SRC}/device/usbd_control.c
${TINYUSB_SRC}/class/cdc/cdc_device.c
${TINYUSB_SRC}/portable/synopsys/dwc2/dcd_dwc2.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_cdc.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c
) in the esp32_common.cmake file to get it to compile and also added #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
mp_usbd_deinit();
#endif to the EDIT: The compiled firmware works without the change to main.c, but I gather the |
Hi @TomFahey 👋 Would you mind sharing your build? I'd love to test HID support on the Arduino Nano ESP32. |
Sure, here's the .uf2 image, as well as the separate bootloader.bin, partition-table.bin and micropython.bin binaries. Just FYI, for the flash_args.txt file, for some reason it sets the 1.56MB micropython binary's memory address to 0xf70000 (16,187,392), which obviously doesn't leave enough space to write it in the 16MB flash memory - no clue why? I simply changed the offset to 0x10000 (app0), however, which allowed me to successfully flash the microcontroller and get the micropython interpreter up and running; I thought I'd leave the flash_args.txt file as is, however, just in case there's a good reason for those memory address offsets. |
I flashed the binaries using |
If I interpret @dpgeorge's comment here correctly, the next step would be to create a PR that enables the runtime support by default. @TomFahey 's approach works fine for me, so maybe we can proceed with this? Or is there anything else needed from your point of view @andrewleech? |
Yep you're right, a PR with those changes is the next step! |
Sounds good 👌 @TomFahey wanna do the honours given that you pretty much already have the changes locally? 🙏 |
Description
The ESP32-S3 chip has excellent USB support built-in. Please implement machine.USBDevice for ESP32-S3.
Code Size
No response
Implementation
I hope the MicroPython maintainers or community will implement this feature
Code of Conduct
Yes, I agree
The text was updated successfully, but these errors were encountered: