Booting Linux on Intel 4004: A Retro Computing Feat

BY Mark Howell 23 h ago6 MINS READ
article cover

Today in Edworking News we want to talk about Slowly booting full Linux on the intel 4004 for fun, art, and absolutely no profit TL;DR I booted Debian Linux on a 4-bit intel microprocessor from 1971 - the first microprocessor in the world - the 4004. It is not fast, but it is a real Linux kernel with a Debian rootfs on a real board whose only CPU is a real intel 4004 from the 1970s. The video is sped up at variable rates to demonstrate this without boring you. The clock and calendar in the video are accurate. A constant-rate video is linked below.

In the beginning...

In 2012, I ran real Linux on an 8-bit microcontroller (AVR), setting a new world record for the lowest-end machine to ever run Linux. This project naturally extended into something faster and more practical. However, nobody tackled the actual record for about eleven years. In 2023, advancements were made with an AVR using less RAM and another project booting Linux on a MOS 6510, an older-style 8-bit CPU. This motivated me to set a new low bar by booting Linux on the Intel 4004, the first commercially-produced microprocessor from 1971.

The 4004

The Intel 4004 operates on 4-bit quantities and has a unique instruction set. It lacks logical operations like AND, OR, or XOR. Instead, it primarily uses ADD and SUB instructions. The 4004 has 16 internal registers, each 4 bits in size, and a 12-bit Program Counter (PC). It also features a hardware return stack that is 4-deep. The chip was designed for calculators, evident from its instruction set and the use of DRAM for its internal state.

The Intel 4004, the world's first commercially-produced microprocessor.

Memory and I/O in the 4004

The 4004 lacks complete processor capabilities, relying on external memory chips like the 4001 ROM and 4002 RAM. The 4001 contains 256 bytes of data and a 4-bit I/O port, while the 4002 has 320 bits of DRAM and a 4-bit output-only port. The 4004 can address up to 8 banks of RAM, each containing 4 4002 chips. The memory addressing is rudimentary, with no addressing modes or pointers. Memory operations are multi-step processes involving selecting a memory bank and sending addresses via the SRC instruction.

Performance and Clocking

The 4004 executes instructions in cycles composed of 8 clock phases. It requires a two-phase non-overlapping clock at 740KHz. Intel's 4201 chip can generate this clock and reset signals. The 4004 operates at a supply voltage of -15V, using inverted logic on all pins.

Emulating the 4004 System

I developed a 4004 emulator ("u4004") to test the feasibility of running Linux on the 4004. The emulator grew to include a virtual SD card, SPI UART chip, VFD, and the same layout of 4002s planned for the hardware. The MIPS R3000 architecture was chosen for emulation due to its simplicity and efficiency in code space. The emulator's code was optimized for space and speed, with lookup tables for logical operations and multiplication.

Hardware Development

The final hardware design aimed to be artistic and retro, with through-hole components and no vias. The board includes a 4201 clock generator, 4004 CPU, 4002 RAM chips, a 4289 ROM controller, and modern components like SPI PSRAM and a VFD display. The VFD adds retro flair, and the UART chip enables serial communication. The board is powered via USB-C, with a combination of modern and vintage components.

The final hardware design, featuring the Intel 4004 and modern components.

Booting and Running Linux

The firmware initializes the TLB entries, VFD, UART, and SD card. It loads the first SD card sector into RAM and jumps to the code there. The second loader, written in C, reads the partition table, loads the Linux kernel, and jumps to its entry point. The Linux system uses a paravirtualized disk driver for efficient disk access. The guest CPU operates at around 74.73Hz, with time dilation of 14,030x.

The Artistic Aspect

The project aims to be an artistic piece, with the board designed to be hung on a wall. It can display the Mandelbrot set on the VFD or build the Linux kernel from source over several years. The board's power consumption is around 6W, making it suitable for continuous operation.

The Mandelbrot set, which can be displayed on the VFD.

Building Your Own

The schematics and Bill of Materials (BOM) are provided for those interested in building their own system. The project can be assembled using a combination of vintage and modern components. Kits and pre-built boards may also be offered.
Remember these 3 key ideas for your startup:

  1. Innovate with Constraints: This project demonstrates how innovation can thrive under constraints. By working with the limited capabilities of the Intel 4004, new techniques and optimizations were developed. Startups can apply this principle by embracing constraints to drive creative solutions. For more insights, read about how to determine realistic goals for a project.

  2. Leverage Emulation: Emulation played a crucial role in this project, allowing for extensive testing and development before building the actual hardware. Startups can use emulation to prototype and test their products, reducing development time and costs. Learn more about how to successfully manage application development projects.

  3. Optimize for Efficiency: The project's success relied on optimizing code for space and speed, demonstrating the importance of efficiency. Startups should prioritize efficiency in their processes and products to maximize performance and minimize resource usage. Check out these best productivity hacks to get your work done efficiently.

Edworking is the best and smartest decision for SMEs and startups to be more productive. Edworking is a FREE superapp of productivity that includes all you need for work powered by AI in the same superapp, connecting Task Management, Docs, Chat, Videocall, and File Management. Save money today by not paying for Slack, Trello, Dropbox, Zoom, and Notion.
For more details on building your own system, you can download the disk image for the SD card here and the main download here.

Much thanks to my cats for keeping me company, Eric (TubeTimeUS) for loaning me MCS-04 chips, eBay for supplying old chips, and M @ Entropic for helping fix the power supply. Special thanks to MCS-04 "collectors" for making this project challenging by hoarding chips.

Vintage components.
For more information and to see the full video, visit here.
For more details, see the original source.

article cover
About the Author: Mark Howell Linkedin

Mark Howell is a talented content writer for Edworking's blog, consistently producing high-quality articles on a daily basis. As a Sales Representative, he brings a unique perspective to his writing, providing valuable insights and actionable advice for readers in the education industry. With a keen eye for detail and a passion for sharing knowledge, Mark is an indispensable member of the Edworking team. His expertise in task management ensures that he is always on top of his assignments and meets strict deadlines. Furthermore, Mark's skills in project management enable him to collaborate effectively with colleagues, contributing to the team's overall success and growth. As a reliable and diligent professional, Mark Howell continues to elevate Edworking's blog and brand with his well-researched and engaging content.

Trendy NewsSee All Articles
Try EdworkingA new way to work from  anywhere, for everyone for Free!
Sign up Now