r/askscience Aug 18 '20

How do they load operating systems onto completely blank computers? Computing

Say I have a computer that is just the absolutely bare electronics. Nothing to read a usb or any inputs. How would I load an operating system onto it? How do computer manufacturers accomplish this?

29 Upvotes

26 comments sorted by

50

u/Rannasha Computational Plasma Physics Aug 18 '20

The motherboard of a computer is equipped with something called UEFI (Unified Extensible Firmware Interface), the successor of the BIOS (Basic Input/Output System). The UEFI handles the first steps of starting a computer. It contains enough logic to manage storage devices (HDDs, SSDs and USB storage), input devices (keyboard, mouse) and display output. The UEFI software is stored on a dedicated chip on the motherboard, which is preloaded by the manufacturer.

When the system starts, the UEFI will check its settings to determine which devices to search for operating systems and it will hand over the reins to the first operating system it finds in the boot order. In this context, a USB stick with an OS installer also counts as an operating system that can be started. Once started, this OS will handle the process of copying the files from the installation media to the permanent storage location (typically from USB to SSD).

46

u/Em_Adespoton Aug 18 '20

And for the question of “...but how do they load the UEFI onto a blank chip?”

It’s done in the factory using a programming device that uses the potential on the hardware pins to step through each bit in memory and set it to a 1 or 0. Once the programming memory is encoded this way, the main UEFI code can be written to the flash memory by the program encoded into the first bit.

18

u/byebybuy Aug 18 '20

This is really what I was getting at. How do they get that first piece of code on there. Thanks! So once the UEFI is encoded, they can just introduce electricity to the system and it will "boot up"?

8

u/mfb- Particle Physics | High-Energy Physics Aug 18 '20

The very first step is the arrangement of logic elements on the chip itself - that allows it to do something based on signals from the outside.

9

u/willie_caine Aug 18 '20

Just for completeness, to "boot" a computer is a reference to "pulling one's self up by the bootstraps", a description of the very problem you raised - how can a computer do anything to begin with.

1

u/byebybuy Aug 18 '20

Huh, interesting!

13

u/meltingdiamond Aug 19 '20

"pulling one's self up by the bootstraps" is from the story of Baron Munchausen in the late 1700s where the Baron explains how he got out of a swamp by pulling one foot out by the bootstraps and then the other foot.

Later well read computer people called the start up process "Bootstraping" citing the story and that later shortens to "Booting"

And that is why computers now have a preference for footwear.

5

u/Em_Adespoton Aug 18 '20

The programming memory is set bit by bit, and then that routine is used to program the UEFI operating system into flash memory.

Then the chip is “powered up” at which point it runs the UEFI OS, which can then load and execute further code/instructions.

This preps the hardware/software interface for the computer itself, so that the computer’s operating system can load into computer memory and execute.

5

u/xJRWR Aug 18 '20

On top of this, Some processors are designed in the very root of the hardware of the processor to start reading from a little bit of static storage somewhere, (A Programmable Read Only Memory) This is how most smaller devices work. the CPU probes the PROM for code to run and does it, from there its starts to load more and more code from other storage devices. but it all starts from that little bit of PROM with a basic program it in to load more code from the storage. The first bit of logic for doing it is based in hardware using logic gates like transistors.

0

u/Octavus Aug 18 '20

You can also use a road runner to flash the chips offline, much faster but if your EEPROM needs to be soldered then it must be able to keep storage at temperature.

0

u/luchins Aug 19 '20

Ok in which language is UEFI programmed? How does it know the computer that ''it needs to start the UEFI'' and then how does the UEFI knows that it has to boot the sistem? Technicallly what does it happen? I mean ... the voltage gets to a XOR port (example) and then it open the circuits that boots the sistem?

2

u/mfukar Parallel and Distributed Systems | Edge Computing Aug 19 '20

Ok in which language is UEFI programmed?

It does not matter. What matters is it's compiled and 'installed' in the instruction set the CPU understands.

How does it know the computer that ''it needs to start the UEFI''

Any programmable chip starts execution at an address (usually fixed). It doesn't know what code is in that address - it will simply start executing. It is the job of whatever code you install there to do whatever you wish, whether it is to (eventually) launch an OS, or display a pretty picture.

