8 ms·
Show HN: Banan-OS, an Unix-like operating system written from scratch
This is my operating system that I've been working for the past 2 years. All of the code is written exclusively by me except from ported software. banan-os has a monolithic kernel targeting x86 (i686) and x86_64 architectures. The project consists of bootloader, kernel and userspace libraries (libc, libGUI, libFont, ...). It also uses my custom C++ standard library partly based on stdc++.
Currently I have basic TTY and GUI environment with some of the basic UNIX utilities like cp, ls and stat. I have basic support for USB (keyboard/mouse/storage), disks (NVMe, AHCI), custom networking stack with TCP and UDP support, and a UNIX-like filesystem with /dev /tmp /proc filesystems.
The whole project is written in C++ except for my BIOS bootloader that is written in 16-bit real mode assembly. I have been testing the OS mainly on virtual machines but also frequently on real hardware.
- keyvank 2y agocan you compile and run smth like gcc in your OS?
- Bananymous 2y agoI've managed to compile the GNU toolchain (binutils + gcc). gcc seems to work fine, it can properly compile source code into assembly. There are some problems with binutils that make it not able to create object files or link. I'm haven't dug deeper to see where the problem actually is.
- keyvank 2y agowow, i envy you! :) i have been working on a really simple self-compiling C compiler for some time, was wondering if you are interested in adding it to your OS haha. but if GCC works fine, then i don't see a reason :d
- nunobrito 2y agoReally enjoyed that you just run and fun from the browser. Doom wasn't loading for me (Brave browser on Ubuntu without javascript disablers). Very good work. It was fun without doubt.
- Bananymous 2y agoOh yeah, sorry. I'm missing documentation on how to access the GUI environment. You have to enter the GUI environment using `start-gui` command. After that doom should start by running `doom` in the GUI terminal. Performance in the web emulator is really bad though, so don't expect much :D
- jart 2y agoRename the project UHHNIX or OOHNIX. Great work!
- PTOB 2y agoAre you trying to start a flame war?? :-D
- jart 2y agoJust paying my respect for what Oskari pulled off. I tried building my own hobby OS and didn't get nearly this far. I just thought that, like Linux, this UNIX-like OS deserved a name that's closer to the source. For example, Linus originally wanted to name Linux "phreax" but Linux is what stuck after his friend changed the folder name when hosting it for him on an FTP server.
- kortex 2y agoHow does one even begin to write drivers for nvme, ata, rtl nics, etc? I know mice and keyboards use HID which is a standard, but are there similar standard protocols for all other devices? Is this how linux manages to avoid needing to "install drivers" in the vast majority of cases? And if there are standard device APIs, why does windows have to go through that whole install driver routine every time I plug something in?
- Bananymous 2y agoYeah basically every commonly used device has its protocol standardized. Although there exist some devices where the manufacturer has to provide the drivers. All of the devices I have written drivers have had their specifications publicly available for free (e.g. NVMe at https://nvmexpress.org/specifications https://nvmexpress.org/specifications). I'm not really familiar with how Linux nor Windows handle drivers. While compiling the Linux kernel you specify which drivers you want to build into the kernel and which ones you want as modules. Usually most common ones compiled along side the kernel so there isn't really need to install them later, just load the driver modules. There are also devices that work with just a generic driver but would have more features with a specific one (e.g. led settings on a gaming mouse). I think Windows is maybe installing these optional drivers.
- caspper69 2y agoSo here's the kicker. Microsoft, having the resources it does, was able to design and implement a stable driver ABI. In fact, they also have a stable userspace ABI. Both have evolved, but that's not the point. Linux conversely (whether by design or by limitation) does not have stable ABIs (although userspace compatibility isn't terrible). Even though you can build kernel drivers as modules (and then load/unload), those modules are unique to each specific kernel build. Remember those guys didn't write the compiler & linker toolchains they were using like Microsoft was able to do. I will be honest, I understand why Linus & Co. have decided to keep it this way, because it encourages hardware manufacturers to submit either their drivers or their specifications to the upstream kernel, which promotes software freedom. It is a noble goal and has served them well. BUT - thieir decision has caused me no small amount of consternation over the years as a system administrator. Once you use Linux for something that is not "server software" (be it auth, file sharing, web, etc.), you are generally using it to drive some piece of hardware (CNCs, industrial tools, cough phone systems cough). Vendors, especially those that deal in low-volume / high-margin products, do not want to release their source code. They're allergic to the idea even. So I have gotten stuck in outdated kernel hell on several occasions because the kernel devs have decided to change internal interfaces in a point-point release that my driver software relied upon. I so wish that Linux would move to a stable driver ABI. It would make administration & upgrades so much easier, especially on the embedded side. But I also know that it'll never happen. FWIW, the "no stable kernel ABI" is unique to Linux, although no one really does this like Microsoft (i.e. the BSDs can break between releases, but I do believe NetBSD is superior to FreeBSD in this respect).
- stevekemp 2y agoA minor bug-report, if you run "cd /proc/3" you cannot "cd .." afterwards. It looks like ".." entries don't exist beneath /proc.
- Bananymous 2y agoThank you!
- MomsAVoxell 2y agoI think it’s going to be quite important to address portability and general flexibility when it comes to architectures. What do you think it will take to target RISC-V?
- Bananymous 2y agoI've tried to abstract everything architecture dependent but there is still a lot of x86 specific code outside of archutecure specific directories. I've been planning on adding support for new platforms, but I've not yet had the motivation to start doing it. I'm not familiar with other architectures than x86 so I can't really say what it will take. At least a lot of work :D
- DigiEggz 2y agoThis is really cool! I like the name, too. Of all the things you've implemented for this, what has been the most difficult part? And have you hit any serious roadblocks along the way?
- bsimpson 2y agoI read it thinking "banyan tree" until I saw the ASCII art and realized it's a banana reference.
- Bananymous 2y agoThere hasn't been any overly difficult parts. I'd say the most difficult one has to be either AML interpreter because the ACPI specs are very badly written or the USB stack just because the size of the specifications is so large with a lot of cross referencing. There hasn't been any major roadblocks. Sometimes I give up on a feature and come back to it maybe month or two later though.
- ksp-atlas 2y agoGood work using a custom AML interpreter instead of a premade one!
- Bananymous 2y agoMy current one is really bad. It does work on maybe 50% of the hardware I have tested. I am in the middle on writing a new proper one, it is already way better but still missing some necessary parts before I can integrate it.
- Findecanor 2y agoI would anticipate that you only have support for boot-mode keyboard and mouse now, considering the complexity of the full USB-HID spec. Otherwise I'd be very impressed.
- Bananymous 2y ago
- whartung 2y agoVery nice. Lot of work. What stand out challenges have you encountered?
- Bananymous 2y agoI think biggest challenges have to be with reading large specifications. I've never really done that before so it took some time to get used to.
- convolvatron 2y agogood for you. it gets easier. and being able to actually get down the meat of things is a real superpower. totally agree with you about ACPI though.
- eismeer 2y agoCould you link a random specification you were working against? I'm curious how there are written
- Bananymous 2y agoYeah sure! NVMe base specification https://nvmexpress.org/wp-content/uploads/NVM-Express-Base-Specification-Revision-2.1-2024.08.05-Ratified.pdf https://nvmexpress.org/wp-content/uploads/NVM-Express-Base-S... xHCI (USB controller) https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf https://www.intel.com/content/dam/www/public/us/en/documents...
- dvh 2y agoThere is a certain customary sentence to be put in new os kernels announcements and your announcement lacks this sentence.
- bityard 2y agoYou surely mean that it's a hobby project and probably won't be big and professional like GNU?
- ASalazarMX 2y agoI can't see anyone seriously suggesting to management that they run Banan-OS. Probably the same self-inflicted handicap of CockroachDB.
- 38 2y agooh fun, a guessing game :|
- xandrius 2y agoThe other poster already answered...
- readyplayernull 2y ago...that the word iiis...
- spiffyk 2y agoVery cool! How much time do you dedicate to this, in terms of hours per week? Looks like a lot of work has gone into it! You say you're a student on your profile - does that mean university? If so, have you also worked on the OS directly as part of your studies?
- Bananymous 2y agoYeah I am a student at an university. I have managed to "skip" some courses like operating systems and concurrency just by showing my project to the professor. Otherwise my project is not integrated to my studies in any way. I also got a part time job in my university's embedded side because of my project. How much time I put to this really depends on what else is happening in my life at the moment. There has been months where I've put total of 5 hours into this and some weeks alone I may reach close to 40 hours.
- zimmund 2y agoJoining these courses may be enriching for everyone though. You may learn something new or a different approach to a problem you've solved. Other students will appreciate your actual experience with the subject. And the professor may learn a thing or two (and appreciate your contributions) if you can add to the subject. That said, I'm not good managing my time and I don't have the guts to code an OS from scratch, so what do I know?
- spiffyk 2y agoAwesome, thanks! One more set of questions: was there something you would call an "it's alive!" moment in the beginning of the project? A part where it would start to get _really_ fun for you? If so, what was it and how long did it take you to get there?
- Bananymous 2y agoThere has been multiple really great moments during the development. Its always cool to see some completely new features working on real hardware, like first time getting keyboard input, USB mouse input, running DOOM, reading from disks, networking, and getting a compiler working! I think it became actually fun after I got all the basic requirements done and could start deviating from more or less standard OS code. When I could actually decide what I want to work on. Maybe after couple of months it was in that state. It was also fun at the beginning. it was just way harder as I didn't have any prior knowledge and I was trying to wrap my head around some basic concepts :D
- ajxs 2y agoReally impressive achievement! I love the name too!
- savgore 2y agoThis is awesome! Can I ask what development looks like? Do you run this in a VM or on bare metal? When you sit down and work on this, what does it look like? I bet you learned a lot with this - how do you keep notes and track your development? Or is the OS your live journal. Thanks
- Bananymous 2y agoI do maybe 95% of testing on a VM. It is way faster and much more convenient. I do test on real hardware regularly though. It's always cool to see stuff actually running on bare metal and bare metal is not as forgiving as VMs can be. Generally I decide a feature I want to add. Then I do a general overview of the corresponding specifications and sometimes look at how already existing OSs handle that. I try to make some kind of mental model about the system and what it needs. Then I basically just write what ever I come up on the spot. I have a really bad habit of not writing docs or taking notes. Basically I just hold everything in my head (and forget about it when I would need that information again). For some more complex stuff I do draw diagrams and write notes but I pretty much only keep those locally for myself.
- johnisgood 2y ago> I have a really bad habit of not writing docs or taking notes. Basically I just hold everything in my head (and forget about it when I would need that information again). This was me for a very long time. I started making notes now, knowing that I will most likely forget (some of it). I still have all sorts of files scattered around though with my notes, i.e. the notes are disorganized (to some extent). I thought of using Obsidian for them and I have tried it but I do not use it consistently, I just go for my XTerm window with emacs or vim.
- sedatk 2y agoThis is so cool! I especially applaud you for managing to implement USB drivers from scratch! By the way, I broke it by typing "cat doom1.wad" :)
- Bananymous 2y agoThank you! Yeah there isn't really any data serialization done to data written into the TTY, so can break if you feed it arbitrary binary data :D
- notawolf 2y agoThis a very cool side project, congratulations! Any tips for anyone that also would like to attempt something similar ? Like where to start or or sources etc
- Bananymous 2y agoPretty much what others said. You should read through https://wiki.osdev.org/Getting_Started https://wiki.osdev.org/Getting_Started and note that it will take a lot time if you decide to go for developing an OS.
- torlok 2y agoOSDev Wiki for practical knowledge, operating system design and computer architecture books for the theory.
- udev4096 2y agoThere's https://os.phil-opp.com/ https://os.phil-opp.com/ for rust, https://github.com/tuhdo/os01 https://github.com/tuhdo/os01 for general OS development and make sure to read Operating Systems: Three Easy Pieces
- VagabundoP 2y agoAwesome. I was not expecting something with that feature set. Do you plan on porting more software?
- Bananymous 2y agoI do plan to port more! I want to keep the base OS free of 3rd party code, but ports are really nice way to get things running that I have not yet written. I have some ports locally that are not yet working. I have git, binutils, gcc, make all compiling but they are giving some weird errors. Probably a bug in my libc or syscalls.
- VagabundoP 2y agoNot enough OS's built from scratch nowadays. Fair play.
- mrbungie 2y agoCool project!, alternative name for a fork: PlatanOS
- p0w3n3d 2y agoPlátanOS with stressed first a