The Commodore Is Keeping Up with Linux, as a Clever RISC-V Hack Brings Support to the Commodore 64

Teaching an old dog some really new tricks, Onno Kortmann has convinced a Commodore 64 to boot Linux — by emulating a 32-bit RISC-V chip.

Gareth Halfacree
9 months agoRetro Tech

Developer Onno Kortmann has brought Linux to a device few would have imagined capable of running it: the eight-bit Commodore 64, released nearly a decade before Linus Torvalds' groundbreaking kernel.

"'But does it run Linux?' can now be finally and affirmatively answered for the Commodore C64," Kortmann writes of his work. "There is a catch (rather: a couple) of course: it runs extremely slowly and it needs a RAM Expansion Unit (REU), as there is no chance to fit it all into just 64KiB."

The Commodore 64 launched in 1982 as an affordable yet reasonably powerful home computer for the masses. Boasting color graphics, an eight-bit MOS 6502 processor, and the iconic Sound Interface Device (SID) chip, the Commodore 64's ROM came pre-loaded with Commodore BASIC — a customized version of Microsoft BASIC. What it definitely didn't come with was a copy of the Linux kernel: Linus Torvalds wouldn't write that for another nine years.

Despite that gap, and the fact Linux was originally written for x86 systems, the worlds of the Commodore 64 and Linux have collided in Kortmann's project. The trick: semu, a compact emulator which implements a 32-bit version of the free and open-source RISC-V architecture. It's been used in the past to bring Linux to a range of resource-constrained platforms, including microcontrollers — but the Commodore 64 is something else entirely.

Using his Commodore 64 port of semu, in combination with a 16MB memory expansion on top of the Commodore 64's original 64kB of internal memory, Kortmann was able to get the eight-bit MOS 6502 processor to emulate both a 32-bit RISC-V chip and a memory management unit — albeit extremely slowly.

"The screenshots took VICE [a Commodore 64 emulator] a couple hours in 'warp mode' (activate it with Alt-W) to generate," Kortmann admits. "So, as is, a real C64 should be able to boot Linux within a week or so. The compiled 6502 code is not really optimized yet, and it might be realistic to squeeze a factor 10x of performance out of this."

Kortmann's semu fork, with instructions for running it in an emulator, is available on GitHub under the permissive MIT license. "I have not tested it on real hardware yet, that's the next challenge… for you," Kormann writes. "So please send me a link to a timelapse video of an original [Commodore 64] unit with REU booting Linux."

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