Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Desktop development for the OLPC laptop

Build an XO-1 image on QEMU and learn the Sugar environment

M. Tim Jones, Consultant Engineer, Emulex Corp.
M. Tim Jones
M. Tim Jones is an embedded software architect and the author of GNU/Linux Application Programming, AI Application Programming, and BSD Sockets Programming from a Multilanguage Perspective. His engineering background ranges from the development of kernels for geosynchronous spacecraft to embedded systems architecture and networking protocols development. Tim is a Consultant Engineer for Emulex Corp. in Longmont, Colorado.

Summary:  The XO laptop (of the One-Laptop-Per-Child initiative) is an inexpensive laptop project intended to help educate children around the world. The laptop includes many innovations, such as a novel, inexpensive, and durable hardware design and the use of GNU/Linux® as the underlying operating system. The XO also includes an application environment written in Python with a human interface called Sugar, accessible to everyone (including kids). This article is excerpted from the developerWorks tutorial "Application development for the OLPC laptop," which takes a look at the Sugar APIs and shows how to develop and debug a graphical activity in Sugar using Python.

Date:  26 Feb 2008
Level:  Introductory PDF:  A4 and Letter (152KB | 11 pages)Get Adobe® Reader®
Also available in:   Japanese  Portuguese

Activity:  14060 views
Comments:  

OLPC and the XO laptop

The XO-1 is a laptop computer designed to be inexpensively manufactured and distributed to children in developing countries around the world. The goal of this laptop is to bring technology and access to information to children who would otherwise not have this ability. The laptop includes wireless networking, allowing children to collaborate locally with each other on projects.

The laptop was first proposed by faculty at the Massachusetts Institute of Technology (MIT) Media Lab under the non-profit organization, One Laptop Per Child. The organization includes such luminaries as Nicholas Negroponte and, in the early days, Seymour Papert (a pioneer in the field of artificial intelligence), whose ideas and research are instrumental to the project.

The project has not been without criticism. As a technology, the laptop is novel, but some wonder whether the money spent on the laptop in some developing countries would be better spent elsewhere. For example, some of the target countries for the XO-1 lack the basic elements of education (such as schools or libraries). See Resources for more details.

The XO-1 laptop

The design of the XO-1 laptop is interesting, because it includes two competing requirements. First, the XO-1 laptop must be inexpensive (selling for USD140) but also feature rich. The design includes a 433MHz AMD Geode processor, 128MB of RAM, 1GB of NAND flash (instead of a hard disk), a 7 1/2-inch dual-mode LCD, wireless networking, and even a video camera. The laptop is also designed to be operated in non-traditional environments and is therefore very durable and rugged (see Figure 1).


Figure 1. The XO-1 laptop
The XO-1 laptop

Wireless networking is based on an 802.11b/g and 802.11s chip, which supports both standard networking and mesh networking. This allows laptops to autonomously route packets between themselves in a peer-to-peer network (without the need for a separate router). The mesh networking works even if the CPU is powered off.

Software

While the ideas behind the XO-1 laptop are intriguing, and its physical and hardware design make it novel, what's most interesting is the software. The XO-1 laptop is powered by GNU/Linux (a minimal version based on the Fedora project). The basic input/output system (BIOS) is the Open Firmware, which is written in a variant of Forth. The graphical user interface (GUI), called Sugar, is based on the X windowing system and written in Python. This is by far the most interesting element, because it makes the XO-1 an immediate development environment. (Python is an interpreted language.) No compilers are necessary, and anyone can develop Sugar activities (that is, applications in the Sugar GUI). In other words, all software on the XO-1 laptop is open source and therefore free and modifiable.

This use of Python is interesting, because as the core of the XO-1 laptop, it exposes Python to millions of children around the world. Python was created as a language to learn programming, so it was an ideal decision and has the potential to create a new population of Python enthusiasts.


XO laptop emulation

QEMU is a platform virtualization application that allows you to emulate an entire computer (processors and associated peripherals) for purposes of virtualizing another operating system on it. With this, you can emulate Linux on Windows, Windows on Linux, or any other operating system on another operating system that runs QEMU. You can even emulate an operating system for a different architecture than the host. For example, you can emulate an Arm Linux system on an x86 host.

A system emulation is made up of the platform emulator (QEMU), an optional accelerator (KQEMU), and a root image (a file in the host operating system) that contains both the kernel and the root file system. For more details on QEMU and its internal operation, see Resources.

