(→Build QEMUGL from source) |
(→Run the image under QEMU with GL acceleration) |
||
| (25 intermediate revisions not shown) | |||
| Line 22: | Line 22: | ||
cd meego-emulator-qemugl-x86 | cd meego-emulator-qemugl-x86 | ||
| - | git checkout -b qemu-gl --track origin/qemu-gl | + | git checkout -b qemu-gl-1.1 --track origin/qemu-gl-1.1 |
Make sure that there is KVM enabled and that the following libraries (development package) are installed on the host machine: | Make sure that there is KVM enabled and that the following libraries (development package) are installed on the host machine: | ||
| Line 28: | Line 28: | ||
* zlib | * zlib | ||
* libSDL | * libSDL | ||
| - | * Xcomposite | + | * Xcomposite |
| + | * libexpat | ||
Configure qemugl: | Configure qemugl: | ||
| - | ./configure --target-list=i386-softmmu --enable-gl | + | ./configure --target-list=i386-softmmu --enable-gl --enable-skinning |
Check the output from <code>configure</code> contains the strings below: | Check the output from <code>configure</code> contains the strings below: | ||
| Line 110: | Line 111: | ||
zypper addrepo http://repo.meego.com/MeeGo/sdk/target/repos/meego/1.1/ meego-sdk | zypper addrepo http://repo.meego.com/MeeGo/sdk/target/repos/meego/1.1/ meego-sdk | ||
| - | (you | + | (you will need to use the '''trunk''' repo if you are using a trunk netbook image) |
'''Another alternative is to [[#Manually build packages for an image running under QEMU GL|manually build the addons, kernel and virtiogl module in a chroot]], then install them into the image.''' | '''Another alternative is to [[#Manually build packages for an image running under QEMU GL|manually build the addons, kernel and virtiogl module in a chroot]], then install them into the image.''' | ||
| Line 134: | Line 135: | ||
<pre> | <pre> | ||
qemugl -m 1024 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -net nic,model=e1000 -enable-kvm \ | qemugl -m 1024 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -net nic,model=e1000 -enable-kvm \ | ||
| - | -vga std -enable-gl -device virtio-gl-pci -boot c -hda meego-netbook.raw | + | -vga std -enable-gl -device virtio-gl-pci -soundhw ac97 -boot c -hda meego-netbook.raw |
</pre> | </pre> | ||
| + | In case that you are not able to boot into MeeGo UX, please have a look at the trouble shooting page [http://wiki.meego.com/MeeGo_SDK_Troubleshooting#QEMU_SDK_Errors here] to see whether the problem could be solved. <br> | ||
Note that you should still be able to ssh to this image as above. | Note that you should still be able to ssh to this image as above. | ||
| Line 143: | Line 145: | ||
If you have a handset image downloaded, follow these instructions to enable it to run in QEMU with GL acceleration. | If you have a handset image downloaded, follow these instructions to enable it to run in QEMU with GL acceleration. | ||
| - | + | You will need to install '''kpartx''' if you don't have it already: | |
| + | $ sudo yum install kpartx | ||
| + | (or whatever the equivalent is for your distro). | ||
| - | + | Download a handset IA32 image (e.g. http://repo.meego.com/MeeGo/builds/trunk/1.1.80.4.20101029.1/handset/images/meego-handset-ia32-mtf/meego-handset-ia32-mtf-1.1.80.4.20101029.1-sda.bin.bz2), and unpack the file: | |
| + | $ bunzip2 meego-handset-ia32-mtf-1.1-sda.bin.bz2 | ||
| + | (Note that this procedure should work for other sda-bin images from http://repo.meego.com/MeeGo/builds/ too.) | ||
| - | + | A useful shortcut is to define a variable for the path to the image first; this can then be used to make later commands simpler: | |
| + | $ IMAGE=~/images/meego-handset-ia32-mtf-1.1-sda.bin | ||
| - | + | Use <code>kpartx</code> to map the partitions in the disk image onto devices, which can then be mounted onto directories: | |
| + | $ sudo kpartx -a -v $IMAGE | ||
| + | add map loop0p1 (253:4): 0 3320312 linear /dev/loop0 1 | ||
| - | + | The output of <code>kpartx</code> indicates the loop device mapped to the partition; in this case, <code>loop0p1</code>. The device we want to mount is determined by prefixing this map with <code>/dev/mapper</code>, i.e.: | |
| - | + | /dev/mapper/loop0p1 | |
| - | + | We also need to note the device which this image has been mapped across; in this case, <code>/dev/loop0</code>. This will be used later to make the image bootable. | |
| - | zypper install xorg-x11-drv-vesa | + | |
| - | zypper install | + | You can then mount this on a directory: |
| - | zypper install openssh-server | + | $ mkdir /tmp/handset |
| - | + | $ sudo mount -t ext3 /dev/mapper/loop0p1 /tmp/handset | |
| + | '''Attention''': on Ubuntu10.04 should be | ||
| + | $ sudo mount /dev/mapper/loop0p1 /tmp/handset | ||
| + | or we'll get message | ||
| + | "mount: wrong fs type, bad option, bad superblock on /dev/mapper/loop0p1,missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so". | ||
| + | |||
| + | And chroot into it: | ||
| + | $ sudo mic-chroot /tmp/handset | ||
| + | |||
| + | Next, modify the packages in the image: | ||
| + | $ zypper remove kernel-mrst # if present | ||
| + | $ zypper install kernel-netbook mesa-dri-* xorg-x11-drv-vesa syslinux-extlinux | ||
| + | |||
| + | Create symlinks to the Linux kernel for extlinux: | ||
| + | $ cd /boot/extlinux | ||
| + | $ ln -sf ../vmlinuz-*netbook . | ||
| + | |||
| + | Modify the extlinux configuration: | ||
| + | $ MEEGO_KERNEL=`ls /boot/vmlinuz-*netbook | sed -e 's%/boot/%%'` && echo \ | ||
| + | "PROMPT 0 | ||
| + | TIMEOUT 1 | ||
| + | DEFAULT meego | ||
| + | LABEL meego | ||
| + | KERNEL $MEEGO_KERNEL | ||
| + | APPEND ro root=/dev/sda1 3" \ | ||
| + | > /boot/extlinux/extlinux.conf | ||
| + | |||
| + | Note that the above command won't work if you have multiple netbook kernels installed: in that case, manually set <code>MEEGO_KERNEL</code>. | ||
| + | |||
| + | Also note that the <code>APPEND</code> configuration line tells the kernel to boot to runlevel 3, which is useful for debugging. | ||
| + | |||
| + | Add SDK repository: | ||
| + | $ zypper addrepo http://repo.meego.com/MeeGo/sdk/target/repos/meego/trunk meego-sdk | ||
| + | You might need to change '''trunk''' to something else, depending on your image (for example, '''1.1''' if using a MeeGo 1.1 image). | ||
| + | |||
| + | Install SDK packages: | ||
| + | $ zypper install meego-sdk-qemugl-addon-handset kmod-virtiogl | ||
| + | |||
| + | Install SSH server and enable it to start on boot: | ||
| + | $ zypper install openssh-server | ||
| + | $ chkconfig --add sshd | ||
| + | |||
| + | Fix permissions on the Xorg binary: | ||
| + | $ chmod u+s /usr/bin/Xorg | ||
| + | |||
| + | Exit the chroot: | ||
| + | $ exit | ||
| + | |||
| + | Now, outside the chroot, install the SYSLINUX bootloader on the filesystem: | ||
| + | $ sudo extlinux --install /tmp/handset/boot/extlinux | ||
| + | |||
| + | Unmount the device: | ||
| + | $ sudo umount /tmp/handset | ||
| + | |||
| + | Make the modified image (still mapped to a device) bootable; NB the device you use with <code>fdisk</code> is the one we made a note of earlier when we ran <code>kpartx</code>: | ||
| + | $ sudo fdisk /dev/loop0 | ||
| + | |||
| + | At the fdisk command prompt: | ||
| + | * Enter ''a'' to toggle the "bootable" flag on a partition. | ||
| + | * Enter ''1'' to select the first partition as the bootable one. | ||
| + | * Enter ''w'' to write your changes to the partition table in the image. | ||
| - | + | Remove the device map: | |
| - | + | $ sudo kpartx -d -v $IMAGE | |
| - | + | ||
| - | + | ||
| - | + | This image can now be booted under QEMU with: | |
| - | + | $ sudo qemugl -m 1024 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -net nic,model=e1000 -vga std \ | |
| - | + | -boot c -enable-kvm -enable-gl -device virtio-gl-pci -hda $IMAGE | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | This will boot to runlevel 3 when you run the image under QEMU. When you get a login prompt after booting under QEMU, login with username '''meego''' and password '''meego'''. | |
| - | + | ||
| - | + | To start the UX once logged it: | |
| - | + | $ uxlaunch | |
| - | + | ||
== Manually build packages for an image running under QEMU GL == | == Manually build packages for an image running under QEMU GL == | ||
| - | You can manually build the software required to run an image (netbook or handset) under QEMU with GL acceleration. But this is only recommended if a pre-built package for the software you want doesn't already exist (up-to-date packages should be available for both handset and netbook | + | You can manually build the software required to run an image (netbook or handset) under QEMU with GL acceleration. But this is only recommended if a pre-built package for the software you want doesn't already exist (up-to-date packages should be available for both handset and netbook). |
| - | The steps below should be followed from ''inside'' a MeeGo image intended to run under QEMU. You could try this inside an emulated image, or by [[Building a MeeGo chroot on Linux|building a chroot]] from the raw disk image and working inside that (the latter is the only reasonable approach for building the kernel). | + | The steps below should be followed from ''inside'' a MeeGo image intended to run under QEMU. You could try this inside an emulated image, or by [[SDK/Docs/1.0/Building a MeeGo chroot on Linux|building a chroot]] from the raw disk image and working inside that (the latter is the only reasonable approach for building the kernel). |
| - | For building both the qemugl addon and the kernel+modules, you will need to install a toolchain first (either into the QEMU image | + | For building both the qemugl addon and the kernel+modules, you will need to install a toolchain first (either into the QEMU image or the chroot; or into both, if you are building some software directly in the image and some in the chroot): |
zypper install make gcc git patch diffutils | zypper install make gcc git patch diffutils | ||
| Line 214: | Line 274: | ||
The approach we take for this is to use a chroot to build an RPM package for the new kernel and modules. This can then be easily transferred to the QEMU image and installed. Building the new kernel directly inside the QEMU image is too slow to be practical. | The approach we take for this is to use a chroot to build an RPM package for the new kernel and modules. This can then be easily transferred to the QEMU image and installed. Building the new kernel directly inside the QEMU image is too slow to be practical. | ||
| - | The first thing you'll need is a MeeGo chroot, built from the same image you're using under QEMU. See [[Building a MeeGo chroot on Linux|this page]] for instructions. | + | The first thing you'll need is a MeeGo chroot, built from the same image you're using under QEMU. See [[SDK/Docs/1.0/Building a MeeGo chroot on Linux|this page]] for instructions. |
| - | Enter the chroot | + | Enter the chroot: |
| + | sudo mic-chroot <path to chroot> | ||
Install <code>rpmbuild</code> (used to build the RPM from the kernel source): | Install <code>rpmbuild</code> (used to build the RPM from the kernel source): | ||
| Line 270: | Line 331: | ||
make rpm-pkg | make rpm-pkg | ||
| - | The resulting package is in <code>/root/rpmbuild/RPMS/i386/kernel- | + | The resulting package is in <code>/root/rpmbuild/RPMS/i386/kernel-<kernel version and architecture>.rpm</code>. |
Copy this to the QEMU image over ssh or equivalent, for example: | Copy this to the QEMU image over ssh or equivalent, for example: | ||
This page describes how to build the MeeGo SDK QEMU tools from source, including QEMU binary, patched kernel module, and stub libGL.
It also covers how to convert stock MeeGo images for use with QEMU.
Together, the QEMU tools and a modified image can be used as a deployment target for Qt Creator.
Contents |
An alternative to building from source is to install the qemu-gl and/or qemu-arm packages from one of the repositories at http://repo.meego.com/MeeGo/sdk/host/repos/
To install on a 64bit system, see these instructions (community-maintained).
If you still prefer to build QEMUGL from sources, proceed with these steps:
Checkout the QEMU GL source code (this is basically QEMU with some patches to enable GL acceleration):
git clone git://gitorious.org/meego-developer-tools/meego-emulator-qemugl-x86.git
Checkout the qemu-gl branch:
cd meego-emulator-qemugl-x86 git checkout -b qemu-gl-1.1 --track origin/qemu-gl-1.1
Make sure that there is KVM enabled and that the following libraries (development package) are installed on the host machine:
Configure qemugl:
./configure --target-list=i386-softmmu --enable-gl --enable-skinning
Check the output from configure contains the strings below:
SDL support yes ...... KVM support yes
Build qemugl:
make sudo make install
This installs various QEMU binaries (default prefix is /usr/local), including qemugl and qemu-img used in this tutorial.
This section explains how to make a standard MeeGo netbook image run in QEMU with GL acceleration.
Create raw image file for MeeGo to install on. The qemu-img command is part of the QEMU build:
qemu-img create -f raw meego-netbook.raw 3.5G
Install MeeGo to the raw hard disk, using the downloaded .img file as the installation CDROM:
qemugl -m 1024 -vga std -boot d -hda meego-netbook.raw \ -cdrom meego-netbook-ia32-1.1.80.1.20101012.1.img
Boot into the image:
qemugl -m 1024 -vga std -boot c -hda meego-netbook.raw
Go through the installation steps to set up a meego user. The password you set here is also used as the root password, which we'll use below.
Note: occasionally I've halted the system before the meego user is setup. When I then try to boot into the UX, it fails because the user is missing. In this case, you can manually create the user from a root prompt (inside the QEMU image) with:
useradd -d /home/meego -M -s /bin/bash meego
Halt the system.
Now boot it again (this time with networking enabled; type the command below, press return, then press tab like crazy so you can get to the boot menu):
qemugl -m 1024 -vga std -net user,hostfwd=tcp:127.0.0.1:6666-:22 -net nic,model=e1000 \ -boot c -hda meego-netbook.raw
Next, edit the kernel command line on the boot menu screen so it looks like this:
vmlinuz-2.6.35.3-8.5-netbook ro root=/dev/sda2 vga=current s
This will get you a root prompt.
Then install ssh server (this makes the following steps easier, as you can cut and paste into the ssh prompt):
zypper install openssh-server chkconfig --add sshd /etc/init.d/sshd start
Use can now use ssh to login to the image with:
ssh -p 6666 root@127.0.0.1
(password is the same as you entered for your normal user when configuring the system)
Once logged in over ssh, set suid on the Xorg binary (so a normal user can start X):
chmod u+s /usr/bin/Xorg
Then install the SDK addons. First, add the MeeGo SDK repo:
zypper addrepo http://repo.meego.com/MeeGo/sdk/target/repos/meego/1.1/ meego-sdk
(you will need to use the trunk repo if you are using a trunk netbook image)
Another alternative is to manually build the addons, kernel and virtiogl module in a chroot, then install them into the image.
Install the qemugl addon package into the image:
zypper install meego-sdk-qemugl-addon-netbook
Install virtiogl module for kernel:
zypper install kmod-virtiogl
Right now above package only supports kernel version of 2.6.35. If you need to build the SDK addons or a kernel and its modules, instructions are given below.
The image should now be ready. It can be started in QEMU with this command:
qemugl -m 1024 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -net nic,model=e1000 -enable-kvm \ -vga std -enable-gl -device virtio-gl-pci -soundhw ac97 -boot c -hda meego-netbook.raw
In case that you are not able to boot into MeeGo UX, please have a look at the trouble shooting page here to see whether the problem could be solved.
Note that you should still be able to ssh to this image as above.
If you have a handset image downloaded, follow these instructions to enable it to run in QEMU with GL acceleration.
You will need to install kpartx if you don't have it already:
$ sudo yum install kpartx
(or whatever the equivalent is for your distro).
Download a handset IA32 image (e.g. http://repo.meego.com/MeeGo/builds/trunk/1.1.80.4.20101029.1/handset/images/meego-handset-ia32-mtf/meego-handset-ia32-mtf-1.1.80.4.20101029.1-sda.bin.bz2), and unpack the file:
$ bunzip2 meego-handset-ia32-mtf-1.1-sda.bin.bz2
(Note that this procedure should work for other sda-bin images from http://repo.meego.com/MeeGo/builds/ too.)
A useful shortcut is to define a variable for the path to the image first; this can then be used to make later commands simpler:
$ IMAGE=~/images/meego-handset-ia32-mtf-1.1-sda.bin
Use kpartx to map the partitions in the disk image onto devices, which can then be mounted onto directories:
$ sudo kpartx -a -v $IMAGE add map loop0p1 (253:4): 0 3320312 linear /dev/loop0 1
The output of kpartx indicates the loop device mapped to the partition; in this case, loop0p1. The device we want to mount is determined by prefixing this map with /dev/mapper, i.e.:
/dev/mapper/loop0p1
We also need to note the device which this image has been mapped across; in this case, /dev/loop0. This will be used later to make the image bootable.
You can then mount this on a directory:
$ mkdir /tmp/handset $ sudo mount -t ext3 /dev/mapper/loop0p1 /tmp/handset
Attention: on Ubuntu10.04 should be
$ sudo mount /dev/mapper/loop0p1 /tmp/handset
or we'll get message "mount: wrong fs type, bad option, bad superblock on /dev/mapper/loop0p1,missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so".
And chroot into it:
$ sudo mic-chroot /tmp/handset
Next, modify the packages in the image:
$ zypper remove kernel-mrst # if present $ zypper install kernel-netbook mesa-dri-* xorg-x11-drv-vesa syslinux-extlinux
Create symlinks to the Linux kernel for extlinux:
$ cd /boot/extlinux $ ln -sf ../vmlinuz-*netbook .
Modify the extlinux configuration:
$ MEEGO_KERNEL=`ls /boot/vmlinuz-*netbook | sed -e 's%/boot/%%'` && echo \ "PROMPT 0 TIMEOUT 1 DEFAULT meego LABEL meego KERNEL $MEEGO_KERNEL APPEND ro root=/dev/sda1 3" \ > /boot/extlinux/extlinux.conf
Note that the above command won't work if you have multiple netbook kernels installed: in that case, manually set MEEGO_KERNEL.
Also note that the APPEND configuration line tells the kernel to boot to runlevel 3, which is useful for debugging.
Add SDK repository:
$ zypper addrepo http://repo.meego.com/MeeGo/sdk/target/repos/meego/trunk meego-sdk
You might need to change trunk to something else, depending on your image (for example, 1.1 if using a MeeGo 1.1 image).
Install SDK packages:
$ zypper install meego-sdk-qemugl-addon-handset kmod-virtiogl
Install SSH server and enable it to start on boot:
$ zypper install openssh-server $ chkconfig --add sshd
Fix permissions on the Xorg binary:
$ chmod u+s /usr/bin/Xorg
Exit the chroot:
$ exit
Now, outside the chroot, install the SYSLINUX bootloader on the filesystem:
$ sudo extlinux --install /tmp/handset/boot/extlinux
Unmount the device:
$ sudo umount /tmp/handset
Make the modified image (still mapped to a device) bootable; NB the device you use with fdisk is the one we made a note of earlier when we ran kpartx:
$ sudo fdisk /dev/loop0
At the fdisk command prompt:
Remove the device map:
$ sudo kpartx -d -v $IMAGE
This image can now be booted under QEMU with:
$ sudo qemugl -m 1024 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -net nic,model=e1000 -vga std \ -boot c -enable-kvm -enable-gl -device virtio-gl-pci -hda $IMAGE
This will boot to runlevel 3 when you run the image under QEMU. When you get a login prompt after booting under QEMU, login with username meego and password meego.
To start the UX once logged it:
$ uxlaunch
You can manually build the software required to run an image (netbook or handset) under QEMU with GL acceleration. But this is only recommended if a pre-built package for the software you want doesn't already exist (up-to-date packages should be available for both handset and netbook).
The steps below should be followed from inside a MeeGo image intended to run under QEMU. You could try this inside an emulated image, or by building a chroot from the raw disk image and working inside that (the latter is the only reasonable approach for building the kernel).
For building both the qemugl addon and the kernel+modules, you will need to install a toolchain first (either into the QEMU image or the chroot; or into both, if you are building some software directly in the image and some in the chroot):
zypper install make gcc git patch diffutils
Alternatively, this command will get you all the MeeGo developer tools:
zypper install -t pattern development-tools
The addon package installed in above section can also be built from source. These steps are fairly easy to do inside the QEMU image itself.
You don't need to do this if you already installed a meego-sdk-qemugl-addon-* package (see above).
Install required packaged first:
zypper install libXfixes-devel libX11-devel
Checkout stub libGL source code:
git clone git://gitorious.org/meego-developer-tools/meego-emulator-libgl-x86.git
Build:
cd meego-emulator-libgl-x86 make make install
The approach we take for this is to use a chroot to build an RPM package for the new kernel and modules. This can then be easily transferred to the QEMU image and installed. Building the new kernel directly inside the QEMU image is too slow to be practical.
The first thing you'll need is a MeeGo chroot, built from the same image you're using under QEMU. See this page for instructions.
Enter the chroot:
sudo mic-chroot <path to chroot>
Install rpmbuild (used to build the RPM from the kernel source):
zypper install rpm-build
Get the MeeGo kernel-source (this contains configuration files for building MeeGo kernels):
git clone git://gitorious.org/meego-os-base/kernel-source.git
Get the virtio patches for the kernel:
git clone git://gitorious.org/meego-developer-tools/meego-emulator-virtiogl-x86.git
Copy the virtio patch into the patches dir of kernel-source:
cp meego-emulator-virtiogl-x86/linux-2.6.35-virtio-for-qemu-gl-acceleration.patch kernel-source/patches
Download the kernel source tarball (NB you want the plain series version, not one with a patch number); in this case, I used a 2.6.35 kernel:
cd kernel-source curl -o linux-2.6.35.tar.bz2 http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.tar.bz2
Remain in the kernel-source directory.
Edit the series file to add the virtiogl patch to the list of patches to apply:
# Add Virtio-mem module for QEMU GL acceleration linux-2.6.35-virtio-for-qemu-gl-acceleration.patch
Edit the config-netbook file (used for both handset and netbook) to enable VIRTIOGL as a module:
CONFIG_VIRTIO_PCI=m CONFIG_VIRTIOGL=m # CONFIG_VIRTIO_BLK is not set # CONFIG_VIRTIO_NET is not set # CONFIG_VIRTIO_CONSOLE is not set # CONFIG_HW_RANDOM_VIRTIO is not set
Delete this line from the same file (we want to set a value and it could be confusing otherwise):
# CONFIG_VIRTIO_PCI is not set
Generate spec files and config files:
make make -f Makefile.config
This generates config files with names in the format kernel-xxx.config.
Patch the kernel:
./scripts/install-git-hooks ./scripts/sequence-patch.sh --quilt
Copy kernel config file into the source tree:
cp kernel-netbook.config tmp/linux-2.6.35-master/.config
Build a kernel RPM package (takes a long time):
cd tmp/linux-2.6.35-master make oldconfig (at each prompt, accept the default) make rpm-pkg
The resulting package is in /root/rpmbuild/RPMS/i386/kernel-<kernel version and architecture>.rpm.
Copy this to the QEMU image over ssh or equivalent, for example:
scp -P 6666 /root/rpmbuild/RPMS/i386/kernel-2.6.35.3+-1.i386.rpm root@127.0.0.1:/root/
Get a root prompt in the QEMU image (either by booting into single user mode or logging in via ssh) and install the RPM:
rpm -ivh /root/kernel-2.6.35.3+-1.i386.rpm
Build and install the new initrd (a RAM disk image) for the kernel and modify the boot loader:
new-kernel-pkg --mkinitrd --install --make-default --depmod 2.6.35.3+
(replace 2.6.35.3+ with the version for your new kernel)
Next time you boot the image, it should default to using the new kernel with the virtiogl module.