This page presents a naive implementation of BOOTP and TFTP, the protocols to use to bootstrap a computer through a TCP/IP network. The source code is released under LGPL (Lesser GNU Public License).

Tftpnaive is available as source code, stable version 1.3.3.

The transfert speed has been improved greatly, see the Change history below.

The code is working on a big endian machine, Nicholas Lin sent me this patch and tested it on a little endian machine. Thanks for this contribution !


The current implementation is for a m68k board, using the CS8900 network chip. The source code of the network chip (cs89x.c) handles the hardware swap which some boards use. All the dependencies are resolved, there is no need for an external library even for libc (the libgcc is still needed but included with the compiler toolchain). The standard functions like printf and strcpy needed by the package are included in the baselib subdirectory. This software will *not* run under uClinux, it is designed to be standalone and to start a uClinux image or any other executable binary file. The memory footprint is quite small, about 7 KBytes for the test program on the DragonEngine. This software can be used as a starting point for your own bootstrap code, the bootp and tftp source code should be easy to reuse.


README a *very* short comment, mainly to send the reader to this page
COMPILING compilation/modification hints
ChangeLog what's new in this release
tftpnaive/src/* core files
tftpnaive/de2/* DragonEngine specific files
tftpnaive/ucdimm/* uCdimm specific files (not tested)
baselib/* a collection of basic functions


The provided Makefiles assume m68k-elf-gcc as compiler/linker. You may use the gcc toolchain at the uClinux distribution page to build this software.

You may have to modify the .ld file to relocate tftpnaive to a region not used by the downloaded file. The .ld contains also the stack address, tftpnaive needs around 12k for the data segment and 8k for the stack segment.

Setting up a BOOTP server

A linux DHCP server can act as a BOOTP server, you will have to install a dhcp server package on a linux machine and add some specific parameters for BOOTP. Add the lines below to your /etc/dhcpd.conf file :

# dhcpd.conf

allow bootp;

host de2 {
  hardware ethernet ff:ff:ff:ff:ff:ff;
  filename "de2.10000.0.bin";
#  next-server; # TFTP server to use

The commented out next-server line can be used if the TFTP server is not the same as the BOOTP server. Replace the hardware MAC address by the real address of your board; set its IP address (I'm using a fixed one as an example).

The filename is formatted to allow tftpnaive to know the loading address and the starting address of the code to be downloaded. The filename should be formatted this way :

name and ext can be anything, the number are in hexadecimal without a leading 0x. In the example above, the download address is 0x10000 and the code will jump to the same address after successfull download. This is to download and run a uClinux kernel image on my board but any code can be downloaded and run. With a filename like 'de2.200000.400.bin' the download address will be 0x200000 and the start address will be 0x200400. The filename should not be longer than 127 characters.

Setting up a TFTP server

The TFTP server is the server which handle the download. It can be the same as the BOOTP server. You will have to install a tftpserver package on your machine and place the binary image to be downloaded into the directory used by TFTP. It may be /tftpboot or /boot.


The code starts by initializing the network card, if there is a fatal error (other than network cable problem) the code will exit. If it is a cable problem, the code will infinitely loop, trying each seconds to initialize the network chip.

The code will then broadcast a BOOTP request and wait for a reply. Without reply, it will wait 1 second then 2, 4 and 8 seconds and start over.

The reply will permit the code to get its IP address, the server's IP address and the filename to download. The code will check first if there is no IP conflict so it can actually use the given IP address.

Then a TFTP get will be issued, if there is an acknowledgement reply, the TFTP get will continue and a jump to the start-address will be issued at the successfull end of the download. There will be 5 tries to download the file; after that, the code will start over with a new BOOTP request.

The code will infinitely loop on the BOOTP requests if the download can not be done without error.

The code answer to ping (ICMP) requests as soon as it has a valid IP address from a BOOTP reply.

Changes / Bugs

If you modify this code, I will be more than happy to receive your comments and changes. My email address is in the README file and on the top level page of this web site. The BOOTP and TFTP source code should be stable now, but you might want to modify or add a new network adapter, or to adapt the source code to another platform. The main idea here is: keep it simple.

Change history

Version 1.3.3 - 2004-03-21

Version 1.3.2 - 2003-10-30

Version 1.3.1 - 2002-10-30

Version 1.3 - 2002-08-31

Version 1.2.1 - 2002-07-30

Version 1.2 - 2002-05-01

Version 1.1 - 2002-03-07

Version 1.0 - 2002-02-21

initial release