XO Hacking
From VpriWiki
Contents |
Compiling Pepsi programs for OLPC OFW
You can write Pepsi programs and run them on the "bare metal" of your OLPC XO. The Pepsi compiler (idc)'s now supports this out-of-the-box on Linux-based build machines. Here's a cheat sheet:
svn co http://piumarta.com/svn2/idst/trunk idst # -r 563 cd idst make # build cola (needs readline dev package of your distro) cd function/examples/xo; make # build OS support based on Openfirmware cd hello; make # build hello-world OS ls -l hello # that's your operating system -rwxr-xr-x 1 lukegorrie wheel 1574003 Oct 9 13:19 hello
To boot this program on an XO you need to have your [http://wiki.laptop.org/go/Activation_and_Developer_Keys developer
key] installed so that you can use the Openfirmware forth
prompt. Then you can follow these steps: copy hello onto
a USB stick, insert into your XO, power on and interrupt startup (you
should see the ok Forth prompt), then type this:
boot u:\hello
There are plenty of other variations for booting and you can read more about that.
For example you can use an olpc.fth that downloads the operating system using HTTP or TFTP over a wireless network.
You can create your own programs by adding subdirectories with a similar simple Makefile to the hello example.
XOOS
Luke Gorrie has created the xoos Git repository containing examples and experiments in Pepsi-based OS development for the OLPC XO. XOOS depends on your having idst checked out and built (including examples/xo) as described in the cheatsheet above. Then you can just export IDST_DIR=.../idst and use make.
XOOS1
The most significant current example is in the xoos1/ directory. xoos1 consists of drivers for keyboard and mouse input (via Openfirmware) and a 32-bit graphics framebuffer (directly via the Geode). You could throw your own code into XOOS1.st to make it do something more exciting -- just look in the selftest methods to see how it's done. And remember to call init for Keyboard and Mouse if you want to use them -- and that you're running without a GC :-)
Note: Mouse support requires minimum Openfirmware version q2e21a.rom. To install: copy the file onto a USB stick and execute flash u:\q2e21a.rom
Sample experiments
A series of throw-away examples written to better understand Pepsi and the XO:
- demo1 (src / pdf): Draw into the default 5:6:5 frame buffer using the CPU. (Includes a crash-half-way bug.)
- demo2 (src / pdf): Draw into a 32bpp frame buffer using a custom Geode hardware blit driver.
- demo3 (src / pdf): Call back into the firmware from Pepsi using the Openfirmware system-call interface.
Related links
Please post any links relevant to programming the XO with Pepsi here!

