Skip to content

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

Closed

Description

@trejan

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.

Activity

  1. JamesH65 commented on Mar 18, 2022

    @JamesH65
    Contributor

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

  2. kilograham commented on May 4, 2022

    @kilograham
    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.

  3. trejan commented on May 4, 2022

    @trejan
    Author

    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?

  4. tjko commented on May 5, 2022

    @tjko
    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?)

  5. kilograham commented on May 12, 2022

    @kilograham
    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.

  6. lurch commented on May 18, 2022

    @lurch
    Contributor
  7. trejan commented on May 18, 2022

    @trejan
    Author

    Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions