Emulating the XO/Quick Start/Linux: Difference between revisions

From OLPC
Jump to navigation Jump to search
(→‎Fedora: Make the line less likely to interfere with nav box)
No edit summary
 
(33 intermediate revisions by 22 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>

{{Deprecated}}

{{emulation-nav}}
{{emulation-nav}}
__TOC__
__TOC__
Line 4: Line 8:
== Fedora ==
== Fedora ==


'''1 - Unpack the image'''
'''1 - Download and Unpack the image'''

You will need to download it from [http://download.laptop.org/xo-1/os/official/latest/ext3/ this image download directory]


bzcat olpc-redhat-stream-development-devel_ext3.img.bz2 \
bzcat olpc-redhat-stream-development-devel_ext3.img.bz2 \
> laptop.img
> laptop.img

or more recently

bzcat olpc-redhat-stream-ship.2-devel_ext3.img.bz2 \
> laptop.img

This step may take some time. Be patient. A laptop.img icon will be created. If you right-click on this and choose Properties in the contextual menu that appears, you will be able to watch the Size of the file grow. The Ship.2 build will create a laptop.img which is 927.6 MB.


'''2 - Obtain qemu'''
'''2 - Obtain qemu'''


yum install qemu
yum install qemu

<b>This will install version 0.9.1 of qemu which can not run the current 8.2 and joyride images based on kernel 2.6.25.</b>

Kernel 2.6.25 in the XO images checks for the availability of 3DNow and if it does not find it refuses to boot. A version of qemu compiled from the qemu Subversion repository does run the XO images since it can emulate AMD type x86 cpus. Just give the extra argument <tt>'-cpu athlon'</tt> to qemu. Sayamindu Dasgupta has produced fedora 8 and fedora 9 rpms with a version of qemu which will run the 8.2 and recent joyride versions. You can find them [http://dev.laptop.org/~sayamindu/qemu/ here]. The qemu shipped with Fedora 10 and later already supports <tt>'-cpu athlon'</tt>.


'''3 - Run qemu on the image'''
'''3 - Run qemu on the image'''
Line 17: Line 34:
'''qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img'''
'''qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img'''


Please check for the required arguments to qemu as explained on [[Emulating_the_XO/Quick_Start]]. At the time of writing, the arguments are as shown above, but this can change/evolve, so please check the Quick Start page for the latest recommended arguments first! Do NOT add the '-kernel-kqemu' argument at this point though, you'll first need to do step 4 before you add that one.
Please check for the required arguments to qemu as explained on [[Emulating_the_XO/Quick_Start]]. At the time of writing, the arguments are as shown above, but this can change/evolve, so please check the Quick Start page for the latest recommended arguments first! (2008-02-19: The arguments above still work. Do not confuse "l" and "1" in the argument "nic,model=rtl8139". To spell it out: nic,mode<L>=rt<L><one>8<one>39).

Do NOT add the '-kernel-kqemu' argument at this point though, you'll first need to do step 4 before you add that one.


Then see [[Emulating the XO/Quick Start#Running for the first time|Running for the first time]].
Then see [[Emulating the XO/Quick Start#Running for the first time|Running for the first time]].
Line 24: Line 43:


If you have an x86 or x86_64 cpu, you can use [http://fabrice.bellard.free.fr/qemu/kqemu-doc.html kqemu] to speed up the emulation several 100%.
If you have an x86 or x86_64 cpu, you can use [http://fabrice.bellard.free.fr/qemu/kqemu-doc.html kqemu] to speed up the emulation several 100%.
As of 2008-01-09 the olpc image seems not to be working on qemu using [http://kvm.qumranet.com/kvmwiki kvm].


'''4 a - Obtain kqemu'''
'''4 a - Obtain kqemu'''
Line 29: Line 49:
On Fedora x86,
On Fedora x86,
:Add the ATRpms repository to /etc/yum.repos.d and then "yum install kqemu". It will install kqemu and kmdl-kqemu. On Fedora 7, this "just works" for me. --[[User:Gregdek|Gregdek]] 08:56, 7 November 2007 (EST)
:Add the ATRpms repository to /etc/yum.repos.d and then "yum install kqemu". It will install kqemu and kmdl-kqemu. On Fedora 7, this "just works" for me. --[[User:Gregdek|Gregdek]] 08:56, 7 November 2007 (EST)
::The Livna repository also has kqemu packages. [http://rpm.livna.org/] -- J Chivall 12 Jan 08


On Fedora x86_64,
On Fedora x86_64,
Line 36: Line 57:


'''4 b - Run modprobe'''
'''4 b - Run modprobe'''
As root, run

sudo /sbin/modprobe kqemu major=0
/sbin/modprobe kqemu major=0


This will need to be run again if the host computer is rebooted (unless noted above). If you forget, qemu will be slow again (and a one-line error message scroll by when you run qemu).
This will need to be run again if the host computer is rebooted (unless noted above). If you forget, qemu will be slow again (and a one-line error message scroll by when you run qemu).

You can ensure that this command will be run every reboot by adding the following commands to your /etc/rc.local file:
#!/bin/sh
/sbin/modprobe kqemu major=0
Add the #!/bin/sh only if the file doesn't contain this line as its first line already.

:''We should add instructions for having it run automatically on boot, so you don't have to manually run it again. [[User:MitchellNCharity|MitchellNCharity]] 13:23, 5 January 2008 (EST)'' - I haven't tried it myself, but it should work.


'''4 c - Run a qemu variant with the <tt>-kernel-kqemu</tt> option'''
'''4 c - Run a qemu variant with the <tt>-kernel-kqemu</tt> option'''
Line 50: Line 78:


If you forget and use just <tt>qemu</tt> instead, things will be slow again. If you get the error message "Could not open '/dev/kqemu' - QEMU acceleration layer not activated", run the emulation as root or by with sudo.
If you forget and use just <tt>qemu</tt> instead, things will be slow again. If you get the error message "Could not open '/dev/kqemu' - QEMU acceleration layer not activated", run the emulation as root or by with sudo.

'''5 - qemu-kvm'''

Hardware-accelerated emulation (KVM) does not support 3DNow so this won't work. (see kvm-userspace: qemu/target-i386/helper.h)


== Debian/Ubuntu ==
== Debian/Ubuntu ==


<p>
'''1 - Unpack the image'''
For Ubuntu 7.04 and up (tested on Hardy 8.04), I have created a script that handles everything automaticaly (even downloading the image). Here it is</p>


<pre>
bzcat olpc-redhat-stream-development-ext3.img.bz2 > laptop.img
#!/bin/bash
## olpc vm script for ubuntu (>= 7.04) by Yannis Tsopokis
## go here for more info:
## http://tsopokis.gr (soon there will be an olpc section there)
## http://wiki.laptop.org/go/Emulating_the_XO/Quick_Start/Linux
## http://xs-dev.laptop.org/~cscott/olpc/streams/ship.2/build659/devel_ext3/olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img.bz2
link=http://xs-dev.laptop.org/~cscott/olpc/streams/ship.2/build659/devel_ext3/olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img.bz2
[ -f olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img ] || wget $link && bunzip2 olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img.bz2
dpkg --get-selections qemu 2>/dev/null | grep install || sudo apt-get install qemu
dpkg --get-selections kqemu-common 2>/dev/null | grep install || sudo apt-get install kqemu-common
dpkg --get-selections module-assistant 2>/dev/null | grep install || sudo apt-get install module-assistant
sudo module-assistant auto-install kqemu
sudo su -c "echo 'options kqemu major=0' > /etc/modprobe.d/kqemu"
sudo su -c 'echo KERNEL==\"kqemu\", NAME=\"%k\", MODE=\"0666\" > /etc/udev/rules.d/60-kqemu.rules'
sudo /sbin/modprobe kqemu major=0
qemu -kernel-kqemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img
</pre>
<p>create a file named qemu-olpc.sh and put the above inside it. then run "source qemu-olpc.sh" and it will do everything for you. it is tested with 32-bit systems and even handles kqemu kernel modules.</p>

OR

'''1 - Download and Unpack the image'''

You will need to download it from [http://xs-dev.laptop.org/cscott/olpc/streams/ship.2/latest/devel_ext3/ this image download directory]

bzcat olpc-redhat-stream-development-devel_ext3.img.bz2 \
> laptop.img

or more recently

bzcat olpc-redhat-stream-ship.2-devel_ext3.img.bz2 \
> laptop.img

This step may take some time. Be patient. A laptop.img icon will be created. If you right-click on this and choose Properties in the contextual menu that appears, you will be able to watch the Size of the file grow. The Ship.2 build will create a laptop.img which is 927.6 MB.


'''2 - Obtain qemu'''
'''2 - Obtain qemu'''
Line 64: Line 131:


'''qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img'''
'''qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img'''

(That's `, not ', for the `tty`. Use in the slash over the tilde, not the quote.)

If you wish not to type this very long and confusing line of code every time you start QEMU, open .bash_aliases (located in your home directory, and can be seen using 'ls -a', and type

alias <ALIAS>='qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img' '''


Please check for the required arguments to qemu as explained on [[Emulating_the_XO/Quick_Start]]. At the time of writing, the arguments are as shown above, but this can change/evolve, so please check the Quick Start page for the latest recommended arguments first! Do NOT add the '-kernel-kqemu' argument at this point though, you'll first need to do step 4 before you add that one.
Please check for the required arguments to qemu as explained on [[Emulating_the_XO/Quick_Start]]. At the time of writing, the arguments are as shown above, but this can change/evolve, so please check the Quick Start page for the latest recommended arguments first! Do NOT add the '-kernel-kqemu' argument at this point though, you'll first need to do step 4 before you add that one.
Line 139: Line 212:
qemu-system-x86_64 -kernel-kqemu ...
qemu-system-x86_64 -kernel-kqemu ...


If you forget and use just <tt>qemu</tt> instead, things will be slow again. If you get the error message "Could not open '/dev/kqemu' - QEMU acceleration layer not activated", run the emulation as root or by with sudo.
If you forget and use just <tt>qemu</tt> instead, things will be slow again. If you get the error message "Could not open '/dev/kqemu' - QEMU acceleration layer not activated", run the emulation as root using sudo.


== Gentoo ==
== Gentoo ==
Line 145: Line 218:
Emerge the packages:
Emerge the packages:


emerge -avuDt qemu qemu-user qemu-softmmu kqemu
echo "app-emulation/qemu-softmmu kqemu" >> /etc/portage/package.use
emerge -avuDt qemu


You will likely need to switch back to gcc 3.x in order to build qemu, if you need to do so, use the gcc-config command:
You will likely need to switch back to gcc 3.x in order to build qemu, if you need to do so, use the gcc-config command:
Line 174: Line 248:
Above setup was tested on a largely amd64 box with minimal ~amd64 packages on 2007-12-03.
Above setup was tested on a largely amd64 box with minimal ~amd64 packages on 2007-12-03.


'''Note:''' Due to a known bug #194681, compiling with gcc-3.4.x might fail on Gentoo x86/i686 platforms. If the above does not work, try with gcc-3.3.x. Howto is provided [[Installing_Qemu_on_Gentoo_x86_with_GCC_3|here]].
== FreeBSD ==

Install qemu from ports:

cd /usr/ports/emulators/qemu && make install clean

or as a package

pkg_add -r qemu

Then load kqemu and aio kernel modules:

kldload kqemu
kldload aio

and launch the image you want:


qemu -hda olpc-stream-development-7-20060609_1600-ext3.img
:Should this take the same arguments as the linux qemu invocation? [[User:MitchellNCharity|MitchellNCharity]] 21:18, 23 May 2007 (EDT)





Latest revision as of 16:14, 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.

modify 

Fedora

1 - Download and Unpack the image

You will need to download it from this image download directory

bzcat olpc-redhat-stream-development-devel_ext3.img.bz2 \
> laptop.img

or more recently

bzcat olpc-redhat-stream-ship.2-devel_ext3.img.bz2 \
> laptop.img

This step may take some time. Be patient. A laptop.img icon will be created. If you right-click on this and choose Properties in the contextual menu that appears, you will be able to watch the Size of the file grow. The Ship.2 build will create a laptop.img which is 927.6 MB.

2 - Obtain qemu

yum install qemu

This will install version 0.9.1 of qemu which can not run the current 8.2 and joyride images based on kernel 2.6.25.

Kernel 2.6.25 in the XO images checks for the availability of 3DNow and if it does not find it refuses to boot. A version of qemu compiled from the qemu Subversion repository does run the XO images since it can emulate AMD type x86 cpus. Just give the extra argument '-cpu athlon' to qemu. Sayamindu Dasgupta has produced fedora 8 and fedora 9 rpms with a version of qemu which will run the 8.2 and recent joyride versions. You can find them here. The qemu shipped with Fedora 10 and later already supports '-cpu athlon'.

3 - Run qemu on the image

qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img

Please check for the required arguments to qemu as explained on Emulating_the_XO/Quick_Start. At the time of writing, the arguments are as shown above, but this can change/evolve, so please check the Quick Start page for the latest recommended arguments first! (2008-02-19: The arguments above still work. Do not confuse "l" and "1" in the argument "nic,model=rtl8139". To spell it out: nic,mode<L>=rt<L><one>8<one>39).

Do NOT add the '-kernel-kqemu' argument at this point though, you'll first need to do step 4 before you add that one.

Then see Running for the first time.

4 - (optional, but recommended) Make qemu run faster

If you have an x86 or x86_64 cpu, you can use kqemu to speed up the emulation several 100%. As of 2008-01-09 the olpc image seems not to be working on qemu using kvm.

4 a - Obtain kqemu

On Fedora x86,

Add the ATRpms repository to /etc/yum.repos.d and then "yum install kqemu". It will install kqemu and kmdl-kqemu. On Fedora 7, this "just works" for me. --Gregdek 08:56, 7 November 2007 (EST)
The Livna repository also has kqemu packages. [1] -- J Chivall 12 Jan 08

On Fedora x86_64,

as of 2007-05-13, there are no official rpms for kqemu, or the kqemu kernel module, and they are not included in the qemu rpm. atrpms.net has kqemu rpms. Or install from source.
I was successful using kqemu-1.3.0-2.fc6.i386.rpm and kqemu-kmdl-2.6.20-1.2962.fc6-1.3.0-2.fc6.x86_64.rpm from atrpms on fc6. 2962 is the kernel version (eg, ls /boot/). MitchellNCharity 19:40, 1 July 2007 (EDT)
Adding the ATRpms repository and then running "yum install kqemu" should be successful here as well, although I have not tried it. --Gregdek 08:59, 7 November 2007 (EST)

4 b - Run modprobe As root, run

/sbin/modprobe kqemu major=0

This will need to be run again if the host computer is rebooted (unless noted above). If you forget, qemu will be slow again (and a one-line error message scroll by when you run qemu).

You can ensure that this command will be run every reboot by adding the following commands to your /etc/rc.local file:

  #!/bin/sh
  /sbin/modprobe kqemu major=0

Add the #!/bin/sh only if the file doesn't contain this line as its first line already.

We should add instructions for having it run automatically on boot, so you don't have to manually run it again. MitchellNCharity 13:23, 5 January 2008 (EST) - I haven't tried it myself, but it should work.

4 c - Run a qemu variant with the -kernel-kqemu option

On x86,

qemu -kernel-kqemu ...

On x86_64,

qemu-system-x86_64 -kernel-kqemu ...

If you forget and use just qemu instead, things will be slow again. If you get the error message "Could not open '/dev/kqemu' - QEMU acceleration layer not activated", run the emulation as root or by with sudo.

5 - qemu-kvm

Hardware-accelerated emulation (KVM) does not support 3DNow so this won't work. (see kvm-userspace: qemu/target-i386/helper.h)

Debian/Ubuntu

For Ubuntu 7.04 and up (tested on Hardy 8.04), I have created a script that handles everything automaticaly (even downloading the image). Here it is

#!/bin/bash
## olpc vm script for ubuntu (>= 7.04) by Yannis Tsopokis
## go here for more info:
## http://tsopokis.gr (soon there will be an olpc section there)
## http://wiki.laptop.org/go/Emulating_the_XO/Quick_Start/Linux
## http://xs-dev.laptop.org/~cscott/olpc/streams/ship.2/build659/devel_ext3/olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img.bz2
link=http://xs-dev.laptop.org/~cscott/olpc/streams/ship.2/build659/devel_ext3/olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img.bz2
[ -f olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img ] || wget $link && bunzip2 olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img.bz2
dpkg --get-selections qemu 2>/dev/null | grep install || sudo apt-get install qemu
dpkg --get-selections kqemu-common 2>/dev/null | grep install || sudo apt-get install kqemu-common
dpkg --get-selections module-assistant 2>/dev/null | grep install || sudo apt-get install module-assistant
sudo module-assistant auto-install kqemu
sudo su -c "echo 'options kqemu major=0' > /etc/modprobe.d/kqemu"
sudo su -c 'echo KERNEL==\"kqemu\", NAME=\"%k\", MODE=\"0666\" > /etc/udev/rules.d/60-kqemu.rules'
sudo /sbin/modprobe kqemu major=0
qemu -kernel-kqemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda olpc-redhat-stream-ship.2-build-659-20080229_1949-devel_ext3.img

create a file named qemu-olpc.sh and put the above inside it. then run "source qemu-olpc.sh" and it will do everything for you. it is tested with 32-bit systems and even handles kqemu kernel modules.

OR

1 - Download and Unpack the image

You will need to download it from this image download directory

bzcat olpc-redhat-stream-development-devel_ext3.img.bz2 \
> laptop.img

or more recently

bzcat olpc-redhat-stream-ship.2-devel_ext3.img.bz2 \
> laptop.img

This step may take some time. Be patient. A laptop.img icon will be created. If you right-click on this and choose Properties in the contextual menu that appears, you will be able to watch the Size of the file grow. The Ship.2 build will create a laptop.img which is 927.6 MB.

2 - Obtain qemu

apt-get install qemu

3 - Run qemu on the image

qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img

(That's `, not ', for the `tty`. Use in the slash over the tilde, not the quote.)

If you wish not to type this very long and confusing line of code every time you start QEMU, open .bash_aliases (located in your home directory, and can be seen using 'ls -a', and type

alias <ALIAS>='qemu -m 256 -soundhw es1370 -serial `tty` -net user -net nic,model=rtl8139 -hda laptop.img' 

Please check for the required arguments to qemu as explained on Emulating_the_XO/Quick_Start. At the time of writing, the arguments are as shown above, but this can change/evolve, so please check the Quick Start page for the latest recommended arguments first! Do NOT add the '-kernel-kqemu' argument at this point though, you'll first need to do step 4 before you add that one.

Then see Running for the first time.

4 - (optional, but recommended) Make qemu run faster

If you have an x86 or x86_64 cpu, you can use kqemu to speed up the emulation several 100%.

4 a - Obtain kqemu

old Ubuntu < 7.04, and Debian(?)

As root, do one of:

apt-get install kqemu-modules-2.6-486    # if you have a 486/original Pentium
apt-get install kqemu-modules-2.6-686    # if you have a later Pentium
apt-get install kqemu-modules-2.6-k7     # if you have a 32-bit AMD Duron/Athlon/AthlonXP

And then

 apt-get install kqemu-common

to add docs and have it auto-load at boot time.

Ubuntu 7.10

Follow the instructions for Ubuntu 7.04

Ubuntu 7.04

In Ubuntu 7.04, you'll have to use module-assistant to compile kqemu.

a) First, run

apt-get install kqemu-common

b) Install the program:

sudo apt-get install module-assistant

c) Download the kernel headers:

sudo module-assistant prepare kqemu

d) Download, compile and install the kqemu module package:

sudo module-assistant auto-install kqemu

e) If you wish to avoid having to modprobe kqemu each time you boot:

Due to an open bug in ubuntu's kqemu-source package, you'll need to do the following as well:

sudo nano /etc/modprobe.d/kqemu

Change the contents to be:

options kqemu major=0

Save the file and exit nano. Then do:

sudo nano /etc/udev/rules.d/60-kqemu.rules

Enter this text into the empty file:

KERNEL=="kqemu", NAME="%k", MODE="0666"

Save the file and exit nano.

f) continue with next step...

4 b - Run modprobe

sudo /sbin/modprobe kqemu major=0

This will need to be run again if the host computer is rebooted (unless noted above). If you forget, qemu will be slow again (and a one-line error message scroll by when you run qemu).

4 c - Run a qemu variant with the -kernel-kqemu option

On x86,

qemu -kernel-kqemu ...

On x86_64,

qemu-system-x86_64 -kernel-kqemu ...

If you forget and use just qemu instead, things will be slow again. If you get the error message "Could not open '/dev/kqemu' - QEMU acceleration layer not activated", run the emulation as root using sudo.

Gentoo

Emerge the packages:

 echo "app-emulation/qemu-softmmu kqemu" >> /etc/portage/package.use
 emerge -avuDt qemu

You will likely need to switch back to gcc 3.x in order to build qemu, if you need to do so, use the gcc-config command:

 gcc-config -l

Then choose the "normal" 3.x gcc, e.g. on my system:

 gcc-config x86_64-pc-linux-gnu-3.4.6

when that completes:

 source /etc/profile

then re-run your emerge command. When you are finished, remember to restore your original gcc with gcc-config again. Note that you will need to re-emerge kqemu every time you update your kernel, and that you will likely want to use your "normal" gcc to do that.

Now, load the kqemu module:

 modprobe kqemu

You may want to add it to your /etc/modules.autoload.d/kernel-2.6 in order to avoid the need for modprobing each time you want to run.

You should now be able to run qemu with kqemu support:

 qemu-system-x86_64 -kernel-kqemu -hda olpc-649.img
   -soundhw es1370 -net user -net nic,model=rtl8139

Above setup was tested on a largely amd64 box with minimal ~amd64 packages on 2007-12-03.

Note: Due to a known bug #194681, compiling with gcc-3.4.x might fail on Gentoo x86/i686 platforms. If the above does not work, try with gcc-3.3.x. Howto is provided here.


Yellow Dog Linux on PlayStation3

Sugar is able to run on a PS3. It can be run using the qemu emulator. Here are some directions for one way of doing this:

1. Install ydl linux for PS3

2. Log on to ydl as root user

3. Install yum (helps install other linux software)

4. Download qemu

5. Download therepos here

6. Unzip therepos.zip

7. Access yum folder (yum.repos.d)

8. Copy unzipped files to yum.repos.d

9. Follow the linux emulation instructions