How to set up for development on linux emulation
Here, in one place, are assembled all the steps to get you to a working
emulated XO. Assuming you are running on linux, and have already
installed qemu and kqemu.
The following will not work on your virtual xo: sound in TamTam, camera. The first because no one has gotten around to figuring out why it isn't working[1]. The second because qemu doesn't yet support them.
downloading a build image
Go to http://xs-dev.laptop.org/cscott/olpc/streams/joyride/latest/devel_ext3/ or http://xs-dev.laptop.org/cscott/olpc/streams/ship.2/latest/devel_ext3/ and obtain the numbered -devel_ext3.img.bz2 and its md5. Sometimes builds don't work in qemu. See Emulating the XO for recommendations.
For this example I used build 602.
md5sum -c olpc-redhat-stream-development-build-602-20070920_2254-devel_ext3.img.bz2.md5 bzcat olpc-redhat-stream-development-build-602-20070920_2254-devel_ext3.img.bz2 > xo-602a.img
The resulting file is 1 GB.
running qemu
export PORT=2221 qemu -kernel-kqemu -serial `tty` -m 256 -redir tcp:$PORT::22 -soundhw es1370 \ -net user -net nic,model=rtl8139 -hda your-image-file
If you have a x86_64 cpu, use qemu-system-x86_64 instead of qemu.
The screen will very briefly be black, and then show the blue "GNU GRUB" screen. If it stays black, that's a qemu bug. Kill qemu and try again.
The boot messages will scroll by, and you should eventually see the normal XO first-time login. We'll save that for later.
using a non-english name
If you want to enter a name with diacritics, you need to do the following. In the window where you started qemu, you should see a login: prompt.
- Enter root
- Then:
su olpc -c"DISPLAY=:0 xmodmap -e 'keycode 77 = Multi_key'"
This sets up Num_lock as Multi_key. Unfortunately, the next time X is restarted, you will lose it. A better solution is needed.
- And Num_lock isn't a great choice. MitchellNCharity 10:46, 29 September 2007 (EDT)
killall X
Killing X should restart sugar.
done, sort of
At this point you could just proceed to use your new XO. However, the screen resolution is wrong (1024x768). So for development, or to get a more accurate feel for how things really look, some extra steps are required.
Once you reach the main sugar screen, you should check the Neighborhood view (F1). If you can't see other people, either the we are having problems with the presence server, you are behind an unusually picky firewall, or networking on qemu is broken again in the build number you are using. (Remember that ping doesn't work inside of qemu).
preparing for ssh/scp
While this next step is not strictly required, it will enable you to use ssh and scp, which can be handy to move stuff back and forth between your host and xo.
Still as root on the xo,
1. Change the root password.
passwd
Don't worry if it says something like "BAD PASSWORD: ", and complains about the password you picked. It will still work.
2. Change the olpc password.
passwd olpc
Now you can use ssh and scp.
getting 1200x900
The current released version of QEMU doesn't support 1200x900, so we use a Xephyr remote X server. Each time you boot the xo, if you want 1200x900, you'll need to do these next steps again, except for the ones marked "(First time only)".
1. Still as root on the xo:
init 3 sleep 5 ifup eth0 su olpc grep export /usr/bin/sugar > ~/env source ~/env
If the ifup eth0 fails with an "already running" message, that's ok. Perhaps it is no longer needed.
2. Back on the host, prepare Xephyr (First time only)
mcookie > xephyr-cookie export COOKIE=`cat xephyr-cookie` rm -f xephyr-xauth; echo "add :1 . $COOKIE" | xauth -f xephyr-xauth echo $COOKIE
3. On the xo, still as "su olpc", record the cookie: (First time only)
echo "add 10.0.2.2:1 . " PUT-THE-COOKIE-HERE | xauth
4. Back on the host, start a Xephyr:
Xephyr :1 -auth xephyr-xauth -reset -screen 1200x900x8 -dpi 200
You will probably want to do this in its own window, as it periodically dies and needs to be restarted.
5. On the xo, still as "su olpc", start sugar:
DISPLAY=10.0.2.2:1 sugar
Actually, I usually ssh in from the host, and run sugar that way:
a. On the host,
ssh -o NoHostAuthenticationForLocalhost=yes -p 2222 olpc@localhost
b. in the resulting shell,
source ~/env export DISPLAY=10.0.2.2:1 sugar
You may also want to run
xmodmap -e 'keycode 77 = Multi_key'
to be able to enter diacritics with the Num_lock key. But I find doing it first thing tends to kill Xephyr. :(
You should now see the XO first-login screen in correct resolution.
You can use Num_lock to enter diacritics. Congratulations. Sorry it
was so much bother.
Update from Hklv, 18:00, 13 April 2008
Qemu does indeed support 1200x900, with the help of a special modeline.
Here's the relevent parts extracted from my xorg.conf :
Section "Device" Identifier "Carte vidéo générique" Driver "cirrus" BusID "PCI:0:2:0" EndSection Section "Monitor" Identifier "Moniteur générique" Option "DPMS" HorizSync 28-51 VertRefresh 43-60 Modeline "1152x864@43" 55.75 1152 1184 1392 1424 864 883 889 908 Modeline "1200x900@43" 60.82 1200 1232 1456 1488 900 919 926 946 EndSection Section "Screen" Identifier "Écran générique" Device "Carte vidéo générique" Monitor "Moniteur générique" DefaultDepth 16 SubSection "Display" Modes "1200x900@43" "1152x864@43" "1024x768" EndSubSection EndSection
running multiple xo's
To run multiple xo's (to play with collaboration, for instance), you can repeat the above steps. Create a xo-485b.img, and use a different PORT number (like 2222). If you are using Xephyr, start a second Xephyr, which will be 10.0.2.2:2, use that instead of ...:1 in the instructions. You should now be able to see yourself, and collaborate in Write.
simplifying ssh use
The following will save you having to periodically type your xo password, but is optional, and can just as easily be done later.
Back on the host,
1. Create an ssh key if you don't already have one. See Emulating the XO/Help_and_tips#SSH into qemu, using a key.
2. Copy it to the xo,
scp -o NoHostAuthenticationForLocalhost=yes -P $PORT ~/.ssh/id_rsa.pub root@localhost:~/
3. On the xo, as root, spread the key around:
mkdir ~root/.ssh mkdir ~olpc/.ssh cat ~root/id_rsa.pub >> ~root/.ssh/authorized_keys cat ~root/id_rsa.pub >> ~olpc/.ssh/authorized_keys
You can now ssh and scp without retyping your password.