Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-commits
Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-commits@g.o
From: "Ned Ludd (solar)" <solar@g.o>
Subject: gentoo commit in xml/htdocs/proj/en/base/embedded/handbook: cross-qemu.xml
Date: Sun, 14 Feb 2010 23:21:49 +0000
solar       10/02/14 23:21:49

  Modified:             cross-qemu.xml
  Log:
  Add initial handbook entry for cross arch qemu-user use

Revision  Changes    Path
1.2                  xml/htdocs/proj/en/base/embedded/handbook/cross-qemu.xml

file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-qemu.xml?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-qemu.xml?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-qemu.xml?r1=1.1&r2=1.2

Index: cross-qemu.xml
===================================================================
RCS file: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-qemu.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cross-qemu.xml	9 Mar 2009 17:48:53 -0000	1.1
+++ cross-qemu.xml	14 Feb 2010 23:21:48 -0000	1.2
@@ -1,7 +1,6 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <!DOCTYPE sections SYSTEM "/dtd/book.dtd">
-
-<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-qemu.xml,v 1.1 2009/03/09 17:48:53 alexxy Exp $ -->
+<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/embedded/handbook/cross-qemu.xml,v 1.2 2010/02/14 23:21:48 solar Exp $ -->
 
 <sections>
 
@@ -9,15 +8,102 @@
 How To compile with QEMU user.
 </abstract>
 
-<version>0.1</version>
-<date>2009-03-09</date>
+<version>0.2</version>
+<date>2010-02-14</date>
 
 <section>
 <title>Usage</title>
 <body>
+
+<p>
+In order to take advantage of qemu-user mode we need to do a few things. First
+we need to merge the main package we are going to need. Note the use of the
+<c>static</c> use flag.
+</p>
+
+<pre caption="Installing qemu-user">
+# <i>USE=static emerge -b1 app-emulation/qemu-user</i>
+</pre>
+
 <p>
+Next we need to build the kernel module <c>binfmt_misc</c>.
+Add this to your kernel <path>.config</path>:
+<c>CONFIG_BINFMT_MISC=m</c> or <c>CONFIG_BINFMT_MISC=y</c>.
+If this module not built already, then the devel host will require a reboot
+after the kernel update and modules_install.
 </p>
+
+<p>
+Mount the <c>binfmt_misc</c> handler if it's not already, then we need to
+register our format with the kernel. 
+</p>
+
+<pre caption="binfmt_misc">
+# <i>[ -d /proc/sys/fs/binfmt_misc ] || modprobe binfmt_misc</i>
+# <i>[ -f /proc/sys/fs/binfmt_misc/register ] || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc</i>
+<comment>(Do not register a handler that matches the host machine)</comment>
+# <i>echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/</i>qemu-wrapper<i>:' > /proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-alpha:' > /proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff\xff:/usr/bin/qemu-sh4:' >/proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sh4eb:' >/proc/sys/fs/binfmt_misc/register</i>
+# <i>echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register</i>
+
+</pre>
+
+<pre caption="Enter/Exit the chroot">
+<comment>(Download your desired stage tarball)</comment>
+# <i>wget http://arch-stageball</i>
+<comment>(Unpack the tarball)</comment>
+# <i>tar -xzvf arch-stageball</i>
+# <i>cd arch-stageball</i>
+<comment>(Install the static qemu-user into the chroot)</comment>
+# <i>ROOT=$PWD/ emerge -K qemu-user</i>
+# <i>mkdir -p usr/portage</i>
+<comment>(Mount the required directories)</comment>
+# <i>mount --bind /usr/portage usr/portage</i>
+# <i>mount --bind /proc proc</i>
+# <i>mount --bind /sys sys</i>
+<comment>(Chroot into the environment)</comment>
+# <i>chroot . /bin/busybox mdev -s</i>
+# <i>chroot . /bin/bash --login</i>
+<comment>(Unmount stuff when not in use)</comment>
+# <i>umount usr/portage</i>
+# <i>umount sys</i>
+# <i>umount proc</i>
+</pre>
+
+<p>
+Sometimes we'll need to pass additional args to QEMU (cpu model), so we'll
+create a wrapper script that'll call QEMU with it.
+</p>
+
+<pre caption="qemu-wrapper">
+#include &lt;stdio.h&gt;
+#include &lt;unistd.h&gt;
+
+int main(int argc, char **argv, char **envp) {
+	char *newargv[argc + 3];
+
+	newargv[0] = argv[0];    
+	newargv[1] = "-cpu";
+	newargv[2] = "<i>cortex-a8</i>";
+   
+	memcpy(&amp;newargv[3], &amp;argv[1], sizeof(*argv) * (argc - 1));    
+	newargv[argc + 2] = NULL;
+	return execve("<i>/usr/bin/qemu-arm</i>", newargv, envp);
+}
+</pre>
+
+<p>
+Compile the wrapper with <c>gcc -static qemu-wrapper.c -o qemu-wrapper</c> and
+copy into the chroot. Notice the first example arm entry in the
+<c>binfmt_misc</c> section uses this method.
+</p>
+
 </body>
 </section>
-
 </sections>





Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
gentoo commit in xml/htdocs/proj/en/base/embedded/handbook: cross-qemu.xml
Next by thread:
gentoo commit in xml/htdocs/proj/en/base/embedded/handbook: cross-qemu.xml
Previous by date:
gentoo-x86 commit in app-accessibility/gnome-mag: gnome-mag-0.16.0.ebuild ChangeLog gnome-mag-0.15.6.ebuild gnome-mag-0.15.7.ebuild gnome-mag-0.15.8.ebuild
Next by date:
gentoo-x86 commit in app-misc/tracker: ChangeLog tracker-0.7.20.ebuild tracker-9999.ebuild tracker-0.7.12.ebuild tracker-0.7.14.ebuild


Updated Jun 26, 2012

Summary: Archive of the gentoo-commits mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.