The engineer launched Linux on an Intel 4004

The engineer launched Linux on an Intel 4004

On September 19, 2024, developer and engineer Dmytro Grinberg detailed in his technical blog that he successfully ran Linux with a rootfs environment from Debian on a 1971 Intel 4004 microprocessor that has 2300 transistors, supports 46K instructions, and provides 6 per second.

The Intel 4004 processor architecture is severely limited and can only address 4KB of permanent memory. Instead of running Linux directly, Greenberg came up with the idea of ​​writing an emulator of the MIPS R3000 processor that Linux can run on.

According to OpenNET, work on the project was complicated by the fact that no compilers for the C language exist and cannot be created for the Intel 4004, so Greenberg had to create an assembler emulator. He was able to get an emulator running directly on the Intel 4004 that ran a Linux kernel-based environment.

For the optimal option for emulation, the engineer chose MIPS, which fits within the limitations of the Intel 4004 and the size of the available memory. For example, the creation of an ARM emulator was hindered by the shift of operands, RISCV – confusing addressing modes, x86 – high memory consumption for decoding instructions, PPC – the general complexity of emulation with a small memory size.

To run programs on a real Intel 4004 system, Greenberg made a motherboard consisting of an Intel 4004 microprocessor, an Intel 4201 clock generator, an Intel 4002-1 20-byte RAM chip, an Intel 4289 non-volatile memory controller, and an ATMEGA48 microcontroller.

During the development of the project, the engineer designed and made a more complex motherboard, which additionally includes memory for hosting the Linux environment, which is launched in the emulator, and supports the simulation of permanent memory using an SD card. Also, to conduct experiments and simplify development on modern systems, Greenberg wrote an emulator of the Intel 4004 chip.

Due to the low performance of the Intel 4004, the emulator was very slow. For example, processing each virtual second in the emulated environment required almost 4 hours of computation on a real system with an Intel 4004 processor. 9 hours.

The source code of the project is available for download on the engineer’s website. The archive contains MCS-04 bus analyzer for Saleae software, source code for i4004 Dectstation2100 emulator, source code for MIPS MBR and second stage boot loaders, kernel configuration and version information, and a very scary u4004 Linux board emulator. The license is free for non-commercial use.

Also separately available for download is a specification archive, schematics, and a Linux system image to reproduce and test this solution.

After making optimizations, Greenberg achieved that booting Linux in a prepared configuration takes just over 8 days. A 120x acceleration was used when recording the full download video (one second of the video corresponds to 2 minutes of the emulated MIPS processor).

Related posts