Using QEMU with MokoMakefile

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (spellcheck)
(Using tested and recommended images: removing link to snapshot review)
 
(24 intermediate revisions by 16 users not shown)
Line 1: Line 1:
[[MokoMakefile]] has support for automatically building, flashing, and running [[OpenMoko under QEMU]] using qemu-neo1973, a fork of qemu which adds simulation of almost all [[Neo1973]] devices  in order allow testing OpenMoko images in a virtual environment.
+
[[MokoMakefile]] has support for automatically building, flashing, and running [[Openmoko under QEMU]] using qemu-neo1973, a fork of qemu which adds simulation of almost all [[Neo1973]] devices  in order allow testing Openmoko images in a virtual environment.
  
For this, it's not required to download and run a complete OpenMoko build (which takes several hours to even days and needs lots of disk space and RAM), because if you only need to test pre-compiled images, it is enough to build qemu-neo1973 and to set it up to run these images. This is what this article deals with and to describe how MokoMakefile makes this easy.
+
For this, it's not required to download and run a complete Openmoko build (which takes several hours to even days and needs lots of disk space and RAM), because if you only need to test pre-compiled images, it is enough to build qemu-neo1973 and to set it up to run these images. This is what this article deals with and to describe how MokoMakefile makes this easy.
  
Note: The [[Talk:MokoMakefile|talk page of MokoMakefile]] may also contain some valuable hints regarding compiling and using QEMU for [[OpenMoko]], including distribution specific issues and workarounds.
+
Note: The [[Talk:MokoMakefile|talk page of MokoMakefile]] may also contain some valuable hints regarding compiling and using QEMU for Openmoko, including distribution specific issues and workarounds.
  
 
== Build requirements ==
 
== Build requirements ==
Line 13: Line 13:
  
 
=== Debian 4.0 and Ubuntu 7.04 ===
 
=== Debian 4.0 and Ubuntu 7.04 ===
   sudo apt-get install gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools
+
   sudo apt-get install git git-core gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools subversion zlib1g-dev
  
 
=== Ubuntu 7.10 ===
 
=== Ubuntu 7.10 ===
   sudo apt-get install gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools subversion  
+
   sudo apt-get install git git-core gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools subversion  
 
   sudo dpkg-reconfigure dash (choose NO upon question about installing /bin/sh )
 
   sudo dpkg-reconfigure dash (choose NO upon question about installing /bin/sh )
