Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.5k
tests/ports/rp2: Add some tests for the PIO assembler.#18301
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Conversation
Check the result of assembling some nonsense test programs, constructedto exercise all variants of every instruction, forward and backwardjumps with every condition type, wrapping, side-setting and delays,pin initialisation, autopush and autopull settings, shift directions andFIFO join.Signed-off-by: Chris Webb <chris@arachsys.com>
codecovbot commentedOct 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## master #18301 +/- ##======================================= Coverage 98.39% 98.39% ======================================= Files 171 171 Lines 22290 22290 ======================================= Hits 21933 21933 Misses 357 357 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
These test programs would also be useful for covering the code paths that load programs into hardware --- i.e. still notexecuting them, but doing everything up to calling |
Yes, definitely! Possible some more reasonable programs which don't depend on GPIO might be worth assembling and running in the test too, if we're running on a real rp2? |
Wait, do we even have a unix target this test can be run against? i.e. with a substitute
Agreed, and IMO the most important place for coverage there isn't the PIO opcodes themselves but everything else, the queues and DMA and IRQs. As a simple place to start with, though, a PIO program that just copies from its input buffer to its output buffer could be used to verify quite a lot --- validate correctness of |
Is should be not too much work to create mock modules based on the |
AJMansfield commentedOct 29, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
If we replaced |
arachsys commentedOct 30, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think for the purposes of testing the assembler itself, it's sufficient for Aside: when it comes to dynamic languages, I'm more of a scheme programmer who is still puzzling over all the special-cases in python's design, so forgive the naive question, but is there a standard mechanism to register a module other than loading it from a .py file? A module namespace is just a map from names to values; the first Anyway, in the interests of not getting lost in the weeds, perhaps it's worth finalising a good set of tests that can run fine on the rp2 boards themselves, and then revisiting the question of whether we can make a subset of those tests run outside the rp2 port so they can be exercised by automated-ci as a follow-up? I'll take a look at exercising more of the 'uploading to hardware' paths with the existing programs as you suggest,@AJMansfield, and maybe write some simple programs that can run on the hardware without needing external hardware on gpios too. |
The other great thing about having these things in tests is that they're then clear demonstrations of what minimal DMA or minimal IRQ handling looks like for PIO. I have examples in my programs of all of these, but they're not so discoverable because they're surrounded by the rest of the program. (DMA from ADC is another one where I keep meaning to do a simple demo and post it somewhere easily searchable/discoverable. There are lots of quite complicated examples, but just to stream to a buffer using the new rp2.DMA is much easier than they would suggest.) |
Uh oh!
There was an error while loading.Please reload this page.
Summary
Take a first cut at some tests for rp2
asm_pio()decorator.Check the result of assembling some nonsense test programs, constructed to exercise all variants of every instruction, forward and backward jumps with every condition type, wrapping, side-setting and delays, pin initialisation, autopush and autopull settings, shift directions and FIFO join.
Testing
Tested on Pico 2 and Pico 2W, but also requires the
asm_pio()bugfix from#18300 to work.At the moment, the .exp file is generated from micropython itself, but once the test is settled in final form, I'll convert to pico sdk format, manually check the generated object code in the test against what the sdk assembler produces, and hand-inspect the other parameters based on my understanding of the representation of a pio program in rp2.py.
Trade-offs and Alternatives
These tests are an early draft. Any suggestions for improvements or extra things to test gratefully received! I'm not testing the new
execctrl=feature from#18133 yet as this hasn't landed in mainline.