It is possible to run a modern Linux on classic 64KB 6502-based computers such as the Commodore 64 and the Apple II.
Some ground work is in order. The basic strategy involves beefing up the 6502-based machines as much as possible and dumbing down Linux as much as possible.
The secret sauce involves writing a new, 6502-based emulation of an ARM Integrator/CP development board. The ARM Integrator/CP is still a first-class target for Linux. I think that with the make tinyconfig command with cross-compilation, we can get the size of the kernel sufficiently small to have it in expanded memory on the 6502 host.
We will need to write an ARM Integrator/CP Linux emulator in 6502/65816 assembly. This sounds a lot harder than it actually will be. While the ARM seems to have a ton of instructions, at the bit level, each 32-bit (ARM) and 16-bit (Thumb) instruction breaks neatly into its command and operand components. Most of the work will be in emulating ARM interrupts and user/supervisor modes in 6502 assembly. Each of the addressing modes will need to be handled, but no individual addressing mode will be that complicated. Contiki can be used as a microkernel on each 6502 host to abstract the details of screen, keyboard, network, and display I/O. The ARM instruction set has a lineage dating back to the original MOS chips.
Sixteen megabytes of memory will need to be added to the 6502 machines, with appropriate bank switching logic. This has been done already for each of the 6502 hosts. There is also a period-appropriate chip, the 74LS610, which was intended specifically for increasing the addressable memory on the 6502 series.
We use 65816 microprocessor (SuperCPU) instructions to access 16 MB of memory in a 6502 machine. Or, we develop a virtual memory abstraction that can arbitrarily bank in and out pages of the 16 MB into the lower 64KB of memory on each host.
To get Linux to be sufficiently small, we use make tinyconfig with a modern Linux cross-compiled kernel to get it under 8 MB. We target the armv4te instruction set in the Linux cross compile, and that’s the instruction set we emulate on the 6502.
For testing the correctness of the emulator, we run QEMU in parallel while running ARM Integrator/CP Linux on it. Write a script that single-steps both virtual machines and verifies that emulator states run in lockstep.
The performance will be abysmally slow, but who cares. Most likely the 6502 machines will, at first, themselves be running in emulation on a much faster PC.
See Woz’s SWEET16 emulator for further inspiration and basic proof of concept for the Thumb portion of ARM emulation.