RP2040 Emulation (Raspberry Pi Pico)
The Raspberry Pi Pico and Pico W are emulated entirely in the browser using rp2040js, an open-source ARM Cortex-M0+ emulator. No QEMU or backend process is required, the binary runs at full speed inside a Web Worker.
Supported Boards
| Board | FQBN | Built-in LED |
|---|---|---|
| Raspberry Pi Pico | rp2040:rp2040:rpipico | GPIO 25 |
| Raspberry Pi Pico W | rp2040:rp2040:rpipicow | GPIO 25 (via CYW43) |
Binary Format
The backend compiles the sketch with arduino-cli targeting rp2040:rp2040:rpipico and returns a raw ARM binary (.bin) encoded in base64. Unlike AVR, there is no Intel HEX, the binary is loaded directly into the RP2040 flash at offset 0.
The backend also prepends #define Serial Serial1 to the sketch so that Arduino Serial calls are redirected to UART0 (the virtual serial port streamed to the Serial Monitor).
Peripherals
| Peripheral | Support | Notes |
|---|---|---|
| GPIO (30 pins) | Full | Digital read/write, pull-up/down |
| UART0 / UART1 | Full | Serial Monitor via UART0 |
| ADC (ch 0-3) | Full | GPIO 26-29; ch 4 = temperature sensor |
| I2C0 / I2C1 | Partial | DS1307 RTC, TempSensor, EEPROM virtual devices |
| SPI0 / SPI1 | Loopback | TX looped back to RX |
| PWM | Frequency only | No waveform output to components |
| Timer / Alarm | Full | Used by delay() and millis() |
WFI Optimisation
When the CPU executes a WFI (Wait For Interrupt) instruction, the emulator fast-forwards the system clock to the next scheduled alarm instead of spinning through idle cycles. This dramatically reduces CPU usage during delay() calls.
Simulation Loop
The simulation runs inside requestAnimationFrame at ~60 FPS. Each frame executes approximately 2,200,000 CPU cycles (133 MHz / 60 fps). GPIO listeners fire whenever a pin state changes and update the visual components on the canvas.
Known Limitations
- Pico W wireless chip (CYW43439) is not emulated, WiFi/Bluetooth will not work
- SPI loopback only, no real SPI device emulation
- PWM produces correct frequency but no visual waveform on components
- DMA not emulated
- Second CPU core (core 1) not emulated,
multicore_launch_core1()has no effect
Full Documentation
See the complete technical reference: RP2040_EMULATION.md