<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>OpenWRT-UML-Netkit</title><revhistory><revision><revnumber>12</revnumber><date>2013-04-12 14:24:02</date><authorinitials>151.100.102.121</authorinitials><revremark>ok, ok, correzione..maledetta trunk traditrice! [Immanuel]</revremark></revision><revision><revnumber>11</revnumber><date>2013-04-12 13:05:41</date><authorinitials>151.100.102.121</authorinitials></revision><revision><revnumber>10</revnumber><date>2013-04-12 12:58:03</date><authorinitials>151.100.102.121</authorinitials></revision><revision><revnumber>9</revnumber><date>2013-04-12 12:55:15</date><authorinitials>151.100.102.121</authorinitials><revremark>Istruzioni aggiornate, le precendenti non funzionavano (almeno per me) con le ultime versioni di OpenWRT [Immanuel}</revremark></revision><revision><revnumber>8</revnumber><date>2010-02-11 15:21:10</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>7</revnumber><date>2009-12-28 19:00:40</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>6</revnumber><date>2009-12-28 17:25:04</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>5</revnumber><date>2009-12-10 15:07:45</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>4</revnumber><date>2009-12-10 01:03:37</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>3</revnumber><date>2009-12-10 00:39:07</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>2</revnumber><date>2009-12-09 18:07:50</date><authorinitials>ZioPRoTo</authorinitials></revision><revision><revnumber>1</revnumber><date>2009-12-09 18:04:35</date><authorinitials>ZioPRoTo</authorinitials></revision></revhistory></articleinfo><section><title>Notes on OpenWRT UML + Netkit</title><para>The goal of this guide is to use Netkit with OpenWRT hosts in the emulated environment. </para><para><ulink url="http://wiki.netkit.org/index.php/Main_Page"/> </para><para>UML binaries are built with the host toolchain and are meant to run on the host they were built on. </para><para>We used a Gentoo machine amd64 profile (64bit processor) </para><section><title>Create OpenWRT UML images</title><para>Download and compile OpenWRT for the UML target (tested at 9/12/2009 revision 18717) </para><screen><![CDATA[svn co svn://svn.openwrt.org/openwrt/trunk/
cd trunk
make menuconfig]]></screen><para>select the UML target and compile </para><itemizedlist><listitem><para>Make sure you disabled kmod-mac8011-hwsim in your OpenWRT config, if you have it enables it will make Netkit act weird. </para></listitem><listitem><para>Make sure the kernel configuration has support for the ext2 file system ! </para></listitem></itemizedlist><para>we are using the following CHOST x86_64-pc-linux-gnu-4.3.4 </para><para>we had a problem with some script looking for a lib64 dir that was not existing, solved like this: </para><screen><![CDATA[cd $trunk_dir$/staging_dir/toolchain-x86_64_gcc-4.1.2_uClibc-0.9.30.1/
ln -s lib lib64]]></screen><para>if the firmware compiles you have the binaries in <code>$trunk_dir$/bin/uml</code> </para></section><section><title>Test the UML binary</title><para>To test if your UML binary boots just use the guide from zoobab <ulink url="http://www.zoobab.com/openwrt-and-user-mode-linux"/> </para></section><section><title>Integrate in Netkit</title><para>Launch in Netkit like this: </para><screen><![CDATA[cd bin/uml
vstart openwrt --eth0=0 --con0=xterm --con1=xterm --verbose -m openwrt-uml-ext2.img -k ./openwrt-uml-vmlinux]]></screen><para>also you may need extra Kernel command line options: </para><screen><![CDATA[--append=root=98:0 --append=init=/etc/preinit]]></screen><para>You will have a OpenWRT machine launched within Netkit, but only the second terminal is properly working for now, adjust inittab (see later) </para><section><title>Remount Read Write</title><para>To remount the filesystem readwrite </para><screen><![CDATA[mount --remount -o rw /dev/root /]]></screen></section><section><title>Adjust inittab</title><para>Original <code>/etc/inittab</code> in OpenWRT looks like this: </para><screen><![CDATA[root@OpenWrt:/# cat /etc/init
/etc/init.d/  /etc/inittab
root@OpenWrt:/# cat /etc/inittab 
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
tts/0::askfirst:/bin/ash --login
tty1::askfirst:/bin/ash --login
root@OpenWrt:/# ]]></screen><para>modify like this: </para><screen><![CDATA[root@OpenWrt:/# cat /etc/inittab 
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
tty0::askfirst:/bin/ash --login
tty1::askfirst:/bin/ash --login
root@OpenWrt:/#]]></screen></section><section><title>Everything in a patch</title><screen><![CDATA[saverio@nordkapp ~/SORGENTI/openwrt-trunk-UML $ svn diff
Index: package/base-files/files/etc/inittab
===================================================================
--- package/base-files/files/etc/inittab        (revisione 18727)
+++ package/base-files/files/etc/inittab        (copia locale)
@@ -1,5 +1,4 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K stop
-tts/0::askfirst:/bin/ash --login
-ttyS0::askfirst:/bin/ash --login
+tty0::askfirst:/bin/ash --login
 tty1::askfirst:/bin/ash --login
Index: package/base-files/files/etc/config/network
===================================================================
--- package/base-files/files/etc/config/network (revisione 18727)
+++ package/base-files/files/etc/config/network (copia locale)
@@ -8,7 +8,7 @@
 
 config interface lan
        option ifname   eth0
-       option type     bridge
+       #option type    bridge
        option proto    static
        option ipaddr   192.168.1.1
        option netmask  255.255.255.0
saverio@nordkapp ~/SORGENTI/openwrt-trunk-UML $]]></screen></section><section><title>Notes on netkit labs</title><screen><![CDATA[lstart --verbose -o --append=root=98:0 -o --append=init=/etc/preinit]]></screen></section></section></section></article>