Skip to content
Advertisement

Why does Raspberry Pi need an OS to work?

I am just new to world of electronics. I was just looking about Raspberry Pi as I want to work on it, but a thing that I found that everyone is installing an OS first on the Raspberry Pi. I have worked upon PICs(16f) and Arduino board and it doesn’t need that I just write a code and make burn on the board Can I do this with the Raspberry Pi?

Can’t we just use an IDE to program the Raspberry Pi in python rather than installing an OS? Please explain if I conclude something wrong about the Raspberry Pi.

Advertisement

Answer

Long story short, the Pi is too complex hardware-wise to operate without an OS (for the vast majority of tasks, anyway).


An operating system is essentially an environment for your program to work in. It provides standardized means to use and manage hardware, interrupts, storage (incl. filesystems), I/O etc. What is more inportant, it does all the non task-specific heavy lifting in those tasks. So, you yourself only have to implement task-specific logic.

Without an operating system, you’ll have to include all that functionality (or rather, the part of it that your task-specifc logic needs) into your program (that is called a “bare bones” programming environment). If the hardware is simple and unified enough (e.g. a specific model of a microcontroller), that it easy enough. But if the task of operating the hardware is complex enough and/or you need to support many different hardware configurations, it simply becomes too taxing to implement all that by hand each time.


For example, you said you’d like to write your program in Python.

A Python program doesn’t exist in vacuum. It’s run by a Python interpreter — that needs to already be installed on the system so that you can feed your program to it. Likewise, the interpreter itself is written for a specific environment. E.g. CPython uses the C standard library. That library in turn may delegate work to whatever environment it is written to work in — e.g. system calls of a specific OS. Finally, the OS, run by the system’s CPU, interacts with peripheral devices in whatever ways the specific hardware environment is designed to (I/O ports, memory-mapped I/O, various standardized I/O protocols (like SATA) which typically consist of reading and writing hardware registers in devices and handling interrupts from them and the CPU itself; large data transfers are nowadays usually done with DMA, a session of which the OS logic still needs to set up.)

So if you’re going to work without an OS, you’ll need to implement any of those layers yourself first that would work in a Pi bare bones environment — all just to run a simple Python program. You can take a look at Raspberry Pi Bare Bones – OSDev Wiki to get an idea of what that experience is like.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement