[HN Gopher] Linux/4004: booting Linux on Intel 4004 for fun, art...
___________________________________________________________________
Linux/4004: booting Linux on Intel 4004 for fun, art, and no profit
Author : dmitrygr
Score : 391 points
Date : 2024-09-20 11:04 UTC (11 hours ago)
(HTM) web link (dmitry.gr)
(TXT) w3m dump (dmitry.gr)
| blueflow wrote:
| At 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 wrote:
| I 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
| alnwlsn wrote:
| We need this for the Usagi Electric vacuum tube computer.
| dmitrygr wrote:
| I'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 wrote:
| At 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 wrote:
| CPU-by-correspondence!
| adrian_b wrote:
| Very 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 wrote:
| No 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.
| dboreham wrote:
| Glad to see someone besides me posting this whenever 4004
| history-rewriting comes up.
| klelatti wrote:
| Your argument is that because the 4004 was built to power a
| calculator that disqualifies it as a microprocessor?
| Independent of the actual nature of the 4004 itself and its
| potential applications beyond its first intended use? Can't
| see how that makes sense at all.
|
| Your statement about Intel 'pushing back' the date to 1971
| also makes little sense given Intel advertised [1] the 4004
| as a CPU in Electronic News in Nov 1971.
|
| [1] https://en.wikipedia.org/wiki/Intel_4004#/media/File:Inte
| l_4...
| dmitrygr wrote:
| The naming and propaganda wouldn't matter. I just wanted
| something lower-end for sure than a 6510 and an AVR. 4004 is
| that
| cdchn wrote:
| Is this the oldest piece of hardware that's ever run Linux,
| I'm left wondering?
| dmitrygr wrote:
| It surely is
| cdchn wrote:
| I'd figure the earliest thing anybody has run Linux on
| before this would be a 386. Although I suppose with this
| MIPS emulator ported to some other proto-processors it
| could go older, but just getting the hardware to do that
| would be a challenge.
|
| PS: love the VFD
| fortran77 wrote:
| There was a 286 Xenix, and Minix (which inspired Linux)
| ran on an 8088.
| cdchn wrote:
| Yeah, and UNIX was developed on a PDP-7 as far back as
| 1969. But I was talking about Linux.
| kens wrote:
| I'm glad to see the Datapoint 2200 is getting attention, but
| by reasonable definitions of "microprocessor", the Intel 4004
| was first, the Texas Instruments TMX 1795 was second, and the
| Intel 8008 was third. It seems like you're ruling out the
| 4004 on the basis of "intent" since it was designed for a
| calculator. But my view is that the 4004 is a programmable,
| general-purpose CPU-on-a-chip, so it's a microprocessor. Much
| as I'd like to rule out the 4004 as the first microprocessor,
| I don't see any justifiable grounds to do this.
|
| Intel's real innovation--the thing that made the
| microprocessor important--was creating the microprocessor as
| a product category. Selling a low-cost general-purpose
| processor chip to anyone who wanted it is what created the
| modern computer industry. By this perspective, too, the 4004
| was the first microprocessor, creating the category.
|
| My article in IEEE Spectrum on this subject goes into much
| more detail: https://spectrum.ieee.org/the-surprising-story-
| of-the-first-...
| artyom wrote:
| I 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 wrote:
| The video took 9 days to film. 4 hours per emulated second.
|
| Also I wonder why he's using Windows 95?
| danirod wrote:
| Sorry for the nitpick, but the laptop in the video looks like
| Windows 2000
| phatskat wrote:
| The best Windows imo
| pkphilip wrote:
| True
| dmitrygr wrote:
| Windows 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 wrote:
| Virtual 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/UCSD_Pascal
| eqvinox wrote:
| oof. 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 wrote:
| While 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)
| jart wrote:
| There needs to be something like a Nobel Prize for this kind of
| thing.
| seqizz wrote:
| Probably closest would be the Ig:
| https://en.wikipedia.org/wiki/Ig_Nobel_Prize
| jart wrote:
| That'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 wrote:
| Supposed to be, apparently.
| sitkack wrote:
| To the winners of an Ig Nobel, it is often their most
| cherished award.
| qwerty456127 wrote:
| Running 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.
| zamadatix wrote:
| Many things which receive an Ig Nobel (but not all) are
| bona fide <thing> that just happen to be funny or have a
| particularly strong aspect (not necessarily in their
| entirety) of triviality. I'd be honored if I did a project
| like this that got enough attention and generated enough
| amusement to deserve an Ig Nobel instead of offended I'm on
| the same list as projects that weren't all genuinely
| representative works of the field.
| 6SixTy wrote:
| There's the Turing award, which is an equivalent prize for
| computing. Could add an acknowledgement for strange and unusual
| applications of computer science.
| jesprenj wrote:
| > 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 wrote:
| I 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 wrote:
| Yes. 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 wrote:
| Update us please!!
| whartung wrote:
| I 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 wrote:
| I like the second version!
| rx_tx wrote:
| the "World's longest song" is from John Cage, called As Slow
| As Possible and is played continuously on an organ in a
| church in Germany.
|
| It will be completed in the year 2640.
|
| https://en.wikipedia.org/wiki/As_Slow_as_Possible
| teaearlgraycold wrote:
| I'd assume you'd have at least a few bit flips occur in the
| process.
| dmitrygr wrote:
| Very large-process DRAM with frequent refreshing, in ceramic
| cases. It might last long enough without flips
| 01HNNWZ0MV43FF wrote:
| Ars Longa, Vita Brevis
| alnwlsn wrote:
| Wow 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.
| hilbert42 wrote:
| Mission impossible -- do it with Windows!
| dmitrygr wrote:
| Windows 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.
| Pet_Ant wrote:
| In 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 wrote:
| Probably nothing unless you want to emulate it on severely
| underpowered hardware.
| TapamN wrote:
| It'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 wrote:
| Okay, so it's more about IMM representation within the
| bytecode rather than some memory addressing mode.
| dmitrygr wrote:
| Well, 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
| molticrystal wrote:
| I 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 wrote:
| Fixed the typo. Thanks
| garganzol wrote:
| The proof of the Turing Completeness Theorem in action.
| Beautiful. Boot time is ~5 days.
| johnklos wrote:
| Wow. 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 wrote:
| I 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.
| johnklos wrote:
| I installed Windows 95 on an Amiga 3000 with a 25 MHz m68030
| via floppy to see if DMF formatted disks would work and to
| play around. By the time it finished, I had forgotten what I
| wanted to try out.
| noufalibrahim wrote:
| There was something called Agora
| (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 wrote:
| There 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?
| jylam wrote:
| That's basically the concept of Turing Completeness. Any Turing
| complete system can run anything. It may be _very_ slow, but it
| will run. ChatGPT could run on a 4004, all you need is time.
| qwerty456127 wrote:
| https://cs.stackexchange.com/a/60978
| byteknight wrote:
| And a gargantuan amount of RAM.
| pclmulqdq wrote:
| A computer is technically not a Turing machine due to the
| lack of infinite RAM. It is a finite state machine with an
| absurdly large state space.
| brudgers wrote:
| Because it has infinite RAM, technically the Turing machine
| is not a machine.
| tcbawo wrote:
| Can't any computer with external connectivity (ie serial or
| network connectivity) be considered to have infinite
| memory?
| johnklos wrote:
| I've always interpreted the definition of storage as
| arbitrarily large, not specifically infinite. The universe,
| after all, is finite. The "well, acshually" arguments
| aren't interesting, because they're 100% abstract.
| brudgers wrote:
| _That 's basically the concept of Turing_
|
| Tarpit,
|
| where everything is possible but nothing of interest is easy.
|
| https://en.m.wikipedia.org/wiki/Turing_tarpit
| retrac wrote:
| 15 MHz m68030 with a 16 bit memory bus and 10 megabytes of RAM
| -- A Mac LC II, by any chance? :)
|
| > towards the late '80s and early '90s
|
| By the late 1960s, really. It would probably be possible to
| port Linux to the IBM Model 67 [1]; might even be easy since
| GCC can already target the instruction set. The MMU is
| sufficient. Maybe a tight squeeze with the max of 2 MB of fast
| core. Would be in a similar ballpark, a bit slower, to that
| 68030 machine.
|
| Full virtualization, and hardware enforced memory and IO
| boundaries, were invented early on, too. It took a while for
| such features to trickle down to mini- and then micro-
| computers. And then much longer for popular software to take
| advantage.
|
| [1] https://en.wikipedia.org/wiki/IBM_System/360_Model_67
| vincent-manis wrote:
| I have fond memories of the System/360 M67 (and its
| successors, starting with a System/370 M168) I used from 1970
| to the early 1980s. It ran the Michigan Terminal System, and
| we had all the modern conveniences (terminal operation in the
| IBM world was klunky, but PDP-10s at the same time did that
| right). And of course Unix dates from exactly that period.
|
| The fact that Linux runs well on a modern zSeries
| demonstrates that, even with all the historical baggage this
| 60+-year-old architecture has, it carries with it many of the
| architectural innovations that current OSes and languages
| need.
| StefanBatory wrote:
| This is absolutely insane - hats off to you. To say it's
| impressive it's like to say nothing.
| Max-q wrote:
| This 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 wrote:
| Make it out of transistors and i'll port my MIPS emulator to it
| :)
| immmmmm wrote:
| Have you considered porting to the vacuum tube 1 bit / 1 Hz
| MC14500 clone?
|
| https://hackaday.com/2021/12/27/single-bit-computer-from-
| vac...
| dmitrygr wrote:
| a thought!
| hnpolicestate wrote:
| See below for boot time after optimization.
| dmitrygr wrote:
| That 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 wrote:
| Yes my fault. Editing original post.
| anyfoo wrote:
| Only 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 wrote:
| it was
| qwerty456127 wrote:
| Didn't anybody try to build a 4004 core running at some hundreds
| MHz?
| dmitrygr wrote:
| not 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 wrote:
| This 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... :)
___________________________________________________________________
(page generated 2024-09-20 23:00 UTC)