The University of Queensland Homepage
School of ITEE ITEE Main Website

 TCP/IP Networking 2

Advanced MicroBlaze uClinux Networking

If you have configured TCP/IP networking on your board, you can really start to speed your development processes.  This page describes a few techniques that I use every day.

Networked Kernel Updates

Waiting for a kernel and filesystem image to load over the serial port (via XMD) is very painful.  The image update can be sped up dramatically, through the use of tftp (trivial FTP).

First, you need to configure your development machine as a tftp server.

Security Warning!  tftp is an insecure protocol.  You should only deploy it on a secure network (i.e. inside a firewall).  Please speak to your local network administrator before proceeding. 

Configuring your host as a tftp server

Please refer to these instructions for configuring your host as a tftp server.  You should test to ensure that the server is working properly before proceeding.

The remainder of this document assumes that you have used the /tftpboot directory as your tftp server root.  If not, adjust accordingly.

uClinux Configuration Settings

In the menu configuration -> vendor/user config, ensure the following are enabled

  • busybox->tftp (get and put)
  • flashtools -> mtdutils -> erase and eraseall

Edit the vendors Makefile for your platform (e.g. for mbvanilla_net, the file is uClinux-dist/vendors/Insight/mbvanilla_net/Makefile)

At the end of the "image:" target, ensure there is a line similar to:

cp $(IMAGE) /tftpboot

This simply copies the final image file into the tftp server root.

Once these changes are complete, perform the usual make dep, make sequence to build the new image.  Confirm that the file image.bin has been copied into the /tftpboot directory on your host.

Networked image updates

This is what it's all about - no more serial downloads:

Boot uClinux with the new kernel and filesystem image.

Erase the flash partition that holds the image:

$ eraseall /dev/flash/image

Now grab the new kernel image via tftp:

$ tftp -g -l /dev/flash/image -r image.bin my.ip.address

substituting the IP address of your development host as appropriate.

A brief explanation of the parameters to the tftp application:

-g "get" mode
-l /dev/flash/image local file.  We write directly into the flash device, avoiding the use of a temporary file
-r image.bin remote file, image.bin

This should complete without errors - you now have a new kernel image stored in the flash.  Simply reboot the board (I press the "program" button to reconfigure the FPGA), the bootloader will start, choose to boot from Flash Slot 1, and off you go!  No more waiting for kernel uploads via the serial port!

Speeding application development

If you are working on developing a new application for uClinux, it can be very slow to rebuild the kernel/filesystem image and upload it every time you make a small change.  Here's a simple way to improve the situation:

  1. Configure your host as an NFS server (instructions for RedHat 8.0 - Google for other distributions).  Configure to export your entire uClinux-dist directory hierarchy.  Here is the relevant line from my /etc/exports file:

            home/jwilliam/uClinux-dist MicroBlaze1(ro,no_root_squash)
     
  2. Enable the NFS mount settings in the kernel config.  This includes enabling NFS support in both the kernel config, and in the busybox mount application.  You must also build the "portmap" application.
     
  3. Boot your new kernel.
     
  4. Launch the portmap server

        $ portmap &
     
  5. Attempt to mount the exported host directory:

            $ mount -t nfs myhost:/my/exported/directory /mnt -o rsize=4096, wsize=4096

    where myhost:/my/exported/directory is replaced with the apporpriate host IP address and directory path. 
    The rsize and wsize parameters specify smaller-than-default block sizes for reads and writes, to allow the ethernet driver to keep up.
     
  6. cd into the /mnt directory, and run ls.  If all has gone well, you should now see the listing of the uClinux-dist directory on your host!

When you make changes to your application (say uClinux-dist/user/my-app), do a "make user_only" from the uClinux-dist directory to rebuild just the applications.

Then, on the uClinux board, simply cd into /mnt/user/my-app, and run the newly rebuilt program:

$ ./my-app

The magic of Linux networking and virtual filesystems means that your new application code will be pulled over the network and executed, just as though it were stored on a local filesystem!

You can streamline things a bit further:

Add the line

portmap &

to the uClinux rc script (e.g. uClinux-dist/vendors/Insight/mbvanilla_net/rc

and create a file vendors/.../.../fstab containing something like

host.ip.address:/home/jwilliam/uClinux-dist /mnt nfs rsize=4096,wsize=4096

that is copied into the uClinux filesystem.  There is already an example of this in the vendors/mbvanilla_net/ directory.

Now, when uClinux boots you can simply type "mount /mnt" to mount the filesystem.


Home Up


Last updated 08-May-2006   
© 2003-2006 John Williams unless otherwise stated