8 ms·
Linux/4004: booting Linux on Intel 4004 for fun, art, and no profit
- ylmzhamdi 2y agoOpen source culture, why can't we hack the Linux kernel and make 16 or 8 bit versions of it?
- ylmzhamdi 2y agoThe open source culture may be offer.. İsn't it? Why can't we hack the Linux kernel and make it 16 or 8 bit versions of linux?
- blueflow 2y agoAt first i was like "I'm pretty sure this is bullshit or some cheat used" but then i was like "Oh, its dimitry." Impressive work, as always.
- ssrc 2y agoI mean, it's fun and interesting bullshit that cheats a lot. I'm sure that you could emulate a MIPS using a one-bit processor like the MC14500[0] with enough supporting hardware, real or virtual. Looking forward to it, Dimitry. [0] https://en.wikipedia.org/wiki/Motorola_MC14500B https://en.wikipedia.org/wiki/Motorola_MC14500B
- dmitrygr 2y agoI’ll work on setting a new lower record every ten years or so. My guess at the next three steps: one bit controller, transistors only, vacuum tubes.
- mrguyorama 2y agoAt some point you will just need to offload the actual "processing" part to some nice old chap named Dave who has himself an abacus, and every now and then you send him a letter and he moves some stones and sends a letter back with the result.
- dmitrygr 2y agoCPU-by-correspondence!
- MobiusHorizons 2y agoI think you have invented the most cursed form of virtualized cloud computing where the memory is connected by a very slow network. Bit of course you can solve this by sending letters speculatively, and having Dave keep copies of his letters back to you so he reference them for recently set values, that way you can at least keep Dave busy while the letters are in flight.
- Frenchgeek 2y agoObligatory https://xkcd.com/505 https://xkcd.com/505 , I think.
- alnwlsn 2y agoWe need this for the Usagi Electric vacuum tube computer.
- adrian_b 2y agoVery impressive work, but most of the work has been necessary because Intel 4004 was not really the first microprocessor, this was just BS propaganda used by Intel to push back by one year the date of the launch of the first microprocessor, to 1971. The first true (civilian) microprocessor was Intel 8008, in 1972. Intel 8008 was a monolithic implementation, i.e. in a single PMOS integrated circuit, of the processor of Datapoint 2200, therefore it deserves the name "microprocessor". The processor of Datapoint 2200 had an ugly architecture, but there is no doubt that it was a general-purpose CPU and traces of its ISA remain present in the latest Intel and AMD CPUs. On the other hand, the set of chips that included Intel 4004 was not intended for the implementation of a general-purpose computer, but it was intended just for the implementation of a classic desktop calculator, not even a programmable desktop calculator. This is the reason for the many quirks of Intel 4004, e.g. the lack of instructions for the logic operations, and many others that have increased the amount of work required for implementing a MIPS emulator suitable for running Linux. Even if Intel 4004 was intended for a restricted application, after Intel has offered to sell it to anyone, there have been many who have succeeded to use it in various creative ways for implementing microcontrollers for the automation of diverse industrial processes, saving some money or some space over a TTL implementation. In the early days of the electronics industry it was very normal to find ways to use integrated circuits for purposes very different from those for which the circuits had been designed. Such applications do not make Intel 4004 a true microcontroller or microprocessor. Very soon many other companies, and later also Intel, have begun to produce true microcontrollers, designed for this purpose, either 4-bit or 8-bit MCUs, then Intel 4004 has no longer been used for new designs.
- MarkusWandel 2y agoNo kidding about unusual uses of ICs. Not related to microprocessors, but I have an old analog triple conversion HF receiver (Eddystone EC958/3 for what it's worth) that uses a TTL IC in an analog circuit! I'd have to look at the schematic again, I think it's a multi-stage counter, but basically what it uses it for is to generate a comb shaped spectrum, one "spike" of which can then be picked up by an analog circuit and locked to, to generate precisely spaced tuning steps for the high stability tuning.
- 2y ago
- artyom 2y agoI didn't know the guy but he clearly knows what he's doing, it's unbelievably entertaining to read the details of achieving an impossible task with the most underpowered tool possible.
- eulgro 2y agoThe video took 9 days to film. 4 hours per emulated second. Also I wonder why he's using Windows 95?
- danirod 2y agoSorry for the nitpick, but the laptop in the video looks like Windows 2000
- dmitrygr 2y agoWindows 2000 For the video, i wanted a laptop with a real serial port (no usb). This one fit the bill and was $20 on eBay. Windows 2000 is the prettiest windows IMHO, so that’s what I installed for the demo video.
- PaulHoule 2y agoVirtual machine (as in the Z-machine or the JVM) worked on early micros when you couldn’t use them as compiler targets. See https://en.wikipedia.org/wiki/SWEET16 https://en.wikipedia.org/wiki/SWEET16 https://en.wikipedia.org/wiki/UCSD_Pascal https://en.wikipedia.org/wiki/UCSD_Pascal
- eqvinox 2y agooof. amazing. …you can see in the high PC bits what's currently executing! P.S.: Still loads the kernel faster than a virtual ISO on a server's shitty IPMI over the internet ;D
- dmitrygr 2y agoWhile it boots, you can look at LEDs and map them to kernel function easily by running “nm” on vmlinux. Also, when in user space, you can tell between the main binary (way below 0x01000000) and shared libraries (loaded high near 0x77000000)
- abound 2y ago> Still loads the kernel faster than a virtual ISO on a server's shitty IPMI over the internet This gave me flashbacks of trying to boot Dell M1000e blade servers from an NFS-hosted ISO running on a Raspberry Pi, which was painfully slow to boot and run.
- jart 2y agoThere needs to be something like a Nobel Prize for this kind of thing.
- seqizz 2y agoProbably closest would be the Ig: https://en.wikipedia.org/wiki/Ig_Nobel_Prize https://en.wikipedia.org/wiki/Ig_Nobel_Prize
- jart 2y agoThat's kind of insulting honestly. Getting Linux to run on an i4004 is bona fide engineering. More real than engineering that we're paid to do most times. Looking at the list of Ig Nobel Prize winners it sounds like The Onion but not funny.
- fortyseven 2y agoSupposed to be, apparently.
- sitkack 2y agoTo the winners of an Ig Nobel, it is often their most cherished award.
- qwerty456127 2y agoRunning a modern kernel on a 4004 just doesn't sound too far from running it on an incandescent light bulb or on a potato. No doubt sorcerer level engineering.
- bschmidt1 2y agoRunning Linux on a computer? I could understand your comment if the display was something very non-conventional like a series of lightbulbs instead of digital output. It's a cool project don't get me wrong, but Nobel Peace Prize? What is this thread? I would consider something like a strandbeest to be more award-worthy - but it too is just a neat invention, not contributing to world peace or anything near it.
- jesprenj 2y ago> But for the one I'll have hanging in my office, I have loftier goals. With swap enabled, the kernel sources can actually be built right on-device. It will take some number of years. The partition where the kernel lives is /dev/pvd2 and is mounted under /boot. The device can build its own kernel from source, copy it to /boot/vmlinux, and reboot into it. If power is interrupted, thanks to ext4, it will reboot, recover the filesystem damage from the journal, and restart the compilation process. That is my plan, at least.
- Pet_Ant 2y agoI wonder of you can calculate when it will finish by counting the instructions and then pin the date it will finish and stream the completion.
- dmitrygr 2y agoYes. I have an emulator of this board (it is in the downloads too) which is much faster than the real thing. It shows how much realtime is needed to get to the current state. Doing a build in it will answer the question unequivocally.
- ladyanita22 2y agoUpdate us please!!
- whartung 2y agoI have two visions of this. One, it reminds me of that "worlds longest song" or somesuch thing, where they play a note every 10 years. The other is just a picture of someone, asleep at their desk, a pile of calendars with days checked off tossed to the side, random unwashed mugs and such all dimly lit by a desk lamp and see the `$ make linux` finally return to an new, unassuming `$` prompt. Like Neo in the Matrix.
- dmitrygr 2y agoI like the second version!
- deleted 2y ago[deleted]
- alnwlsn 2y agoWow this was not a cheap project! Thanks Ebay collectors. Also probably the only time I'd have gone for an LCD over a VFD. If you're running a multi-year long compile, it'll probably be burned in to hell by the end.
- larodi 2y agoIs a project worth receiving a honorary PHD if you ask me. Sadly university staff does not read HN too much.
- wolf550e 2y agoIt's not original research. A Master's Thesis at most, or only a Bachelor's Degree Final Project. Regardless, doing such amazing work for a blog (and geek fame) is amazing.
- capitantrueno 2y agoSince when does an honorary PhD requires original research?
- wolf550e 2y agoSorry, bad reading comprehension on my part! I see honorary PhDs often used to express political support, instead of honest admiration of achievements.
- larodi 2y agohm perhaps you right, I just meant that this is worth appraisal since it is so academic-level detailed, and I can imagine few universities where this can be a PHD thesis. I guess some parts of the whole reading can also rate original research.
- hilbert42 2y agoMission impossible — do it with Windows!
- dmitrygr 2y agoWindows ran on a similar MIPS machine (Microsoft jazz). The issue is emulating scsi. I think I’d need a lot more rom space to do that. Scam is messy and hard. The alternative is to find the Windows MIPS DDK and build a paravirtualized disk driver for it like I did for Linux. That would make it more doable.
- hilbert42 2y agoHa. Jazz a dim distant memory but methinks it's concept is ~20 later than the 4004. Just thought about emulating/writing SCSI on the 4004, might be easier to climb Everest. Perhaps we need a competition, assembly programmers only need apply. :-)
- Pet_Ant 2y agoIn the "Why MIPS?" section: > some have shitty addressing modes necessitating that they would be slow (RISCV) What is wrong with the RISC-V addressing modes?
- Rohansi 2y agoProbably nothing unless you want to emulate it on severely underpowered hardware.
- TapamN 2y agoIt's not really the addressing modes, but the instruction format. Immediate values on RISC-V are not stored contiguously on certain RISC-V instructions. On all MIPS instructions, the bits for a immediate add, load constant, branch, etc value are always stored in order. On RISC-V, the bits are (sometimes) jumbled around. For example, on a unconditional branch, the bits for the destination offset are stored in the order of bit 19, bits 9-0, bit 10, bits 18-11. In hardware, reordering that is free, you just run your wires the right way to decode it. In software, you have to do a ton of bit manipulation to fix it up. The reason RISC-V does that is to simplify the hardware design.
- Pet_Ant 2y agoOkay, so it's more about IMM representation within the bytecode rather than some memory addressing mode.
- dmitrygr 2y agoWell, lack of REG+REG and REG+SHIFTED_REG addressing modes handicaps it significantly. And no, it will not get magically fused by magic fusing fairies in your cpu
- snvzz 2y ago>lack of REG+REG and REG+SHIFTED_REG addressing modes handicaps it significantly Is this a guess, or statistically supported on a body of empirical evidence like the RISC-V spec is?
- molticrystal 2y agoI love giving the AVR example when people ask if something can run on an underpowered machine, now I have a new example to link. Considering the frequencies and wattage I wonder how RF it spits out and what is detectable and decodable on the waterfall of a SDR. By the way still reading through it, but at the time of this comment I see the word "soubroutine" which is probably a misspelling.
- dmitrygr 2y agoFixed the typo. Thanks
- garganzol 2y agoThe proof of the Turing Completeness Theorem in action. Beautiful. Boot time is ~5 days.
- johnklos 2y agoWow. And I thought modern NetBSD on a 15 MHz m68030 with a 16 bit memory bus and 10 megabytes of RAM is slow. This is crazy! It illustrates a point I've explained to many people over the years: once computers started coming with persistent storage, open address spaces and MMUs towards the late '80s and early '90s, we basically arrived at modern computing. An Amiga 3000 or i80486 computer can run the same things as a modern computer. Sure, we have ways to run things orders of magnitude faster, and sure, we now have things that didn't exist then (like GPUs that can run code), but there's no functional difference between those machines and new ones. I love that Dmitry shows how loosely "functional" can be defined :)
- dmitrygr 2y agoI don’t know if this was a thing in America, but in USSR in the 70s and 80s it was very popular to play chess-by-correspondence. You would literally snail-mail letters back-and-forth with your move. Games would last months or years. It added an extra challenge to chess because by the time you got a response, you might have forgotten what strategy you had had. This project is basically Linux-by-correspondence. The challenge is here too. By the time the command produces an output, you might have forgotten why you ran it.
- noufalibrahim 2y agoThere was something called Agora (https://en.wikipedia.org/wiki/Agora_(web_browser) https://en.wikipedia.org/wiki/Agora_(web_browser)) which was sort of an email/http proxy. You could browse the web via. email and set "GET", "POST" etc. commands. It was my first exposure to the web. It sounds very similar to what you mentioned.
- asdefghyk 2y agoThere was also a system where a person could email a request for a webpage to a certain email address and the web page would be returned by email. Existed in late 1980s? I think or maybe early 1990s?
- StefanBatory 2y agoThis is absolutely insane - hats off to you. To say it's impressive it's like to say nothing.
- Max-q 2y agoThis was a very interesting read. I have read a bit about the 4004 before so I knew it was strange. But the level of obscurity is mind-blowing. Now I just got the urge to see how well I would be able to make a CPU with the same transistor count. It's not that much fewer than a 6502. 8 bit would make it so much easier to program. Thanks for documenting your work so well!
- dmitrygr 2y agoMake it out of transistors and i'll port my MIPS emulator to it :)
- immmmmm 2y agoHave you considered porting to the vacuum tube 1 bit / 1 Hz MC14500 clone? https://hackaday.com/2021/12/27/single-bit-computer-from-vacuum-tubes/ https://hackaday.com/2021/12/27/single-bit-computer-from-vac...
- dmitrygr 2y agoa thought!
- analog31 2y agoAll it needs is to run a 4004 emulator. :-)
- hnpolicestate 2y agoSee below for boot time after optimization.
- dmitrygr 2y agoThat is before many optimizations. Current boot time (on a real 4004 at 790KHz) is ~4.5 days. At 740 it would thus be 4.8 days
- hnpolicestate 2y agoYes my fault. Editing original post.
- anyfoo 2y agoOnly started reading, but: Just to keep you on your toes, there does exist a single one-byte instruction that takes 16 cycles - FIN. However, that is only the beginning. Please tell me that was intentional.
- dmitrygr 2y agoit was
- qwerty456127 2y agoDidn't anybody try to build a 4004 core running at some hundreds MHz?
- dmitrygr 2y agonot that I found. And it makes sense since without MHz-fast 4002 and 4289, it is useless. Plus, swinging a bus from -15V to 0V at MHz speeds will take quite some drive current.
- np1810 2y agoThis is so awesome. I hope I can expand my knowledge such that I can understand most of this project, right now it was way past my limited CS proficiency. Though my highlight (which I could completely comprehend) is "Section 14.b & 14.c - Getting the data..." All it took was 400K files (~275 photos/day after 4 years). We have so much of raw power of processing, storage & network still the most-used (probably) media-sync apps crashed or faced slow sync, AirDrop fails & lack of 'Select-All' UI feature. Crazy times we live/will live in... :)
- solstice 2y agoI wonder if Dmitry considered a syncing tool like MobiusSync or Syncthing to copy the pictures to a PC continuously after they are taken.
- anshargal 2y agoI wonder if there is a simple chip, similar to the 4004, 8080, or Z80, that can run at modern high frequencies — 4–5 GHz, or even higher due to its simplicity? Not much of a practical use, but it could be fun for emulation projects. 100x slower with emulation - still fast enough for retro platforms.
- xandrius 2y agoWonderful read but that ending bit about taking the video truly hurt... It kind of shows that no one can be an expert in everything at the same time.
- roygbiv2 2y agoWhat did he do wrong? Seems he knew what he needed to do but the technology wouldn't work.
- dmitrygr 2y agoI think the implication is that there is probably a much more reasonable way to do what I was trying to accomplish, and I didn’t do that. That is almost certainly true. This was my first time trying to film such an extreme time lapse so it is quite possible that I wasn’t aware of some tools designed for it
- mkl 2y agoBogoMIPS : 0.00 Very impressive project. Recording it with a phone seems complicated though. Why not a Raspberry Pi with camera module? Or a decent webcam and any computer?
- unwiredben 2y agoAt Hackaday Supercon in 2002, the badge for attendees (https://hackaday.com/2022/10/12/the-2022-supercon-badge-is-a-handheld-trip-through-computing-history/ https://hackaday.com/2022/10/12/the-2022-supercon-badge-is-a...) implemented a fictional 4-bit CPU along with control panel for directly entering instructions and running and stepping through code. I had a huge amount of fun implementing a space shooter video game on it, as the panel included a bit-by-bit view of one of its pages of memory. Comparing its Voya4 architecture with the 4004 was fascinating. Some similar tradeoffs, but the Voya4 has the benefit of 50 years of CPU instruction set exposure. Alas, dimitygr's method wouldn't work on the badge, as the memory and RAM are all internal to the PIC24 that implements the CPU emulator. BTW, 4-bit CPUs are still made and used. Many of the mass-produced IR remotes are programmed using a 4-bit MCU. See https://www.emmicroelectronic.com/sites/default/files/products/datasheets/em6607_ds.pdf https://www.emmicroelectronic.com/sites/default/files/produc... for a datasheet.
- schubart 2y ago2022
- unwiredben 2y agoand also its Voja4, not Voya (my mistake in remembering name spellings)
- nickpsecurity 2y agoJack Ganssle’s The Embedded Muse covers tools and techniques in embedded development. In one article, he reported that 4-bit MCU’s were still competitive in some sectors: https://www.ganssle.com/rants/is4bitsdead.htm https://www.ganssle.com/rants/is4bitsdead.htm I suspected we’d see either 4- or 8-bit return for neural networks. IBM did try the kilocore processor which was a massively-parallel, 8-bit system. Multicore 4- and 8-bitters are also the kind thing people could build on cheaper nodes, like Skywater’s 130nm.
- kazinator 2y agoAnd the txr lisp virtual machine there is a t0 register, which is always nil, and that symbol can be used as an alias for it in the assembly. This was consciously inspired by the MIPS $zero. A write to t0 is not simply ignored. It will generate an exception. Another MIPS-like thing is that t1 is an assembler temporary.
- amszmidt 2y agoThe CADR had a convention for the A and M memory (essentially what we would call registers today) for the Lisp Machine microcode where the first 32 locations had special meaning. Location 2 was for constant 0, and 3 for constant -1.
- kazinator 2y agoThe funny thing is that the 4004 was used in emulation from pretty much it's beginning. It was used to make a calculator, the Busicom 141-PF. But the calculator couldn't be programmed in 4004 directly. 4004 ran virtual machine. The calculator was written in the virtual instruction set for this machine. A chip like the 4004 could be used in some simple embedded applications using its instruction set directly. But that calculator was the original application was developed for. Already that was too complicated, not unlike, say, booting Linux.
- bdbdnxjdj 2y agoWhat a great project! Especially directly emulating MIPS in 4004 It would have been far easier to write an MIPS Emulator in a tiny VM and run that VM instead of MIPS It would also be even slower ^^
- valdrinNereth 2y agoGreat job! But can you run DOOM on it?