Hacking the OLPC XO Laptop - Part 1: Initial Setup
Monday, January 28, 2008
I wrote a post titled
Why you should buy an OLPC XO Laptop a couple of months ago. In
the post, I indicated that I had ordered one. Well, my XO arrived a
week ago (Canadian G1G1 orders were shipped later than US orders;
therefore, Canadians only started to receive XO's in mid-January). I
received the laptop on the weekend, just before I was supposed to fly
out for a one week trip. Normally, when I travel, I take my 17"
MacBook Pro laptop with me. However, I decided to plunge right in and
take only the XO with me on this trip. I think that was a really good
idea as it forced me to use it for everything while I was away and to
customize it for my own use.
First of all, some initial impressions:
- It's really tiny!
- The display is incredible!
- I'll never touch type on that keyboard! (after one week of use though, my two-finger typing speed got pretty fast and I am starting to get better at multi-finger typing)
- The laptop "feels" very robust (not as "toy-like" as some of the pictures would have you think).
The XO's software is basically Fedora Linux with a custom UI and a lot of educational programs. Since I will probably be mostly using the XO when travelling, my needs are primarily: web browsing, email, audio/video playback, and some programming. So, I installed a few things to get a better working environment. Since US XO shipments started a month before Canadian XO shipments, I was able to benefit from the experiences of others (the OLPC News Forum, the OLPC Community Support Forum, and the OLPC Wiki are all great resources). Here are some of the things I did (note: where there are on-line instructions available, I've added a link to those instructions so that others don't have to figure out how to do some of these things too):
- Upgraded to build 653: I initially had some wifi issues but these were resolved by upgrading to the latest stable build. A word of caution: upgrades wipe out your custom installs (e.g. - anything you used "yum install xxx" to install as well as anything that is not in your home directory). Therefore, it's a good idea to set up a script that you can run after an upgrade to re-install all of your customizations.
- Installed the Opera browser: The customized Firefox browser that comes with the XO is well-suited for collaborative learning; however, it is missing a lot of "standard" browser functionality. In the future, I might drop Opera and move to either Firefox or SeaMonkey.
- Installed Emacs: I "live" in Emacs most of the time, so I had to
have Emacs on the XO. This was as simple as "yum install emacs";
however, I soon discovered a number of issues:
- The "standard" font that is used in Emacs is way too small and there didn't seem to be any way to change the font (normal Emacs font commands don't work and it would appear that others have encountered the same problem). I subsequently found some ways to change the console and terminal fonts; however, I still haven't found a way to change the font in a windowed Emacs.
- When I used the "emacs -nw" startup, the font was much better. However, I soon found that the Control-s and Control-q keys weren't being recognized by Emacs. Initially, I thought this was a flow control problem. The normal way to disable flow control is to do "stty -ixon" before starting Emacs. However, that didn't work. For a while, I just did "M-x enable-flow-control" in Emacs so that the C-s and C-q keys would be remapped to C-\ and C-^. After a bit more digging though, I discovered that Sugar was mapping those keys for the UI. I found a way to disable those mappings (I also disabled a lot of other "standard" Sugar mappings that could potentially interfere with Emacs at the same time), so now I can happily use Emacs on my XO.
- Installed the
Quake terminal: The standard Terminal Activity that
comes with the XO is a bit limited. Here are some of the limitations
and a description of what Quake provides:
- Terminal opens with the activity bar at the top. This can be removed by pressing Alt-Enter; however, I disliked having to do this each time I started the terminal. Quake opens without the activity bar.
- You can't create tabbed terminal windows in Terminal. Quake lets you create tabs with C-t and switch between them with C-left/right.
- The default Terminal "paste" is mouse-3 (which doesn't exist unless you are using a 3-button mouse!). Quake lets you do a paste using either C-S-v or mouse-2.
- Installed mplayer: The video player that OLPC provides only plays OGG videos. Although this is keeping with the OLPC philosophy of support for open standards and software, the reality is that most audio and video content is in non-free formats, so I installed mplayer.
- Installed some development utilities: Some basic stuff for
programming with Lisp and C:
yum install gcc yum install glibc-headers yum install make yum install texinfo yum install cvs yum install sbcl cvs -d :pserver:anonymous:firstname.lastname@example.org:/project/slime/cvsroot co slime
- I setup my .emacs file as follows (basically, just some standard
customizations that I normally do plus some basic setup for CL and elisp programming):
;;__________________________________________________________________________ ;;;; Directories
(defvar home-dir (concat (expand-file-name "~") "/"))
(push (concat home-dir "elisp") load-path) (push (concat home-dir "elisp/slime") load-path) (push (concat home-dir "elisp/slime/contrib") load-path)
(push (concat home-dir "projects/emacs/info") Info-default-directory-list) (push (concat home-dir "elisp/info") Info-default-directory-list)
;;__________________________________________________________________________ ;;;; System Customizations
(defconst use-backup-dir t) (setq backup-directory-alist (quote ((".*" . "~/.backups/"))) version-control t ; Use version numbers for backups kept-new-versions 16 ; Number of newest versions to keep kept-old-versions 2 ; Number of oldest versions to keep delete-old-versions t ; Delete excess backup versions history-delete-duplicates t ; Delete dups in history history-length 100 ; Larger history size than default 30 inhibit-splash-screen t ; No initial splash screen dired-listing-switches "-l" ; Don't display dot files dired-recursive-deletes 'top ; Recursive deletes dired-recursive-copies 'top ; Recursive copies backup-by-copying-when-linked t) ; Copy linked files, don't rename
(fset 'yes-or-no-p 'y-or-n-p) ;replace y-e-s by y
;; Conventional mouse/arrow movement & selection (pc-selection-mode) (delete-selection-mode t)
;; Display overrides (show-paren-mode 1) (tool-bar-mode nil) (menu-bar-mode nil) (iswitchb-mode)
;; Global key overrides (global-set-key [(control c) (F)] 'ffap) (global-set-key [(control c) (j)] 'join-line)
;;__________________________________________________________________________ ;;;; Programming - Common Lisp
;; Specify modes for Lisp file extensions (setq auto-mode-alist (append '( ("\.lisp$" . lisp-mode) ("\.lsp$" . lisp-mode) ("\.cl$" . lisp-mode) ("\.asd$" . lisp-mode) )auto-mode-alist))
(eval-after-load "slime" '(progn (setq inferior-lisp-program "sbcl" slime-complete-symbol*-fancy t slime-complete-symbol-function 'slime-fuzzy-complete-symbol slime-when-complete-filename-expand t slime-truncate-lines nil slime-autodoc-use-multiline-p t)
(slime-setup '(slime-fancy slime-asdf))
(define-key slime-repl-mode-map (kbd "C-c ;") 'slime-insert-balanced-comments) (define-key slime-repl-mode-map (kbd "C-c M-;") 'slime-remove-balanced-comments) (define-key slime-mode-map (kbd "C-c ;") 'slime-insert-balanced-comments) (define-key slime-mode-map (kbd "C-c M-;") 'slime-remove-balanced-comments) (define-key slime-mode-map (kbd "RET") 'newline-and-indent) (define-key slime-mode-map (kbd "
") 'newline-and-indent) (define-key slime-mode-map (kbd "C-j") 'newline)))
(add-hook 'lisp-mode-hook (lambda () (cond ((not (featurep 'slime)) (require 'slime) (normal-mode))) (modify-syntax-entry ?- "w")))
;;__________________________________________________________________________ ;;;; Programming - Elisp
(add-hook 'emacs-lisp-mode-hook '(lambda () (interactive) (define-key emacs-lisp-mode-map (kbd "RET") 'newline-and-indent) (define-key emacs-lisp-mode-map (kbd "
") 'newline-and-indent) (define-key emacs-lisp-mode-map (kbd "C-j") 'newline) (require 'eldoc) (turn-on-eldoc-mode) (modify-syntax-entry ?- "w"))) ; now '-' is not considered a word-delimiter
;;__________________________________________________________________________ ;;;; Initial buffer
- I setup my .bashrc file as follows (basically just a custom
prompt (so that I can easily see when I'm 'root') and some
if [ "$INSIDE_EMACS" ]; then export PS1='\w \$ ' else PS1error='$( ret=$? ; test $ret -gt 0 && echo "\[\e[41;93m\] [$ret] \[\e[0m\]" )' PS1user='$( test `whoami` == root && echo "\[\e[101m\]root:" )\[\e[0m\]' PS1color='\[\e[1;37;44m\]' # color of working directory PS1="$PS1error$PS1color\w\[\e[0m\] $PS1user$ " export PS1 fi export PATH=~/bin:/sbin:/usr/sbin:/usr/local/sbin:$PATH alias ll='ls -l' alias la='ls -la' alias e='emacs -nw -fg white -bg black' alias gf='grep-find' alias ff='firefox &' alias mp='mplayer -fs'
- Fixed a few "minor" annoyances:
- Get a good PDF viewer. The one that comes with the XO can only be started from the Journal activity (I dislike using the Journal and most of the PDF documents that I would have on the XO wouldn't be accessible from the Journal) and it seems to "choke" on large PDF documents. I tried installing xpdf (using "yum install xpdf"), but the install didn't work. Since I didn't need to have a PDF viewer for the stuff I was doing last week, I just deferred trying to work out what the issues were. I would appreciate it if someone could suggest a PDF viewer that they've been able to successfully install on the XO.
- I still haven't decided whether to stick with the Opera browser or swap to Firefox or SeaMonkey. Apparently, you have to edit the "/etc/yum.repos.d/olpc-koji-ship2.repo" file to remove firefox/seamonkey from the exclude list at the bottom of the file so that you can use yum to install them.
- I'm planning to install Xubuntu on a USB stick or SD card. Although I currently intend to keep Sugar as the default UI and Fedora as the default OS, I would like to try out Xubuntu as an alternative as well.
- I've ordered a D-Link USB Ethernet adapter so that I can use a wired connection with my XO when wifi isn't available.
- I've setup emulated XO environments on my MacBook Pro using both Parallels and QEMU (Parallels is a commercial product and QEMU is OSS). The Parallels setup seems to run faster but is more complicated to setup and the Internet connection doesn't work. QEMU seems slower but is much easier to setup and the Internet connection does work. Apparently, the OLPC developers mostly use QEMU (the screenshot above is XO build 653 running under QEMU). I'll have to see whether I prefer developing on an Emulated XO or directly on the XO itself. When I'm at home, I have the XO setup as in the picture above - on the document tray of my laptop stand, nicely positioned below the MacBook display. I can easily swap the USB cable (one cable since the USB mouse is connected to the Kinesis keyboard) when I want to switch to/from the MacBook and the XO.
- I've replaced the fancy PS1 definition in my .bashrc file with a simple "export PS1='\w \$'" as the fancy one didn't work well when I invoked a shell from within Emacs.
- I've eliminated opera and, after trying out both SeaMonkey and Firefox, have settled on Firefox as my web browser (I just did a "yum install firefox" to install it).
- I am using gv and Xpdf to display PDF files now (installed with "yum install gv" and "yum install xpdf"). Xpdf seems to work best so far.