qemu configuration [was: netdemo echoServer issue [was: Re: listen/select and then accept pattern not working?]]

Keith Robertson kjrobert at alumni.uwaterloo.ca
Mon Jan 17 17:45:38 UTC 2005

Joel Sherrill <joel at OARcorp.com> wrote:
> I would like to get your RTEMS network configuration for qemu. I haven't
> had a chance to play enough to get this working and am always willing
> to take a handout :)

Hi Joel,

Hopefully I'm not stepping on Karel's toes here.  I've spent sometime 
trying to figure out the minimum configuration that gets everything 
going on qemu.  I'm aiming to get a development environment with eclipse 
working so those who are not so big on the command line can have an 
environment that they like.  Some of this material has been gleaned from 
Lars Munch's post a while back: 

To try and make this as useful as possible for those new to rtems and 
googling for answers, I've laid this out in a step-by-step format.

Here's the steps that worked for me:

1) configure/make/make install rtems for i386/pc386.  The following 
configure line was appropriate for me:
../rtems-4.6.2/configure --enable-posix --enable-networking 
--enable-rdbg --enable-cxx --enable-rtemsbsp="pc386" --target=i386-rtems 

2) download qemu from: http://fabrice.bellard.free.fr/qemu/  I'm using 
version 0.6.1.  I downloaded and used the source as I wanted to ensure 
gdbstub was enabled.
2a) configure with:
$cd <qemu source dir>
$./configure --target-list="i386-softmmu" --prefix=/opt/qemu --gdbstub=yes
$make install

Note that --gdbstub=yes is not mentioned in ./configure --help and 
doesn't show up in the list printed to stdout of enabled features.  To 
ensure it's on, look in config-host.mak in the qemu build directory.

3) Build the example programs.

4) Run the following commands to create a grub boot iso
$cd ~
$mkdir -p iso/boot/grub
$cp /usr/share/grub/stage2_eltorito iso/boot/grub
<copy all the example executables you want to run to ~/iso> For instance:
$cp ~/examples/hello/o-optimize/hello.exe ~/iso
$mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 
-boot-info-table -o grub.iso iso

5) Run qemu with your iso image -- note that no other configuration 
files are required.  This should do it for the basic test programs.
$/opt/qemu/bin/qemu -cdrom grub.iso

6) qemu boots grub at which point you type:
 > kernel (cd)/hello.exe
 > boot

That's the basic setup.

Now for networking:

7) Download the network-demos-4.6.2.tar.gz source package.

8) Edit network-demos-4.6.2/networkconfig.h:
a) Ensure that the defines RTEMS_BSP_NETWORK_DRIVER_NAME and 
RTEMS_BSP_NETWORK_DRIVER_ATTACH are "ne1" and rtems_ne_driver_attach 
respectively.  (Probably the best way to do this is from the 
$RTEMS_MAKEFILE_PATH/lib/include/bsp.h and set the defaults to be the 
ne2000 driver -- I suppose ideally one could create a new bsp that was 
almost the same as the pc386 but had the ne2000 driver as the default.)

b) ensure RTEMS_USE_BOOTP is defined -- qemu has a built in dhcp server.
c) ensure RTEMS_SET_ETHERNET_ADDRESS is not defined.
d) use the following rtems_bsdnet_ifconfig initialisation:

  * Default network interface
static struct rtems_bsdnet_ifconfig netdriver_config = {
     RTEMS_BSP_NETWORK_DRIVER_NAME,      /* name */
     RTEMS_BSP_NETWORK_DRIVER_ATTACH,    /* attach function */

     &loopback_config,       /* link to next interface */
     NULL,               /* No more interfaces */

#if (defined (RTEMS_USE_BOOTP))
     NULL,               /* BOOTP supplies IP address */
     NULL,               /* BOOTP supplies IP net mask */
     NULL,       /* IP address */
     NULL",      /* IP net mask */
#endif /* !RTEMS_USE_BOOTP */

     ethernet_address,               /* Ethernet hardware address */
     NULL,                           /* Driver supplies hardware address */
     0,		/*ignore_broadcast*/
     0,		/*mtu */
     0,		/*rbuf_count*/
     0,		/*xbuf_count*/
     0x300,	/*port*/
     9,		/*irno*/
     0           /*bpar*/ 


Note that only the last 7 lines of this have changed from the defaults. 
  This is because the ne2000 driver defaults to looking for card at irq 
5.    If one were to create a qemu bsp, this is another thing I'd change.

9) Set DATA_SINK_HOST in test.c to a machine that accepts connections on 
the discard port.

10) compile netdemo.exe and copy it into your iso directory.

11) remake the iso image as described in 4.

12) run qemu:
$/opt/qemu/bin/qemu -cdrom grub.iso -user-net -isa -redir tcp:24742::24742

-user-net adds the user mode networking.  Note that ICMP requests won't 
work in user mode networking so you'll be unable to ping or be pinged. 
See Lars' post for info on how to setup tun/tap networking.
-redir allows another machine to telnet to the echo server.
- telnet <host machine -- the one running qemu> 24742 should be 
forwarded to the echo server running in rtems.
-isa removes pci simulation and allows the ne2000 card to be found (not 
sure why this is required yet).

13) grub should have booted and then run:

 > kernel (cd)/netdemo.exe
 > boot

14) You should get the standard output from netdemo.exe.  Specifically:

the guest ip address will be
the guest's gateway (qemu on your host) will be
the guest's dns server (qemu's dns relay) will be
subnet mask is set to
mac address is set to: 52:54:0:12:34:56

These are all the defaults from qemu's built-in dhcp server.  If you're 
lucky this doesn't clash with your network and you should be off to the 
races.  As this hasn't been a problem for me, I haven't had to go 
looking for how to convince qemu's dhcp server to use different 
defaults.  I presume it is possible.  If worst comes to worst, you can 
always specify these directly in networkconfig.h

Hope this is helpful.  Please correct any mistakes/typos.



More information about the users mailing list