James Selby's Rust-Based OxidGB Game Boy Emulator Gets Ported to the Raspberry Pi Pico's RP2040

Wholly written in Rust, the emulator already runs and displays games — but speed-ups and input are awaiting additional work.

Gareth Halfacree
5 years ago

Developer James Selby is working on turning the Raspberry Pi Pico into a Nintendo Game Boy emulator by porting his Rust-based OxidGB software to the RP2040 microcontroller — and has celebrated an initial success by getting the games to run and display, with input support to follow.

"The Raspberry Pi Pico is a recently released Raspberry Pi-branded microcontroller with 264kB of RAM and 2MB of flash (alternative third party boards exist with more/less flash)," Selby writes of the project's origins. I thought it would be a fun challenge to port something to this platform and I have a bunch of Rust projects that looked suitable. This has been a ride - a frustrating ride, but a ride I've thoroughly enjoyed nonetheless from an educational perspective."

"This is pretty much pure Rust (so the Raspberry Pi SDK isn’t used here), which did mean I’ve had to reimplement a significant portion of the SDK (Rewrite-it-in-Rust, no? :P). This was greatly accelerated by adapting the (lovely) interfaces designed by the svd2rust and cortex-m Rust crates."

Running entirely on the RP2040 microcontroller, launched earlier this year aboard the Raspberry Pi Pico development board as the first product of Raspberry Pi's in-house application specific integrated circuit (ASIC) design team, the OxidGB emulator leaves around 70kB of RAM and plenty of flash storage free.

The project is, however, at a very early stage: Despite overclocking the RP2040 to double its stock clock, the emulator runs slower than real hardware at around 10 frames per second. "The main bottlenecks are my emulation code (which was originally focused on simplicity and accuracy rather than speed), as well as the slow SPI interface to the screen," Selby explains. "There are things that I want to do to speed this up (like DMA to the screen), but this will take more time to plan and implement."

A bigger issue is that while the games run fine, you can't actually interact with them yet. "Input is not far away at all — all the interfaces are there, I just need to be bothered to actually link the GPIOs to the emulator core," Selby says. "Given the game speed this wasn’t all that important though."

The OxidGB port can be found on GitHub under the permissive MIT licence; those interested in trying it themselves should note that they'll need a nightly build of their Rust compiler, plus the elf2uf2 tool from the Raspberry Pi Pico software development kit (SDK).

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles