Can You Run Linux On a Commodore 64? (github.com) 68
llvm-mos adapts the popular LLVM compiler to target the MOS 6502 processor (the 1980s microprocessor used in early home computing devices like the Apple II and the Commodore 64). So developer Onno Kortman used it to cross-compile semu, a "minimalist RISC-V system emulator capable of running Linux the kernel and corresponding userland." And by the end of the day, Kortman has Linux running on a Commodore 64.
Long-time Slashdot reader johnwbyrd shared the link to Kortman's repository. Some quotes: "But does it run Linux?" can now be finally and affirmatively answered for the Commodore C64...!
It runs extremely slowly and it needs a RAM Expansion Unit (REU), as there is no chance to fit it all into just 64KiB.
It even emulates virtual memory with an MMU....
The screenshots took VICE a couple hours in "warp mode" (activate it with Alt-W) to generate. 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. Maybe even a simple form of JIT compilation? It should also be possible to implement starting a checkpointed VM (quickly precomputed on x86-64) to avoid the lengthy boot process...
I also tested a minimal micropython port (I can clean it up and post it on github if there is interest), that one does not use the MMU and is almost barely remotely usable with lots of optimism at 100% speed.
A key passage: I have not tested it on real hardware yet, that's the next challenge .. for you. So please send me a link to a timelapse video of an original unit with REU booting Linux :D
Its GitHub repository has build and run instructions...
Long-time Slashdot reader johnwbyrd shared the link to Kortman's repository. Some quotes: "But does it run Linux?" can now be finally and affirmatively answered for the Commodore C64...!
It runs extremely slowly and it needs a RAM Expansion Unit (REU), as there is no chance to fit it all into just 64KiB.
It even emulates virtual memory with an MMU....
The screenshots took VICE a couple hours in "warp mode" (activate it with Alt-W) to generate. 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. Maybe even a simple form of JIT compilation? It should also be possible to implement starting a checkpointed VM (quickly precomputed on x86-64) to avoid the lengthy boot process...
I also tested a minimal micropython port (I can clean it up and post it on github if there is interest), that one does not use the MMU and is almost barely remotely usable with lots of optimism at 100% speed.
A key passage: I have not tested it on real hardware yet, that's the next challenge .. for you. So please send me a link to a timelapse video of an original unit with REU booting Linux :D
Its GitHub repository has build and run instructions...
cluster (Score:5, Funny)
Re: (Score:1)
Aah ya beat me to it. Glad to see it's still funny, though!
Re: cluster (Score:2)
It seems old folks are struggling to imagine it, especially maintaining a cadre of imaginary friends PLUS an imaginary girlfriend
Re: (Score:2)
why, I'm running one in emulation right now--on my watch!
Re: (Score:2)
It's been a long time since I wish I had mod points, but this comment definitely deserves them.
I'm just gonna sit over here with my bowl of hot grits and see how this plays out.
Obviously (Score:2)
Given enough RAM, you can basically emulate every CPU on every other CPU. Very slowly. Does not mean you should.
Re: (Score:1)
Re: Obviously (Score:3)
Hmm yeah. Let the youngsters try such wild things out and test their limits. The OP did use a conditional expression, to be fair. Has seen it all, I guess.
Re: (Score:3)
The OP did use a conditional expression, to be fair. Has seen it all, I guess.
Not all. Just all the easy stuff.
Re: (Score:2)
> Very slowly.
When are they going to port Linux to Ethereum? The world's most resilient global Linux instance.
Re: (Score:3)
Doesn't even have to be random access, because blah blah long enough tape...
Re: (Score:1)
That's how Jeff Goldblum took down the aliens in Independence Day. It wasn't that the virus was actually dangerous, it was just *really* inefficient to emulate and tied up all their compute.
Re: (Score:2)
So the aliens do not have load management? The mind boggles. Babes in the woods.
minimalist RISC-V system emulator (Score:5, Informative)
Re: (Score:3)
Yep - to really say it was done would require doing a lot of work to make it run without the emulation layer. Which would presumably also be significantly faster... But probably still very slow.
Then again, Linux has been run in some pretty tight places.
Re:minimalist RISC-V system emulator (Score:4, Informative)
Can't be done. Linux requires an MMU. A C64 doesn't have one. So you either emulate it, or Linux won't work.
Re: (Score:1)
Has that always been the case? I thought there was an older Linux kernel version that had been ported to the 6502 some time ago but not before the creation of this website.
Re:minimalist RISC-V system emulator (Score:4, Interesting)
According to Google, Linux can indeed be compiled to run without an MMU, at the cost of compatibility with what I would assume is the vast majority of applications.
Re: (Score:3)
You're wrong. Not only can Linux run without an MMU, MMU-less Linux runs on RISC-V. Ergo, it's likely that Doom can run on the Commodore 64.
https://hackaday.com/2022/12/0... [hackaday.com]
Re: (Score:3)
Doom runs on a C64... via a RAD cartridge. The cartridge contains a raspberry pi that takes over the 6510 and runs DOOM. Basically it streams DOOM to the VIC-2 and the SID fast enough to be playable via the C64 keyboard. Demo here:
https://www.youtube.com/watch?... [youtube.com]
There is also a tiny raycaster running in a demo on a vanilla C64 here: https://youtu.be/B4gC397tdlY?t... [youtu.be]
Re: (Score:3)
Doom runs on a C64... via a RAD cartridge.
Like strapping a model T on top of a Lamborghini and then claiming it can do 150mph.
Re:minimalist RISC-V system emulator (Score:4, Informative)
Lol, I've contemplated attempting a similar feat with a Pi-in-a-cartridge for the Atari 2600... but for the 2600, the problem is exponentially harder, because it has no concept of bitmap graphics per se... or even sprites in any sense that someone with a Commodore 64 or Amiga background would recognize.
The 2600's TIA chip is mind-blowingly hard to program. The CPU and your executing code is literally responsible for telling the TIA chip how to draw each and every scanline... in realtime, as the scanline is being drawn.
C64: tell the VIC-II chip to display sprite 0 at (23,160) after setting the color, bitmap data, and optionally double its height and/or width, halve the horizontal resolution to achieve 4 colors instead of 2, etc.
2600: Have the 6507 twiddle its thumbs executing NOP statements (or other precisely-timed statements) until exactly the right instant before the raster is supposed to begin drawing the ball/missile/player sprite... then tell it to start (possibly modified by another register that tells it to delay for a pixel-clock or two, since each 6507 clock equals 3 pixel-clocks). On a computer like the c64, you could bitbang the video chips to make them do more advanced things. On a 2600, you have to bitbang TIA to make it do anything at all.
Basically, neither the Atari 2600 or its TIA chip has any concept of DMA, or even video ram. On an Amiga, you had a display-list coprocessor that could wait until the raster reached a particular row and column, update registers by writing values into them, then waiting until the next milestone. On an Atari 2600, the 6507 is the display list processor.
Re: (Score:3)
Technically it is a bit different, but there is uclinux:
https://www.eetimes.com/how-uc... [eetimes.com]
Which is designed for micro controllers without MMU. And since 2.6 it is actually in mainline Linux kernel.
But given even the more capable ESP32 Linux hackers went with the RISC-V emulation way:
https://hackaday.com/2021/07/2... [hackaday.com]
It is probably not worth the extra effort to make it work, than emulating a more capable CPU.
Re: (Score:1)
So they squeezed an emulator into an 8-bit system and 'ran' Linux on said emulator. That's kind of a loose definition of 'ran'. Like claiming you're playing a game when the frames are really rendered one per fortnight on a turing machine.
When then...you will have plenty of time to contemplate that next move...of your big toe at these compute speeds! /sarcasm
misread your post, sans glasses (Score:4, Funny)
I (correctly) saw this as, "So they squeezed an emulator into an 8-bit system and 'ran' Linux on sad emulator.
Re: (Score:2)
Well, that's one of the neat things with RISC-V - the core implementation is rather minimal (to call yourself RISC-V compatible, you just need the integer core - everything else is optional). So as long as you implement the bare minimum, any compliant RISC-V software should work on it.
But yes, emulating Linux via RISC-V on C64 is kind of loose. Like running Linux on Magic The Gathering because you run it via an emulator that
Re: minimalist RISC-V system emulator (Score:2)
Seems like a logical next step.
Next step: (Score:1)
Mr. Rogers (Score:2)
As I recall reading in some computer magazine decades ago, someone decided to put a GUI on a Commodore 64. I think it was GEOS. I later saw a demo of it. Slow and unresponsive doesn't begin to describe it. So, with regard to putting something modern like Linux on a C64 I'll start channeling Mr. Rogers: "Can you say 'waste of time', children? Good, I knew you could."
Re: (Score:2)
Seriously...GEOS back in those days was a jump forward from having to remember the obtuse command line incantations used on a C-64.
Yeah I am old enough to remember stuff like that...and have the neckbeard (when I choose to grow it out) to prove it :))))
Re:Mr. Rogers (Score:4, Insightful)
>obtuse command line incantations used on a C-64.
Troll. It ran BASIC, not an operating system. Nothing obtuse about BASIC. I wrote assembly on that platform. That was obtuse, but it was not the normal interface.
Re: (Score:2)
For most people that were new to computing, like I and many around me were at the time, it was obtuse. A GUI, no matter how simplistic, was a welcome addition as we all learned what went on inside the computer.
At the other end, IBM x86 Assembly was an interesting programming experience. Great if you needed to do simple "utility" tasks very quickly, especially if you could compile your code to the ".com" filespec.
Somewhere between the C-64 and the x86 I dabbled in Z-80 and CP/M 2.2 and 3.0 (aka CP/M Plus) an
Re: (Score:2, Insightful)
He's not a Troll, you are an ignoramus.
How to start a floppy disk game when powering on an ATARI 800XL:
_Press Start when powering on
How to start a floppy disk game when powering on a C64:
_Wait for basic command invite
_Type LOAD"*",8,1
_Type Return
(Disclaimer: cannot vouch 100% the command as I didn't own a C64, but you get the idea).
Re: Mr. Rogers (Score:2)
eh kind of. you didn't have to "wait" for a basic prompt; it loaded off ROM pretty much instantly.
also, many commercial C64 games did boot off the disk, but some didnâ(TM)t and even the ones that did often got cracked and re-distributed without that feature anyway.
Re: (Score:3)
What is this command line luxury to which you're referring in a c64 context? From what I remember, on a c64, listing the files on a disk consisted of:
load "$",8
list
Or... if you had Epyx Fastload, hitting $ and enter.
Re: Mr. Rogers (Score:5, Interesting)
I once saw a youtube video of a dude who built an electromechanical square root calculator. Probably hundreds of relays, a rat's nest of hand-wiring, nixie tube displays, and a brass and wood case the size of a small refrigerator that likely took weeks of work to finish.
Sounded like a chorus or typewriters and computed a square root (and only a square root) in a sizeable fraction of a minute.
Totally useless.
But also absolutely gorgeous.
Re: (Score:2)
At the Exploratorium, there is a square root calculator consisting of a ball rolling down a cycloid curve and then dropping onto a meter stick.
The horizontal distance of the impact is equal to the square root of the starting height of the ball.
Figuring out why it works is a good high school physics question.
Re: Mr. Rogers (Score:3)
Sounds like a more advanced version of IBM 602 from 1946. The Big Blue would hire him.
Re: (Score:2)
Here is a link to the relay logic square root calculator:
https://www.youtube.com/watch?... [youtube.com]
It is gorgeous. Personally, I might have used slightly more modern components, like 7-segment LEDs and reed relays, to make it a bit smaller, faster, and quieter, but he did a bang-up job!
Re: Mr. Rogers (Score:2)
Re: (Score:2)
They also have it for PC, which is a place it made some sense. There it sits atop DOS, so drivers you've loaded for network or dis[ck] function. The Zoomer/Gridpad 2390 ran GEOS — its distribution of GEOS (and the handful of pen-related apps to go with it) was Palm computing's first product. Then they made Graffiti for it...
Re: (Score:2)
Indeed. I bought a 80386-driven PC from a warehouse store in 1990 that had GEOS on it. It was not only quite slick but ran very nicely. However, I only used it for the word processor and playing Tetris. But when I bought a 486 three years later it came with Windows 3.1 and that was the end of my GEOS experiment.
Re: (Score:2)
Re: (Score:2)
Then there came Windows and computing went to shit.
Re:Mr. Rogers (Score:4, Interesting)
GEOS was actually quite usable for the times. It may be slow and unresponsive by today's standards, but I mean c'mon, this was 40 years ago. Pretty impressive and functional stuff back then.
Re: Mr. Rogers (Score:2)
no it wasn't. it was a sluggish anemic pain back then tooâ¦
Re: (Score:2)
Whatever man, I'm sure you could code something much better up on that same hardware, huh? lol
Re: Mr. Rogers (Score:2)
i mean it was impressive that it worked at all back then, but it was practically useless. it's built in apps were feeble and if you were using anything else. it had to unload itself and then reload itself when you were done, off a floppy.
why are you taking this personally? roflmao
Re: (Score:2)
I'm not taking it personally, I just think you're not seeing how big of a deal that was back then. Saying "It had to unload itself and then reload itself when you were done, off a floppy" was pretty par for the course for something like that back then. Remember playing games where you had to flip disks over, do stuff like that during gameplay? We didn't have multi-terrabyte NVMe drives back then, lol.
I remember getting a lot of schoolwork done on GEOS. Word processing, for one, was much easier. I never felt
Re: (Score:2)
Re: (Score:2)
GEOS... load a disk to swap in the GUI, then another for the program you used the GUI to call.
Honestly, it's a miracle it ran at all.
No, you can't run Linux on a C-64 (Score:3, Funny)
But with enough memory, you might be able to crawl it ... very slowly.
one upmanship (Score:3)
Re: (Score:2)
Citation required for the abacus being turing complete.
But nice post though!
Meh (Score:1)
Re: (Score:1)
Remember when some guy got UNIX running on a gameboy? slashdot article: https://tech.slashdot.org/stor... [slashdot.org]
GNO/ME on Apple 2GS (Score:2)
https://en.wikipedia.org/wiki/... [wikipedia.org]
Though why you would want to is still an open question.
Impressive (Score:2)
Impressive.
But you need a big REU RAM extension cartridge. 16Mo. Way beyond what the REU offered when the C64 was still commercially alive. And REU were not common at all.
P.S. If you do not enjoy these kind of news what the hell are you doing on (what is left of) slashdot !?
Stupid question (Score:2)
You can run any operating system on any Turing complete machine with enough storage. It may take one trillion years to boot up and be slow as fuck but it will run.
Is this post missing a link? (Score:2)
News for nerds (Score:5, Insightful)
For once a story that does what this site says on the tin, and the comments are all "so what", "not really running Linux", yada yada yada. Show us your repos if you're doing anything equally ingenious and joyfully useless. I for one welcome our beowulf cluster of these in a bowl of hot grits and Netcraft confirms it.
Re: (Score:2)
Right? One of the few things recently that's interesting.
Granted, the amount of nerdery on the internet seems greatly diminished and silo'd now, versus 20 years ago in the /. heyday: research labs posting stuff on the internet are not a thing, it's all individual contributor efforts.
I'm personally surprised a modern kernel was used, given how much more bloated today's kernel is versus one from eg. the 1990s. Just goes to show how adaptable it is due to all the multi-platform efforts.
GeckOS (Score:4, Interesting)
If you want to run unix-like OS on your C64/C128, just use GeckOS (https://en.wikipedia.org/wiki/GeckOS for info, https://github.com/fachat/Geck... [github.com] for repo).
Jokingly asking Why ?? (Score:2)
Microware OS9 Would Be Better Fit (Score:2)
The Level I could likely be made to run on a C64, something would need to be done for the lack of the 2nd stack. The 512k Coco, under OS9 could do things like this: https://youtu.be/UyD2w1Z5R-E?s... [youtu.be]