Emulating the XO/Help and tips: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
 
(87 intermediate revisions by 33 users not shown)
Line 1: Line 1:
<big><b><font color=red>For current information on emulation of OLPC software images, see [[Emulating the XO]]</font></b></big>
More often than not, technology manages to get us 95% of the way... being the last 5% a mix of magical incantations, rituals and other esoteric activities only clear to the initiated. This page tries to take some of the magic away from the ''sufficiently advanced science''.


{{Deprecated}}
Please remember to end your comments with <nowiki>~~~~</nowiki>, which is replaced by a timestamp when you save the page. Without them, notes months old and obsolete look just like notes added yesterday.


When it comes to emulating systems like the XO, sometimes it seems like technology only manages to get us 95% of the way there--the last 5% an assortment of mystical incantations and other superstitious activities just to confuse the uninitiated. This page is a humble attempt to take some of the magic and mystery away from this ''sufficiently advanced science''.
Some of the information on this page is obsolete. Some of it only applies to the XO disk images.

Please remember to '''end your comments with <nowiki>~~~~</nowiki>''', which is replaced by a time stamp when you save the page. Without them, notes that are months old and obsolete look the same as notes added yesterday.

Bear in mind that some of the information on this page is obsolete, and some of it only applies to certain XO disk images.


== How to ==
== How to ==

=== Keyboard and buttons ===
The XO has dedicated keys on the keyboard for [[Sugar]] features such as the Home view, the Neighborhood, and showing/hiding the frame; it also has buttons around the screen for screen rotation and gamepad controls. Some of these correspond to function keys on regular keyboards, and there are keystroke combinations for others; see [[Keyboard shortcuts]].


{{anchor|sendkey}}
{{anchor|sendkey}}

=== Change the keymapping to your local keyboard layout ===

To change the keyboard layout when you are using an Emulation do:

