The next step is to make the kernel and rootfs.gz
available to the router. There are two methods:
Boot the kernel from the CF card. This is reliable,
straightforward and suitable for production environments.
The main drawback is that you need to move the CF card to
a different machine to upgrade the files. Once the router
is up and running this may be overcomeby using
tftp.
Boot the router from a PXE server. This is more complicated
and relies on a PXE server to be up and running. The advantage
is that the kernel and rootfs.gz do not
have to be copied to the
CF card each time a new version is available. This makes it
suitable during development.
The boot loader uses a configuration file
syslinux.cfg to find the kernel and
rootfs.gz. It also sets kernel parameters
to use the serial port as a console and initialize the watchdog
timer margin.
The commands below create the syslinux.cfg
configuration file on the CF card.
mkdir -p $FLASH_MNT sudo mount -t msdos $FLASH_PART $FLASH_MNT cat > /tmp/$$ <<EOF DEFAULT linux LABEL linux KERNEL linux APPEND initrd=rootfs.gz console=ttyS0,38400 root=/dev/ram0 boot=/dev/hda1,msdos rw scx200_wdt.margin=15 EOF sudo cp /tmp/$$ $FLASH_MNT/syslinux.cfg rm /tmp/$$ sudo umount $FLASH_MNT
The final step is to copy the kernel and
rootfs.gz to compact flash. The CF card
can then be inserted in the router.
sudo mount -t msdos $FLASH_PART $FLASH_MNT sudo cp $ROOTFS_FILE.gz $FLASH_MNT/rootfs.gz sudo cp $LINUX_DIR/arch/i386/boot/bzImage $FLASH_MNT/linux sudo umount $FLASH_MNT
The BIOS on the WRAP does not support PXE. This section presents a workaround that consists of three stages:
boot etherboot from CF;
etherboot loads pxelinux from the PXE server; and
pxelinux loads the kernel and rootfs.gz and starts the kernel
Etherboot is a software package for creating images that can download code over an Ethernet network.
Download and compile etherboot for the Ethernet chip present in
the router. The example below is for the NatSemi
DP83816.
wget -P $DL_DIR http://etherboot.berlios.de/dist/etherboot-5.3.9.tar.bz2 tar -C $PRJ_DIR/bootldr -xvjf $DL_DIR/etherboot-5.3.9.tar.bz2 cd $PRJ_DIR/bootldr/etherboot-5.3.9/app make ARCH=i386 bin/natsemi.zlilo
The configuration file syslinux.cfg
contains two labels. The first label allows the user to boot
from CF directly and is similar to the one described in
Section 3.5.1, “Boot from CF”. The second label points
the boot monitor to the ethboot binary.
The commands below create this configuration file.
sudo mount -t msdos $FLASH_PART $FLASH_MNT sudo cp $PRJ_DIR/bootldr/etherboot-5.3.9/apps/bin/natsemi.zlilo $FLASH_MNT/ethboot cat > /tmp/$$ <<EOF DEFAULT ethboot TIMEOUT 10 PROMPT 1 LABEL linux KERNEL linux APPEND console=ttyS0,38400 root=/dev/ram0 initrd=rootfs.gz rw scx200_wdt.margin=15 LABEL ethboot KERNEL ethboot APPEND console=ttyS0,38400 EOF sudo cp /tmp/$$ $FLASH_MNT/syslinux.cfg rm /tmp/$$ sync sudo umount $FLASH_MNT
When etherboot starts, it does a DHCP request for an IP
address and PXE filename. The file name that it receives will
be pxelinux. It then uses the TFTP protocol
to load and run this files. This implies that both a DHCP and a
TFTP server need to be present on the network.
Popular daemons for TFTP and DHCP are tftpd
and dhcpd. The ISC DHCP daemon
dhcpd can be configured for PXE by adding
the following section to an existing
/etc/dhcpd.conf.
host siso {
option root-path "/home/tftp";
hardware ethernet 00:0D:B9:00:78:90;
fixed-address 10.0.1.1;
if substring (option vendor-class-identifier, 0, 9) = "Etherboot" {
filename "pxelinux.0";
}
host siso2 {
option root-path "/home/tftp";
hardware ethernet 00:0D:B9:07:36:BC;
fixed-address 10.0.1.1;
if substring (option vendor-class-identifier, 0, 9) = "Etherboot" {
filename "pxelinux.0";
}
}
Restart dhcpd on the server.
ssh root@pxeserver /etc/init.d/dhcpd restart
PXElinux is part of the syslinux suite and downloaded in
Section 3.3.2, “Boot Loader”. Instead of compiling
syslinux (that boots from FAT), the PXE
compatible binary needs pxelinux.0 to be
generated.
cd $PRJ_DIR/bootldr/syslinux-2.11 make pxelinux.0
Copy pxelinux.0 to the server, and create a
configuration file.
sshpxeservermkdir -p /home/tftp/pxelinux.cfg sshpxeserverchmod 555 /home/tftp /home/tftp/pxelinux.cfg scp pxelinux.0pxeserver:/home/tftp/ sshpxeservercat ">" /home/tftp/pxelinux.cfg/default <<EOF SERIAL 0 38400 DEFAULT 1 TIMEOUT 30 PROMPT 1 LABEL 1 KERNEL linux APPEND console=ttyS0,38400 root=/dev/ram0 initrd=rootfs.gz rw scx200_wdt.margin=15 EOF