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

Use only DMA0 for PIO background read/write #9980

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

dhalbert
Copy link
Collaborator

Changes PIO background read/write to use only DMA0, not DMA1. This is a minimal change that does not change the current use of a static IRQ handler in ports/raspberrypi/audio_dma.c. It reverts to using only DMA0, and uses two background_pio... arrays to distinguish between read and write. picodvi now works again.

If this works, then I can explore using irq_add_shared_handler() as discussed in #9868.

@timchinowsky I tried to test this using a loopback test from https://github.com/timchinowsky/tac5/blob/main/README.md. But those tests as written use a test= arg which is no longer present. Could you test this (and update the loopback tests)? Thanks.

@timchinowsky
Copy link

Great, thanks for these changes, and sorry about the broken tests, I will get them going.

@relic-se
Copy link

@dhalbert The pio_i2s library relies on the background read and write features as well. The examples within that library should work as a test for these updates as well. https://github.com/relic-se/CircuitPython_PIO_I2S/tree/master/examples

@dhalbert
Copy link
Collaborator Author

@relic-se Would you be willing to test the artifact builds here with those examples? Maybe if you are already set up to do so.

@dhalbert
Copy link
Collaborator Author

@relic-se if you could describe how to set up a simple test, that would be great. I see the examples programs in the library, but I'm not sure how to set them up to actually send data and test the functionality, in the simplest way possible. For instance, I'm not sure if I need to connect an I2s mic and amp to verify that it works, or whether some loopback test could be set up.

@relic-se
Copy link

@dhalbert Here's a basic loopback test: https://gist.github.com/relic-se/b90aae77ec4fccb7b03826007b0e41b3. I haven't gotten around to building the fork of this PR, but I've tested it on v9.2.3 using an RP2040-Zero.

Copy link

@relic-se relic-se left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this build using the example provided in the gist above. The program locks up with the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 16, in <module>
  File "pio_i2s.py", line 361, in write
  File "pio_i2s.py", line 340, in write_ready
  File "pio_i2s.py", line 316, in _get_write_index

The changes in this review result in a functioning test with an error output of 0.

ports/raspberrypi/audio_dma.c Outdated Show resolved Hide resolved
ports/raspberrypi/common-hal/rp2pio/StateMachine.c Outdated Show resolved Hide resolved
@dhalbert dhalbert force-pushed the pio-background-dma0-only branch from 3d3b81d to a9d41bb Compare January 23, 2025 03:44
@dhalbert dhalbert requested a review from relic-se January 23, 2025 03:45
@dhalbert
Copy link
Collaborator Author

@relic-se I added your changes and rebased as well, to catch up. Could you re-test?

Copy link

@relic-se relic-se left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good and test runs without a hitch!

@dhalbert dhalbert marked this pull request as ready for review January 23, 2025 15:11
@dhalbert dhalbert requested review from tannewt and jepler January 23, 2025 15:11
Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Though I didn't follow the whole discussion this looks sensible and I didn't spot any mistakes. No testing performed.

@dhalbert dhalbert merged commit 09d9136 into adafruit:main Jan 23, 2025
154 checks passed
@dhalbert dhalbert deleted the pio-background-dma0-only branch January 23, 2025 18:04
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

Successfully merging this pull request may close these issues.

PicoDVI crashes in CircuitPython 9.2.1
4 participants