|
epio
A cycle-accurate RP2350 PIO emulator
|
While RP2350 PIO programs are conceptually simple and easy to write, testing their precise behaviour is hard:
epio solves both of these problems, by providing a cycle-accurate emulator for RP2350 PIO programs, that can run on non-RP2350 hosts, including CI runners. This allows you to test and verify your PIO programs in a convenient and deterministic way, without needing to rely on real hardware.
It provides a `wasm` build, allowing you to run and visualise PIO programs in the browser, with a simple JavaScript API.
To make it easy to setup, epio integrates with apio, a runtime PIO assembler and disassembler. apio allows you to write your PIO programs with C macros directly in your RP2350 firmware (avoding the need for a separate pioasm step), and run them both on real RP2350 hardware and emulated using epio on non-RP2350 hosts.
epio includes comprehensive automated testing to ensure correct, cycle exact PIO emulation behaviour, and to avoid regressions.
Existing PIO emulators lack comprehensive support for RP2350 PIOs, which are more advanced than RP2040 PIOs and support additional instructions. A fully tested implementation is essential to ensure the emulation can be relied upon. Being C-based allows integration with existing bare-metal RP2350 firmware, and the design targets portability across a wide range of hosts, including WASM.
This video shows what is possible with epio:
https://youtu.be/eNu0JAY1Dvc?si=N3-KCYJ04APH3RlB
Try the interactive demo of the WASM example.
See the example for a complete bare-metal RP2350 firmware with a PIO, using apio and epio. This example can be built and run on both a real RP2350 and emulated on non-RP2350 hosts. Here is a snippet that demonstrates how to use epio to run a PIO program assembled with apio:
apio.Start here.
See the GitHub repo.
In order to use epio for emulation, you can either use apio to set up your PIO programs, or manually configure the epio instance to match the state of your PIOs.
You must stub out any RP2350-specific non-PIO functionality that your program relies on when operating in the emulator, such as direct hardware register access, SDK usage, interrupts, etc. Direct hardware register, SRAM, and other peripheral access will cause faults on the host.
There are currently some limitations in epio's PIO emulation. If you need a feature that isn't implemented yet, please raise an issue or submit a PR.
Current limitations:
epio provides a wasm build, allowing you to run and visualise PIO programs in the browser, with a simple JavaScript API.
Try the live demo.
The example is documented in the example README, and the source code is in the example directory.
See also the JS API for details.
MIT License, see [LICENSE](LICENSE).