This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: eCos, qemu and rtlk8139
On 2009-03-04, Bessemer <bessemer@gmail.com> wrote:
> We are starting the planning for an embedded industrial control
> project using an ARM7 and thinking about using IAR PowerPac as our
> RTOS. However I'd like to consider eCos too. I'm not familiar with
> eCos so I'd like to get a 'feel' for the API first. We don't have any
> hardware yet so I figured a good way would be to emulate an i386 using
> qemu. I see that qemu supports a realtek 8139 and I have been able to
> build redboot with the pc-rtlk8139 target. Redboot starts OK but it
> always says "No network interfaces found."
When you started qemu, did you tell it to emulate an 8139
network controller? The default is some other type (ne2K, I
think).
> Should this work or am I on the wrong track?
It works quite nicely.
Here is the shell script I use to run an eCos elf binary using
qemu. The first one creates a bootable ISO image containing
grub and the eCos app to run. Then it runs qemu using the
StartQemu shell function, with a telnet session attached as
serial port 0. Usage is:
$ ./runit.sh foobar.elf
Qemu will start and an aterm window (you can change "aterm" to
whatever terminal emulator you like) will pop up running a
telnet sessaion connected to the virtual serial port. Initially
you'll see the Grub boot screen. After a second, the eCos app
will be loaded and started by Grub. Once the app is running,
you should be able to ping it at 172.16.0.16 network. [The
script assumes you've configured that static IP address in your
application.]
You'll need a kernel that does tun/tap networking along with
the associated utilities. You'll also need "sudo" configured
so that it allows the calling user to do a couple commands:
modprobe kqemu
ifconfig
tunctl
--------------------------runit.sh-------------------------
#!/bin/bash
#set -x
# a shell script to run in the Qemu PC emulator an eCos
# application that's been built with "Grub" startup mode for the
# pc_rltk8239 target.
#
# The program to be run is $1. It runs Qemu with the no-graphics
# option and with a single serial port connected to a telnet
# server socket.
#
# An instance of the "aterm" X11 terminal emulator is started with
# telnet command to connect to that virtual serial port.
#
# TUN/TAP networking is used to create a point-to-point Ethernet link
# to the virtual machine. The host end is 172.16.0.1, so you should
# configure the eCos build to use a static 172.16.0.x network address.
#
# The script could be modified to bridge the virtual TAP interface
# with a physcial interface if you want to make the virtual machine
# accessible from other hosts. Or you could start a DHCP server on
# the TAP interface so that you don't have to build apps with static
# IP configurations.
# set this to point to your grub el torito stage 2 file
ElToritoStage2=/lib/grub/i386-pc/stage2_eltorito
function StartQemu {
# create a TAP interface belonging to the user
User=$USER
TAP=$(sudo /usr/bin/tunctl -b -u $User)
sudo /sbin/ifconfig $TAP 172.16.0.1 promisc up
# try to load the kqemu module to speed up emulation
sudo /sbin/modprobe kqemu
# start the emulator using the TAP interface we created above
qemu -net nic,model=rtl8139 -net tap,ifname=$TAP,script=no -nographic $*
# remove the TAP interface
sudo /usr/bin/tunctl -d $TAP
}
test -f $ElToritoStage2 || { echo "grub el torito stage 2 file not found"; exit 1; }
test -z "$TEMP" && TEMP=/tmp
# create a bootable ISO image with Grub configured to load the program
ProgPath="$1"
Prog=$(basename "$ProgPath")
Iso=$TEMP/grub-$$.iso
Tree=$TEMP/grub-$$-tree
# we want to end up with an ISO image with this structure:
#
# /
# |-- boot
# | `-- grub
# | |-- menu.lst
# | `-- stage2_eltorito
# `-- eCosApplication
# create the empty directry "tree" (only has the one branch)
mkdir -p $Tree/boot/grub
# copy Grub stage2 file
cp $ElToritoStage2 $Tree/boot/grub
# create Grub configuration file that loads program
cat >$Tree/boot/grub/menu.lst <<EOF
serial --unit=0 --speed=115200
terminal --timeout=2 serial console
default 0
timeout 1
title /$Prog
kernel /$Prog
EOF
# application goes in "root" directory, and stripping it will
# speed up loading
cp $ProgPath $Tree
strip $Tree/$Prog
# create the bootable ISO9660 image
mkisofs -quiet -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -o $Iso $Tree
# done with the tree
rm -rf $Tree
# start a terminal that will telnet to the virtual machine's serial port
(sleep 0.5; aterm -title "eCos Serial 0" -name "eCos Serial 0" -e telnet localhost 9876)&
# start the emulator
StartQemu -boot d -cdrom $Iso -serial telnet:localhost:9876,server
# clean up
rm -rf $Iso
-----------------------------------------------------------
--
Grant Edwards grante Yow! On the road, ZIPPY
at is a pinhead without a
visi.com purpose, but never without
a POINT.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss