Run RTEMS sample applications on the Milkymist One board and on Qemu

From Milkymist Wiki

Jump to: navigation, search

This is a tutorial on how to run RTEMS sample applications on the Milkymist One board and on Qemu.

Questions about the Milkymist BSP for RTEMS ?

GO ask them on irc.freenode.net on #milkymist

I (Yann Sionneau aka Fallenou on IRC) or lekernel or mwalle will try to answer :)

Contents

[edit] First you must build the RTEMS port to Milkymist

[edit] Run the sample applications

[edit] Run the sample applications on the Milkymist One board

Go to the bsp-milkymist directory, say we wanna test the "hello world" sample :

 ~$ cd bsp-milkymist/
 ~/bsp-milkymist$ cd lm32-rtems4.11/c/milkymist/testsuites/samples/hello
  • Plug your RS-232 serial usb wire to your computer and to the Serial port of the board
  • Install flterm (the software for uploading the application into on-board Flash through RS-232 line) :
    • This software is available in milkymist's debian repository (works for ubuntu too), just do :
 # echo "deb http://www.milkymist.org/debian ./" >> /etc/apt/sources.list
 # aptitude update && aptitude install flterm
  • Power-on the board
  • Then upload the sample application hello.exe to the board :
 ~/bsp-milkymist/lm32-rtems4.11/c/milkymist/testsuites/samples/hello$ flterm --kernel hello.ralf --port /dev/ttyUSB0
  • If nothing is uploading then push two push-buttons, then push the third and release it, then release the two others. (in this order)

[edit] Run the sample applications on Qemu

  • You must compile Qemu with Milkymist support, Check this wiki page Using QEMU
  • Go to the binary directory
 ~$ cd bsp-milkymist/lm32-rtems4.11/c/milkymist/testsuites/samples/hello
  • Run the .exe binary file with Qemu
 ~/bsp-milkymist/lm32-rtems4.11/c/milkymist/testsuites/samples/hello$ ~/path/to/qemu-lm32/lm32-softmmu/qemu-system-lm32 -M milkymist -kernel hello.exe -nographic
  • How to run the others samples :
    • milkymist_networking - starts a shell that you can reach through a telnetd daemon over the network
 ~$ cd ~/bsp-milkymist/lm32-rtems4.11/c/milkymist/testsuites/samples/milkymist_networking
 milkymist_networking$ ~/path/to/qemu-lm32/lm32-softmmu/qemu-system-lm32 -M milkymist -kernel milkymist_networking.exe \
 -nographic -net nic -net user,net=192.168.101.0/24,restrict=n,host=192.168.101.254,hostfwd=::5555-192.168.101.100:23 \
 -net dump
 milkymist_networking$ telnet 127.0.0.1 5555
 Trying ::1...
 Trying 127.0.0.1...
 Connected to localhost.
 Escape character is '^]'.
 == Starting shell inside telnetd ==
 
 Welcome to rtems-4.10.99.0(LM32/lm32/milkymist)
 COPYRIGHT (c) 1989-2008.
 On-Line Applications Research Corporation (OAR).
 
 running on (LM32/lm32)
 /dev/pty0 login: root
 root
 Password: 
 
 RTEMS SHELL (Ver.1.0-FRC):/dev/pty0. Oct 27 2010. 'help' to list commands.
 [/] # 
      • a .pcap file will be generated with a dump of the network packets involved in the sample run, so that you can monitor the network activity of the sample, you can open this file with wireshark.
    • milkymist-networking2 - sends a UDP packet to 4.2.2.1:1234 with "toto" as payload
 ~$ cd ~/bsp-milkymist/lm32-rtems4.11/c/milkymist/testsuites/samples/milkymist_networking2
 milkymist_networking2$ ~/path/to/qemu-lm32/lm32-softmmu/qemu-system-lm32 -M milkymist -kernel milkymist_networking2.exe \
 -nographic -net nic -net user,net=192.168.101.0/24,restrict=n,host=192.168.101.254 -net dump
      • a .pcap file will be generated with a dump of the network packets involved in the sample run, so that you can monitor the network activity of the sample, you can open this file with wireshark.
    • milkymist-networking3 - listens on the TCP port 23 for connections, and echoes what you type (no more than 4 bytes/line), ends with "quit"
 ~$ cd ~/bsp-milkymist/lm32-rtems4.11/c/milkymist/testsuites/samples/milkymist_networking3
 milkymist_networking3$ ~/path/to/qemu-lm32/lm32-softmmu/qemu-system-lm32 -M milkymist -kernel milkymist_networking3.exe \
 -nographic -net nic -net user,net=192.168.101.0/24,restrict=n,host=192.168.101.254,hostfwd=::5555-192.168.101.100:23 \
 -net dump
 milkymist_networking3$ telnet 127.0.0.1 23
 toto
 tata
 quit
      • a .pcap file will be generated with a dump of the network packets involved in the sample run, so that you can monitor the network activity of the sample, you can open this file with wireshark.