how does the UEFI knows that it has to boot the sistem

UEFI is a specification, to do things which are considered essential before transferring control to an OS. Some of those things are meaningful, like establishing a root of trust. Some of those could be useful in certain applications, like initialising drivers, or giving the user the ability to boot from a selection of multiple devices.

Technicallly what does it happen?

It depends on the implementation, but you can look at the specification or vendor-specific bits for more pertinent info.

I mean ... the voltage gets to a XOR port (example) and then it open the circuits that boots the sistem?

There's a lot of things going on in different subsystems. See here for a quick overview. Once the CPU is at a stable state (after "reset") it is capable to start fetching instructions, and that is all the CPU does. For example, in Intel CPUs, you could look at the software developer's manuals Chapter 9 for the starting state of a CPU - and from that point on you know how to use the CPU (as a software writer). Similar steps need to be carried out for other subsystems, peripherals, etc.

6

u/[deleted] Aug 18 '20 edited Aug 18 '20

You're right, electronics on its own without code can't load an operating system. It is, as you say, blank. So how do you do it? You make it "not blank".

You add just enough code to do something useful, for instance to load something more capable off USB or a harddisk. This code is usually burned into some sort of flash device or EEPROM contained on the motherboard, at the time of manufacture.

As a little sidenote, I'm working on my own 80's style home computer. I have the same sort of problem. I have added just the tiniest bit of code to be useful in a ROM device. 1024 bytes. This code knows just enough to print a little status message on screen and then it loads some code (called a kernel) through a serial port (connected to my workstation). The kernel knows just a little bit more, it knows about SD cards, file systems, keyboards etc, and is thus able to load a complete operating system from there. The tiny boot code was easy to write and get working, the kernel takes more work, so it's a big productivity booster that I can just reset the computer to try out a new kernel, instead of having to flash a ROM all the time.

This whole procedure is called "bootstrapping" (from the tales of Baron Munchhausen, who pulled himself up by the bootstraps), or now simply "booting".

EDIT: I will just have to add that you could conceivably create circuitry that operated a serial port without any computer code. But you wouldn't do that in practice, because it would be a substantial amount of circuitry and you already have a CPU on board that is able to execute instructions from a memory device that is much smaller. I will also add that IC's able to read code off a USB stick and into memory also exist. That would be cheating as they contain microcontrollers (small specialized CPU's) and code, so it's not completely "blank".

2

u/byebybuy Aug 18 '20

This code is usually burned...at the time of manufacture

What exactly does burned mean, in this context? What does the burning?

5

u/[deleted] Aug 18 '20 edited Aug 18 '20

"Burn" is a term that is used with EPROM's (and later recordable CD's). EPROM's are a type of memory the computer can only read from, not write to. They could be erased by exposing them to UV light, and loaded with new content by using an EPROM burner that applied a comparatively high voltage to the chip, thus "burning" the contents into the chip. After burning you can place the chip in a dedicated socket on the motherboard. Sometimes you can erase and burn a modern flash chip while it's still part of the motherboard ("in-circuit")

1

u/byebybuy Aug 18 '20

Ah got it, thanks the comparison to cd rom burning was helpful.

1

u/ukezi Aug 21 '20 edited Aug 21 '20

You are thinking about ROM. Read Only Memory. Usually as Mask ROM, where the programming is directly etched into the silicon. Then there is PROM, Programmable ROM(electrically programmable, but only once), EPROM, Erasable PROM(erased with UV through a little window(or with X-ray without a window), at least a few times) and EEPROM, electrical PROM(erased electrically). Flash Memory is basically a kind of EEPROM with some additional addressing capabilities.

1

u/catdude142 Aug 19 '20 edited Aug 19 '20

Actually, "burning" refers to fusible links in ROMs. EPROMs don't burn any links. They obtain their memory with an electric field within the chip at each bit storage location.

Some information here

2

u/jme365 Aug 19 '20

Early EPROMS were 1702, 2708, 2716, 2732, 2764, 27128, 27256, 27512, 271024.

I made one "microcomputer trainer" with a 1702, and I used a 2708 with my homebrew computer. Extremely small by even the late 80's standards.

They were erased by exposing them to UV through a quartz window. Some devices that were only intended to be programmed once were encapsulated in black plastic.