Page 1 of 1

Can Linux running on 6502?

Posted: Sun Nov 28, 2004 6:44 am
by clockrun
Can Linux running on 6502?
I think it can ,but i don't know if it will support mult-thread......

If the Kernel do not support 6502 , how to change the Kernel File to support it ?

Thanks for your help.

Posted: Mon Nov 29, 2004 9:17 am
by BitWise
Compared to the Intel x86 processor normally used to run Linux a 6502 is very limited. It has a small fixed stack, a slow clock speed, small memory addressing range and no support for memory protection.

It might be possible to implement a small number of 'Linux'-like operating system functions but it is not powerful enough to implement a proper kernel.

Posted: Mon Nov 29, 2004 6:40 pm
by GARTHWILSON
Can you tell us some of the requirements of Linux? How much stack space would it need? The 6502's hardware stack is limited to 256 bytes which some people think sounds awfully small; but when I wrote my Forth for the 65816 which can use tens of thousands of bytes for the hardware stack, I still used only page 1 (256 bytes) because it's more than I needed. In fact 256 bytes is enough to run at least three tasks at once with no worries of running out of stack space.

As for memory requirements, how does Linux (which I understand was written non-commercially) compare to common bloatware which requires tens of megabytes to run something that could run with under 100K if programmers weren't so careless with the resources and weren't always under pressure to get things to market before they've had reasonable time to do it right? The 65816 addresses 16MB (256 times as much as the 6502's 64KB). I have no doubt that 16MB would be far more than enough for Linux with good programming practices. The same goes for 16MHz clock speed which gives about 3MIPS while handling 16 bits at once instead of 8.

GEOS was available for the Commodore 64 (whose processor was essentially a 6502). Due to the slow disc drive interface, it kind of tried your patience; but the C64 could initially load GEOS and get into a useful application in less time than it takes my Pentium to load Windoze and get into a useful application. I understand there was a 512KB plug-in RAM module that used DMA that would speed up the C64's GEOS by a factor of anywhere from 10 to 100 times.

Posted: Thu Dec 02, 2004 11:32 am
by b0rje
I think its not possible to port Linux on a 6502, maybe Minix could be used as a base for a port. As far as I know (??), early versions of Minix did not require
an MMU.
But check out the LUnix Project, its a kind of unix for c64 and c128 from
scratch, ports to other systems should be possible:

http://lng.sourceforge.net/

best regards, b0rje

Posted: Thu May 05, 2005 6:51 pm
by Tancor
if you could get the source to GNO (www.gno.org) - that might also be a good starting point. Granted, it was written for the 65816 and a lot more memory then the 6502 has, but it might provide some ideas at least... that is assuming you can get the source, I never contacted the authors to ask.

Posted: Thu May 05, 2005 9:33 pm
by wirehead
The problem is that GNO/ME is pretty bound up to GS/OS. So I'm not sure if the code would help you that much, because it was mostly a unix-like operating system wrapper over the existing operating system.

Minix is a nice idea, but it was designed for a machine with a 20 bit address space. Which then means that you need a 65816 instead.

I think that porting Unix/Linux/etc. to the 6502 or even 65816 is of the those crazy projects. If you want a usable Unix port, you'd probably build a 68k or ARM computer instead of a 6502/65816... both of which have versions that could be done by a hobyist. If you want a nice easy OS for the 6502 or 65816, there's stuff like Contiki. But if you try to make Unix or a Unix-like OS for the 6502 or 65816, your project is going to be to put an OS on a weird platform.... it's going to be a challenge, not a way to make your life easier.

Posted: Wed May 25, 2005 12:10 am
by kc5tja
It is certainly possible to implement "Unix", the API, on a 6502. Indeed, the world's first versions of Unix all ran on PDP-6s, with less than 64KB of memory capacity total. However, it executed a very, very limited set of programs concurrently, and wasn't really all that more powerful than, say, MP/M or CP/M. Remember that Unix (formerly named Unics) was the "single-user" version of Multics, created out of frustration from those who participated in the project from AT&T. It was never intended to be the mainframe-class behemoth it currently is today.

It is also possible to implement a Linux-clone for the 65816. However, again, you'll need an out-board MMU to support the multiple address spaces required by Linux. This means you MUST use a 65816, since the 65816 has full hardware-level support for external MMU circuitry.

The best bet is to employ a variation of Minix, preferably one built on a proper and fully orthogonal microkernel (Minix is microkernel based, but it's intertwined with the Unix environment it provides, thus reducing the benefits of such an architecture). Again, a 65816 would be required for the memory requirements. Expect a minimum memory requirement of 256KB (as demonstrated by the Amiga 1000 when it first shipped).

Posted: Thu Jul 14, 2005 8:44 pm
by ninja
Some versions of Linux for embeded applications needn't MMU

Posted: Thu Jul 14, 2005 8:54 pm
by kc5tja
ninja wrote:
Some versions of Linux for embeded applications needn't MMU
Again, the choice of and the number of applications that you can run are very limited. And Linux certainly will not fit in the paltry 64KB address space that 6502 provide.s You'll need *at least* a 65816 with 256K of memory.

Re: Can Linux running on 6502?

Posted: Fri Jul 15, 2005 4:52 am
by leeeeee
Quote:
Can Linux running on 6502?
I think it can ,but i don't know if it will support mult-thread......
Perhaps this is what you're looking for ..

http://lng.sourceforge.net/

Lee.

Posted: Thu Aug 11, 2005 2:17 am
by asmlang_6
Maybe we should try Minix 1.0.0 on 65816 (It's 16-bit, so it should be easier then Linux). As soon as I get an Apple ][gs emulator, I'll try to port Minix to it.

Re: Can Linux running on 6502?

Posted: Mon Aug 28, 2023 5:39 am
by johnwbyrd
Necro'ing a dead thread just to demonstrate how common wisdom can be wrong. "But does it run Linux?" can now be finally and affirmatively answered for the 6502, running for example on 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. https://github.com/onnokort/semu-c64

Re: Can Linux running on 6502?

Posted: Mon Aug 28, 2023 6:52 am
by BigEd
Just to note, you also started a new thread:
Linux now running on the 6502