5 ms·
Linux on a Commodore 64
- sedatk 3y agoThis isn't Linux running on C64 per se. This is C64 emulating a RISC-V environment on which Linux runs. Still impressive of course, but semantics matter :)
- gbraad 3y agoSemu-ntics to be precise ;-)
- userbinator 3y agoNow someone needs to do the same with a ZX spectrum ;-) As others have mentioned, a 6502 is very poorly suited to C-style code, but a Z80 should be somewhat better with that.
- johnwbyrd 3y agoOnno Kortman has taken semu, a minimal RISC-V emulator, and cross-compiled it with llvm-mos, an LLVM port to the MOS 6502 processor, in order to run Linux on the Commodore 64. Kortman writes: "The screenshots took VICE a couple hours in 'warp mode' to generate. So, as is, a real C64 should be able to boot Linux within a week or so."
- mattl 3y agoI'd be curious to see this running on real hardware. I hope someone's able to make it work.
- pengaru 3y agoIt might be more interesting than watching paint dry, just via risk that an old C64 will let the smoke out.
- usr1106 3y agoWhy would it let smoke out? I doubt a C64 has any power management. So whether it idles or boots Linux via a couple of emulation layers, the thermal load will be exactly the same.
- pengaru 3y agoJust because it's likely an old and long dormant piece of electronics, nothing to do with linux beyond it having to run the machine for multiple days 24x7. My understanding is they don't come out of deep dusty storage in ready for service condition. Leaky caps.
- einr 3y agoC64 caps are generally fine and do not need replacing. The most common things to spontaneously go bad of ”old age” on a 64 are probably RAM chips and the PLA, and of course the power supply is a time bomb.
- hakfoo 3y agoI know there can be issues with thermal saturation on a heatsink design-- it was expected not just to generate N watts of heat, but to only do so for M hours. Can you expect to leave a real 64 on for days or weeks and it will stay up? I wonder if stores that had them as demo units when it was a relevant product, for example, power-cycled them regularly. I know from experience if you block the bottom intake vents on a VIC 20, so it can't convect properly, it will eventually start acting funky. On a related note, I understand the 64's original power bricks are considered timebombs, they might also not appreciate being left on for weeks at a time.
- userbinator 3y agoCan you expect to leave a real 64 on for days or weeks and it will stay up? Yes. These early computers found their way into various embedded control applications too, and I suspect there's quite a few C64s still in operation that way; they would've been replaced long ago if they weren't stable. An article occasionally appears when someone discovers this: https://news.ycombinator.com/item?id=12604414 https://news.ycombinator.com/item?id=12604414
- wk_end 3y agoThe 6502 is a notoriously poor target for C compilation, especially C that hasn't been written with the 6502's limitations in mind. I'll bet if you wrote a RISC-V emulator in native 6502 you could get Linux booting on a real machine in a day instead of a week. Think about how many lives that'd save! https://www.folklore.org/StoryView.py?story=Saving_Lives.txt https://www.folklore.org/StoryView.py?story=Saving_Lives.txt
- johnwbyrd 3y agoSays you. llvm-mos generates surprisingly efficient 6502 code given its age and maturity. Don't take my word for it, try some experiments with it on godbolt.
- wk_end 3y agoSure. Here's a couple of functions to iterate over an array of "Ball" objects, as you might do in a Breakout-style game that has a multi-ball powerup. I didn't do anything to make it particularly 6502-amenable; it's how I'd write it for a modern machine, probably. Even compiled with -O2: as expected, the code is slow and enormous - a single addition compiles to something like 30 instructions. [0] https://godbolt.org/z/f6Ysv7nve https://godbolt.org/z/f6Ysv7nve
- deleted 3y ago[deleted]
- johnwbyrd 3y agoSeems like your problem is more with the venerable 6502 itself rather than the compiler. Most of that assembly code is spent calculating the offsets inside the Ball struct, which must be done at 16 bits of resolution in every case. The compiler's using the indirect indexed (zero page address with Y offset) 6502 addressing mode to get at all the fields in your struct. It has placed all the variables in zero page, so no instruction is more than two bytes long; additionally, the code in question is entirely linear, with no JSRs or other subroutines. Note in particular how it efficiently uses DEY/INY pairs of one byte instructions to get at low and high bytes of 16-bit memory. Hand-written assembly might be speedier, but not by much and still deal with all the corner cases that your generated code does. "While writing Apple BASIC for a 6502 microprocessor I repeatedly encountered a variant of Murphy's Law. Briefly stated, any routine operating on 16 bit data will require at least twice the code that it should." -Steve Wozniak
- nxobject 3y agoOh wow! This bootstrapping method reminds me of yet another Linux-on-an-8-bit-micro project (https://dmitry.gr/?r=05.Projects&proj=07.%20Linux%20on%208bit https://dmitry.gr/?r=05.Projects&proj=07.%20Linux%20on%208bi...), which used an 8-bit AVR with an ARMv5 emulator. But, this takes the cake in terms of geek coolness.
- userbinator 3y agoThat's exactly what it reminded me of too; there's been plenty of HN discussion about it: https://news.ycombinator.com/item?id=19762928 https://news.ycombinator.com/item?id=19762928
- dusted 3y agoSo, I like Linux and I love my C64, but.. Linux are for computers too primitive to come with their own kernel and.... the C64 comes with a kernel and shell right from the factory :P
- deleted 3y ago[deleted]
- Agingcoder 3y agoYes, but it’s fun :-)
- msla 3y agoThe Commodore 64 doesn't come with a mere kernel, it comes with a mighty KERNAL https://en.wikipedia.org/wiki/KERNAL https://en.wikipedia.org/wiki/KERNAL > The KERNAL was known as kernel[6] inside of Commodore since the PET days, but in 1980 Robert Russell misspelled the word as kernal in his notebooks. When Commodore technical writers Neil Harris and Andy Finkel collected Russell's notes and used them as the basis for the VIC-20 programmer's manual, the misspelling followed them along and stuck.[7] > According to early Commodore myth, and reported by writer/programmer Jim Butterfield among others, the "word" KERNAL is an acronym (or, more likely, a backronym) standing for Keyboard Entry Read, Network, And Link, which in fact makes good sense considering its role. Berkeley Softworks later used it when naming the core routines of its GUI OS for 8-bit home computers: the GEOS KERNAL.
- chungy 3y agoOnce you add more RAM to a Commodore 64, is it still a Commodore 64?
- tpmx 3y agoNo, it's a Commodore 16384. (The max addressable memory with a C64 REU is 16 Megabytes.)
- johnwbyrd 3y agoYes, if you use an REU, which is a correctly contemporary memory upgrade for the C64.
- mdp2021 3y agoExpanding from Johnwbyrd's nearby: -- Commodore sold a Ram Expansion Unit named "1764" to bring the C64 to 256kb of RAM; -- it was possible to use the REU for the C128 named "1750" to bring the C64 to 512kb of RAM; -- and it is possible to expand on that to have a 2MB REU for the C64 - see https://www.neperos.com/article/rlut8ce90fbb7701 https://www.neperos.com/article/rlut8ce90fbb7701 You can have two megabytes on the C64, pretty "legally".
- Roark66 3y agoI can imagine "someone" back in the day could take PC SIMM modules and cobble together some monstrosity that would allow one to fill 16MB of RAM on a c64 using simple bank switching. However, the main "innovation" of these original and later REUs wasn't the memory amount, but the chip that implemented DMA. That DMA chip could be used to copy ram contents very quickly with minimal CPU involvement. This is why c64 equipped with the REU has much better graphics capabilities (used for background animation etc). As far as I know, we still don't have an open source equivalent of that dma chip.
- mgkimsal 3y agoIs this different from Lunix? https://en.wikipedia.org/wiki/LUnix https://en.wikipedia.org/wiki/LUnix
- skavi 3y agothis is linux
- yeseveryway 3y ago[flagged]
- sedatk 3y agoLUnix is an actual C64-native operating system that you can write apps for and run on C64 hardware directly. This is a RISC-V emulator running on C64 emulating a Linux boot up.
- mgkimsal 3y agothanks. had hit 'post' too soon, but diving in, i see the emulator aspect of this. looks like it can't run in just the standard 64k though, and needs (much?) more memory?
- wang_li 3y agoA demonstration of Turing equivalency. Any Turing complete computer can do what any other Turing complete computer can do if you don’t care about time.
- rhplus 3y agoTime and memory.
- jhallenworld 3y agoYeah, so technically a Turing machine has infinite memory.. so no real-world computer is fully Turing complete.
- vidarh 3y agoA Turing machine has infinite tape. Which can be implemented in terms of RAM but can just as well be implemented in terms of sequentially addressable IO, and pretty much every real-world computer has that, so it's a meaningless technicality as while there are practical limits on our ability to feed it more input, those are not conceptual limits of the machine.
- jwilk 3y agoHow do you run Linux in lambda calculus?
- krylon 3y agoSlowly. Very slowly.
- Decabytes 3y agoThis begs the question. What is the oldest hardware that can boot modern Linux but still be used as a daily driver?
- speed_spread 3y agoThe main "daily driver" constraint is probably the crypto required to access most modern websites. You can make the leanest and meanest system you can to run great on the slowest machine but the internet is nowadays an unforgiving place.
- charcircuit 3y agoSurely video encoding / decoding is more compute intensive than the crypto. Taking video calls is a reasonable part of being daily driver capable.
- jpc0 3y agoVideo delivered in real time over an encrypted connection, this is a double whammy. You need to both decrypt and decode all at above the framerate of the video, doubt that will be doable on any older hardware, unless ssid hardware has dedicated components for those functions. If I had to implement this on an old CPU I would likely be passing network, video and encryption off to co-processors and the older chip will effectively only be running control information. But that that point why not just use a modern low power chip.
- teawrecks 3y agoThe bar for "daily driver" is different for different people's requirements. Would streaming Netflix be included? Running simple games?
- TillE 3y agoFor the sake of argument, let's say a computer where you can install Debian 12 and run a WM and a browser, and it's not excruciatingly slow. I think you'd want to aim somewhere around the Pentium 4 / Athlon XP era. The docs say it doesn't support the original Pentium, so I suppose you could go back as far as the Pentium II if you really want to suffer.
- erwincoumans 3y agoWhat's the BogoMips?
- johnwbyrd 3y agoThe loading screen reports 130 BogoMIPS, but remember that it's emulating the timer as well, so the number is meaningless.
- jandrese 3y agoI assume that's the "warp speed" BogoMIPS, on real hardware the number would be around 1.
- LocalH 3y agoAFAIK, C64 software cannot detect the difference between normal and warp mode in normal circumstances. Warp mode speeds up the emulation, but all of the internal timings are still accurate to the C64 in a relative sense.
- jandrese 3y agoI have to wonder how the Bogomips are calculated on a machine with no RTC.
- sys_64738 3y agoRun Neofetch!
- ryukoposting 3y agoI recently came into possession of a fully-functioning TRS-80 Model 4, and I fantasize regularly about putting some vaguely Unix-esque thing on it. The fantasy continues.
- whartung 3y agoYou should be able to boost that up to 128k. Once there you have a solid chance of being able to run Fuzix on it. Start there and you’ll find a rabbit hole of reasonable depth.
- ryukoposting 3y agoJesus, the documentation for Fuzix is... well, there isn't any is there! This will be an adventure.
- jhallenworld 3y agoNot Linux related, but I've been trying trying recent (at least to me..) C-64 accessories: I've tried the "Kung Fu Flash"- it's a software defined cartridge that is cheap- just a single STM32 and can do pretty much everything. I bought this because I'm trying to duplicate the developer experience I see on "8-bit show and tell"- it can emulate the "super snapshot", but not the REU. It's a really nice way to quickly try a lot of C-64 software and games. https://8bithardware.wixsite.com/website/post/kung-fu-flash https://8bithardware.wixsite.com/website/post/kung-fu-flash https://github.com/KimJorgensen/KungFuFlash https://github.com/KimJorgensen/KungFuFlash I also have an SD2IEC: what I've learned is that it would have been useful to get a variant with an extra DIN socket. It's nice but I was never a fan of C-64's DOS and this reinforces it. To mount a D64 disk image you have to: OPEN1,8,15,"CD:MYIMAGE.D64":CLOSE1... yuck.. JiffyDOS (replacement ROM for the C-64) improves this (it's faster and includes a permanent DOS wedge), I bought one- it's on the way. I'm curious to try it with the real 1541 drive. What got me started on this recently is the "Penultimate +2" cartridge for the VIC-20: https://www.youtube.com/watch?v=eNGyneXHKJQ https://www.youtube.com/watch?v=eNGyneXHKJQ In this case, I basically bought a VIC-20 just to try out the cartridge.
- vlasky 3y agoHow long does a kernel recompile take?
- snvzz 3y agoRISC-V is inevitable.
- doctor_radium 3y agoBut will it impact the sales of GEOS?
- peter_d_sherman 3y agoMinimal FORTHs (https://en.wikipedia.org/wiki/Forth_(programming_language) https://en.wikipedia.org/wiki/Forth_(programming_language)) can run on an unexpanded VIC-20 (5K) or even early TRS-80 Model 1 (4K) -- with room and functionality to spare... On the VIC-20, you even get a few colors!
- Roark66 3y agoVery nice, but my first thought was "surely this will not fit in 64k of ram!". And it doesn't. It requires a 16MB REU! To explain for the uninitiated how rare this bit of hardware is. The REU available for the c64 back in the day were 256kB and 512kB. These are most commonly built replicas as there are schematics available for them. Sometime in the late 90s there was also an "expansion" for c64 that contained a completely new CPU (superCPU - 65816) that was code compatible with the original and I believe this device could accommodate up to 16mb. Later reimplementations based purely on fpga popped up including a REU with 16mb. The original SuperCPU schematic was lost to time. Allegedly fpga based expansions are available to buy for few hundred EUR now, but I don't know anyone that attempted to buy one or has one. So, although it is a neat trick(still a cool tech achievement) , saying it runs on c64 is akin to saying I got doom3 running on a 386, but my 386 is actually a pci card in a modern pc... If I can't pull my c64 with hardware available back in the day (or hardware one could realistically built back in the day) I'm not sure saying "runs on c64" is correct. Coming back to the subject of a REU, why has no one published a schematic for one yet? There are cheap SRAM chips floating on ebay. It should be trivial to put one together. Unfortunately it isn't, because the original (Super Cpu) had two components we need a beefy fpga to emulate. The supercpu itself and it's dma controller which was a custom asic I believe. Perhaps as cheap(ER) fpgas or uC with fpga-like functionality become available someone will create an open source "super cpu". As of yet, everyone I ever heard using these, uses emulation. Nothing wrong with that, but I get the most out of my "retro hobby" by running original hardware. Emulation is very useful for dev, but for general use it's a bit "meh" for me.
- Sharlin 3y ago> but my 386 is actually a pci card in a modern pc... Now I want one of those. I guess these days you could easily fit a 386, 486, Pentium and who knows what other SoCs on a single PCIe card, passively cooled…
- yellowapple 3y agoThis is exactly how some SPARC workstations offered x86 compatibility back in the day IIRC.
- brazzy 3y agoThat 16MiB memory requirement makes this rather disappointing, given that you can run Linux on machines with only 4 MiB of RAM: https://tldp.org/HOWTO/4mb-Laptops.html#toc3 https://tldp.org/HOWTO/4mb-Laptops.html#toc3
- gattilorenz 3y agoThat’s written for linux 2.2.x at best, SysV init, old versions of bash (or maybe even ash) and whatnot. I don’t think you’ll manage with a recent linux kernel. Heck, even 2.6-era stuff won’t fit easily.
- layer8 3y agoI wonder, if instead if requiring REU, it could work by using a few dozen floppy discs as RAM, prompting the user to swap discs as needed. I’d be interested in watching a time-lapse video of that on real hardware, if someone has a couple of months/years to spare. ;)
- aappleby 3y agoGah, this reminds me that I need to finish my "Risc-v on a Gameboy" lolproject.