Download and install QEMU

Installing QEMU and the accelerator is as simple as you would expect with GNU/Linux. Listing 1 provides the QEMU download, build, and installation instructions.


Listing 1. Downloading, building, and installing QEMU
$ wget http://fabrice.bellard.free.fr/qemu/qemu-0.9.0.tar.gz
$ tar xfvz qemu-0.9.0.tar.gz
$ cd qemu-0.9.0
$ ./configure
$ make
$ make install
$
            

The QEMU accelerator is an optional step, but I recommend it because it results in greater performance. Listing 2 gives the QEMU accelerator download, build, and installation instructions.


Listing 2. Downloading, building, and installing the QEMU accelerator
$ wget http://fabrice.bellard.free.fr/qemu/kqemu-1.3.0pre11.tar.gz
$ tar xvfz kqemu-1.3.0pre11.tar.gz
$ cd kqemu-1.3.0pre11
$ ./configure
$ make
$ make install
$ insmod kqemu.ko
            

Note: At the end of Listing 2, the QEMU accelerator kernel module is installed.

Get the XO kernel and file system images

The final step in preparation is to download and prepare the QEMU image for the XO-1 laptop. Listing 3 shows how to retrieve this image and extract it prior to use. The image is quite large (183MB), so the download time can be long. Also, the downloaded image expands to almost 1GB in size, so make sure that you have sufficient space available.


Listing 3. Download and extract the OLPC image
$ wget http://olpc.download.redhat.com/olpc/streams/development/LATEST-STABLE-BUILD/
  devel_ext3/olpc-redhat-stream-development-devel_ext3.img.bz2
$ bunzip2 olpc-redhat-stream-development-devel_ext3.img.bz2
            

Start the XO-1 laptop

With the OLPC image downloaded and extracted, it's time for a test run. Start QEMU with two options that specify the amount of memory to make available (256MB) and the hard disk to use for the emulation (the image you downloaded above):


Listing 4. Starting QEMU
$ qemu -m 256 -hda olpc-redhat-stream-development-devel_ext3.img
            

You should then see the standard Linux boot from GNU GRUB (GRand Unified Boot loader). At the end is the startup window, which requests that you provide a user name (see Figure 2). After you provide a name, you can optionally change the color scheme. In the end, you'll end up with the home screen for the XO-1 laptop, which you explore in the next section.


Figure 2.
First-time login for the XO-1 laptop

If you'd like to leave QEMU and return the mouse context to your host operating system, press Ctrl-Alt. To return to the XO-1, click within the Sugar frame, and the mouse context returns to QEMU.


Navigating Sugar

Now that you're logged in and ready to start, explore the OLPC Sugar UI.

Home mode and the frame

The main window in Sugar is called Home mode (see Figure 3). This window is basically the desktop and tells you about your environment, activities, and so on. In the center of the window is the XO icon, which represents you and your laptop. If other users were visible to you wirelessly, you would see them, as well. To shut down the laptop, place the mouse cursor over the X icon, then click the shutdown option.


Figure 3. Home mode for the XO-1 laptop
Home mode for the XO-1 laptop

The ring around your laptop shows you the activities that are currently running. You can click any icon here to return to a running activity. To return to Home mode, move the mouse to a corner of the window. Doing so returns the frame to view. Notice the four circle "zoom" icons at the top left of the frame: The last represents the most recently accessed activities. Clicking this icon takes you back to that activity (which occupies the entire window). The second-to-last icon (the icon with a single dot in the center) represents the Home window. Clicking this icon takes you back to Home mode. The next icon (the icon with three dots) shows you the groups, which are local friends and the activities that they're running. Finally, the first icon (the icon with many dots) represents the entire neighborhood. This icon shows all users and the activities they're sharing.

Start an activity

At the bottom of the frame is the collection of activities that you can run. An activity is an application; as you saw in Figure 3, the XO-1 laptop supports several activities. Sugar comes equipped with a Web browser, a calculator, a paint program, a news reader, and other programs that you can share with other users to collaborate on projects. To start an activity, click that activity's icon in the lower part of the frame. In Figure 4, I've started the Write activity and added some text.


Figure 4. A running activity in Sugar
A running activity in Sugar

Control keys

Using the mouse to navigate is simple enough, but Sugar allows control keys for faster transitions between applications and modes. Table 1 lists several important control sequences that you can use to easily switch between modes.


Table 1. Control sequences for switching between modes
Control keyAction
F1Switch to neighborhood view
F2Switch to group view
F3Switch to home mode
F4Switch to the last activity

Developer console

Because Sugar is built on the Linux operating system, development work requires access to a shell. You can access the shell by pressing Alt-=, which brings up a login prompt. From here, type root to call up a friendly Bash prompt. You can also access a shell through the developer's console, shown in Figure 5. This console includes five tabs for accessing a resource panel, a log viewer, a presence panel (for wireless attached XO-1 laptops), and a terminal (Bash shell), respectively.


Figure 5. The developer console
The developer console

Whenever you want to return to Sugar, press Ctrl-Alt-F3. The shell remains active, so you can conveniently switch back and forth between Sugar and Bash.

Other shortcuts include Alt-F to toggle the frame (that is, the border around the window) on and off. You can exit the current activity by pressing Alt-C and terminate the Sugar GUI by pressing Ctrl-Alt-Backspace.

Extend the XO laptop

Downloading a file system image for the XO-1 laptop means that you get a kernel and root file system in one. The file system contains all the necessary applications and OLPC components to power the XO-1 laptop. But this doesn't mean that you can't extend the software. One of the resident packages in the file system, YUM (Yellow-dog Updated, Modified), is a package-management system that simplifies the downloading, installation, and configuration of software packages.

With YUM, you can download and install new packages as well as update all existing packages on a system. For example, Listing 4 shows how to update packages that have changed since the last update.


Listing 5. Using YUM to install new updates
-bash-3.2# yum -y update
Loading "installonlyn" plugin
Setting up Update Process
olpc_development          100% |==========================| 1.1 kB    00:00
primary.xml.gz            100% |==========================| 2.9 MB    00:17
olpc_devel: ################################################### 11448/11448
olpc_devel_kernel_repo    100% |==========================|  951 B    00:00
olpc_devel: ################################################### 23/23
No Packages marked for Update/Obsoletion
-bash-3.2#


Learn more

For the full story on developing activities for the XO laptop, including the details behind activity development, Python programming, and the Sugar API for Python, read "Application development for the OLPC laptop."


Resources

Learn

  • In Tim's article "Sugar, the XO laptop, and One Laptop per Child" (developerWorks, April 2007), take a tour of Sugar, the XO laptop's novel user interface.

  • In this developerWorks interview with OLPC visionary Walter Bender (developerWorks, April 2007), hear about the OLPC vision, challenges faced, and progress to date.

  • The official OLPC Web site introduces the philosophy and vision of the OLPC project and explores how the laptop will benefit children around the world.

  • Wikipedia has a great introduction to the XO-1 laptop, its history, design, software, and features. The laptop is novel, but some critics wonder whether the money spent on the laptop in some developing countries would be better spent elsewhere.

  • In "System emulation with QEMU" (developerWorks, September 2007), learn about QEMU and its use as a platform emulator. This article introduces you to virtualization, then discusses the internals of QEMU and its use. For more detail on virtualization and the range of Linux solutions, check out "Virtual Linux" (developerWorks, December 2006).

  • A list of activities and projects for the XO-1 is on the laptop.org site. In the early days, the list was sparse, but today you'll find a large number of activities ranging from educational activities, audio and video players, media-creation tools, programming tools, and necessary network applications (such as browsers, feed-readers, and mail programs). You'll even find a variety of games. (Python is a great language for game development.)

  • In the developerWorks Linux zone, find more resources for Linux developers, and scan our most popular articles and tutorials.

  • See all Linux tips and Linux tutorials on developerWorks.

  • Stay current with developerWorks technical events and Webcasts.

Get products and technologies

  • With IBM trial software, available for download directly from developerWorks, build your next development project on Linux.

Discuss

About the author

M. Tim Jones

M. Tim Jones is an embedded software architect and the author of GNU/Linux Application Programming, AI Application Programming, and BSD Sockets Programming from a Multilanguage Perspective. His engineering background ranges from the development of kernels for geosynchronous spacecraft to embedded systems architecture and networking protocols development. Tim is a Consultant Engineer for Emulex Corp. in Longmont, Colorado.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux, Open source
ArticleID=291814
ArticleTitle=Desktop development for the OLPC laptop
publish-date=02262008
author1-email=mtj@mtjones.com
author1-email-cc=tomyoung@us.ibm.com