1. enter Console (Alt-Ctrl-F1)<br>
2. login as root (just hit RETURN, no password needed)<br>
3. type
loadkeys xy
:where xy is your keyboard layout shortcut, e.g. "de" for german layout.
:(be careful: as you havn't changed your keyboard layout when you type the command, you might have to hit the key "z" to get an "y" and/or the key "q" to get an "a".)

4. edit /etc/sysconfig/keyboard (this changes the keyboard layout within SUGAR)
vi /etc/sysconfig/keyboard
:"a" starts edit-mode (insert '''a'''fter cursor)
:change "us" to your keycode ''two'' times.
:leave edit-mode (ESCAPE)
:type ":wq" and hit Enter to '''w'''rite the changes and '''q'''uit the editor
:If you produced a chaos and want to quit without writing the changes, type ":q!"

:''You find additional information about the codes used in /etc/sysconfig/keyboard in the [[Manufacturing Data]] page.

5. edit /etc/rc.d/rc.local (this changes the keyboard layout permanently for the console)
vi /etc/rc.d/rc.local
:"a" starts edit-mode (insert '''a'''fter cursor)
:move the cursor to the end of the file, hit RETURN to create a new line.
:type "loadkeys de" (or whatever keycode you want)
:leave edit-mode (ESCAPE)
:type ":wq" and hit Enter to '''w'''rite the changes and '''q'''uit the editor
:If you produced a chaos and want to quit without writing the changes, type ":q!"

If you don't know the mapname/code for your keyboard layout, go to /lib/kdb/keymaps, switch to the subdirectory that covers your architecture (eg "i386" for Intel-platforms), and then enter the subdirectory which covers your keyboard type (look at the first six letters on the upper left of your keyboard to distinguish the "azerty", "qwerty" or "qwertz" layout type). In the subdirectory, you find some keymaps for your keyboard layout - find out which one fits your keyboard exactly. The keymap code is the filename without "map.gz".

Valid examples (among others) are:

''"by", "cf", "cz", "dk", "emacs", "es", "et", "fi", "gr", "hu101", "il", "is-latin1", "it", "jp106", "ko", la-latin1", "lt", "nk", "nl", "no", "pc110", "pl", "pt", "ro", "ru", "se-latin1", "sk-qwerty", "sr-latin", "sv-latin", "trq", "ua", "uk", "us" (QWERTY)<br>
''"cz-us-qwertz", "de", "croat", "fr", "fr_CH", "sg", "sk-qwertz", "slovene", "hu" (QWERTZ)<br>
''"azerty", "be-latin1", "fr", "wangbe" (AZERTY)''

If those examples don't fit your keyboard layout exactly, please have a look into the directories for yourself to look for alternatives or define your own keymap (see http://wiki.linuxquestions.org/wiki/Configuring_keyboards#The_Loadkeys_Method for instructions)

=== Sending Ctrl-Alt combos in Qemu (or Q.app) ===
=== Sending Ctrl-Alt combos in Qemu (or Q.app) ===
According to [[Sugar Instructions#Terminal, Shell, or Linux Prompt|Sugar Instructions]] you need to "hold down <tt>Ctrl+Alt+F1</tt> to leave the Sugar screen and return to the login prompt" and then "you can return to Sugar with <tt>Ctrl+Alt+F7</tt>". Unfortunately for me the "<tt>Ctrl+Alt</tt>" action seems to be grabbed by the Q.app "mouse pointer ungrab" functionality.
According to ''(now obsolete)'' [[Sugar Instructions#Terminal, Shell, or Linux Prompt|Sugar Instructions]] you need to "hold down <tt>Ctrl+Alt+F1</tt> to leave the Sugar screen and return to the login prompt" and then "you can return to Sugar with <tt>Ctrl+Alt+F7</tt>". Unfortunately for me the "<tt>Ctrl+Alt</tt>" action seems to be grabbed by the Q.app "mouse pointer ungrab" functionality.


Under Linux, this will be grabbed by the X server running on your computer, and not the one running in the emulator, and will switch your own computer to a terminal.
Under Linux, this will be grabbed by the X server running on your computer, and not the one running in the emulator, and will switch your own computer to a terminal.
Line 24: Line 72:
=== Get a login prompt ===
=== Get a login prompt ===


If you started qemu with the <tt>-serial `tty`</tt> argument, you can simply use that login prompt.
If you started qemu with the <tt>-serial `tty`</tt> argument, you can simply use that login prompt (Linux only, doesn't work on Windows).


Otherwise, pressing <tt>ctrl alt 3</tt> will bring up the console. (But then you can't cut and paste from/to the host machine).
Otherwise, pressing <tt>ctrl alt 3</tt> will bring up the console. (But then you can't cut and paste from/to the host machine).


You can alternatively press alt+0 to open the Sugar Developer Console which includes a terminal.
You can alternatively use the [[Terminal]] activity.


=== Login as root ===
=== Login as root ===


[[#Get a login prompt]].
[[#Get a login prompt]].

The root password on fresh xo/qemu images is empty.
In post-650 builds, do not directly login as root, but first as user 'olpc'. The password for user olpc on fresh xo/qemu images is empty. (Pre-650 you could login as root with an empty password by default.)

Then "sudo su -" to get a root prompt.


=== Change the root password ===
=== Change the root password ===
Line 108: Line 159:
If you want to use '''[http://www.nano-editor.org/ nano]''' for system file edits,
If you want to use '''[http://www.nano-editor.org/ nano]''' for system file edits,
make sure line wrap is disabled by '''Alt-L'''
make sure line wrap is disabled by '''Alt-L'''
(or look here for it's [http://www.gnu.org/software/nano/manual/ documentation]).
(or look here for its [http://www.gnu.org/software/nano/manual/ documentation]).


=== My emulator is very slow ===
=== My emulator is very slow ===
Line 114: Line 165:
See [http://www.h7.dion.ne.jp/~qemu-win/ Qemu on Windows] and [http://fabrice.bellard.free.fr/qemu/download.html QEMU Home Page]
See [http://www.h7.dion.ne.jp/~qemu-win/ Qemu on Windows] and [http://fabrice.bellard.free.fr/qemu/download.html QEMU Home Page]


== Display ==

=== Font Size correction ===

You will want to edit /etc/X11/xorg.conf and apply the changes suggested in {{Trac|3681}} to get the fonts to look bigger and nicer in emulation: ([[User:Vorburger|Vorburger]] 13:35, 7 October 2007 (EDT))

Edit xorg.conf

Ctrl-Alt-3
nano /etc/X11/xorg.conf

Add a new section "monitor"

Section "Monitor"
Identifier "Monitor0"
DisplaySize 153 115
EndSection

Add a "Monitor" line to the "Screen" Section

Section "Screen"
...
Monitor "Monitor0"
EndSection

Restart X [ kill it and let init respawn it. ]

killall -i X

=== Fullscreen ===

If you run qemu on a physical 1024x768 display (e.g. a laptop with 1024x768 LCD), you get a MUCH more "natural" experience if you switch qemu to fullscreen: Add "-full-screen" as argument to qemu start-up, and/or press Ctrl-Alt-F on a running qemu to toggle. ([[User:Vorburger|Vorburger]] 13:35, 7 October 2007 (EDT))


== Development ==
== Development ==
Line 122: Line 205:


=== Communicating between host and xo image ===
=== Communicating between host and xo image ===

==== Check networking ====

Make sure networking is working. In short, an "ifconfig" should show inet addr:10.0.2.15 on eth0, you should be able to do a "ping 10.0.2.2" (that's how the host is visible) and have a working e.g. "wget http://wiki.laptop.org/" from CLI before going any further.

Recent builds (i.e. 613) work out of the box IFF you pass the correct qemu start-up parameters (see [[Emulating the XO/Quick Start]]). If not, you can try a manual "ifup eth0", but as of build 613 there will be other problems (X/X11/Sugar start-up) if networking is not working during start-up.

[[User:Vorburger|Vorburger]] 04:14, 7 October 2007 (EDT)


==== SSH into qemu ====
==== SSH into qemu ====
Line 154: Line 245:


Now you can ssh into the xo image without typing a password.
Now you can ssh into the xo image without typing a password.

You may need to change the permissions of the authorized_keys file like this:
chmod g-w ~root/.ssh/authorized_keys
chmod g-w ~olpc/.ssh/authorized_keys

==== SSH into qemu, without having to specify the user or port ====

Setup a ssh config entry on your host to simplify using ssh. The following steps are all performed on the host.

* Create a config file if you don't already have one:
touch ~/.ssh/config
* Add a section for your host (vi ~/.ssh/config or nano ~/.ssh/config) :
Host olpc
User root
Port 2222
Hostname localhost

You can now just use the alias '''olpc''' to use ssh/scp without specifying the user or port

ssh olpc

or

scp somefile olpc:

==== Comfortably transfer Files between Host and XO ====

To transfer Files between Host and XO, once you have set-up a root passwd and added the argument <tt>-redir tcp:2222::22</tt> whenever you run qemu as described above, the easiest is to use scp with a graphical scp client. This will allow you to easily "browse" and "explore" the XO's file system.

ToDo: On Linux, Nautilus und Konqueror can natively do scp as well; you probably just type scp://localhost:2222/ (or fish://localhost:2222/, or sftp://localhost:2222/ ?) in the address bar, but I haven't tested this.

On Windows, use WinSCP from http://winscp.net/eng/download.php and connect as root to localhost port 2222.

PS: And while we're on tools for Windows... use Putty from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to SSH (localhost:2222) from Windows into your XO, not Cygwin. Putwin will emulate the terminal correctly by default, give you colors, scrolling and copy/pasting easily work, etc.

[[User:Vorburger|Vorburger]] 04:23, 7 October 2007 (EDT)


==== Pull things from a webserver ====
==== Pull things from a webserver ====
Line 198: Line 325:
sendkey ctrl-alt-backspace
sendkey ctrl-alt-backspace


=== Issue - incorrect screen size ===
=== Get 1200x900 resolution ===


Qemu does not currently support 1200x900 (though the cvs version is said to, via -vmwarevga). It defaults to 1024x768. Which is what the laptop's X and cairo see. So code you write assuming 1200x900, gets an unexpected down-scaling. Cairo make-it-smaller scaling is currently much faster than its make-it-bigger, so the performance impact may not be large. But if you were hoping to do nifty things with 200bpi, you need the CVS version. Or maybe use 1280x1024, and only use part of the screen? [[User:MitchellNCharity|MitchellNCharity]] 21:16, 6 June 2007 (EDT)
Qemu does not currently support 1200x900 (though the cvs version is said to, via -vmwarevga). It defaults to 1024x768. Which is what the laptop's X and cairo see. So code you write assuming 1200x900, gets an unexpected down-scaling. Cairo make-it-smaller scaling is currently much faster than its make-it-bigger, so the performance impact may not be large. But if you were hoping to do nifty things with 200bpi, you need the CVS version. Or maybe use 1280x1024, and only use part of the screen? [[User:MitchellNCharity|MitchellNCharity]] 21:16, 6 June 2007 (EDT)
:See [[#Run a Xephyr remote X display]] for a workaround. [[User:MitchellNCharity|MitchellNCharity]] 10:48, 23 June 2007 (EDT)
:See [[#Run a Xephyr remote X display]] for a workaround. [[User:MitchellNCharity|MitchellNCharity]] 10:48, 23 June 2007 (EDT)

Qemu does indeed support 1200x900, with the help of a special modeline.
Here's the relevent parts extracted from my xorg.conf :
<pre>
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
</pre>
[[User:Hklv|Hklv]] 18:13, 5 April 2008


=== Run a Xephyr remote X display ===
=== Run a Xephyr remote X display ===
Line 233: Line 388:
'''Every time:'''
'''Every time:'''
*run Xephyr
*run Xephyr
Xephyr :1 -auth xephyr-xauth -reset -screen 1200x900x16 -dpi 200
Xephyr :1 -auth xephyr-xauth -reset -screen 1200x900x8 -dpi 200
*and in another window, start sugar
*and in another window, start sugar
ssh -o NoHostAuthenticationForLocalhost=yes -p 2222 olpc@localhost
ssh -o NoHostAuthenticationForLocalhost=yes -p 2222 olpc@localhost
Line 241: Line 396:


Only because it might be easier on non-linux platorms, I note: A simpler, but '''much less secure''', and probably slower (-X uses encryption) alternative is to run Xephyr with the -ac argument (disabling access control! Don't do this unless you ''really'' trust your firewall and local environment). And then in another window on the host, run xterm -display :1 -e ssh ... .xinitrc. Interestingly, this approach didn't require repeatedly restarting Xephyr.
Only because it might be easier on non-linux platorms, I note: A simpler, but '''much less secure''', and probably slower (-X uses encryption) alternative is to run Xephyr with the -ac argument (disabling access control! Don't do this unless you ''really'' trust your firewall and local environment). And then in another window on the host, run xterm -display :1 -e ssh ... .xinitrc. Interestingly, this approach didn't require repeatedly restarting Xephyr.

=== Switching to a different presence server ===

Here we switch to olpc.collabora.co.uk:

cp -p /home/olpc/.sugar/default/config /home/olpc/.sugar/default/config.old
gawk '/^server =/ {print "server = olpc.collabora.co.uk"} !/^server =/ {print}' /home/olpc/.sugar/default/config.old > /home/olpc/.sugar/default/config

Then [[#Restart_sugar]].


=== Running multiple qemus ===
=== Running multiple qemus ===
Line 272: Line 436:


=== Logging boot messages ===
=== Logging boot messages ===

WARNING: This disables (at least on Windows) the Ctrl-Alt-3 console (you get a "parallel0 console" instead) !!!

For Linux:


qemu -serial stdio -hda olpc-redhat-stream-development-ext3.img | tee boot.log
qemu -serial stdio -hda olpc-redhat-stream-development-ext3.img | tee boot.log

For Windows:

qemu.exe -serial file:boot.log -hda olpc*.img


The kernel params in /boot/grup/menu.lst are already set to send to console IO to both the screen and serial ( console=ttyS0,115200 console=tty0), so -serial stdio is all it takes to have it sent to stdout.
The kernel params in /boot/grup/menu.lst are already set to send to console IO to both the screen and serial ( console=ttyS0,115200 console=tty0), so -serial stdio is all it takes to have it sent to stdout.

PS: Qemu on Windows doesn't like "-serial stdio", thus the "-serial file:boot.log" - might actually work on Linux, too?

PPS: Repeating warning - this disables (at least on Windows) the Ctrl-Alt-3 console (you get a "parallel0 console" instead) !!!

=== Cut and paste text from qemu ===

One simple approach is to login in the window from which qemu was started. This window is in the X of the host, but has the shell in qemu. So you can cat the text, and cut and paste it.

x2x might be another alternative. We should explore and document it. http://borderworlds.dk/blog/20070224-00.html [[User:MitchellNCharity|MitchellNCharity]] 15:45, 2 October 2007 (EDT)


=== Mounting a qemu image (to directly manipulate its filesystem) ===
=== Mounting a qemu image (to directly manipulate its filesystem) ===
Line 290: Line 472:
=== Expand a qemu image ===
=== Expand a qemu image ===


With ''N'' changed to the desired size in MB,
With ''N'' changed to the desired size in MB: (If on Windows, get Cygwin and install a dd; that works! ( The Qemu Manager allows a volume/drive image to be created and then accessed as e.g. /dev/hdb ))

dd if=/dev/zero of=''laptop.img'' seek=''N'' obs=1MB count=0
dd if=/dev/zero of=''laptop.img'' seek=''N'' obs=1MB count=0

Obtain the gparted .iso LiveCD, from http://gparted.sourceforge.net/livecd.php (~50MB).
Obtain the gparted .iso LiveCD, from http://gparted.sourceforge.net/livecd.php (~50MB).
qemu -kernel-kqemu -boot d -cdrom gparted-livecd-0.3.4-7.iso ''laptop.img''
qemu -kernel-kqemu -boot d -cdrom gparted-livecd-0.3.4-7.iso ''laptop.img''

Make sure you chose the second option in the Grub boot menu, "GParted-liveCD (Do X Configuration = mkxf86config)", not the default first "... (auto-configuration)".

(Alternatively, with the Qemu Manager, start up a regular image with a second (larger) volume e.g. /dev/hdb, once booted up, copy the original drive (/dev/hda) to the expanded image on /dev/hdb with e.g. "dd if=/dev/hda of=/dev/hdb" then follow the #Enlarging_the_Partition and #Enlarging_the_filesystem instructions...)

Do http://gparted.sourceforge.net/larry/resize/resizing.htm
Do http://gparted.sourceforge.net/larry/resize/resizing.htm

For more background information, see also: (But you do not have to execute these steps when using gparted)
*[[Installing Fedora Core#Enlarging_the_Partition]]
*[[Installing Fedora Core#Enlarging_the_filesystem]]


=== Emulating the xo's unusual color display ===
=== Emulating the xo's unusual color display ===
Line 315: Line 508:
== Network startup ==
== Network startup ==


Should now "just work".
Chances are that the network will not be enabled. Following are two possible ways to enable it.


For the next week or few (Dec 2007), presence service (collaboration and mesh view) in joyride builds wont work out of the box, as they are configured to use a not yet existant ship2.jabber.laptop.org. You might try the currently overloaded and fragile jabber.laptop.org instead. [[User:MitchellNCharity|MitchellNCharity]] 22:46, 14 December 2007 (EST)
=== Network setup ===
:''(This section is linked to from elsewhere, so don't rename it casually.)''


== Configuration ==
*[[#Change the root password]]
*As root:
To see the net:
echo ifup eth0 >> /etc/rc.local
To also see other sugar machines:
mv /etc/rc3.d/S98NetworkManager /etc/rc3.d/DISABLED-S98NetworkManager
mv /etc/rc5.d/S98NetworkManager /etc/rc5.d/DISABLED-S98NetworkManager


<DIV ID="Anchor:how to change desktop resolution"></DIV>
*Reboot the image. Simply exiting qemu and starting it again is fine.
=== Altering display size and resolution ===


If you really can't get 1200x900, you can use 1280x1024 or 1024x768 instead. You can even use 800x600 to perhaps do development on small displays, but the result looks very different than on the real 1200x900.
Congratulations, your network should now be working.


=== Dealing with NetworkManager ===
==== Setting Framebuffer size ====


The kernel can be started with a VGA framebuffer of a few sizes. The <tt>vga=0x317</tt> option.
NetworkManager is intended to make wireless networking "just work". As connectivity comes and goes, it notices and sets things up. Unfortunately, it doesn't work in xo disk images on qemu.


You can edit the kernel line in <tt>/boot/grub/grub.conf</tt>, or at boot time, in the initial blue GRUB screen.
Logged into an image as root, you can see
ifconfig
thinks eth0 is up, as the web browers proves, but NetworkManager's
nm-tool
thinks eth0 is Active: no, and thus that you are disconnected from the net.


<tt>
The problem is nm expects a modern network interface card which supports line/carrier detect.
{|align=center border="1" style="text-align: center;"
Qemu's default emulated nic, ne2k_pci, doesn't. An alternate model=rtl8139 is reported to, and to work with nm, but the xo images don't have a driver for it.
|+VGA kernel color / resolution table
!Colors!!640x480!!800x600!!1024x768!!1280x1024
|-
!256
|0x301||0x303||0x305||0x307
|-
!32k
|0x310||0x313||0x316||0x319
|-
!64k
|0x311||0x314||style="background:lightgreen"|0x317||style="background:lightgreen"|0x31A
|-
!16M
|0x312||0x315||0x318||0x31B
|-
|}
</tt>


'''NOTE:''' If you don't set the VGA kernel parameter to <tt>'''0x317'''</tt> (in order to get a 1024x768 with 64k colors) you will NOT be able to view / use [[Etoys]] properly.
Fortunately, inside qemu, with our hardwired eth0, we don't care about the functionality nm provides.
:This NOTE is old. It may or may not be still true. 0x31A seems to work too. [[User:MitchellNCharity|MitchellNCharity]] 18:56, 8 November 2007 (EST)
And also fortunately, sugar has reasonable fallbacks for when it finds nm isn't running.


==== Setting DPI and font size for odd display sizes ====
So if we avoid running nm, everything works.


https://dev.laptop.org/ticket/3681
mv /etc/rc3.d/S98NetworkManager /etc/rc3.d/DISABLED-S98NetworkManager
mv /etc/rc5.d/S98NetworkManager /etc/rc5.d/DISABLED-S98NetworkManager


=== Enabling the Network Alternative #1 ===
==== Altering the desktop resolution on the [[LiveCd]] ====
When the emulator is starting GRUB boot loader, press a key.
#Choose then the Qemu line with arrow keys.
#Press ''E''
#Move to the 'Kernel' line and press ''End''
#Add Space ''1'' to end of the line
#Press ''Enter''
#Press ''B''


I am not sure what this (below) does and if reducing the resolution to 800x600 is really a good idea, but what is outlined in https://dev.laptop.org/ticket/3681 seems to help to make things a bit less ugly in Emulation. ([[User:Vorburger|Vorburger]] 07:15, 7 October 2007 (EDT))
You will be automaticaly log in as superuser in terminal (in single user mode).

You can start network and put your local keyboard layout command there like this (using tabulator key to complete the filenames):

echo ifup eth0 >> /etc/rc.local
or
#(change '''ONBOOT''' from "no" to '''"yes"''')
nano '''/etc/sysconfig/network-scripts/ifcfg-eth0'''
#(disable NetworkManager)
mv /etc/rc5.d/S98NetworkManager /etc/rc5.d/K98NetworkManager

On build 432, the following is also needed to have the network automatically started on bootup:
mv /etc/rc5.d/K90network /etc/rc5.d/S10network
It also helps sugar to find other people automatically upon startup.

Put your own keyboard layout for text terminals

echo loadkeys ''Your_two_letter_country_code'' >> /etc/rc.local
. /etc/rc.local

Type '''Ctrl-D''' to continue normal boot.

Keyboard layout and network should work automatically every time you start the QEMU image.
--[[User:Tonyv|Tonyv]] 01:52, 13 January 2007 (EST)

=== Enabling the Network Alternative #2 ===
Make sure the the window has the focus (label should say <tt>QEMU - Press Ctrl-Alt to exit grab</tt>).
If the following keys do not work try pushing also the Shift key down to exit the Sugar environment.
If it does not work see the sendkey method of Alternative #3
#
#Press <tt>Alt + Ctrl + F1</tt> to enter the terminal mode of the OLPC.
#Make sure that you're logged in.
#*If not, just hit <tt>enter</tt> and it'll ask you to.
#*Login as <tt>root</tt> (no password is required)
#Type <tt>dhclient</tt> and press return.
#Press <tt>Alt + Ctrl + F7</tt> to return to the graphical mode of the OLPC.
#Your browser / network connection should be working fine.

=== Enabling the Network Alternative #3 ===

The steps below work on QEmu regardless of which operating system you are running.

'''If you are having trouble getting an internet connection inside QEmu:'''

Get the image running in QEmu so that you can see the normal view with the XO icon in the middle.
[[Image:Empty_no_apps_no_frame.png|300px]]

Make sure your mouse is active in QEmu, then press ctrl+alt+2 together.

This will bring up a screen like a command line, called the QEmu monitor.

Type the following:

sendkey ctrl-alt-f1

And press return.

Then with the keyboard hold down the following keys: '''ctrl+alt+7'''

Another text based screen will appear, asking you to log-in. Sometimes there can be an extra "1" after the word "Login:", just delete it. Type '''root''' and press return

Then type:

dhclient

or

ifup eth0:

You should see the screen fill with text.
[[Image:QEmu_running_dhclent.png|400px]]

Some of the numbers have been removed from the screenshot above - they're not important.

Then hold down the following keys on the keyboard: '''ctrl+alt+2'''

and type the following:

sendkey ctrl-alt-f7

[[User:Justin|Justin]]: Using the latest disk image (Build 385), I found that it was "ctrl-alt-f3" that returned to the Sugar interface.

Then using the keyboard, hold down the following keys: '''ctrl+alt+1'''

Now open the browser and you should have internet access.

[[Image:Sugar_browser_with_frame_google_home_page.png|300px]]
[[Image:OLPC_20070104.png|300px]]



== Configuration ==

<DIV ID="Anchor:how to change desktop resolution"></DIV>
=== Altering the desktop resolution ===


This is said to work on the current [[LiveCd]]. It might also work in xo/qemu images? [[User:MitchellNCharity|MitchellNCharity]] 13:50, 5 June 2007 (EDT)
This is said to work on the current [[LiveCd]]. It might also work in xo/qemu images? [[User:MitchellNCharity|MitchellNCharity]] 13:50, 5 June 2007 (EDT)
Line 476: Line 573:
EndSection
EndSection


=== Configuring X ===


* In some builds X is configured to load the Geode driver by default. You need to modify it to load the frame buffer driver instead. In '''/etc/X11/xorg.conf''', go to the "Device" section and change the Driver setting from "amd" to "fbdev"


== Problems ==
* You can then change '''XKbLayOut''' in the same file to ''your keyboard code'' with for example '''nano''' text editor by


=== Sound doesn't work ===
nano /etc/X11/xorg.conf


=== Setting Framebuffer resolution ===

'''NOTE:''' If you don't set the VGA kernel parameter to <tt>'''0x317'''</tt> (in order to get a 1024x768 with 64k colors) you will NOT be able to view / use [[Etoys]] properly.

In order to set the framebuffer's VGA kernel parameter you must edit <tt>/boot/grub/grub.conf</tt> according to the following table:

<tt>
{|align=center border="1" style="text-align: center;"
|+VGA kernel color / resolution table
!Colors!!640x480!!800x600!!1024x768!!1280x1024
|-
!256
|0x301||0x303||0x305||0x307
|-
!32k
|0x310||0x313||0x316||0x319
|-
!64k
|0x311||0x314||style="background:green"|0x317||0x31A
|-
!16M
|0x312||0x315||0x318||0x31B
|-
|}
</tt>

=== Sound ===


Latest images add support of sound. Emulation does not work properly with Tam-Tam, yet, even with kqemu at 2 GHz Pentium4 (performance or insufficient emulation issue?). Maybe somebody could install Csound in host and pipe sound over the virtual network?
Latest images add support of sound. Emulation does not work properly with Tam-Tam, yet, even with kqemu at 2 GHz Pentium4 (performance or insufficient emulation issue?). Maybe somebody could install Csound in host and pipe sound over the virtual network?
Line 517: Line 583:
--[[User:Tonyv|Tonyv]]
--[[User:Tonyv|Tonyv]]


=== Keyboard and Mouse ===
=== Keyboard and Mouse don't work ===


A typical case is that their keyboard and mouse don't work. A solution to the problem is:
A typical case is that their keyboard and mouse don't work. A solution to the problem is:
#Make sure the the window has the focus (label should say <tt>QEMU - Press Ctrl-Alt to exit grab</tt>).
#Make sure the the window has the focus (label should say <tt>QEMU - Press Ctrl-Alt to exit grab</tt>).
#Press <tt>Alt + Ctrl + 1</tt> (or <tt>Alt + Ctrl + 3</tt>) to enter the terminal mode of the OLPC. Notice that QEMu seems to respond better to by pushing first down Ctrl, after Alt and finally the number.
#Start the [[Terminal Activity]], or press <tt>Alt + Ctrl + 1</tt> (or <tt>Alt + Ctrl + 3</tt>) to enter the terminal mode of the OLPC. Notice that QEMu seems to respond better to by pushing first down Ctrl, after Alt and finally the number.
#Make sure that you're logged in.
#Make sure that you're logged in.
#*If not, just hit <tt>enter</tt> and it'll ask you to.
#*If not, just hit <tt>enter</tt> and it'll ask you to.
#*Login as <tt>root</tt> (no password is required)
#*Login as <tt>[[root]]</tt> (no password is required)
#Type <tt>modprobe i8042</tt> (oddly, you may need to try this multiple times before it works, so ''keep trying!'')
#Type <tt>modprobe i8042</tt> (oddly, you may need to try this multiple times before it works, so ''keep trying!'')
[[Image:Tty1_ps.PNG]]
[[Image:Tty1_ps.PNG]]
Line 533: Line 599:
Alternatively you can use the developers console and <tt> su </tt> command. I have not been able to bring up the terminal in most images. Quote from [[BTest-1_Release_Notes]] :
Alternatively you can use the developers console and <tt> su </tt> command. I have not been able to bring up the terminal in most images. Quote from [[BTest-1_Release_Notes]] :


Note: this does not work on joyride build 1483. I get FATAL: Module i8042 not found. [[User:LinuxMercedes|LinuxMercedes]] 20:33, 21 January 2008 (EST)
The terminal (activity) does not appear on the Frame, but can be launched by typing Alt-Shift-F11.
(F11 is found in the 3rd position from the left in the Volume Slider key.)
Note that on some newer builds, the terminal window (Memphis) is launched by typing Alt-Shift-F12.
In even more recent builds, e.g., '''Build 224, Memphis is launched by typing
Alt-View_Source or Alt-F12'''.


===Sugar GUI won't start===
See also [[Sugar_Instructions#Terminal_.28linux_prompt.29|Sugar Instructions:Terminal]]
--[[User:Tonyv|Tonyv]] 01:24, 13 January 2007 (EST)


If the GUI fails to start, you may have forgotten to choose emulated when you booted, or you may have encountered the "GUI won't start" bug. The "GUI won't start" bug is fixed by reinstalling the hard disk image. (Or it may be because of a bug in the image file, see {{Trac|1295}}). In QEMU, delete the .img file (it has become corrupted), and extract the original .img file from the bz2 file, or download the image file again. Upgrading to a later version isn't necessary.
== Problems ==

=== On Ubuntu with Xinerama, mouse behaves strangely and cursor disappears ===

Try running "export SDL_VIDEO_X11_DGAMOUSE=0" before running Qemu (if you use another shell instead of bash, use something like "setenv SDL_VIDEO_X11_DGAMOUSE 0").[http://www.morphix.org/wiki/index.php/Qemu] [[User:MitchellNCharity|MitchellNCharity]] 15:38, 2 October 2007 (EDT)


=== On Fedora, "service qemu start" needed? ===
=== On Fedora, "service qemu start" needed? ===
Line 591: Line 656:


== Misc ==
== Misc ==

== Obsolete ==
This section should be periodically cleaned out. Say once the relevant builds are a month or two old.

=== Builds between 445 and 48? -- Workaround for "Cannot find root filesystem!" preventing boot ===

Build 445 was the last version which booted cleanly under qemu ([http://dev.laptop.org/ticket/1809 ticket]).
More recent builds require workarounds. Build 485 resolved one problem.

*When booting on qemu, add root=/dev/hda to the grub kernel line. This needs to be done every time.
*#When you start your xo disk image on qemu, you should see a blue grub screen, doing a "Booting .. in N seconds" countdown. Press space to interrupt it.
*#Press '''e''' (edit). This will show you 3 lines.
*#Move to the second, which begins "kernel". Press '''e'''. This will take you to the end of the kernel line.
*#Add <tt> root=/dev/hda1</tt> Then press enter.
*#Press '''b''' to continue booting.
:(This workaround avoids "WARNING: Cannot find root file system!", and being dropped into an emergency shell.)

Should add instructions to modify the image's grub config, so this doesn't need to be done every time you boot. [[User:MitchellNCharity|MitchellNCharity]] 12:04, 3 July 2007 (EDT)

It might be worth gathering the currently scattered notes, into a single list of step by step instructions, for getting from nothing, to a pair of qemu images running with Xephyr's and ssh. [[User:MitchellNCharity|MitchellNCharity]] 12:04, 3 July 2007 (EDT)

''And some related content from elsewhere:''

0. Press any key to interrupt the countdown to boot. Then,

# Press '''e'''.
# Press down-arrow to get the "kernel" line.
# Press '''e'''. This takes you to the end of the kernel command line.
# Type space and <tt>root=/dev/hda1</tt>
# Press Enter.
# Press '''b'''.

mv /boot/grub/grub.conf /boot/grub/grub.conf.orig
awk '/kernel/ {print $O,"root=/dev/hda1";next} {print}' < /boot/grub/grub.conf.orig > /boot/grub/grub.conf
grub-install hd0

If grub-install hangs, just kill it. It may even have worked anyway.

''Fixed by 494.''

=== Builds between 445 and 485, non-inclusive -- Workaround for netfs preventing boot ===
*The boot currently hangs in rc netfs. So we disable it. This only needs to be done once.
*#Get a shell. Do this by following the instructions below, but add a "2" to the end of the kernel line. So it is <tt> root=/dev/hda1 2 </tt>
*#Log in as root, no password.
*#Then:
mv /etc/rc.d/rc3.d/S25netfs /etc/rc.d/rc3.d/DISABLED-S25netfs
mv /etc/rc.d/rc5.d/S25netfs /etc/rc.d/rc5.d/DISABLED-S25netfs
::4. Done. Now restart qemu, following the instructions below.
:(This workaround avoids the boot hanging after saying "Mounting other filesystems:".)
''Fixed in build 485.''




== See also ==
*[[/Obsolete]] help and tips.


[[Category:Emulation]]
[[Category:Emulation]]

Latest revision as of 16:15, 8 February 2011

For current information on emulation of OLPC software images, see Emulating the XO

Stop hand.png WARNING:
The content of this section is considered
DEPRECATED and OBSOLETE
It is preserved for historical or documenting reasons.

When it comes to emulating systems like the XO, sometimes it seems like technology only manages to get us 95% of the way there--the last 5% an assortment of mystical incantations and other superstitious activities just to confuse the uninitiated. This page is a humble attempt to take some of the magic and mystery away from this sufficiently advanced science.

Please remember to end your comments with ~~~~, which is replaced by a time stamp when you save the page. Without them, notes that are months old and obsolete look the same as notes added yesterday.

Bear in mind that some of the information on this page is obsolete, and some of it only applies to certain XO disk images.

How to

Keyboard and buttons

The XO has dedicated keys on the keyboard for Sugar features such as the Home view, the Neighborhood, and showing/hiding the frame; it also has buttons around the screen for screen rotation and gamepad controls. Some of these correspond to function keys on regular keyboards, and there are keystroke combinations for others; see Keyboard shortcuts.

Change the keymapping to your local keyboard layout

To change the keyboard layout when you are using an Emulation do:

1. enter Console (Alt-Ctrl-F1)
2. login as root (just hit RETURN, no password needed)
3. type

loadkeys xy
where xy is your keyboard layout shortcut, e.g. "de" for german layout.
(be careful: as you havn't changed your keyboard layout when you type the command, you might have to hit the key "z" to get an "y" and/or the key "q" to get an "a".)

4. edit /etc/sysconfig/keyboard (this changes the keyboard layout within SUGAR)

vi /etc/sysconfig/keyboard
"a" starts edit-mode (insert after cursor)
change "us" to your keycode two times.
leave edit-mode (ESCAPE)
type ":wq" and hit Enter to write the changes and quit the editor
If you produced a chaos and want to quit without writing the changes, type ":q!"
You find additional information about the codes used in /etc/sysconfig/keyboard in the Manufacturing Data page.

5. edit /etc/rc.d/rc.local (this changes the keyboard layout permanently for the console)

vi /etc/rc.d/rc.local
"a" starts edit-mode (insert after cursor)
move the cursor to the end of the file, hit RETURN to create a new line.
type "loadkeys de" (or whatever keycode you want)
leave edit-mode (ESCAPE)
type ":wq" and hit Enter to write the changes and quit the editor
If you produced a chaos and want to quit without writing the changes, type ":q!"

If you don't know the mapname/code for your keyboard layout, go to /lib/kdb/keymaps, switch to the subdirectory that covers your architecture (eg "i386" for Intel-platforms), and then enter the subdirectory which covers your keyboard type (look at the first six letters on the upper left of your keyboard to distinguish the "azerty", "qwerty" or "qwertz" layout type). In the subdirectory, you find some keymaps for your keyboard layout - find out which one fits your keyboard exactly. The keymap code is the filename without "map.gz".

Valid examples (among others) are:

"by", "cf", "cz", "dk", "emacs", "es", "et", "fi", "gr", "hu101", "il", "is-latin1", "it", "jp106", "ko", la-latin1", "lt", "nk", "nl", "no", "pc110", "pl", "pt", "ro", "ru", "se-latin1", "sk-qwerty", "sr-latin", "sv-latin", "trq", "ua", "uk", "us" (QWERTY)
"cz-us-qwertz", "de", "croat", "fr", "fr_CH", "sg", "sk-qwertz", "slovene", "hu" (QWERTZ)
"azerty", "be-latin1", "fr", "wangbe" (AZERTY)

If those examples don't fit your keyboard layout exactly, please have a look into the directories for yourself to look for alternatives or define your own keymap (see http://wiki.linuxquestions.org/wiki/Configuring_keyboards#The_Loadkeys_Method for instructions)

Sending Ctrl-Alt combos in Qemu (or Q.app)

According to (now obsolete) Sugar Instructions you need to "hold down Ctrl+Alt+F1 to leave the Sugar screen and return to the login prompt" and then "you can return to Sugar with Ctrl+Alt+F7". Unfortunately for me the "Ctrl+Alt" action seems to be grabbed by the Q.app "mouse pointer ungrab" functionality.

Under Linux, this will be grabbed by the X server running on your computer, and not the one running in the emulator, and will switch your own computer to a terminal.

The other method(s) suggested for opening a terminal activity didn't work for me either (OLPC build 239). I eventually discovered that Q.app actually has a "Monitor" accessible by "ctrl-alt-2". When in this monitor mode you can send key-presses directly to the OLPC emulation by using the "sendkey" command. For example:

  sendkey ctrl-alt-f1       # to switch to the shell
  sendkey ctrl-alt-f7       # to return to Sugar

Note: you will need to exit the monitor mode and return to the emulated machine by pressing "ctrl-alt-1" once you type either of the above commands.

Note: you type the name of the keys to send, you don't actually press the keys.

Get a login prompt

If you started qemu with the -serial `tty` argument, you can simply use that login prompt (Linux only, doesn't work on Windows).

Otherwise, pressing ctrl alt 3 will bring up the console. (But then you can't cut and paste from/to the host machine).

You can alternatively use the Terminal activity.

Login as root

#Get a login prompt.

In post-650 builds, do not directly login as root, but first as user 'olpc'. The password for user olpc on fresh xo/qemu images is empty. (Pre-650 you could login as root with an empty password by default.)

Then "sudo su -" to get a root prompt.

Change the root password

#Login as root. Then:

passwd

Complaints about "BAD" passwords won't stop things from working.

Speed

Does my qemu have kqemu?

Does the version of the QEMU support KQEMU? Type ctrl+alt+2 and type info kqemu. Use ctrl+alt+1 to return to OLPC screen.

On x86_64 you must run qemu-system-x86_64 instead of qemu.

Giving the -kqemu-kernel argument if kqemu is not supported will cause a one-line warning to go by as qemu starts up:

Could not open '/dev/kqemu' - QEMU acceleration layer not activated
I run 'sudo qemu -kqemu-kernel ...' and this error doesn't appear. Does it mean it's being used? I haven't measured time differences yet, but it feels faster to boot and use.HoboPrimate 17:56, 6 August 2007 (EDT)

kqemu impact

After installing kqemu and modprobe'ing, I get a 3x speedup in booting (to 45 sec), and a 5x in starting the webrowser (to 7 sec). It actually feels usable. MitchellNCharity 17:25, 13 May 2007 (EDT)

Coping with Slowness

It is possible for the OLPC image to boot successfully and load the Sugar UI in the emulator but then be too slow to successfully load any activities.

For example, between build 239 and build 303 activity loading slowed enough for me (Qemu / 1.6GHz G4 PPC / OS X) that no activities loaded successfully. Symptons include messages in /home/olpc/.sugar/default/logs/shell.log like this:

DEBUG - Shell.start_activity
DEBUG - Activity f4a9f5322b49dcc3364a4eca9b13633c0ce1868e (org.laptop.ChatActivity) launching...
DEBUG - Activity f4a9f5322b49dcc3364a4eca9b13633c0ce1868e (org.laptop.ChatActivity) launch timed out
STDERR - Introspect error: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

DEBUG - Couldn't create activity f4a9f5322b49dcc3364a4eca9b13633c0ce1868e (org.laptop.ChatActivity): Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
ERROR - Model for activity id f4a9f5322b49dcc3364a4eca9b13633c0ce1868e does not exist.
DEBUG - Activity f4a9f5322b49dcc3364a4eca9b13633c0ce1868e (org.laptop.ChatActivity) launching...
DEBUG - Activity f4a9f5322b49dcc3364a4eca9b13633c0ce1868e (org.laptop.ChatActivity) finished launching

Another sympton is the flashing activity load icon appearing in the donut for a length of time and then disappearing without the activity loading. (Although this can also be caused by other issues such as uncaught programming errors.)

These failures are due to two timeouts values configured in the system, one in Sugar and one in D-Bus. If you're more patient than OLPC/Sugar is by default then it's possible to tweak these values to enable activities to eventually load:

D-Bus

Insert the following line in /etc/dbus-1/session.conf below the </policy> tag:

  <limit name="service_start_timeout">120000</limit>

This means D-Bus will wait 120 seconds before giving up--the icon will still disappear from the donut but eventually the activity will load. (Strictly speaking this setting might really need to be in session-local.conf. See man dbus-daemon.)

Sugar

To ensure the flashing activity load icon appears in the donut longer the following untested change should work:

In shell/model/homeactivity.py replace:

self._launch_timeout_id = gobject.timeout_add(20000, self._launch_timeout_cb)

with (for example) this:

self._launch_timeout_id = gobject.timeout_add(120000, self._launch_timeout_cb)

As far as I can tell this only has a cosmetic impact and activities should still load without it.


More often than not, technology manages to get us 95% of the way... being the last 5% a mix of magical incantations, rituals and other esoteric activities only clear to the initiated. This page tries to take some of the magic away from the sufficiently advanced science

  If you want to use nano for system file edits,
  make sure line wrap is disabled by Alt-L 
  (or look here for its documentation).

My emulator is very slow

Are you using the kqemu or qvm accelerator modules? You do have to have administrator rights to install the services. QEMU manager (in Windows) knows to start these services according to your profile settings. See Qemu on Windows and QEMU Home Page

Display

Font Size correction

You will want to edit /etc/X11/xorg.conf and apply the changes suggested in (Trac #3681) to get the fonts to look bigger and nicer in emulation: (Vorburger 13:35, 7 October 2007 (EDT))

Edit xorg.conf

  Ctrl-Alt-3
  nano /etc/X11/xorg.conf

Add a new section "monitor"

  Section "Monitor"
          Identifier "Monitor0"
          DisplaySize 153 115
  EndSection

Add a "Monitor" line to the "Screen" Section

  Section "Screen"
       ...
       Monitor "Monitor0"
  EndSection

Restart X [ kill it and let init respawn it. ]

  killall -i X

Fullscreen

If you run qemu on a physical 1024x768 display (e.g. a laptop with 1024x768 LCD), you get a MUCH more "natural" experience if you switch qemu to fullscreen: Add "-full-screen" as argument to qemu start-up, and/or press Ctrl-Alt-F on a running qemu to toggle. (Vorburger 13:35, 7 October 2007 (EDT))

Development

Use the -devel_ext3.img xo disk image

You need a "*-devel_ext3.img" image, rather than a standard (non-devel) one. The -devel image has extra software like sshd and wget. The code changes rapidly, so you probably want LATEST rather than LATEST-STABLE.

Communicating between host and xo image

Check networking

Make sure networking is working. In short, an "ifconfig" should show inet addr:10.0.2.15 on eth0, you should be able to do a "ping 10.0.2.2" (that's how the host is visible) and have a working e.g. "wget http://wiki.laptop.org/" from CLI before going any further.

Recent builds (i.e. 613) work out of the box IFF you pass the correct qemu start-up parameters (see Emulating the XO/Quick Start). If not, you can try a manual "ifup eth0", but as of build 613 there will be other problems (X/X11/Sugar start-up) if networking is not working during start-up.

Vorburger 04:14, 7 October 2007 (EDT)

SSH into qemu

  1. #Change the root password
  2. Add the argument -redir tcp:2222::22 whenever you run qemu. 22 is the ssh port (on the guest). 2222 is a semi-arbitrary port on the host, which gets mapped to it. If you run a second image simultaneously, you could use 2223::22 for it.
  3. You can now log into the laptop image, from your real machine, using ssh. And you can use scp, etc.
ssh -o NoHostAuthenticationForLocalhost=yes -p 2222 root@localhost
scp -o NoHostAuthenticationForLocalhost=yes -P 2222 filefoo.py root@localhost:/usr/share/activities/Your.activity
scp -o NoHostAuthenticationForLocalhost=yes -P 2222 -r Your.activity/ root@localhost:/usr/share/activities/Your.activity

Unfortunately, you have to keep typing the password, unless you have set up a key.

SSH into qemu, using a key

Setting up a key means you don't have to keep typing the password.

The -devel xo .img is already running sshd.

  • Create a key pair if you don't already have one:
ssh-keygen -N '' -t rsa -f ~/.ssh/id_rsa   # If it asks you Overwrite?, say NO!.  You already have one.

This creates a no-passphrase key pair. Which is fine for using with the xo image (no-one is trying to break into the xo from your machine;), but you shouldn't later use this weak key on other, more important systems.

  • Copy the public key onto the xo image:

#Change the root password if you haven't already.

scp -o NoHostAuthenticationForLocalhost=yes -P 2222 ~/.ssh/id_rsa.pub root@localhost:~/

Inside ssh, do:

mkdir ~root/.ssh
mkdir ~olpc/.ssh
cat id_rsa.pub >> ~root/.ssh/authorized_keys
cat id_rsa.pub >> ~olpc/.ssh/authorized_keys

Now you can ssh into the xo image without typing a password.

You may need to change the permissions of the authorized_keys file like this:

chmod g-w ~root/.ssh/authorized_keys
chmod g-w ~olpc/.ssh/authorized_keys

SSH into qemu, without having to specify the user or port

Setup a ssh config entry on your host to simplify using ssh. The following steps are all performed on the host.

  • Create a config file if you don't already have one:
touch ~/.ssh/config
  • Add a section for your host (vi ~/.ssh/config or nano ~/.ssh/config) :
Host olpc
       User root
       Port 2222
       Hostname localhost

You can now just use the alias olpc to use ssh/scp without specifying the user or port

ssh olpc

or

scp somefile olpc:

Comfortably transfer Files between Host and XO

To transfer Files between Host and XO, once you have set-up a root passwd and added the argument -redir tcp:2222::22 whenever you run qemu as described above, the easiest is to use scp with a graphical scp client. This will allow you to easily "browse" and "explore" the XO's file system.

ToDo: On Linux, Nautilus und Konqueror can natively do scp as well; you probably just type scp://localhost:2222/ (or fish://localhost:2222/, or sftp://localhost:2222/ ?) in the address bar, but I haven't tested this.

On Windows, use WinSCP from http://winscp.net/eng/download.php and connect as root to localhost port 2222.

PS: And while we're on tools for Windows... use Putty from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to SSH (localhost:2222) from Windows into your XO, not Cygwin. Putwin will emulate the terminal correctly by default, give you colors, scrolling and copy/pasting easily work, etc.

Vorburger 04:23, 7 October 2007 (EDT)

Pull things from a webserver

If you don't want to deal with ssh, and have a webserver, you might simply download stuff using wget or the Browser activity.

Get an xterm from the xo

Use -X

ssh -X -o NoHostAuthenticationForLocalhost=yes -p 2222 root@localhost
...
xterm&

However, there are security vulnerabilities associated with -X.

Miscellaneous

  • Under QEMU the Laptop image can see the host as IP address 10.0.2.2 .

Doables:

  • Perhaps describe using samba and qemu's tftp.
  • Describe passphrase avoidance if you already have an id. Is giving folks a no-passphrase id just setting them up for future problems? What's the right thing here?

Running sugar activities from shell

Running sugar activities from the command-line, instead of via the gui, can be useful when debugging.

Log in as root, then:

su olpc
grep export /usr/bin/sugar > /tmp/env
source /tmp/env

You can then run activities:

sugar-activity web

Restart sugar

Sugar notices new activities, and changed activity icons, only when it starts.

To restart sugar, you can do any of:

  • Restart qemu
  • Kill X using killall: As root, run
killall -i X
  • Kill X using the qemu console (see #sendkey):
sendkey ctrl-alt-backspace

Get 1200x900 resolution

Qemu does not currently support 1200x900 (though the cvs version is said to, via -vmwarevga). It defaults to 1024x768. Which is what the laptop's X and cairo see. So code you write assuming 1200x900, gets an unexpected down-scaling. Cairo make-it-smaller scaling is currently much faster than its make-it-bigger, so the performance impact may not be large. But if you were hoping to do nifty things with 200bpi, you need the CVS version. Or maybe use 1280x1024, and only use part of the screen? MitchellNCharity 21:16, 6 June 2007 (EDT)

See #Run a Xephyr remote X display for a workaround. MitchellNCharity 10:48, 23 June 2007 (EDT)

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

Hklv 18:13, 5 April 2008

Run a Xephyr remote X display

You can use Remote Display to run X in a window on your host machine, rather than in the qemu window. Xephyr might also be used to get 1200x900 with a sugar-jhbuild sugar.

Once qemu supports 1200x900, or if you are using a different emulator, this may not be of interest.

In qemu, as root,

The first time:

  • Give olpc a password
passwd olpc
  • disable S98NetworkManager for rc3 if you earlier needed to do this for normal rc5.
mv /etc/rc3.d/S98NetworkManager /etc/rc3.d/DISABLED-S98NetworkManager

Every time:

  • partially shut down:
init 3
  • wait a bit, and then turn the network back on:
ifup eth0

On the host, (based on http://etbe.blogspot.com/2007/01/xephyr.html ):

The first time:

  • give an xauth cookie to olpc and Xephyr
mcookie > xephyr-cookie
export COOKIE=`cat xephyr-cookie`
rm -f xephyr-xauth; echo "add :1 . $COOKIE" | xauth -f xephyr-xauth
ssh -o NoHostAuthenticationForLocalhost=yes -p 2222 olpc@localhost "echo \"add 10.0.2.2:1 . $COOKIE\" | xauth"

Every time:

  • run Xephyr
Xephyr :1 -auth xephyr-xauth -reset -screen 1200x900x8 -dpi 200
  • and in another window, start sugar
ssh -o NoHostAuthenticationForLocalhost=yes -p 2222 olpc@localhost

and then as olcp:

DISPLAY=10.0.2.2:1 sugar

Ideally we would run /bin/sh .xinitrc, instead of sugar, but it currently crashes Xephyr repeatedly. The right thing is probably to extract the lines Xephyr is ok with, like setting keyboard repeats, and check that dropping the others doesn't lose something important.

Only because it might be easier on non-linux platorms, I note: A simpler, but much less secure, and probably slower (-X uses encryption) alternative is to run Xephyr with the -ac argument (disabling access control! Don't do this unless you really trust your firewall and local environment). And then in another window on the host, run xterm -display :1 -e ssh ... .xinitrc. Interestingly, this approach didn't require repeatedly restarting Xephyr.

Switching to a different presence server

Here we switch to olpc.collabora.co.uk:

cp -p /home/olpc/.sugar/default/config /home/olpc/.sugar/default/config.old
gawk '/^server =/ {print "server = olpc.collabora.co.uk"} !/^server =/ {print}' /home/olpc/.sugar/default/config.old > /home/olpc/.sugar/default/config

Then #Restart_sugar.

Running multiple qemus

You can run multiple qemus at the same time. Each must have its own disk image.

There are a couple of options:

1. Just run them as you would individually.

This is easiest, and sugar Presence Service and tubes seem to work fine. Even though the copies all think they have the same ip address and mac.

2. Give the instances distinct macs and ips.

Illustrate... MitchellNCharity 23:45, 27 June 2007 (EDT)

3. Start a virtual network.

Eg, see http://olpcaustria.org/mediawiki/index.php/Devserver . Instances must be able to see the internet for Presence Service to work.

Are there any advantages to doing a VDE versus option 2? MitchellNCharity 23:45, 27 June 2007 (EDT)
Allows incoming connections, by avoiding qemu's default firewall. What else? MitchellNCharity 12:12, 28 June 2007 (EDT)

Installing software on the -devel image

The -devel_ext3 images have yum to install normal fedora x86 .rpm's.

If an olpc repository is down (eg olpc_development) one can still run yum by saying yum install package --disablerepo=olpc_development.

There is little free disk space on the -devel images, so you will need to #Expand a qemu image to install anything large.

Logging boot messages

WARNING: This disables (at least on Windows) the Ctrl-Alt-3 console (you get a "parallel0 console" instead) !!!

For Linux:

qemu -serial stdio -hda olpc-redhat-stream-development-ext3.img | tee boot.log

For Windows:

qemu.exe -serial file:boot.log -hda olpc*.img

The kernel params in /boot/grup/menu.lst are already set to send to console IO to both the screen and serial ( console=ttyS0,115200 console=tty0), so -serial stdio is all it takes to have it sent to stdout.

PS: Qemu on Windows doesn't like "-serial stdio", thus the "-serial file:boot.log" - might actually work on Linux, too?

PPS: Repeating warning - this disables (at least on Windows) the Ctrl-Alt-3 console (you get a "parallel0 console" instead) !!!

Cut and paste text from qemu

One simple approach is to login in the window from which qemu was started. This window is in the X of the host, but has the shell in qemu. So you can cat the text, and cut and paste it.

x2x might be another alternative. We should explore and document it. http://borderworlds.dk/blog/20070224-00.html MitchellNCharity 15:45, 2 October 2007 (EDT)

Mounting a qemu image (to directly manipulate its filesystem)

You can mount a ext3.img, to directly manipulate its filesystem. Caution: running qemu on it while it's mounted is said to be bad.

file olpc-redhat-stream-development-ext3.img

will say something like

olpc-image/olpc-redhat-stream-development-ext3.img: x86 boot sector; partition 1: ID=0x83, starthead 1, startsector 62, 984994 sectors, extended partition table (last)\011, code offset 0x48

Here the startsector is 62. Multiply it by 512 to get the mount offset (here 62*512=31744).

mkdir tmp_img
sudo mount -o loop,offset=31744 olpc-redhat-stream-development-ext3.img tmp_img

Expand a qemu image

With N changed to the desired size in MB: (If on Windows, get Cygwin and install a dd; that works! ( The Qemu Manager allows a volume/drive image to be created and then accessed as e.g. /dev/hdb ))

dd if=/dev/zero of=laptop.img seek=N obs=1MB count=0

Obtain the gparted .iso LiveCD, from http://gparted.sourceforge.net/livecd.php (~50MB).

qemu -kernel-kqemu -boot d -cdrom gparted-livecd-0.3.4-7.iso laptop.img

Make sure you chose the second option in the Grub boot menu, "GParted-liveCD (Do X Configuration = mkxf86config)", not the default first "... (auto-configuration)".

(Alternatively, with the Qemu Manager, start up a regular image with a second (larger) volume e.g. /dev/hdb, once booted up, copy the original drive (/dev/hda) to the expanded image on /dev/hdb with e.g. "dd if=/dev/hda of=/dev/hdb" then follow the #Enlarging_the_Partition and #Enlarging_the_filesystem instructions...)

Do http://gparted.sourceforge.net/larry/resize/resizing.htm

For more background information, see also: (But you do not have to execute these steps when using gparted)

Emulating the xo's unusual color display

GTK for OLPC links to a patch to Xephyr, which adds a --swizzle argument, which very roughly emulates the appearance of an xo screen.

The patch requires only one small change to apply against the current xserver source (git://anongit.freedesktop.org/git/xorg/xserver). But I've not been able to try compiling it (dependency issues). It might be easier on a distribution which handles source better than fedora, or on fc7. MitchellNCharity 14:13, 23 June 2007 (EDT)

There is now a display simulator for screenshots. MitchellNCharity 19:26, 23 June 2007 (EDT)

To erase the Journal

rm -r ~/.sugar/default/datastore 

If using nano (an editor), disable line wrapping

If you want to use nano for system file edits, make sure line wrap is disabled by Alt-L (or look here for it's documentation).

Network startup

Should now "just work".

For the next week or few (Dec 2007), presence service (collaboration and mesh view) in joyride builds wont work out of the box, as they are configured to use a not yet existant ship2.jabber.laptop.org. You might try the currently overloaded and fragile jabber.laptop.org instead. MitchellNCharity 22:46, 14 December 2007 (EST)

Configuration

Altering display size and resolution

If you really can't get 1200x900, you can use 1280x1024 or 1024x768 instead. You can even use 800x600 to perhaps do development on small displays, but the result looks very different than on the real 1200x900.

Setting Framebuffer size

The kernel can be started with a VGA framebuffer of a few sizes. The vga=0x317 option.

You can edit the kernel line in /boot/grub/grub.conf, or at boot time, in the initial blue GRUB screen.

VGA kernel color / resolution table
Colors 640x480 800x600 1024x768 1280x1024
256 0x301 0x303 0x305 0x307
32k 0x310 0x313 0x316 0x319
64k 0x311 0x314 0x317 0x31A
16M 0x312 0x315 0x318 0x31B

NOTE: If you don't set the VGA kernel parameter to 0x317 (in order to get a 1024x768 with 64k colors) you will NOT be able to view / use Etoys properly.

This NOTE is old. It may or may not be still true. 0x31A seems to work too. MitchellNCharity 18:56, 8 November 2007 (EST)

Setting DPI and font size for odd display sizes

https://dev.laptop.org/ticket/3681

Altering the desktop resolution on the LiveCd

I am not sure what this (below) does and if reducing the resolution to 800x600 is really a good idea, but what is outlined in https://dev.laptop.org/ticket/3681 seems to help to make things a bit less ugly in Emulation. (Vorburger 07:15, 7 October 2007 (EDT))

This is said to work on the current LiveCd. It might also work in xo/qemu images? MitchellNCharity 13:50, 5 June 2007 (EDT)

  1. Somehow pull up a terminal (there is one easily accessible via the classic Gnome desktop)
  2. Either edit /etc/X11/xorg.conf (example below focusing on the 'Modes' line setting 800x600) OR run system-config-display and select the appropriate resolution from the GUI
  3. Restart the X server with ctrl-alt-backspace (NOTE: This may take some seconds. It will drop back to a login prompt but if you wait it will start up X again, assuming you provided a valid resolution.)
Section	"Screen"
	Identifier	"Screen0"
	Device		"Videocard0"
	DefaultDepth	24
	SubSection	"Display"
		Viewport	0 0
		Depth		24
		Modes		"800x600"
	EndSubSection
EndSection


Problems

Sound doesn't work

Latest images add support of sound. Emulation does not work properly with Tam-Tam, yet, even with kqemu at 2 GHz Pentium4 (performance or insufficient emulation issue?). Maybe somebody could install Csound in host and pipe sound over the virtual network? Windows version can be found in Cecilia and Csound for Windows installer --Tonyv

Keyboard and Mouse don't work

A typical case is that their keyboard and mouse don't work. A solution to the problem is:

  1. Make sure the the window has the focus (label should say QEMU - Press Ctrl-Alt to exit grab).
  2. Start the Terminal Activity, or press Alt + Ctrl + 1 (or Alt + Ctrl + 3) to enter the terminal mode of the OLPC. Notice that QEMu seems to respond better to by pushing first down Ctrl, after Alt and finally the number.
  3. Make sure that you're logged in.
    • If not, just hit enter and it'll ask you to.
    • Login as root (no password is required)
  4. Type modprobe i8042 (oddly, you may need to try this multiple times before it works, so keep trying!)

Tty1 ps.PNG

  1. Press Alt + Ctrl + 7 to return to the graphical mode of the OLPC.
  2. Your keyboard and mouse should be working fine.
    • Usually the result is a continuous series of 1's will flow (as if the key is stuck)
    • Just hit any key (to stop it) and delete the offending 1's

Alternatively you can use the developers console and su command. I have not been able to bring up the terminal in most images. Quote from BTest-1_Release_Notes :

Note: this does not work on joyride build 1483. I get FATAL: Module i8042 not found. LinuxMercedes 20:33, 21 January 2008 (EST)

Sugar GUI won't start

If the GUI fails to start, you may have forgotten to choose emulated when you booted, or you may have encountered the "GUI won't start" bug. The "GUI won't start" bug is fixed by reinstalling the hard disk image. (Or it may be because of a bug in the image file, see (Trac #1295) ). In QEMU, delete the .img file (it has become corrupted), and extract the original .img file from the bz2 file, or download the image file again. Upgrading to a later version isn't necessary.

On Ubuntu with Xinerama, mouse behaves strangely and cursor disappears

Try running "export SDL_VIDEO_X11_DGAMOUSE=0" before running Qemu (if you use another shell instead of bash, use something like "setenv SDL_VIDEO_X11_DGAMOUSE 0").[1] MitchellNCharity 15:38, 2 October 2007 (EDT)

On Fedora, "service qemu start" needed?

On fedora linux, to get qemu working, you may have to start the service for it. As root run:

service qemu start
Why would this be needed?? Emulation works without it. And making .exe files self launching seems unfortunate. MitchellNCharity 21:21, 23 May 2007 (EDT)

On Linux, if qemu complains about insufficient space in /dev/shm

then

mount -t tmpfs -o remount,size=144m none /dev/shm

Boot hangs on Debian-derived distros

We have heard multiple people say that QEMU doesn't work with these images on the debian-derived distributions. The symptom is that the kernel hangs during boot. There's a problem with bochsbios version 2.2, version 2.3 works. As a quick fix, apm=off can be added to OLPC kernel arguments.

We have heard multiple people say that QEMU doesn't work with these images on the debian-derived distributions. We also haven't heard of any solutions to these problems. The symptom is that the kernel hangs during boot.

Marcin: On Ubuntu Dapper it hangs with qemu 0.8.0 (from distro), but works with 0.8.1 from i386 binary tarball.

Budgester (I can confirm this situation on Ubuntu Dapper)

Vedran: It also hangs on Debian unstable with qemu 0.8.1-1 (from distro), but works with 0.8.1 from i386 binary tarball.

kevin.mark@verizon.net: It also hangs on Debian unstable with bochs 2.2.6-2 (from distro) the same way it does for qemu as noted above

MikeX: qemu 0.8.1-1 packaged for debian sid amd64 seems to work for me (system boots but sugar hangs, tried with build84).

[2]: It works on Debian Etch with qemu 0.8.2-4 (a little slow but works ok).

Spawn968: Hangs using qemu 0.8.2 with kqemu-1.3.0pre9, but runs fine on qemu 0.8.2 in Ubuntu Dapper.

dilinger: This is not actually a qemu issue; it's a bochsbios issue. Bochsbios 2.2 is broken in this regard; bochsbios 2.3 might work (an sti was added). A quick fix for allowing it to boot is to add 'apm=off' as a kernel argument. Debian bug #363047 has additional details.

Jwaddell:: Thanks Marcin...getting the 0.8.2 binary tarball from the link you provided made the image work under Ubuntu Dapper for me ;)

Tomhannen:: Please could some of you document your successes/failures on this page?

lealcy:: OLPC image doesn't work with Qemu 0.8.2 on Ubuntu 6.10 (Edgy Eft). It freeze in startup process. Check this shot:

http://wiki.laptop.org/go/Image:OLPC-qemu0.8.2-ubuntu6.10.png

Update: With the qemu 0.8.2 downloaded from http://fabrice.bellard.free.fr/qemu/download.html (the binaries) 1b2 loaded to the graphic interface, but I feel the interface a bit unresponsible (maybe an issue by emulation.) Thanks to Fernando <fernandogrd at yahoo dot com dot br> by the Qemu 0.8.2 Ubuntu issue tip.

SandwichButton:: lealcy, try entering the apm=off kernel argument. You need to enter the grub menu, edit the 'for qemu target' option by highlighting it and pressing e. The second line is the kernel arguments you pass at boot time. enter 'apm=off' without the single quotes at the end of the line, hit enter, then press b. It was previously freezing while mounting hda. My machine runs qemu 8.2, edgy 6.10 (w/ updates), and build 185 just fine now.

Misc

See also