Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Amiga Linux

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...
This discussion has been archived. No new comments can be posted.

Can You Run Linux On a Commodore 64?

Comments Filter:
  • cluster (Score:5, Funny)

    by bugs2squash ( 1132591 ) on Sunday August 27, 2023 @02:46PM (#63801646)
    Imagine a Beowulf cluster of these
    • Aah ya beat me to it. Glad to see it's still funny, though!

    • by hawk ( 1151 )

      why, I'm running one in emulation right now--on my watch!

    • by Reeses ( 5069 )

      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.

  • Given enough RAM, you can basically emulate every CPU on every other CPU. Very slowly. Does not mean you should.

    • by Anonymous Coward
      You must be a hoot at parties.
      • 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.

        • by gweihir ( 88907 )

          The OP did use a conditional expression, to be fair. Has seen it all, I guess.

          Not all. Just all the easy stuff.

    • > Very slowly.

      When are they going to port Linux to Ethereum? The world's most resilient global Linux instance.

    • Doesn't even have to be random access, because blah blah long enough tape...

    • by Gleenie ( 412916 ) *

      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.

  • by blugalf ( 7063499 ) on Sunday August 27, 2023 @03:06PM (#63801676)
    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.
    • 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.

      • by ShanghaiBill ( 739463 ) on Sunday August 27, 2023 @03:46PM (#63801752)

        Can't be done. Linux requires an MMU. A C64 doesn't have one. So you either emulate it, or Linux won't work.

        • 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.

        • 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]

          • 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]

            • 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.

            • by Miamicanes ( 730264 ) on Sunday August 27, 2023 @10:28PM (#63802406)

              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.

        • by stikves ( 127823 )

          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.

    • 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

    • by bjdevil66 ( 583941 ) on Sunday August 27, 2023 @07:11PM (#63802076)

      I (correctly) saw this as, "So they squeezed an emulator into an 8-bit system and 'ran' Linux on sad emulator.

    • by tlhIngan ( 30335 )

      So they squeezed an emulator into an 8-bit system and 'ran' Linux on said emulator.

      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

  • Run Linux on a C-64 emulator running under Linux.
  • 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."

    • 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)

        by mustafap ( 452510 ) on Sunday August 27, 2023 @03:42PM (#63801746) Homepage

        >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.

        • 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)

          by Saffaya ( 702234 )

          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).

          • 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.

      • 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)

      by RightwingNutjob ( 1302813 ) on Sunday August 27, 2023 @03:34PM (#63801730)

      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.

      • 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.

      • Sounds like a more advanced version of IBM 602 from 1946. The Big Blue would hire him.

      • by pz ( 113803 )

        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!

    • They had that for the Apple II. It wasn't so terrible. I never used it seriously but for what it was...
      • 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...

        • by mendax ( 114116 )

          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.

          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.

    • I used it occasionally, it wasn't that much more sluggish than the alternatives at the time.
    • Re:Mr. Rogers (Score:4, Interesting)

      by TheDarkener ( 198348 ) on Sunday August 27, 2023 @04:25PM (#63801834) Homepage

      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.

      • no it wasn't. it was a sluggish anemic pain back then tooâ¦

        • Whatever man, I'm sure you could code something much better up on that same hardware, huh? lol

          • 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

            • 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

    • I wonder what is the most globally destructive waste of electricity - crypto, AI or GUIs.
    • 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.

  • by davidwr ( 791652 ) on Sunday August 27, 2023 @03:30PM (#63801718) Homepage Journal

    But with enough memory, you might be able to crawl it ... very slowly.

  • by Walt Dismal ( 534799 ) on Sunday August 27, 2023 @03:36PM (#63801734)
    Bah. Two hundred years ago my ancestor Linus Chung Ho created Linux for the abacus. We're still waiting for it to finish booting though.
  • I'll be impressed when it's running on my TI-59 calculator.
  • https://en.wikipedia.org/wiki/... [wikipedia.org]

    Though why you would want to is still an open question.

  • 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 !?

  • 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.

  • I can't find a link to TFA.Only to related projects.
  • News for nerds (Score:5, Insightful)

    by ratbag ( 65209 ) on Sunday August 27, 2023 @09:48PM (#63802322)

    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.

    • by CAIMLAS ( 41445 )

      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)

    by Zarhan ( 415465 ) on Monday August 28, 2023 @02:45AM (#63802656)

    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).

  • Just so you can say you did it ! Useful, naaaaa !
  • The source-code for a real-time multitasking operating system for 8-bit micros is out there: https://sourceforge.net/projec... [sourceforge.net]
    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]

The biggest difference between time and space is that you can't reuse time. -- Merrick Furst

Working...