Introducing VarkOS

I have never really been satisfied to just know that something works, I want to know HOW it works. What makes it tick? How does it all fit together? Getting an in depth understanding of how the magic is performed, is more than just a passing fascination. I have been writing ‘embedded’ software professionally for many years and was always intrigued by how the operating system functions, deep inside the circuit board.

To this end, I finally decided to dedicate some time on the subject and started digging. I don’t have allot of experience with writing assembler, I find it way too tedious. But, writing an OS requires one to get very intimate with the platform, so I decided to brush up on some basic assembler. The Cambridge University’s Baking Pi series of tutorials is an excellent place to start. I worked through these and felt confident that I have a fairly good idea of what is going on and so it came about that VarkOS was born. ‘Vark’ is the Afrikaans word for pig. Why would I name my project after a pig? Well, I expect it to be dirty and in some places it might even smell funny. So there you go.

The Raspberry Pi turned out to be the ideal platform for this adventure, since I already have a couple lying around. There is also allot of information available on the Raspberry Pi platform, although for my purposes, allot of digging was required.

The trickiest part of starting a project like this, is getting the environment sorted out. I am using the Mac version of the Yagarto tool chain. Normally it would be customary to do a ‘Hello world’ type of project to confirm that everything is working well. Well, in a bare metal environment it is not that simple. To this end I cheated just a little bit. I ‘borrowed’ a small build project from somewhere that contained a working uart example. This allowed me to do the “Hello world” thing via the serial port, in order to confirm that my environment is up and running. From here I started by implementing some logging functions to allow me to send formatted messages out the serial port. Being able to format binary values into a human readable format is crucial for debugging purposes.

With the logging sorted, I though it might be a good time to use my new found knowledge from theĀ Baking Pi tutorials, to implement a module that can manage the GPIO pins of the Raspberry Pi. With the customary blinking LED functionality sorted, it was time to move on to some more serious functionality.

First priority is being able to display stuff on the screen. It will also go a long way in making debugging easier if I have access to the screen to display data. As such, the frame buffer beast has to be tamed. This proved to be allot harder than expected, since documentation is sparse, to say the least. I am writing this in the hope that it might assist other people in digging through the dirt in order to get a better understanding of how these things work.

In my next article, I will write in more detail about my understanding of the way the frame buffer operates and how it was implemented. In the meantime, the code for VarkOS is available in my Github repository if you would like to give it a spin. At the moment is does very little, but it can display text and a logo, which is a good place to start.