#Ultibo – a “unikernel” for the #raspberrypi

I just came across Ultibo , a “unikernel” for the RPi (Raspberry Pi), any version. What a fascinating idea it is! If you are like me, you have no idea what a unikernel is. Wikipedia describes it as:

a specialised, single address space machine image constructed by using library operating systems.[1][2] A developer selects, from a modular stack, the minimal set of libraries which correspond to the OS constructs required for their application to run. These libraries are then compiled with the application and configuration code to build sealed, fixed-purpose images (unikernels) which run directly on a hypervisor or hardware without an intervening OS such as Linux or Windows.

From what I gather, a unikernel is designed to run a single application on virtual hardware; to be contrasted with an exokernel, which is designed to run multiple applications that needn’t know of each other’s existence, on real hardware. And to be contrasted yet again with a kernel, like Linux or Windows, that provide a whole host of services.

You write your application in Lazurus, which is an IDE for the FreePascal compiler. The version of Lazurus is a custom version. I’m not Pascal wizard, but I was able to get up a “program” that created a console, asked for the user’s name, and printed it back to the console. I say “program”, but it is actually the complete guts of the machine. There’s no separation between program and kernel.

Writing in Pascal makes it much more pleasurable to program in than C. For example, Pascal has proper strings.

When you build the project, Lazarus creates a kernel.img file. You then copy that to your SD card, insert it into your Pi (I chose a Pi 2), and boot your machine. It boots straight into your program.

Here’s a simple program that I wrote:

program Joy;

{$mode objfpc}{$H+}

{ Raspberry Pi Application }
{ Add your program code below, add additional units to the "uses" section if }
{ required and create new units by selecting File, New Unit from the menu. }
{ }
{ To compile your program select Run, Compile (or Run, Build) from the menu. }

uses
RaspberryPi,
GlobalConfig,
GlobalConst,
GlobalTypes,
Platform,
Threads,
SysUtils,
Classes,
Ultibo,
Console,
Framebuffer
{ Add additional units here };

var
WindowHandle:TWindowHandle;
name:String;
begin
{ Add your program code here }
WindowHandle:=ConsoleWindowCreate(ConsoleDeviceGetDefault,CONSOLE_POSITION_FULL,True);
ConsoleWindowWriteLn(WindowHandle,'Hello Ultibo! What is your name?');
ConsoleReadLn(name);
ConsoleWindowWrite(WindowHandle, 'Your name is ');
ConsoleWindowWriteLn(WindowHandle, name);
ThreadHalt(0);
end.

It creates a console, asks you for your name, and prints it back to the console. Then stops. Not, perhaps, the most useful of programs, but I was impressed by the ease of it.

I have no idea how the authors of Ultibo manage to get all this to work, but it works quite well.

The work is reminiscent of Charles Moore’s colorForth, and Niklaus Wirth’s Oberon OS.

Ultibo is well suited to those who like tinkering; so those interested in an RPi should find it very appealing. The RPi is an excellent platform to target, too.

I look forward to delving deeper into the system. I would like to try to build its version for Linux. Ultibo currently runs from Windows. Lazarus runs on all platforms, so I think that it should be possible to compile a version for Linux. Theoretically.

Anyway, worth checking out.

EMUZ80-RPI.png

Image taken from the web

About mcturra2000

Computer programmer living in Scotland.
This entry was posted in Uncategorized. Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s