QEMU emulation
Hans Bezemer
thebeez at xs4all.nl
Sat Sep 15 18:19:37 EDT 2012
On Saturday 15 September 2012, you wrote:
Hi Delbert!
> Looks like you have something quite useful already. I looked
> at using QEMU shortly after my NN arrived about two years
> ago. Looked too complicated for potential return. For
> someone who claims to not "know" much about the process,
> you have done very well.
I have been playing to get the Raspberry Pi going and wonderdd whether I could
apply the same thing to the NanoNote. I must admit I never thought it would
work and the first steps indicated that much. Think about it: taking a kernel
from a random Debian MIPS Malta distribution and use it to boot a rootfs that
was never made to be bootstrapped this way.
But after I got past "init" (note I used "init=/bin/sh" the first few times
just to get a prompt) I started to solve problem by problem - simply by
googling it and applying the solution. Then I started to reinstate things,
first "init", then "rcS", etc. IOW, one simple step at the time.
Note I had to fsck.ext2 the thing after each crash - which I did with a
fast-booting Debian ARM distribution I'd used to develop the RasPi emulation.
For comparison I kept an untouched rootfs, cleanly untarred. After a certain
moment I started to add functionality, mostly networking stuff. As others
have said: I could most likely do that from the prompt of my host, but it's
awkward and error prone. Better safe than sorry.
After having SSH things became much easier, because I could bring the thing
down in a controlled way when it crashed - very handy while testing the right
setting for MPLayer ;-)
There are only a handful of things that don't work: two games, the "listener"
stuff - most are related to missing sound, the rest with the non-working file
selection program. You could fix that with a ported "dialog" and a bit of
shell scripting.
Note that two years ago this would probably not have been possible. QEMU has
developed quite a bit lately, even with the recent v1.2.0. E.g. I never got
Coherent to work - now it does.
> Right now I'm immersed in several other software development
> tasks but look forward to a summary of the steps you took
> to get where you are now.
My last steps have been to erradicate the "setfont2" entries in
the /usr/share/gmenu2x entries. I think most of the rest is pretty much
condensed in this file:
NOTE THAT THE FILE BELOW HAS NOT BEEN PROPERLY TESTED YET!
*** USE AT YOUR OWN RISK ***
---8<---
#!/bin/sh
set -x
PROGNAME=`basename $0`
ROOTDIR=$1
if [ -z $ROOTDIR ]; then
echo "Cannot apply changes to your root directory!"
exit 1
fi
# Make devices.
mkdir /dev/pts
mknod -m 0666 "$ROOTDIR/ptmx" c 5 2
mknod -m 0600 "$ROOTDIR/dev/console" c 5 1
mknod -m 0660 "$ROOTDIR/dev/full" c 1 7
mknod -m 0640 "$ROOTDIR/dev/kmem" c 1 2
mknod -m 0660 "$ROOTDIR/dev/loop0" b 7 0
mknod -m 0640 "$ROOTDIR/dev/mem" c 1 1
mknod -m 0666 "$ROOTDIR/dev/null" c 1 3
mknod -m 0640 "$ROOTDIR/dev/port" c 1 4
mknod -m 0666 "$ROOTDIR/dev/random" c 1 8
mknod -m 0660 "$ROOTDIR/dev/tty" c 5 0
mknod -m 0666 "$ROOTDIR/dev/urandom" c 1 9
mknod -m 0666 "$ROOTDIR/dev/zero" c 1 5
mknod -m 0666 "$ROOTDIR/dev/fb0" c 29 0
mknod -m 0666 "$ROOTDIR/dev/sda" b 8 0
mknod -m 0666 "$ROOTDIR/dev/sda1" b 8 1
ln -s /proc/kcore "$ROOTDIR/dev/core"
ln -s /dev/ram1 "$ROOTDIR/dev/ram"
ln -s /dev/sda1 "$ROOTDIR/dev/root"
for N in `seq 0 5` ; do
mknod -m 0660 "$ROOTDIR/dev/tty$N" c 4 $N
done
for N in `seq 0 15` ; do
mknod -m 0660 "$ROOTDIR/dev/ram$N" b 1 $N
done
mkdir "$ROOTDIR/sys/kernel"
mkdir "$ROOTDIR/sys/kernel/debug"
cat << 'EOF' > "$ROOTDIR/etc/inittab"
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
::askfirst:/bin/sh /usr/bin/gmenu2x
EOF
cat << 'EOF' > "$ROOTDIR/etc/init.d/qemu"
#!/bin/sh
mount -t proc none /proc
mount -t devpts devpts /dev/pts
if [ -f /var/run/dbus.pid ]; then
rm /var/run/dbus.pid
fi
setfont /usr/share/kbd/consolefonts/kernel-6x11-font
EOF
cd "$ROOTDIR/etc/rc.d"
ln -s ../init.d/qemu S09qemu
rm K01ben-nanonote
rm S01ben-nanonote
rm S93triggerhappy
cd -
cat << 'EOF' > "$ROOTDIR/etc/config/network"
# Copyright (C) 2006 OpenWrt.org
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option proto static
option ipaddr 192.168.254.101
option netmask 255.255.255.0
option gateway 192.168.254.100
option dns "8.8.8.8 8.8.4.4"
option hostname BenNanoNote
EOF
cat << 'EOF' > "$ROOTDIR/etc/uci-defaults/01-optimization-for-ben-nanonote"
#!/bin/sh
# no need in NanoNote
/etc/init.d/atd disable
/etc/init.d/led disable
/etc/init.d/telnet disable
# generate fontconfig cache
/usr/bin/fc-cache
exit 0
EOF
cat << 'EOF' > "$ROOTDIR/etc/uci-defaults/99-set-time"
#!/bin/sh
date --set 201207072133
EOF
cat << EOF > "$ROODIR/usr/bin/backgammon.sh"
#!/bin/sh
setfont /usr/share/kbd/consolefonts/kernel-6x11-font
exec /usr/bin/backgammon
EOF
---8<---
> An acid test of the system would be to compile the OpenWRT
> kernel under the system and get it running:) May not return
> the effort but would be an interesting challenge.
A better kernel, geared to the NN would be best, I think. E.g. with an
embedded es1370, ac97 (which is closest to the NN) or Intel sound driver
(hda). I'm sure someone here can make one. I'm not too much into kernel
compilation. Never did it, don't know what QEMU requires in that respect.
> Thanks for your work and enthusiasm--I can sense it in
> your E-mails!
Well, it was fun to do. And with my NN misbehaving I needed a replacement to
test my 4tH compiler. I've compiled it in the blind for the last few releases
and I don't like to release stuff I can't test. For the record: I've tested
the latest 4tH BNN release and it worked out of the box, so I've worried for
nothing.
Personally, I feel that every H/W manufacturer should release and maintain
something like this. Yes, I know: "It's only $25, $35, $99" or whatever your
price is, but developers (especially FOSS) won't buy a device for every darn
port they want to support.
.. and of course, I have a weak spot for my little thingy. It felt good to see
the "root at BenNanoNote" prompt again ;-)
Hans Bezemer
--
Absolutely no trees were killed to produce this sig. Well, OK, we had to tie
one up and torture it. That's it.
Visit our website! http://thebeez.home.xs4all.nl/4tH/
*** Home of the 4tH compiler! ***
More information about the discussion
mailing list