Installing LEAF on a PC Engines WRAP board

Starting with the walkthrough from the Q*Box project, I’ve gotten a base Bering uClibc 2.4.2 image installed on a Compact Flash card in a PC Engines WRAP board.

Initially, you have to get the CF card FAT formatted and a boot sector written on to it. The easiest way to do this is to PXE boot the WRAP board and use the utilities provided in the pxeinstall packages. Following the chapter in the Bering uClibc guide on setup for pxeinstall, there are some very specific configuration details that need to be set on the DHCP server:
host wrap {
hardware ethernet 10:d0:b9:64:99:9a;
fixed-address 192.168.1.253;
option host-name "pxe";
filename "pxelinux.0";
next-server 192.168.1.2;
}

Next, you need to download pxeinstall.tgz from the CVS area. Extract this file into the root of your tftp server, on my system it is /tftpboot, with something like cd /tftpboot;tar -zxvf pxeinstall.tgz
Once you’ve extracted the files, you will need to copy the appropriate file in pxelinux.cfg/ to default, pcengines in my case. After copying the file, you will still need to edit the file and verify that the ip of the host is correct and the ip of the tftp server is correct:
ip=192.168.1.253:::255.255.255.0:pxe:eth0
The ip address here is the ip of the WRAP board, matching the one you configured above in dhcpd.conf.
boot=/tftp/192.168.1.2
The ip address here is the address of the DHCP/tftp server. And, so that reboot will work without the wd1100 module, add reboot=bios to the append line. You may also want to look into the ipappend setting from pxelinux

Assuming your dhcpd and tftpd are running, you should now be able to boot the WRAP board, pressing (N) when the BIOS asks you if you want to boot from Disk or Network. If you don’t get asked, power cycle it and hit “s” during the memory test, then “e” to enable etherboot, “q” to quit and “y” to save. You’ll have to power cycle the board again for the change to take effect.

Once you’ve got the WRAP board booted off the network, partitioning the CF card is fairly simple:
fdisk /dev/hda
o - create an empty DOS partition table
n - add a new partition
p - to create a new primary partion
1 - for first partition
enter - default cylinder
enter - default end cylinder
a - make it bootable
1 - first partition
t - select a partition type
6 - for FAT
w - write partition table and exit

Then, format it:
mkfs.msdos /dev/hda1

Write syslinux to the CF card:
syslinux /dev/hda1

Contrary to what the Q*box documentation says, you may need to write a Master Boot Record (mbr) to the flash device, syslinux does not do that. The first CF card I got for this project worked without doing this, the second one I ran around in circles trying to get it working until I did this:
dd if=/usr/bin/mbr.bin of=/dev/hda bs=512 count=1

At this point, you have a bootable CF card with nothing on it. My first time through, I put the card into a Windows machine with a CF to PCMCIA adapter and wrote on the .lrp files that I needed from the Bering uClibc floppy image. This time through, I think I’ll try pulling them down with wget.

Starting from the Bering Guide chapter about the PCEngines WRAP boards and the serial console config, we need to do a few things:

  1. Fix up /etc/inittab, /etc/securetty and /etc/modules
    This presents a bit of a “chicken and egg” problem: How do you edit the content inside a .lrp file without a working LEAF host to edit it on? There a a couple ways to tackle this: Edit the file on a working LEAF box (or a VM) or you can use tar on a linux box to expand the .lrp file, edit the contents and then compress it back to an .lrp. The developer’s guide spells out the steps pretty clearly, though the one part it fails to mention is that you need to be root to do this correctly, or else the files will end up being owned by strange users on the leaf system and things won’t work quite right:
    mkdir etc
    cd etc
    tar -zxvpf ../etc.lrp
    nano -w etc/inittab
    nano -w etc/securetty
    tar -c * |gzip -9 > ../etc-new.lrp

    In /etc/inittab, you need to comment out the normal virtual terminal lines and uncomment the serial line, with the proper port name and speed:
    T0:23:respawn:/sbin/getty -L ttyS0 38400 vt100

    Next you need to load the proper watchdog and ethernet modules for the WRAP board, wd1100 instead of softdog for the watchdog and crc32 and natsemi for ethernet.
    mkdir modules
    cd modules
    tar -zxvpf ../modules.lrp
    nano -w etc/modules
    tar -c * |gzip -9 > ../modules-new.lrp

    Now, you’ve got a nearly complete set of files on the WRAP board, but not on the CF card yet. You’ve got a file to edit yet.
  2. Add 2 lines for the serial console, the watchdog timer and edit another to change the config locations and package path in syslinux.cfg:serial 0 38400
    display syslinux.dpy
    timeout 0
    append console=ttyS0,38400 reboot=bios
    default linux initrd=initrd.lrp init=/linuxrc rw root=/dev/ram0 LEAFCFG=/dev/hda1:msdos PKGPATH=/dev/hda1:msdos syst_size=12M log_size=4M LRP=root,config,etc,local

  3. Once you’ve got those files edited, add them to your archive of stuff to dump onto the CF card. I copied all the files off a burned copy of the most recent Bering uClibc 2.4.2 ISO I had laying around, but you could also use a loopback device to mount the iso image.
    mount /dev/cdrom /mnt/cdrom
    mkdir -p ~/public_html/leaf/bering-uclibc-2.4.2
    cp /mnt/cdrom/* ~/public_html/leaf/bering-uclibc-2.4.2
    cp etc-new.lrp ~/public_html/leaf/bering-uclibc-2.4.2/etc.lrp
    cp modules-new.lrp ~/public_html/leaf/bering-uclibc-2.4.2/modules.lrp
    cd ~/public_html/leaf/bering-uclibc-2.4.2/
    tar -c * | gzip -9 > ../242.tar.gz

    Then, get them onto the CF card (in the serial console on the WRAP board):
    cd /tmp
    wget http://192.168.1.2/~blah/leaf/242.tar.gz
    mkdir root
    cd root
    tar -zxvf ../242.tar.gz
    mount -t msdos /dev/hda1 /mnt
    cp * /mnt
    umount /mnt

At this point, you should be able to shutdown -r now (just to be certain the CF card gets synced one last time) and pull the power plug. From here on, you can treat the WRAP board just like any other host running Bering uClibc. With a really slow console, so get dropbear running as fast as possible.

Update (09/11/2006): Add caveat about root requirement when using tar on another host.
Update (09/16/2006): Add section about reboot=bios and ipappend.
Update (12/06/2006): Fix links into the bering uClibc docs

Leave a Reply

Your email address will not be published. Required fields are marked *