Can Linux running on 6502?

Let's talk about anything related to the 6502 microprocessor.
Post Reply
clockrun
Posts: 3
Joined: 02 Aug 2004

Can Linux running on 6502?

Post 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.
I am a Chinese~
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Post 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.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post 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.
b0rje
Posts: 2
Joined: 07 Sep 2004

Post 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
Tancor
Posts: 113
Joined: 18 Dec 2002
Contact:

Post 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.
-Tony
KG4WFX
wirehead
Posts: 59
Joined: 24 Mar 2004
Location: Bay Area, CA
Contact:

Post 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.
kc5tja
Posts: 1706
Joined: 04 Jan 2003

Post 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).
ninja
Posts: 6
Joined: 09 Feb 2005
Location: China Mainland

Post by ninja »

Some versions of Linux for embeded applications needn't MMU
kc5tja
Posts: 1706
Joined: 04 Jan 2003

Post 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.
leeeeee
In Memoriam
Posts: 347
Joined: 30 Aug 2002
Location: UK
Contact:

Re: Can Linux running on 6502?

Post 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.
asmlang_6
Posts: 53
Joined: 20 Jul 2005
Location: Hawaii

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

---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
johnwbyrd
Posts: 89
Joined: 01 May 2017

Re: Can Linux running on 6502?

Post 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
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Can Linux running on 6502?

Post by BigEd »

Just to note, you also started a new thread:
Linux now running on the 6502
Post Reply