When using Ubuntu you really want to have a look here: [http://wiki.openmoko.org/wiki/Automatic_emulation_in_Ubuntu]
+
When using Ubuntu you really want to [[Automatic_emulation_in_Ubuntu|have a look here]].
  
 
=== SUSE Linux / openSUSE ===
 
=== SUSE Linux / openSUSE ===
Line 25: Line 25:
 
  rpm -Uhv cpp33-*.rpm gcc33-*.rpm
 
  rpm -Uhv cpp33-*.rpm gcc33-*.rpm
  
Install the packages <code>lynx</code>, <code>netbpm</code>, <code>SDL-devel</code> and <code>dosfstools</code> e.g. using <code>yast</code>, <code>apt</code>, or <code>smart</code>.
+
Install the packages <code>lynx</code>, <code>netpbm</code>, <code>SDL-devel</code> and <code>dosfstools</code> e.g. using <code>yast</code>, <code>apt</code>, or <code>smart</code>.
  
On 10.1 and 10.2, apply the [[Talk:MokoMakefile#QEMU_build_fails_to_compile_USB_code|workaround for qemu-neu1973 USB compilation]].
+
On 10.1 and 10.2, apply the [[Talk:MokoMakefile#QEMU_build_fails_to_compile_USB_code|workaround for qemu-neo1973 USB compilation]].
 +
 
 +
=== Gentoo ===
 +
Gentoo will usually have some version of gcc-3 installed by default.  You don't need to use gcc-config to switch the default compiler to gcc-3 - Qemu should find there right version if it's installed.
 +
 
 +
GCC 3.4 is known to be broken on 32-bit Gentoo.  If your 32-bit i386 system has a 3.4 GCC installed from portage you will need to downgrade to 3.3.6.(Note: GCC 3.3 is currently broken and masked in Gentoo, consider disabling QEMU if you are running gentoo)
 +
 
 +
Some Gentoo users who have multiple GCC versions installed have had to modify the Makefile (by adding --cc=gcc-3.4.6 to the qemu-configure call, after --target-list=arm-softmmu) otherwise the compilation fails during compilation of softmmu_template.h see [http://lists.openmoko.org/pipermail/community/2007-July/008416.html this link] for more details.
 +
 
 +
Gentoo users will need to install sys-fs/dosfstools for the mkdosfs command then create a link in /sbin:
 +
ln -s /usr/sbin/mkdosfs /sbin/mkdosfs.
 +
 
 +
=== Fedora 9 ===
 +
Found the following install commands on some other webpage, and they work fine:
 +
<pre>
 +
yum install monotone git-core git-svn git-email git-cvs git-arch gitk python-dev ccache m4 sed bison make cvs gawk libc6-dev g++ subversion sharutils docbook openjade quilt libmpfr-dev libpcre3-dev texinfo texi2html libboost-date-time-dev libboost-filesystem-dev libboost-regex-dev libboost-test-dev libboost-dev zlib1g-dev build-essential dh-make debhelper devscripts gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools help2man python-psyco lynx
 +
yum install monotone git-core cogito python-dev ccache m4 sed bison make cvs gawk libc6-dev g++ subversion sharutils docbook openjade quilt libmpfr-dev libpcre3-dev texinfo texi2html libboost-date-time-dev libboost-filesystem-dev libboost-regex-dev libboost-test-dev libboost-dev zlib1g-dev build-essential dh-make debhelper devscripts gcc-3.4 netpbm libsdl1.2-dev dosfstools help2man python-psyco lynx
 +
</pre>
 +
<small>(If you have trouble with cut-and-paste of the lines above, go to edit mode and copy from there)</small>
 +
 
 +
Not all packages exist, but you can (or at least I could) safely ignore this.
 +
 
 +
You also need to install gcc3.x, which was neither found by yum nor by rpmseek/rpmfind. But Fedora 7 has the rpm, so go to any site which archives Fedora packages (e.g. http://sunsite.rwth-aachen.de) and grab e.g. <tt>compat-gcc-34-3.4.6-7.x86_64.rpm</tt> (adapt to your architecture, any 3.x.y version should do). Then do a <tt>yum localinstall</tt>.
  
 
== Compilation and use ==
 
== Compilation and use ==
Line 36: Line 58:
 
   wget http://www.rwhitby.net/files/openmoko/Makefile
 
   wget http://www.rwhitby.net/files/openmoko/Makefile
  
'''make qemu'''” will build qemu-neo1973, download the latest official OpenMoko images, flash the images into the virtual NAND flash, create an empty virtual SD card, and run the emulator (you still need to install the makefile as mentioned above, however).
+
If that doesn't work, try
  
* <code>'''make run-qemu'''</code> - restarts qemu with the currently flashed OpenMoko images and current virtual SD card.
+
  wget http://svn.projects.openmoko.org/svnroot/mokomakefile/trunk/Makefile
* <code>'''make run-qemu-snapshot'''</code> - does the same but starts qemu with -snapshot which causes QEMU to write all changes to temporary files instead of flash and disk image files.<BR>This has the benefit that the virtual neu1973 is not changed, but that also all changes <code>make run-qemu-snapshot</code> in parallel without creating incoherent flash and SD card state as it would occur when one (or even more) instances would update disk or flash images while other instances do not expect this to happen underneath. You can however force the write back by pressing <code>C-a s</code> in the QEMU window which may be useful to update the flash and disk images in the last qemu instance which is running to preserve the changes, after all other instances are terminated.
+
 
 +
 
 +
“'''make qemu'''” will build qemu-neo1973, download the latest official Openmoko images, flash the images into the virtual NAND flash, create an empty virtual SD card, and run the emulator (you still need to install the makefile as mentioned above, however).
 +
 
 +
* <code>'''make run-qemu'''</code> - restarts qemu with the currently flashed Openmoko images and current virtual SD card.
 +
* <code>'''make run-qemu-snapshot'''</code> - does the same but starts qemu with -snapshot which causes QEMU to write all changes to temporary files instead of flash and disk image files.<BR>This is beneficial in that the virtual Neo1973 is not changed.  Also all changes that <code>make run-qemu-snapshot</code> creates occur in parallel.  This allows you to run multiple instances without creating incoherent flash and SD card state. You can, however, force the write back by pressing <code>C-a s</code> in the QEMU window. This may be useful to update the flash and disk images in the last qemu instance that is running to preserve the changes.
  
 
You may also use:
 
You may also use:
Line 45: Line 72:
 
* <code>'''make flash-qemu-official'''</code> - to flash those images
 
* <code>'''make flash-qemu-official'''</code> - to flash those images
 
* <code>'''make flash-qemu-local'''</code> - to flash your latest locally built images, which can then be followed by
 
* <code>'''make flash-qemu-local'''</code> - to flash your latest locally built images, which can then be followed by
* <code>'''make qemu-copy-package-''foo'''''</code> - copies <code>''foo''.ipk</code> to the virtual SD card,  which allows you to use <code>ipkg install /media/mmcblk0/''file''</code> inside the running OpenMoko to install the package.
+
* <code>'''make qemu-copy-package-''foo'''''</code> - copies <code>''foo''.ipk</code> to the virtual SD card,  which allows you to use <code>ipkg install /media/mmcblk0/''file''</code> inside the running Openmoko to install the package.
  
 
If you want to calibrate your screen,
 
If you want to calibrate your screen,
 
look at [http://onlinedev.blogspot.com/2007/08/calibrating-openmoko-v20072.html]
 
look at [http://onlinedev.blogspot.com/2007/08/calibrating-openmoko-v20072.html]
  
For detailed information on advanced usage of qemu-neo1973 see also: ''[[OpenMoko under QEMU]]''
+
For detailed information on advanced usage of qemu-neo1973 see also: ''[[Openmoko under QEMU]]''
 +
 
 +
If you get an error while flashing, see [http://lists.openmoko.org/pipermail/community/2008-March/014356.html]
 +
 
 +
== Using tested and recommended images ==
 +
 
 +
The process described above will download the latest daily build, which may be broken or non-working in many cases. If you delete the images downloaded into the <code>'''images/openmoko'''</code> directory, you can add another set of the 3 files there and flash them into QEmu by <code>'''make flash-qemu-official'''</code>.
 +
 
 +
To be able to flash FSO images you must change the file search pattern in '''build/qemu/openmoko/env''' to match the:
 +
  rootfs_wildcard="Open?oko-*image*-om-gta01.rootfs.jffs2"
 +
Or change the downloaded images filename to match '''Open?oko-openmoko-*image*-om-gta01.rootfs.jffs2'''.
 +
 
 +
[[Category:Emulation]]

Latest revision as of 14:14, 9 December 2009

MokoMakefile has support for automatically building, flashing, and running Openmoko under QEMU using qemu-neo1973, a fork of qemu which adds simulation of almost all Neo1973 devices in order allow testing Openmoko images in a virtual environment.

For this, it's not required to download and run a complete Openmoko build (which takes several hours to even days and needs lots of disk space and RAM), because if you only need to test pre-compiled images, it is enough to build qemu-neo1973 and to set it up to run these images. This is what this article deals with and to describe how MokoMakefile makes this easy.

Note: The talk page of MokoMakefile may also contain some valuable hints regarding compiling and using QEMU for Openmoko, including distribution specific issues and workarounds.

Contents

[edit] Build requirements

  • gcc 3.4 or 3.3: You need gcc-3.x for building qemu. If you have no precompiled gcc-3.x packages, you need to compile it. [1]
  • lynx
  • netpbm
  • SDL-devel
  • mkdosfs (from dosfstools)

[edit] Debian 4.0 and Ubuntu 7.04

 sudo apt-get install git git-core gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools subversion zlib1g-dev

[edit] Ubuntu 7.10

 sudo apt-get install git git-core gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools subversion 
 sudo dpkg-reconfigure dash (choose NO upon question about installing /bin/sh )

When using Ubuntu you really want to have a look here.

[edit] SUSE Linux / openSUSE

get gcc33 and cpp33 for SUSE Linux 10.1, openSUSE 10.2 and openSUSE Factory and install both rpms at once using:

rpm -Uhv cpp33-*.rpm gcc33-*.rpm

Install the packages lynx, netpbm, SDL-devel and dosfstools e.g. using yast, apt, or smart.

On 10.1 and 10.2, apply the workaround for qemu-neo1973 USB compilation.

[edit] Gentoo

Gentoo will usually have some version of gcc-3 installed by default. You don't need to use gcc-config to switch the default compiler to gcc-3 - Qemu should find there right version if it's installed.

GCC 3.4 is known to be broken on 32-bit Gentoo. If your 32-bit i386 system has a 3.4 GCC installed from portage you will need to downgrade to 3.3.6.(Note: GCC 3.3 is currently broken and masked in Gentoo, consider disabling QEMU if you are running gentoo)

Some Gentoo users who have multiple GCC versions installed have had to modify the Makefile (by adding --cc=gcc-3.4.6 to the qemu-configure call, after --target-list=arm-softmmu) otherwise the compilation fails during compilation of softmmu_template.h see this link for more details.

Gentoo users will need to install sys-fs/dosfstools for the mkdosfs command then create a link in /sbin: ln -s /usr/sbin/mkdosfs /sbin/mkdosfs.

[edit] Fedora 9

Found the following install commands on some other webpage, and they work fine:

yum install monotone git-core git-svn git-email git-cvs git-arch gitk python-dev ccache m4 sed bison make cvs gawk libc6-dev g++ subversion sharutils docbook openjade quilt libmpfr-dev libpcre3-dev texinfo texi2html libboost-date-time-dev libboost-filesystem-dev libboost-regex-dev libboost-test-dev libboost-dev zlib1g-dev build-essential dh-make debhelper devscripts gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools help2man python-psyco lynx
yum install monotone git-core cogito python-dev ccache m4 sed bison make cvs gawk libc6-dev g++ subversion sharutils docbook openjade quilt libmpfr-dev libpcre3-dev texinfo texi2html libboost-date-time-dev libboost-filesystem-dev libboost-regex-dev libboost-test-dev libboost-dev zlib1g-dev build-essential dh-make debhelper devscripts gcc-3.4 netpbm libsdl1.2-dev dosfstools help2man python-psyco lynx

(If you have trouble with cut-and-paste of the lines above, go to edit mode and copy from there)

Not all packages exist, but you can (or at least I could) safely ignore this.

You also need to install gcc3.x, which was neither found by yum nor by rpmseek/rpmfind. But Fedora 7 has the rpm, so go to any site which archives Fedora packages (e.g. http://sunsite.rwth-aachen.de) and grab e.g. compat-gcc-34-3.4.6-7.x86_64.rpm (adapt to your architecture, any 3.x.y version should do). Then do a yum localinstall.

[edit] Compilation and use

Create a new directory and download the Moko Makefile to it:

 mkdir openmoko
 cd openmoko
 wget http://www.rwhitby.net/files/openmoko/Makefile

If that doesn't work, try

 wget http://svn.projects.openmoko.org/svnroot/mokomakefile/trunk/Makefile


make qemu” will build qemu-neo1973, download the latest official Openmoko images, flash the images into the virtual NAND flash, create an empty virtual SD card, and run the emulator (you still need to install the makefile as mentioned above, however).

  • make run-qemu - restarts qemu with the currently flashed Openmoko images and current virtual SD card.
  • make run-qemu-snapshot - does the same but starts qemu with -snapshot which causes QEMU to write all changes to temporary files instead of flash and disk image files.
    This is beneficial in that the virtual Neo1973 is not changed. Also all changes that make run-qemu-snapshot creates occur in parallel. This allows you to run multiple instances without creating incoherent flash and SD card state. You can, however, force the write back by pressing C-a s in the QEMU window. This may be useful to update the flash and disk images in the last qemu instance that is running to preserve the changes.

You may also use:

  • make download-images - to download the latest official images
  • make flash-qemu-official - to flash those images
  • make flash-qemu-local - to flash your latest locally built images, which can then be followed by
  • make qemu-copy-package-foo - copies foo.ipk to the virtual SD card, which allows you to use ipkg install /media/mmcblk0/file inside the running Openmoko to install the package.

If you want to calibrate your screen, look at [2]

For detailed information on advanced usage of qemu-neo1973 see also: Openmoko under QEMU

If you get an error while flashing, see [3]

[edit] Using tested and recommended images

The process described above will download the latest daily build, which may be broken or non-working in many cases. If you delete the images downloaded into the images/openmoko directory, you can add another set of the 3 files there and flash them into QEmu by make flash-qemu-official.

To be able to flash FSO images you must change the file search pattern in build/qemu/openmoko/env to match the:

 rootfs_wildcard="Open?oko-*image*-om-gta01.rootfs.jffs2"

Or change the downloaded images filename to match Open?oko-openmoko-*image*-om-gta01.rootfs.jffs2.

Personal tools

MokoMakefile has support for automatically building, flashing, and running OpenMoko under QEMU using qemu-neo1973, a fork of qemu which adds simulation of almost all Neo1973 devices in order allow testing OpenMoko images in a virtual environment.

For this, it's not required to download and run a complete OpenMoko build (which takes several hours to even days and needs lots of disk space and RAM), because if you only need to test pre-compiled images, it is enough to build qemu-neo1973 and to set it up to run these images. This is what this article deals with and to describe how MokoMakefile makes this easy.

Note: The talk page of MokoMakefile may also contain some valuable hints regarding compiling and using QEMU for OpenMoko, including distribution specific issues and workarounds.

Build requirements

  • gcc 3.4 or 3.3: You need gcc-3.x for building qemu. If you have no precompiled gcc-3.x packages, you need to compile it. [1]
  • lynx
  • netpbm
  • SDL-devel
  • mkdosfs (from dosfstools)

Debian 4.0 and Ubuntu 7.04

 sudo apt-get install gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools

Ubuntu 7.10

 sudo apt-get install gcc-3.4 lynx netpbm libsdl1.2-dev dosfstools subversion 
 sudo dpkg-reconfigure dash (choose NO upon question about installing /bin/sh )

When using Ubuntu you really want to have a look here: [2]

SUSE Linux / openSUSE

get gcc33 and cpp33 for SUSE Linux 10.1, openSUSE 10.2 and openSUSE Factory and install both rpms at once using:

rpm -Uhv cpp33-*.rpm gcc33-*.rpm

Install the packages lynx, netbpm, SDL-devel and dosfstools e.g. using yast, apt, or smart.

On 10.1 and 10.2, apply the workaround for qemu-neu1973 USB compilation.

Compilation and use

Create a new directory and download the Moko Makefile to it:

 mkdir openmoko
 cd openmoko
 wget http://www.rwhitby.net/files/openmoko/Makefile

make qemu” will build qemu-neo1973, download the latest official OpenMoko images, flash the images into the virtual NAND flash, create an empty virtual SD card, and run the emulator (you still need to install the makefile as mentioned above, however).

  • make run-qemu - restarts qemu with the currently flashed OpenMoko images and current virtual SD card.
  • make run-qemu-snapshot - does the same but starts qemu with -snapshot which causes QEMU to write all changes to temporary files instead of flash and disk image files.
    This has the benefit that the virtual neu1973 is not changed, but that also all changes make run-qemu-snapshot in parallel without creating incoherent flash and SD card state as it would occur when one (or even more) instances would update disk or flash images while other instances do not expect this to happen underneath. You can however force the write back by pressing C-a s in the QEMU window which may be useful to update the flash and disk images in the last qemu instance which is running to preserve the changes, after all other instances are terminated.

You may also use:

  • make download-images - to download the latest official images
  • make flash-qemu-official - to flash those images
  • make flash-qemu-local - to flash your latest locally built images, which can then be followed by
  • make qemu-copy-package-foo - copies foo.ipk to the virtual SD card, which allows you to use ipkg install /media/mmcblk0/file inside the running OpenMoko to install the package.

If you want to calibrate your screen, look at [3]

For detailed information on advanced usage of qemu-neo1973 see also: OpenMoko under QEMU