public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] eCos, qemu and rtlk8139
@ 2009-03-04 17:53 Bessemer
  2009-03-05 10:07 ` [ECOS] " Grant Edwards
  0 siblings, 1 reply; 4+ messages in thread
From: Bessemer @ 2009-03-04 17:53 UTC (permalink / raw)
  To: ecos-discuss

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."
Should this work or am I on the wrong track? I did do a lot of
searching but the closest I got was this:
http://sources.redhat.com/ml/ecos-discuss/2008-03/msg00092.html
which was not replied to at the time.

Thanks for your help,

James.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ECOS]  Re: eCos, qemu and rtlk8139
  2009-03-04 17:53 [ECOS] eCos, qemu and rtlk8139 Bessemer
@ 2009-03-05 10:07 ` Grant Edwards
  2009-03-09 15:46   ` Bessemer
  0 siblings, 1 reply; 4+ messages in thread
From: Grant Edwards @ 2009-03-05 10:07 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Re: eCos, qemu and rtlk8139
  2009-03-05 10:07 ` [ECOS] " Grant Edwards
@ 2009-03-09 15:46   ` Bessemer
  2009-03-09 15:52     ` Grant Edwards
  0 siblings, 1 reply; 4+ messages in thread
From: Bessemer @ 2009-03-09 15:46 UTC (permalink / raw)
  To: ecos-discuss

On Wed, Mar 4, 2009 at 4:06 PM, Grant Edwards <grante@visi.com> wrote:
> It works quite nicely.
Thanks very much for that information; sorry it's taken so long to get
back to you.
I've got it working now (at least, I can ping the qemu internal server
from the redboot prompt) The problem was that I was making changes via
ecosconfig but that wasn't updating the final redboot.bin product
(which I _finally_ realised when I did an ls -l) It seems that
'ecosconfig tree && make clean && make' is not sufficient to force a
complete rebuild. Once I made a fresh build directory and started with
the correct pc_rltk8139 target it was fine.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ECOS]  Re: eCos, qemu and rtlk8139
  2009-03-09 15:46   ` Bessemer
@ 2009-03-09 15:52     ` Grant Edwards
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Edwards @ 2009-03-09 15:52 UTC (permalink / raw)
  To: ecos-discuss

On 2009-03-09, Bessemer <bessemer@gmail.com> wrote:

> I've got it working now (at least, I can ping the qemu
> internal server from the redboot prompt) The problem was that
> I was making changes via ecosconfig but that wasn't updating
> the final redboot.bin product (which I _finally_ realised when
> I did an ls -l) It seems that 'ecosconfig tree && make clean
> && make' is not sufficient to force a complete rebuild.

I think we've all tripped over that one.  I usually use a shell
script to rebuild after I've changed configuration:

------------------------------buildecos.sh------------------------------
#!/bin/bash
set -x
export ECOS_REPOSITORY=$PWD/ecos-src
rm -rf ecos-build
mkdir ecos-build
cd ecos-build
../newTree.sh && make

-----------------------------------8<-----------------------------------


-------------------------------newTree.sh-------------------------------
#!/bin/bash

ecosconfig new <whatever>
ecosconfig remove CYGPKG_IO_SERIAL 
ecosconfig add CYGPKG_IO_NSERIAL
ecosconfig add CYGPKG_IO_WATCHDOG CYGPKG_DEVICES_WATCHDOG_DALLAS_DS1501

cat >.tmp$$.cdl <<EOF
cdl_option CYGPKG_IO_NFILE {user_value 256}
cdl_option CYGNUM_FILEIO_NFILE {user_value 256}
cdl_option CYGNUM_FILEIO_NFD {user_value 256}
cdl_option CYGPKG_NET_MAXSOCKETS {user_value 256}
cdl_component CYGSEM_KERNEL_SCHED_TIMESLICE {user_value 0}

# set IP configuration for test/devel purposes.  These settings
# are ignored by real applications
cdl_component CYGHWR_NET_DRIVER_ETH0_BOOTP        {user_value 0}
cdl_component CYGHWR_NET_DRIVER_ETH0_DHCP         {user_value 0}
cdl_component CYGHWR_NET_DRIVER_ETH0_ADDRS        {user_value 1}
cdl_option CYGHWR_NET_DRIVER_ETH0_ADDRS_IP        {user_value "10.0.0.101"}
cdl_option CYGHWR_NET_DRIVER_ETH0_ADDRS_NETMASK   {user_value "255.0.0.0"}
cdl_option CYGHWR_NET_DRIVER_ETH0_ADDRS_BROADCAST {user_value "10.255.255.255"}
cdl_option CYGHWR_NET_DRIVER_ETH0_ADDRS_GATEWAY   {user_value "10.0.0.1"}
cdl_option CYGHWR_NET_DRIVER_ETH0_ADDRS_SERVER    {user_value "10.0.0.1"}
EOF

cat .tmp$$.cdl
ecosconfig import .tmp$$.cdl
rm -f .tmp$$.cdl
ecosconfig tree
-----------------------------------8<-----------------------------------

-- 
Grant Edwards                   grante             Yow! FROZEN ENTREES may
                                  at               be flung by members of
                               visi.com            opposing SWANSON SECTS ...


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-09 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-04 17:53 [ECOS] eCos, qemu and rtlk8139 Bessemer
2009-03-05 10:07 ` [ECOS] " Grant Edwards
2009-03-09 15:46   ` Bessemer
2009-03-09 15:52     ` Grant Edwards

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).