Roll Your Own Raspberry Pi OS

Writing an operating system is no small task, but like everything else it is easier than it used to be. [JSandler] has a tutorial on how to create a simple operating system for the Raspberry Pi. One thing that makes it easier is the development environment used. QEMU emulates a Raspberry Pi so you can do the development on a desktop PC and test in the virtual environment. When you are ready, you can set up a bootable SD card and try your work on a real device.

The operating system isn’t very complex, but it does boot, organize memory, displays on the screen, handles interrupts, and manages processes. What else do you need?

There’s quite a bit of ancillary information about the Pi, also, which is great. Want to know about the Pi’s configuration? The organization of the framebuffer? Which interrupts are available? All that information is there.

This isn’t the first OS tutorial for the Pi that we’ve seen. Even if you don’t want to build a general-purpose operating system, you might want to try your hand programming the Pi at the “bare metal” level.

Raspberry Pi image: Evan-Amos [Public domain].

27 thoughts on “Roll Your Own Raspberry Pi OS

  1. For serious IOT is very useful to be able customize the IOS:
    – removing useless OS parts that is not used on specific task
    – beter manage resources (CPU, memory)
    – reducing risk of conflict
    – reducing risk on security
    – using custom FS
    – faster (re)boot

    For example, many of our device are only used as node-red server and we don’t need at all xserver or any other graphics and sound related OS part / services.

          1. He probably means the Broadcom source license. Some parts of the source package are proprietary. Using them to build a Yocto BSP is almost certainly a violation of the license.

      1. Or you can integrate a stripped FreeRTOS, BSD, VxWorks, or Linux kernel… and actually work on getting your core project running.

        As with all OS, the use cases will certainly evolve… it is foolish to believe an individual is more thorough than millions of users, and thousands of developers.

        This DIY comment really annoyed me, as I have seen some companies inherit a dumpster-fire of legacy code auto-generated from Yocto (or some other flavor of the week), that would make even the most devout fan-boy blush.. Custom OS are good for learning how to port a full system, but really doesn’t allow anyone to produce anything but refactoring-tickets in the long-term. Linux is in almost everything because of the modular cross-platform monolithic kernel, and minix is in the Intel CPU because of the licensing. It is simply unethical to recommend a vanity project in a commercial setting — but people seem to do this once in awhile for dubious reasons, and it is about as practical as inventing your own keyboard layout.

        1. OH MY GOD !!!!!!!!!!!!!!
          —————————–

          What the FWGQE was that???????
          My keyboard locked up and had to watch the hole thing.
          Grab a hammer to smash the computer the head fell off.
          Then I tried to grab my gun to shoot me. The safe wouldn’t open.
          Just came out of my coma.
          What the FWGQE was that?????

        2. ich verstehe nicht…

          Buildroot, Yocto, OpenW(a)RT, etc are tools. Nothing more.

          Blaming them for some random developer’s misuse of them is like Mr. Clumsy ™ blaming the hammer because he’s too stupid to keep his thumb out of the way.

        3. Yes. I bought an assembler for my Radio Shack Color Computer in 1985, and it included a rudimentary operating system. That was reality at one point, everyone had to start from scratch to get the needed functions because there wasn’t an “operating system” to run under. So I had to patch that program to get a left hand margin when printing listings, so I could put them in a binder.

          A real operating system cuts out the duplication of the low level stuff, so the effort can be put on the program, and provide more flexibility.

          My two tv sets run Linux, so does my blu-ray player, and my TomTom One GPS. It’s work they don’t have to do, and is safer because of the much larger user base. They can use just the kernel, or they can add some utilities or applications, and then focus on the program that matters.

          Michael

  2. This is going to seem strange but….

    There was an old real-time multitasking operating system that was ported for Tandy Color Computers called OS9, and maintained by a few people, that was quite compact and very elegant. I wanted to learn enough to port it in C for a device such as the Raspberry Pi or even a Teensy.

    https://sourceforge.net/projects/nitros9/

    It was a different metaphor: everything is a module–instead of a file. The modules were arranged in a hierarchical layers, such as on page 6. (This is the underpinnings.)
    http://www.nitros9.org/NitrOS-9_Technical_Reference.pdf

    It had some nice features, such as: The entire kernel fits in 8K. It had smooth granular time-slicing multitasking-not like what you find in windows. (I could still use the keyboard while running intensive applications, such as fractals in the background.)
    It had a rudimentary windowing system, whereas windows were treated as devices, as virtual terminal windows. /w1 /w2, such as this would would send a directory output (ls) of the default drive to device window 1.
    dir /dd >/w1

    It had a separate execution and data directories, which meant fewer path variables. Any executable could be pre-loaded into memory for later use, as if there was a RAM drive running all the time. Yes, it had RAM drives, as well. /r0, which could also be reassigned to /dd.

    Because all IO was done through the OS, things you think might work–did, such as sending the output of a graphic program–to a file, or start a shell within a shell, within a shell, which was oddly handy for file work, because when you exited each shell, you were back where you invoked the previous.

    So, what there is: the complete assembly source code for an old obsolete 8-bit computer operating system, yet, for small computers and controllers, this could be the next big thing–because, from the get-go, it was designed from the ground up to be Unix for small computers and controllers.

    User manual: http://www.nitros9.org/Getting_Started_With_NitrOS-9.pdf

    Take Care,
    BrendaEM

    1. I wonder how many more “modern” uPs support that nice position-independent code NITros9 seems to require. I first encountered the ability to do that with PDP-11’s (but I was a hardware guy) and was amazed that it seemed like no one would use it – it would have saved the time and hassle of linking loaders for example. I guess shared libs would still be possible. I was glad when Motorola picked up on this (the basic idea being the PC is a gen purpose register that could be indexed off of like any other pointer) but it seemed no one used it there either (my first work with Moto, as a software guy, was with 68k, somewhat before Apple came out with any of that – we in the gov had priority on new cool tech.
      I still wonder…I don’t “do” asm much anymore – and this is obviously kinda big for an arduino. Teensy? ESP 32?
      Obviously a pi would work if it did position independent code…

      Seems to me that was one of the better ideas out there with a lot of potential that just dropped on the floor when everyone went with pre-written code standards for “that other platform” that couldn’t do that. The good enough being the enemy of the great in this case.

    2. Hey – very cool – I ran OS9 Level 2 on a Coco 3 many years ago. It was so clean. I like how it even allowed the memory mapper hardware to utilize the full 512k of the machine.

      This was also the machine I really learned C on. I bought the compiler for $5 or $10 on sale at Radio Shack.

      Amazing. Thanks for posting that.

  3. Interesting — many of the early products I did the employed embedded, I cranked out my own OS which ” boot, organize memory, displays on the screen, handles interrupts, and manages processes”. My instinct because I am now lazy and other folks have now contributed amazing OS works, is to find something common, supported that will do my bidding.

    For example, all my websites I do with WordPress, using Themes and plugins and try not to do a line of code.

    1. Well bugger me…

      A programmer who doesn’t believe in re-inventing the wheel at every opportunity.

      You Sir, are obviously a hallucination induced by a lack of tea. A situation I shall rectify this instant.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s