Linux for the Sega MegaDrive
Linux for the Sega MegaDrive
The LinuxMD 项目已成功将 Linux 内核移植到 Sega MegaDrive(在北美被称为 Sega Genesis)。这一成就通过利用 Mega EverDrive 卡带来绕过控制台的原生内存限制,并为现代内核的启动提供必要的硬件环境。
Hardware Requirements and Memory Management
在 Sega MegaDrive 上运行 Linux 需要特定的硬件来扩展系统的能力,使其超出其原始的 1980 年代的规格。该项目依赖于 Mega EverDrive Core or Pro 卡带,它通过特殊的 SSF2 mapper 提供 4MB 的 RAM。这至关重要,因为 MegaDrive 原生的 RAM 不足以支持 Linux 内核。
Software Stack and Build Process
LinuxMD 环境是使用自定义工具链、引导加载程序和轻量级根文件系统构建的。构建过程涉及几个不同的阶段:
- Toolchain: 使用 Buildroot 构建
m68k-linux工具链,能够为 68000 CPU 生成二进制文件。 - Bootloader: 使用 U-Boot 处理内核镜像的初始加载。
- Kernel: 编译并加载 Linux 内核镜像 (vmlinux.lz4)。
- Root Filesystem: 使用包含
smolutils的erofs镜像作为 rootfs。 - Utility Tools: 使用名为
medtool的自定义工具与 EverDrive 进行串口控制台通信。
对于没有物理硬件的人,该项目包含一个 QEMU fork,可以模拟 MegaDrive 和 EverDrive 的特定 mapper 和定时器寄存器,尽管作者指出 QEMU 模拟的 CPU 速度明显快于真实硬件。
System Performance and Interface
虽然可以运行,但该移植版本目前面临严重的性能瓶颈。作者指出系统“极其缓慢”,特别是在与 EverDrive FIFO 交互时,并建议需要进一步的优化。
尽管存在性能问题,该项目实现了两种主要的系统交互方式:
- Serial Console: 通过使用
medtool和minicom的 USB 连接到 PC 进行访问。 - VDP Console: 一个利用 MegaDrive 原生视频输出的自定义控制台。该接口包含一个用于指示内核正在运行的“心跳”绿框和一个用于指示磁盘活动的红框。
Community Insights and Technical Context
围绕该项目的技术讨论突显了该移植版本的历史和架构上的好奇心。社区成员注意到 MegaDrive 的 CPU 配置(Motorola 68000 和 Z80)与 TRS-80 Model 16 等早期 Unix 机器的相似性。
关于内存限制,一位贡献者观察到:
"I was wondering how it was squeezed into 64KB of RAM but it uses the 4MB on the Everdrive cart. With that it makes sense, considering Linux can run on an N64 with 4MB of RAM."
另一位用户指出了关于 MMU 的特定架构限制:
"The lowly 68000 in the Sega doesn't have a memory management unit required for the full Linux experience, so what's really running here is a kernel compiled with the -nommu option."