[edit] Another example of application built against RTEMS : tftpclient

[edit] Run the tftpclient on the Milkymist One board

tftpclient is an example application that you can build against RTEMS kernel.

This application downloads a file from a tftp server and prints it's content to the serial console.

This application has been added to the network-demos provided by RTEMS as a CVS module, it is available on Yann's github

  • Checkout the github repo of network-demos :
 ~$ git clone git://github.com/fallen/network-demos.git
  • Compile the applications against RTEMS kernel :
 ~$ cd network-demos
 ~$ export PATH=$PATH:/opt/rtems-4.11/bin
 ~/network-demos$ RTEMS_MAKEFILE_PATH=/opt/rtems-4.11/lm32-rtems4.11/milkymist make all
  • Install a tftpd server on your computer :
 ~# aptitude install tftpd
  • Configure it :
 ~# touch /etc/xinetd.d/tftp
 ~# vim /etc/xinetd.d/tftp
  • Put this in the file :
 service tftp
 {
   protocol    = udp 
   port        = 69
   socket_type = dgram
   wait        = yes 
   user        = nobody
   server      = /usr/sbin/in.tftpd
   server_args = /tftpboot
   disable     = no
 }
  • Create the tftp root directory and put your file in it
 ~# mkdir /tftpboot
 ~# cp yourfile /tftpboot/sample.data
 ~# chown -R nobody /tftpboot
 ~# chmod -R 777 /tftpboot
  • Restart xinetd :
 ~# /etc/init.d/xinetd restart
  • Upload the file to the board using the procedure described previously :
 ~/network-demos$ cd tftpclient/o-optimize
 ~/network-demos/tftpclient/o-optimize$ lm32-rtems4.11-objcopy -Obinary tftpclient.exe
 ~/network-demos/tftpclient/o-optimize$ flterm --kernel tftpclient.exe --port /dev/ttyUSB0
  • While uploading the binary into the board, set-up your network configuration :
 ~# ifconfig eth0 192.168.101.254 netmask 255.255.255.0

You can change the ip address taken by the board, the ip address of the gateway it's supposed to use, the ip address of the tftp server, the port of the tftp server and the name of the file tftpclient is supposed to download and print in the network-demos/networkconfig.h and directly into network-demos/tftpclient/init.c

[edit] Run the tftpclient on Qemu

  • Go through all the previous sections untill you reach the "Restart xinetd" point.
  • Go to the tftpclient binary directory
 ~$ cd ~/dev/network-demos/tftpclient/o-optimize
  • Create a TAP device interface (do this as root) :
 ~# aptitude install uml-utilities
 ~# tunctl -u YOUR_USER -g YOUR_GROUP -t tap0
  • Start the tftpclient with Qemu (in user) :
 o-optimize$ ~/path/to/lm32-qemu/lm32-softmmu/qemu-system-lm32 -kernel tftpclient.exe -nographic -net nic -net tap,iface=tap0,script=no,downscript=no -net dump
  • It will show you the content of the /tftpboot/sample.data file
  • It will produce a .pcap file with all the network activity involved in this tftp transaction. You can open this file with wireshark.
Personal tools