Skip to content
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

RP2040-E5 fix needs tinyusb_additions added to CMakeLists.txt #759

Closed
trejan opened this issue Mar 17, 2022 · 7 comments
Closed

RP2040-E5 fix needs tinyusb_additions added to CMakeLists.txt #759

trejan opened this issue Mar 17, 2022 · 7 comments

Comments

@trejan
Copy link

trejan commented Mar 17, 2022

The RP2040-E5 fix needs TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX to be set for tinyusb to call rp2040_usb_device_enumeration_fix() during the IRQ handler. TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX is defined by PICO_RP2040_USB_DEVICE_ENUMERATION_FIX and that is set in the RP2040 family cmake file as part of the tinyusb_additions library. The docs/examples don't have tinyusb_additions in the target_link_libraries list or use family_configure_* which adds tinyusb_additions so pico_fix/rp2040_usb_device_enumeration is compiled as part of the SDK but never used by tinyusb.

There is a thread on the Pi forum where the RP2040-E5 issue has was causing problems. Explicitly setting TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX was found to workaround the issue so pointed at the fix not being used.

Proposed fix would be to add tinyusb_additions to target_link_libraries as family_configure_* does other things. If there is a cleaner way of setting that flag then that would also work.

@JamesH65
Copy link
Contributor

@kilograham @liamfraser FYI in case you hadn't already seen it.

@kilograham
Copy link
Contributor

I'm not 100% sure where you are asking for this to be added? What "docs/examples" are you referring to.

Note that the fix is not the default, as it takes control of GPIO 15, and 16 briefly, so you have to know you are allowed to do that.

@trejan
Copy link
Author

trejan commented May 4, 2022

The datasheet shows the E5 errata and points to https://github.com/raspberrypi/pico-sdk/tree/master/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c as the workaround. It doesn't say that you need to specifically enable it or how to enable it. Nothing in https://github.com/raspberrypi/pico-examples mentions it either.

What is the approved method for enabling the E5 workaround? Do you add the tinyusb_additions library or manually set the define? If you set a define, which one do you set?

@tjko
Copy link
Contributor

tjko commented May 5, 2022

I had missed the part that this uses GPIO 15/16. Brief explanation what happens and when would be helpful.

I ran into this "enumeration" issue recently and adding following into CMakeLists.txt seemed to work fine (on a RP2040-B1):

target_compile_definitions(targetname PRIVATE PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)

I'm using GPIO 15 for PWM input and GPIO 16 for PWM output, so presumably I might see short interruption on PWM output, etc? But presumably this would happen only when USB cable is plugged in (or could this happen if there is USB "bus reset" etc?)

@kilograham
Copy link
Contributor

I had missed the part that this uses GPIO 15/16. Brief explanation what happens and when would be helpful.

I ran into this "enumeration" issue recently and adding following into CMakeLists.txt seemed to work fine (on a RP2040-B1):

target_compile_definitions(targetname PRIVATE PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)

I'm using GPIO 15 for PWM input and GPIO 16 for PWM output, so presumably I might see short interruption on PWM output, etc? But presumably this would happen only when USB cable is plugged in (or could this happen if there is USB "bus reset" etc?)

Correct; just adding PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1 is all you need to do; I have added info to the errate for the imminent SDK1.3.1. release

actually only GPIO 15 is affected.

it happens on any bus reset.

@lurch
Copy link
Contributor

lurch commented May 18, 2022

See also raspberrypi/pico-examples#210

@trejan
Copy link
Author

trejan commented May 18, 2022

Thanks!

@trejan trejan closed this as completed May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants