Skip to content

scorpio: spurious USB resets when running demo code #7515

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

Closed
jepler opened this issue Jan 30, 2023 · 3 comments · Fixed by #7558
Closed

scorpio: spurious USB resets when running demo code #7515

jepler opened this issue Jan 30, 2023 · 3 comments · Fixed by #7558
Labels
bug rp2040 Raspberry Pi RP2040 usb
Milestone

Comments

@jepler
Copy link

jepler commented Jan 30, 2023

CircuitPython version

Adafruit CircuitPython 8.0.0-beta.6 on 2022-12-21; Adafruit Feather RP2040 Scorpio with rp2040

Code/REPL

# grab the code sample from https://learn.adafruit.com/introducing-feather-rp2040-scorpio/using-adafruit_neopxl8

Behavior

Sometimes the USB device will disconnect and reconnect.

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
157.9fps
154.2fps
159.0fps
156.6fps

[tio 16:28:51] Disconnected
[tio 16:28:52] Connected
[tio 16:28:53] Disconnected
[tio 16:28:54] Connected
156.7fps
156.4fps
158.7fps
154.6fps
156.3fps
156.6fps

Description

Compared to most boards / exampes, this is using two less used features: StateMachine.background_write and bitops.bit_transpose.

Additional information

This or something like it has been seen by me, @jedgarpark and @djecken as discussed on slack. I'm on a prerelease board while they have store revisions.

@jepler jepler added the bug label Jan 30, 2023
@tannewt tannewt added usb rp2040 Raspberry Pi RP2040 labels Jan 31, 2023
@tannewt tannewt added this to the 8.0.0 milestone Jan 31, 2023
@dhalbert
Copy link
Collaborator

dhalbert commented Feb 3, 2023

Compared to most boards / examples, this is using two less used features: StateMachine.background_write and bitops.bit_transpose.

Would either of these spend time in a tight loop and freeze out USB task handling?

Do you feel this is a showstopper for 8.0.0?

@jepler
Copy link
Author

jepler commented Feb 3, 2023

Would either of these spend time in a tight loop and freeze out USB task handling?

I looked for that, as it's the first explanation that occurred to me too.

background_write has one place where it loops (based on the status of an ongoing DMA transaction), but it calls RUN_BACKGROUND_TASKS every loop.

bit_transpose is a tight loop, but it runs with interrupts enabled:

static void bit_transpose_8(uint32_t *result, const uint8_t *src, size_t src_stride, size_t n) {
    for (size_t i = 0; i < n; i++) {
        transpose_8(result, src, src_stride);
        result += 2;
        src += 1;
    }
}

but for the amount of data being processed (8 strands of 30 LEDs at 24bpp), the time is only ~100us.

Another possible explanation would be electrical, though I don't like it: the PIO program, when running, causes 8 outputs to switch at the same time, and with wiring problems that can amount to ~400mA being switched on and off. something ground bounce something words an EE would say?

Just running the bitops.bit_transpose in a loop did not reproduce the problem over the course of 5 minutes.

@dhalbert dhalbert modified the milestones: 8.0.0, 8.x.x Feb 6, 2023
@jepler
Copy link
Author

jepler commented Feb 8, 2023

Based on internal discussions, this is also affecting Arduino. Internal testing indicates that reducing the drive strength on the #16-23 pins to 2mA seems to fix it.

@jepler jepler closed this as completed Feb 9, 2023
@dhalbert dhalbert modified the milestones: 8.x.x, 8.0.x Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug rp2040 Raspberry Pi RP2040 usb
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants