This is an old revision of the document!
Resources
XO Laptop
Getting Started
General Tips
An XO can be installed with one of many Sugar(
OS) versions. You may or may not need to have the most updated version of Sugar. See the table for what versions have been installed at CCCS:
Version Numbers for XO-1 laptops at CCCS
There is no password for root so it is fairly easy to brick the XO
CTL-ALT-ERASE is the XO equivelent to CTL-ALT-DEL on a windows computer, you also need to do this anytime you make a change in Terminal before it will take effect
When the touchpad gets too sensitive it needs to be recalibrated; for instructions on how to do this look at issue 4 in the
Past Issues section
The battery tends to die in about 1.5-2 hrs of constant use
-
There is a slot on the lower right hand side of the screen where a SD card can be inserted if you need extra storage space.
The
floss manual is a great place to get more information on the XOs.
Investigating the XO
These are general ideas of things you should do and understand before trying to program for the XO
Turn on your XO, go to the control panel, give it a new name, and choose a new color icon for your XO
Flip through and understand the different views: Neighborhood, Group, Home, and Activity
Neighborhood: Press the circle on the left side of the keyboard that has a ring of dots around it
Group: The circle next to the neighborhood view key that contains three dots
Home: the circle located next to the group view, and containing a single dot
Activity:The fourth button in the row of keys, It is a circle with a square in the middle
Look at the information available in the frame
Investigate the journal and how to open and save files there
Investigate the wireless networks available and how they appear
Go to the Terminal Activity and play around, try to figure out the filesystem layout
Note that there are no folders in the journal
Sugar GUI
Preparing for crashes
DO NOT try to open more than three activities at the same time
Save work early and often
Create a USB drive for your group with the image of the
operating system so that if you brick your XO is can be fixed quickly.
Keep a backup copy of all of your code on a USB or another computer
Reflashing
Reflashing will restore the XO to its factory settings. This process can be used for upgrading or downgrading the XO. Directions can be found in the Floss manual. While off, insert a USB stick with the image to reflash with, and while holding down the four game buttons, power on the XO.
Running Sugar
Version numbers for XO-1 laptops at CCCS
XO series: (CT4Y machine: XO-1)
Sugar
OS version: (CT4Y machine: 8.2.1 if not upgraded)
Python version: (CT4Y machine: 2.5.1)
PyGame version: (CT4Y machine build 802: 1.8.0, CT4Y machine build 852: 1.8.1)
- pygameversion.py
import pygame.version
print "PyGame version:", pygame.version.ver
OLPCGames version: (CT4Y machine: won't be installed. It is only installed on xo machines that are used to develop games and publish xo files. xo files can be transferred to other xo machines without OLPCGames.)
Security: disabled
Version Numbers
See this page which describes how to check your XO version. The information is most likely found under “Control Panel : About my XO”.
Build, release, and update information.
CCCS has XO-1's with build 802.
“OLPC is not the only one making XO-1 operating system builds. You can also obtain builds from others in the wider community” (link).
Sugar Labs build:
Dextrose, Sugar 0.88, Fedora 11.
How to differentiate between XO-1 and XO-1.5?
Success with getting to the OK prompt by holding the “X” game button when powering on, and then hitting ESC when prompted to halt the normal startup. So, the laptops at CCCS all appear to be unsecured, and that we will not need a developer key.
Differences between XO versions
| Xo-1 | XO-1.5 | XO-1.75 |
Number of dots on hinge | none | three | seven |
Wiki Pages | XO-1 | XO-1.5 | XO-1.75 |
DRAM | 256 MiB | 1 GiB | n/a |
Mass Storage | 1024 MiB | 4 GiB | n/a |
Fedora | varied | 11 | 14 |
Python Version | n/a | v2.6 | v2.7 |
Emulation
Emulating the XO
Install the sugar package that comes with Ubuntu to use their Sugar Emulator. You can actually open up two different emulators and have them act as two different XOs.
Open two different emulators using these two seperate commands:
ubuntu-prompt$ SUGAR_PROFILE=cat sugar-emulator
ubuntu-prompt$ SUGAR_PROFILE=dog sugar-emulator
Note that cat and dog can be anything, as long as they are different.
Sugar on a Stick
With Sugar on a Stick (SOAS), you can boot directly to the Sugar OS on any machine without the need virtualizing or emulating Sugar. Students can use the journal on the stick to save their work.
In order to use sugar on a stick:
-
Either download sugar on a stick onto the flash drive or use the liveUSB creator to install a version of sugar
Follow the instructions for the USB creator to make a live USB
Note: When making a live USB make sure to leave persistent storage space if you want to be able to save anything
Restart your computer and look for an option to go into settings and change BIOS boot order so that the USB flash drive is first
Some computers do have the option of booting to a USB drive without changing your settings, but if you intend to use sugar on a stick more than a couple of times, you will most likely want to change your BIOS settings anyway
You should now boot to your flash drive. It is possible that you will have to press and extra key in order to successfully boot sugar on a stick, so pay attention
Linux
Familiarity with the Linux family of operating systems can be useful when dealing with the XO. If you haven't done so before, you might consider installing Linux on a machine you have access to. Ubuntu is a distribution that is particularly suited for beginners, and Fedora (the basis for the XO operating system) is good for intermediate users. The Gentoo installation process is considerably more involved, but upon completion you will have a better understanding and appreciation for Linux. For Windows users, the Ubuntu CD provides Wubi, a Windows program that allows Ubuntu to be installed without re-partitioning your computer. Sun Microsystem's VirtualBox provides Windows and Mac OS X users the ability to install any flavor of Linux as a virtual machine inside their existing OS, free of charge.
Some useful links related to Linux:
Programming
Setting up a Development Environment
The XO Laptop Wiki Provides these guides for setting up a development environment (These are extremely important!!):
XO API and Software
When an application is ready for deployment on the XO, the source code is packaged into a .xo file which can be natively imported by the XO laptop. If you need to obtain the source code for an XO application, there are 2 possible ways to do it:
If the program has been imported as an XO activity:
If you have access to the .xo file:
A .xo file is really a compressed zip file: it can be extracted/opened to show the source code and other relevant files. Use:
or a similar command. The source code for the application can be found in DESTINATION_DIRECTORY/bin/
Downloading an activity
Copy the activity folder onto a flash drive
Plug the flash drive into the XO and give it about 20 seconds to process
Open the Terminal and type in the following commands pressing enter at the end of each line:
Go to the journal and find the activity there. If you click on it, it should install
Bundling activities for the XO
Mesh
Mesh Networks are no longer supported in XO 1.5 source
Python
Install Python on your computer
For Windows Users:
Python
The first step in this process is to download a copy of the Python installer, this can easily be accomplished via Python’s website.
-
Click on “Downloads”
Select the appropriate Windows installer and download it.
Pygame will will mostly work with python 3 with a few exceptions
Pygame FAQ but version 2 is still necessary for working on the XOs.
After the file is completely downloaded, open the containing folder and open the executable file you just downloaded
Follow the installer instructions
This method of installation will also install the default Python IDE (called IDLE) for editing code, there is additional information needed to install Python for a different IDE such as Emacs, Eclipse, or VI
Pygame
-
Click on the “Download” tab from the main page
Under the sub-category Windows select the appropriate version of the installer for your machine (this is completely dependent on which version of Python was installed in Step1)
Find and open this update to Python, it will run an automated installer
Upon completing the setup be sure to test that functions and other aspects of Pygame are working correctly.
For Ubuntu (or similar Unix Distributions)
Python
Being a developer friendly environment, Ubuntu comes with a pre-installed and fully operational version of Python
Otherwise, one would the package manager of your specific distribution to download the necessary files…
# apt-get install python
# yum install python
# emerge -av python
To access Python, simply enter ‘python’ in the command shell; this will allow one to interact with the Python interpreter via the shell
The pre-installed build of Python on Ubuntu does not come with an editor, however, it is fairly easy to configure Emacs or any other editor to be used with the language.
# apt-get install emacs21
Python's default editor, IDLE, is also friendly for programmers new to python, and can be installed with the package manager.
Pygame
Pygame is not a standard library for the Python programming language, therefore it is not included in your Ubuntu environment and must be installed
As mentioned in Step 1, the package manager can be made use of to install applications and packages – the same can be done to install the Pygame graphics library using:
# apt-get install python-pygame
Vista and PyGame Instructions
If you have Python (2.5 or higher) and PyGame 1.8 installed, you should be good to go. I've tested crashRun on both MacOS X and Windows and I hope it'll run on Linux, too.
If you need Python, you can download it from: http://python.org/download/
And PyGame is available here: http://pygame.org/download.shtml
Vista users note: when I tried the python installer on a Vista machine, the installer didn't modify the PATH to include Python (it appeared to on XP). You can set this variable by right-clicking My Computer in the Start menu, selecting Properties, Advanced, and then pressing the Environment Variables button. You'll need to append “;C:\Python25\” to the end of the PATH variable.
Some Python Notes
Recursion
Python is not optimized for tail recursion
Recursion uses a lot of memory, not good on an OLPC
It is recommended to use loops instead of recursion when possible
Python Links
For those new to python, the following links can be of great benefit:
Some Slides from previous classes:
Python and Game development tutorials:
A separate page has been created that contains example python programs and games made by previous classes.
Python Example Programs
Pygame
Pygame provides a relatively simple API for programming games in python, and is incredibly usefull for animations. It does not however, provide GUI elements such as buttons/text fields/menus/etc. These must be created by hand when using pygame.
Pygame Tips
Spyral
Virtual Machine
We have a virtual machine set up for our server needs. The information for it is located on this page.
The database information is here
Example Communication via POST
This file passes data via the POST method to the server. The server will log all data passed by $_POST[“data”]. So in this example, “test data from python again” will be passed.
The server script post-server.php catches this string and appends it to an output file test-output.txt.
Try it out, and run this python script from your local machine!
- python-client.py
'''
Richard Burns
November 28, 2010
Test script which passes information to the class apache server via the POST method.
The server script currently captures this information and appends it to a testing
output file, demonstrating one way that we can pass data to the server for it to
record.
Taken from:
http://docs.python.org/library/httplib.html
TODO: test size limitations of the POST
'''
import httplib, urllib
#params = urllib.urlencode({'milk': 1, 'eggs': 2, 'bacon': 0})
params = urllib.urlencode({'data': "test data from python again"});
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
conn = httplib.HTTPConnection("cisc367.acad.cis.udel.edu:80")
#conn.request("POST", "/cgi-bin/query", params, headers)
conn.request("POST", "/post-server.php", params, headers)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
conn.close()
Useful Links