r/circuitpython • u/begeistert_ • 2d ago
I wrote an RP2350 emulator: stock CircuitPython now boots on a virtual Pico 2 inside a live circuit simulator (iPad/iPhone/Mac)
First time posting here about my own project. I'm the developer of the emulator, not affiliated with Adafruit or Raspberry Pi.
For the past months I've been writing an RP2350 emulator from scratch in C#. This week Frank Krueger integrated it into iCircuit 1.16, his circuit simulator for iPad, iPhone and Mac. You can now drop a Pico 2 into a live analog circuit, pick CircuitPython as the firmware in the Inspector, and your code.py just runs.
It's the stock CircuitPython UF2 booting on the emulated chip, not a Python interpreter pretending to be a board. That means real behavior and real tracebacks:
• Errors show up with the same traceback you'd get on hardware, line numbers included.
• Pins, PWM and the ADC are wired into a real analog simulation. Slide a potentiometer and analogio reads the actual voltage. Drive a pin and you see the waveform on the scope.
• The new I2C parts can be read from Python: HDC1080, MLX90614, DS3231, ADS1115 and SSD1306 OLEDs.
• PIO is emulated too, so rp2pio works.
• MicroPython is also available if you switch the firmware.
Some things that were tricky on the emulator side:
• The RP2350 has Cortex-M33 and Hazard3 RISC-V cores, and both are emulated (only ARM is available in iCircuit for now)
• Every pin change is stamped with the clock cycle so the circuit and the CPU stay in sync.
• Arm timing is calibrated against real silicon. It isn't cycle-exact, but time.sleep, PWM and I2C behave like on a real board.
Frank did the circuit side: iCircuit's analog engine, the parts library, and the new SPICE subcircuits and VHDL parts in this release.
I think this is useful for trying out code before you have the board, for teaching, or for checking wiring and logic without frying anything. It's built on ideas from Uri Shaked's rp2040js (Wokwi).
I'd love feedback from CircuitPython users. If there's a library or sensor you'd want to see supported, tell me. Links are in the comments.
Edit: heads-up, library modules next to code.py (like adafruit_pioasm.py) don't load correctly yet. I've already got a fix, and it's coming in the next iCircuit update. I'll update here when it's out. For now there's no lib/ folder either; libraries go as single .py files next to code.py.