You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
higher level micropython-lib usb-device drivers, which make use of machine.USBDevice) however so far everything has worked flawlessly.
Fantastic job and thank you very much for you efforts here!
to the soft_reset_exit block in main.c, however I don't know if the latter change is necessary (I was basically just trying to mirror the main.c file in the rp2 port).
EDIT: The compiled firmware works without the change to main.c, but I gather the mp_usb_deinit() call is intended for deinitialising the dynamic usb drivers when performing a soft reset, so it is probably worth including, seeing as the RP2 port follows this behaviour.
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 esptool.py write_flash --flash_mode dio --flash_freq 80m --flash_size 16MB 0x0 bootloader.bin 0x10000 micropython.bin 0x8000 partition-table.bin 0xe000 ota_data_initial.bin
and then ran the HID keyboard example from the usb-device-keyboard library.
Works beautifully ✨ Thanks everyone who contributed to enable USB device support on the S3 ❤️
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!
I'd suggest adding the define next to the existing USB ones in mpconfigport.h surrounded by a #ifndef like many others in that file so boards can override it if needed.
I'd suggest adding the define next to the existing USB ones in mpconfigport.h surrounded by a #ifndef like many others in that file so boards can override it if needed.
Sounds good 👌 @TomFahey wanna do the honours given that you pretty much already have the changes locally? 🙏
Activity
andrewleech commentedon Jul 29, 2024
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.
projectgus commentedon Jul 30, 2024
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.
TomFahey commentedon Oct 14, 2024
@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
higher level micropython-lib usb-device drivers, which make use of machine.USBDevice) however so far everything has worked flawlessly.
Fantastic job and thank you very much for you efforts here!
andrewleech commentedon Oct 15, 2024
That's really interesting to hear @TomFahey did you just enable the runtime build config?
TomFahey commentedon Oct 15, 2024
Pretty much - I also had to add
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.ctoin the esp32_common.cmake file to get it to compile and also added
to the
soft_reset_exitblock in main.c, however I don't know if the latter change is necessary (I was basically just trying to mirror the main.c file in the rp2 port).EDIT: The compiled firmware works without the change to main.c, but I gather the
mp_usb_deinit()call is intended for deinitialising the dynamic usb drivers when performing a soft reset, so it is probably worth including, seeing as the RP2 port follows this behaviour.sebromero commentedon Oct 16, 2024
Hi @TomFahey 👋 Would you mind sharing your build? I'd love to test HID support on the Arduino Nano ESP32.
TomFahey commentedon Oct 16, 2024
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.
Arduino Nano ESP32.zip
sebromero commentedon Oct 17, 2024
I flashed the binaries using
esptool.py write_flash --flash_mode dio --flash_freq 80m --flash_size 16MB 0x0 bootloader.bin 0x10000 micropython.bin 0x8000 partition-table.bin 0xe000 ota_data_initial.binand then ran the HID keyboard example from the
usb-device-keyboardlibrary.Works beautifully ✨ Thanks everyone who contributed to enable USB device support on the S3 ❤️
sebromero commentedon Oct 18, 2024
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?
andrewleech commentedon Oct 19, 2024
Yep you're right, a PR with those changes is the next step!
I'd suggest adding the define next to the existing USB ones in mpconfigport.h surrounded by a #ifndef like many others in that file so boards can override it if needed.
sebromero commentedon Oct 19, 2024
Sounds good 👌 @TomFahey wanna do the honours given that you pretty much already have the changes locally? 🙏
Vincent1-python commentedon Jul 29, 2025
But now this driver is too old for ESP32P4 driver, and the code needs to be updated.
projectgus commentedon Jul 30, 2025
Closing as support was added in MicroPython v1.25 (as of #16356).
MicroPython doesn't yet support ESP32-P4, so this is a question for the PR that adds ESP32-P4 support rather than a question for this issue.