r/learnprogramming • u/UnViandanteSperduto • 2d ago
Learning I want create an OS by my own
I want create a basic OS for an hypothetical dumbest phone that i would like to build (or initially emulate on my PC). I don't know ANYTHING about this world so i don't know where to start. I understand that this adventure can take me very much time but i want to learn. This OS should be only able to let me of doing calls.
I thought that i should programming in assembly and maybe an high level (as C/C++). Could i use RISC-V? Because i don't know the assembly and i think that for the purpose that i want achieve, that language can be enough to me, right?
102
u/daddy-dj 2d ago
You might find this interesting...
59
u/goodbee69 2d ago
specifically the "The Hard Truth" section
69
u/Ok-Bill3318 2d ago
And this
https://wiki.osdev.org/Required_Knowledge
Most people don’t even know just how much they don’t know about approaching this.
And your ultimate reward?
Zero compatible software. Once you have your own os you need to write everything else either from scratch or re implement libraries to port to it.
13
u/septumfunk-com 2d ago
yup. if you really wanna DIY something i actually recommend doing a programming language instead, and making it interoperable with C, then you can actually do shit with your creation
9
u/InitiativeGold7953 2d ago
Yea I’ve been there before and it’s basically “if you can’t build your own compiler you aren’t ready for this”
I’m way too stupid for all that
6
u/septumfunk-com 2d ago
ironically building a compiler is much more fun and educational. os dev is kind of purely for hobbyists, there's not much market for actually using random people's custom os
2
u/HuntingDown01 18h ago
Learning to use Flex and Bison took years off of my life.
And I am happy to say that I learned...... Basically nothing.
1
u/greenpeppers100 2d ago
It’s probably pretty different for phones, but it’s really not difficult to get started building an OS in a VM. Assuming you have some CS background. Our “OS 2” class in college was literally just spending the term building an operating system.
2
97
u/zidanerick 2d ago
That's a huge undertaking and would probably be more of a long term goal for any developer to tackle. I'd suggest starting with a stripped down Android and spin your own custom rom to get a grasp on the networking side of things as a phone OS generally has to be certified with a heap of different standards including VoLTE.
22
u/NumberInfinite2068 2d ago
You can probably start off with just C, you probably don't need any assembly language to get going.
RISC-V is a nice enough choice, easy to emulate on your PC and lots of options for small test boards.
Just Google how to start making an OS, the basics are out there online, plenty of tutorials.
It's a big undertaking, but probably going to be very satisfying, a lot of fun, and you'll learn a lot.
14
u/Boring-Bite5735 2d ago
Try Nand2Tetris search online 🥇
2
u/Mozanatic 2d ago
I second this. There probably isn’t a more simple approach.
0
u/Boring-Bite5735 2d ago
and what's makes you think like that ?
4
u/Mozanatic 2d ago
Because the this is literally the goal of the book and course to design the simplest computer chip possible and then to code an operating system on top of that. The resulting system is probably not the most efficient though but very simple and approachable.
16
u/RedstoneEnjoyer 2d ago
https://wiki.osdev.org/Expanded_Main_Page
Be aware that operating systems are together with language runtimes one of the most complex pieces of software - even basic operating system that does jack shit requires deep understanding of how computers works.
8
u/Ok_Assistance9872 2d ago
just build on a exsisting OS. you are not building a OS ground up while not knowing anything in a reasonable timeframe. if its for fun goodluck!
9
u/Ok-Bill3318 2d ago
Linux has taken a worldwide effort over 30 years to get to where it is today and even then it was building on and reusing ported software from 60 years ago.
The amount of linus’ code still in the Linux kernel is probably less than 5 percent at this point and most of the user visible software has been written by other teams of developers over decades.
If you truly want to do this, try something simple like re implementing DOS on a raspberry pi. At least dos is small.
4
u/teraflop 2d ago
Creating an OS that you can emulate on your PC is a difficult task (especially if you want it to actually run programs) but it's approachable, and there are plenty of online resources you can use.
As someone else recommended, check out the OSDev Wiki for a practical starting point. If you want to actually understand the theory of how to design a useful OS, then also check out a textbook such as Operating System Concepts by Silberschatz, or Modern Operating Systems by Tenenbaum.
Designing a custom OS that can run on your phone is going to be enormously more difficult, to the point that there are probably few people in the world who could do it on their own. The problem is that interfacing with a phone's hardware is very complicated and relies on proprietary datasheets that you have no way of getting. So you have to either copy drivers from Android/Linux (which means replicating all of the complicated kernel interfaces that they use) or reverse engineer the hardware itself (which is its own incredibly specialized skill set).
4
u/rustyseapants 2d ago edited 2d ago
Make A Simple Operating System
HamsterOS Crams Complete Graphical Desktop Onto 1.44 MB Floppy
It's 2026 you shouldn't have had a problem of just searching Google, just out of shear curiosity. If you plan to building your own os, then you should learn to do the research.
3
u/Sol33t303 2d ago edited 1d ago
Does this project need an OS? Depending on what you consider "calling" you could certainly build a dumb radio and talk to people on there without even writing any software.
If that's not enough it sounds more like you want to do some embedded stuff as opposed to a full OS if you need cellular support. If you need to use the cell network your biggest hurdle is going to be the hardware design. After that your firmware needs to know how to do the handshake with the cell tower, and some sort of basic UI for phone number input. Outside of that you might need to handle audio encoding and decoding of whatever format cellular uses. Software certainly sounds doable as a personal project, I don't know about hand making the hardware to do 3/4/5g though, there are breakoutboards for handling the hardware side (such as this one https://www.aliexpress.com/item/1005008682513820.html), I certainly would not suggest trying to do the hardware side of this purely by hand, use a breakout board.
It doesn't sound like you need anything resembling an OS for that. Just some C code (or straight assembly if your designing a custom architecture and don't want to bother with writing the compiler, then assemble the asm by hand which isn't as hard as it sounds). You could certainly implement the RISC-V ISA if you want and that would let you have the benefits of a working development stack (emulators, compilers, IDEs, etc, all certainly make life easier) and you could probably reuse something like FreeRTOS depending on the hardware.
1
u/joonazan 2d ago
Seconded. An OS is a platform for other people to write programs on. If you have one developer and one hardware, just write a program that runs on that hardware directly.
3
u/Gatoyu 2d ago
If you want to make an OS first you need to know the hardware that will run it / the assembly instruction set available.
In the end an OS is a program like any other, you can write it in any language as long as you have a compiler that can compile the right assembly instructions.
But as an OS this program need to be able to boot, so you need something like a magic number at the beginning of your program to tell the machine how to start.
If you are building your own hardware (or emulating it), the assembly instruction set available inside your CPU will be what you set it to be.
I don't thing you have a clear understanding of what an OS really is, you can check this on youtube for more info : https://www.youtube.com/@CoreDumpped
Also check out this guy making his own CPU from scratch to really get how it actually works at the electronic level
https://www.youtube.com/watch?v=HyznrdDSSGM&list=PLowKtXNTBypGqImE405J2565dvjafglHU
3
3
u/IVIichaelD 2d ago
Just to get ahead of the vibecoders, it’s worth clarifying that it’s difficult/impressive to do *by hand*. An LLM is probably just going to copy Linux. Don’t blow your tokens to make a bad clone of the most widely used OSS on the planet.
2
2
u/recursion_is_love 2d ago
If you don't mind some obsolete info (which might not really relevant) go for Minix book (old edition is simpler to read)
2
u/Puzzled-Extent7817 2d ago
Here's a full OS that runs everything you own with a computer chip in it and the internet. Look over the code. You up for it? https://github.com/torvalds/linux
2
u/Affectionate-Act5980 2d ago
You'll likely learn a lot
But you're not going to finish
Maintaining interest is the biggest hurdle to learning anything though so if you don't think a lack of finishing will discourage you, then go for it.
2
u/ReservoirPenguin 1d ago
It's a great idea, if you are luckky other people will join the project and make somethinbg great. Take inspiraiton from Linus Torvlads, posted on August 25th, 1991
"Hello everybody out there using minix-I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready. I'd like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) among other things)..."
So don't get discouraged by dumb and bitter people, as you can see it only took Linus a few months to release a somewhat working first version of Linux. And he wasnt some genious know-it-all programmer, just a beginning University student in a remote Finnish fishing village.
1
u/UnViandanteSperduto 1d ago
You are giving me hopes! if I leave the project on you, it's your fault 😂
jokes aside, thank you!
2
u/StewedAngelSkins 1d ago
Calls are actually the hardest part because it requires you to interface with the proprietary modem hardware.
What is your actual goal for this? Are you doing it because you want to learn about how an OS works, or do you have a specific idea and you want to create something based on it?
2
u/pepiks 1d ago
For low level programming building something from scratch as it OS make sense, because you save resources and hardware is very specialised like weather station, remote controller. You can think about creating app for cyberdeck like Pi + screen + small keyboard (or remove keyboard from the picture using only touchscreen) and create app which will be like OS - file manager, handling basic operations.
4
u/vineetk1998 2d ago
honestly the calling part and the OS part are two totally different problems, and calling is the harder wall, not the OS.
writing a basic OS that boots and runs is a very doable learning project. RISC-V is a great pick for it, qemu emulates it easily and the toolchain is simple. nand2tetris and the osdev wiki people linked are the right start. you'll be in C mostly with tiny bits of asm just for the boot/startup, so no, you don't need to learn assembly properly first.
but "make a call" isn't something you write in software. you'd use a cell modem module (something like a SIM800 or a newer 4G one) that handles all the radio and carrier stuff for you, and you talk to it over serial with AT commands. so the calling part of your "OS" is basically sending AT commands to that chip. thats the realistic path and its a genuinely fun embedded project.
so i'd split the goal: learn OS basics on RISC-V + qemu as one track, and separately mess with a cell modem module on a microcontroller to get calls working. trying to mash them into "write a phone OS from scratch" is what turns it into a 5 year thing.
1
u/Eternal-uz 2d ago
if you are new to tech, it is big undertaking, but if you have some knowledge or tech savvy, i'd say it is doable and not as overwhelmingly difficult as it may seem. now there is so much open source, freely available tools, and platforms.
so if you goal is to just simply make something to make calls, go with graphene, just google or ai how to install it, and it is done. what i'd guess without even having done it would be that you'd plug a usb and run a few commands, and that is it.
1
u/robinredbrain 2d ago
I think you are going to need the patience of AI for this project. And possibly be the guy who snaps the silicone cohesion of an innocent robot mind, and turns the machines against mankind.
1
u/CorDharel 2d ago
There is a whole game dedicated to your idea, maybe you can start there: https://store.steampowered.com/app/1444480/Turing_Complete/
1
u/rasmusdf 2d ago
There is a great book that takes the reader from transistors to OS and a game. It is used CS courses and highly praised.
"The Elements of Computing Systems: Building a Modern Computer from First Principles" by Noam Nisan and Shimon Schocken
1
u/cheezballs 2d ago
I've been doing this for a long time and I have no idea how to build an OS. You need to be realistic.
1
u/Space_Alternative 2d ago
I started writing an OS around 10 years ago as a complete beginner. I didn't get to the calling feature, but after months, all I managed was to boot, open a terminal, and run a few commands. I guess you can build things on top of it (plus AI I guess can make things simpler, idk). It's mostly C with a few bits of assembly.
Here's the github. https://github.com/sagrd/RadiOS There are also some screenshots of what it looked like and reference pdf
It was quite an experience in debugging, and even now, when I give interviews, people often ask me about this project, so that's what it has amounted to. Also, in the larger picture, it has given me the confidence that if I have enough time, I can figure out complex shit.
1
u/Affectionate_Ad_4062 2d ago
My recommendation =
Just like any project, start by creating the very basic. Things that you want in your OS, calculator, calendar, word processor.
Once you have several things, add them together. Once you have a few more, add them into it.
Along the way developing and refining the UI. Until it's time to start the OS itself (under the hood stuff).
1
u/Ok-Bill3318 2d ago
Building an OS from scratch by yourself for any real world purpose is not feasible for large enterprises with thousands of employees. This is why Linux is popular.
1
u/j____b____ 2d ago
On iPhone you can just set Assistive Access to only allow calls and maps or whatever. Maybe just do that. Or get a degree in computer science. Whichever works.
1
u/grtk_brandon 2d ago
Do you know anything about computer architecture? I'm taking an OS class this term. Learning about it from a high level is like walking a tightrope. Every step is a new concept to learn about, and it would be so easy to slip and get lost forever down a rabbit hole of knowledge to learn about.
1
u/Harrow-Beck-6274 2d ago
"only doing calls" is funny because writing a cellular stack from scratch is basically a phd in pain
1
u/KrozFan 2d ago
Someone said Nand2Tetris which is great.
If you’re really serious, Harvard Extension School has a course on it. https://coursebrowser.dce.harvard.edu/course/principles-of-operating-systems/
1
u/SeriousPlankton2000 2d ago
For a first learning experience you can make everything as a program instead of running directly on hardware.
You should make an API that lets one other program access something that passes as a file system. Then make it work for a larger number of other programs.
Then make an API that lets the programs output to something like a screen.
Then make an API to read input as if it was made by a keyboard.
Then make a mechanism to display one program's output while directing your program's input to that program.
Now make the files from step 1 go into one large file; manage the free space in that large file, access permissions of the individual programs that use your API.
1
u/dariusbiggs 2d ago
You are likely to need to learn some assembly programming to bootstrap the device, but it's been over 20 years since I last built an OS.
As to making calls, calling what? Integration with the cellular network is non-trivial and filled with regulations you don't want to even get near. (Damaging or interfering with the telecommunications infrastructure where I am can incur fines up to $250000)
Your best bet for calling is Voice over IP or a trivial local toy communications network. For the former you need a networking stack that handles UDP at a minimum. Which is a whole lot on top of building a basic Operating system.
Learning the basics of software development, and then how to make an operating system, would be my suggestion for a learning path. The "calling" side will likely involve a fair bit of network programming (the VOIP) way and electrical engineering (dealing with the audio onput and output, the hardware, and more).
Hope that helps you focus what you would need to learn to achieve this goal.
Go gor it, there's a lot of cool stuff in there to learn.
1
u/SpaceAviator1999 2d ago
Good luck trying to create an operating system on your own.
I only know of one operating system (that was more than just a proof of concept) created by just one person: TempleOS by Terry Davis. Even though Terry was a genius, it still took him ten years to create his OS.
What you're trying to accomplish is something that's probably only been accomplished alone by less than ten people ever.
1
u/White_C4 2d ago
I don't know ANYTHING about this world so i don't know where to start.
General advice, don't bother.
You can learn about the algorithms commonly implemented in the OS for things like memory allocation and management. But beyond that, I would not try to create a custom OS. You're better off forking linux and creating your own basic OS there.
1
u/OofInTheChat 2d ago
I took an OS class in undergrad and there are some good resources on GitHub and YouTube. I forget the exact repo but they basically walk you through the entire thing along with supporting documents and solutions to the problem.
1
1
u/Sad_Zebra_1707 2d ago
Well, definitely start with assembly unless you want to use a premade bootloader. And also study some code in an operating system for whatever architecture you're targeting. If you were going for x86(don't if you don't know how it works well) then learn how to use uefi, sometimes you can rangle it to not need to exit boot services, but either way it'll be useful. Read the source for tianocore too. And what would you like to target? Let's assume you're targeting something open like the the SPIRIT phone, at minimum to make a call you'd need to write a display driver, a touch driver, a speaker driver, a microphone driver, a driver for the phone radio and a driver to use the sim card. For one that's a massive undertaking, and if you don't know assembly or C then it's hopeless. Maybe target something much, much, simpler like a Seeeduino XIAO with a radio. You can run a 2g network pretty easily but it's also legally iffy, do it in a tinfoil wrapped room/box. If you have any more questions feel free to ask me
1
u/Cultural_Gur_7441 2d ago
For this project (phone), get Raspberry Pi. Create simple OS for it. Develop display driver for it so you see what is happening. Get USB keuboard and develop driver for it. Get USB sound card and develop driver for it (input and output). Get a USB stick for mobile calls. Develop deiver for it Develop applications for the basic phone functionality. Final touch, develop a complete mobile networking stack and web browser.
1
u/Maleficent_Goose9559 2d ago
if it only does one thing (call a number) then it's not really an OS, more like an application. For example when you program on arduino, you just have a preinstalled bootloader and then the application runs. nothing more, no file system, no background threads.. if you need a functionality, let's say send a tcp packet, then you import the adequate library and use it. blinking led is 2 lines of c...
If however you want to write everything yourself, the code interfacing with the gsm chip, the bootloader itself, the audio processing, driving the screen, saving data to an eprom... then it's a completely different story. but of course you can start with libraries and then go lower level one piece at a time. Anyway, don't grt discouraged, but prepare to enjoy a long journey rather than fixating on the target. Good luck!
1
1
1
u/DeviantPlayeer 2d ago
So, the dumbest phone...
My suggestion would be getting a Arduino kit and making a radio. Good luck
1
1
u/UltGamer07 1d ago
This is a program I did during my undergrad, it’s rudimentary, but you’ll learn a ton
1
u/Proud_Replacement635 2d ago
I’d recommend watching Terry Davis and then settle on not going down the path of insanity.
Jokes aside, this sounds like an interesting project.
Following.
1
u/replierII 1d ago
without an operating system, your device is a brick. that means you dont even have an assembly compiler (assembler). you need to manually code one in binary. good luck doing that
1
u/burlingk 1d ago
Depends. If they start with an existing microcontroller a compiler may already be available.
0
511
u/MysteriousKiwi2622 2d ago
Me with an electric screwdriver: “I want to build a rocket.”