Differences between revisions 4 and 5
Revision 4 as of 2005-12-03 13:10:15
Size: 18978
Comment: smoothing out backtracks
Revision 5 as of 2005-12-03 17:47:40
Size: 20168
Comment: adding bootstrap instructions
Deletions are marked like this. Additions are marked like this.
Line 410: Line 410:
  [ more to come ]   In the case that there is a running system on the device, the solution is easy. Log in to the device, leave /dev/hda1 mounted read-only, and execute something like this, where "hostname" is where the image lives and "username" is an account that has read access to that image:

  {{{
  # ssh username@hostname 'dd if=/src/mississippi/metrix-missnet-new.img' | dd of=/dev/hda1
  }}}

  Writing underneath a mounted filesystem is a little rude, but since it is read-only, the only likely result is the running system getting confused. Reboot immediately after the dd completes and you should be fine. If the running system doesn't have ssh, you can use wget instead. Something like:

  {{{
  wget -O - <url-of-metrix-missnet-new.img> | dd of=/dev/hda1
  }}}

  If the device does not have a running system, then things are a little more complex to bootstrap. Since the flash on the Soekris boards is soldered on, you can't simply remove it to program on a different machine. Basically, you need to netboot enough of a system to run one of the alternatives above. The approach I am going to take is to nfs-mount the root filesystem of the Soekris, and then dd directly from that nfs mount.

Firmware Image

The image for the Metrix boxen is at http://cornerstone.personaltelco.net/~brj/metrix-missnet.img It is setup with all 3 interfaces bridged, and br0 set to 10.11.104.5/22.

To flash:

  • Setup a sarge installer pxeboot environment.
  • Netboot the metrix into the installer
    • Attach a serial terminal.
    • 19200 baud, 1 bit parity, no flow control
    • Press ctrl+p at the prompt to get to the BIOS
    • boot f0

    • Use expert26. You don't need any extra options.
  • Go through the installer up through step 9 (Download installer components). This is where device drivers are loaded.
  • After the drivers are loaded, go to a shell.
  • wget -O - http://somewhere/foo/metrix-missnet.img | dd of=/dev/discs/disc0/disc bs=1M (don't get it straight from cornerstone, copy it to your machine first)

  • Reboot

Note: as of 2005-10-11 this process isn't working for me. The Metrix stalls during the PXELINUX stuff. I think it's probably just an issue with my setup but I've got it working fine using the documentation from Metrix. (- KeeganQuinn)

The way the Metrix website says to do it is actually better. When I was working on the metrixes, though, that documentation didn't exist, to my memory. The debian netboot was simply the easiest way I could find to get a shell netbooted. (- BenjaminJencks)

Can KeeganQuinn or BenjaminJencks please point at or reiterate the referred-to Metrix documentation here? --RussellSenior

Maintaining the Image

The following is a description of how RussellSenior has been working on the software running on the metrixes. When I encountered them, all of the metrixes already had the BenjaminJencks firmware, referenced above.

Updating in place

The metrix firmware is a minimized Debian distribution. The /etc/apt/sources.list include these archives:

deb http://www.backports.org/debian/ stable kernel-2.6
deb http://debian.oregonstate.edu/debian woody main
deb http://security.debian.org woody/updates main

As long as the metrix has access to the internet it can be updated using the standard Debian methods.

# remountrw
# apt-get update
# apt-get upgrade
# apt-get clean
# remountro

For my personal sanity, I have installed "less". For testing/debugging, I have installed "tcpdump", and to keep the clock remotely in sync I have installed "ntpdate" (this seems to be hanging briefly during bootup, not sure why).

Building Software

In order to incrementally build software (e.g., new kernels, madwifi drivers, utilities) for the metrix, one needs a build environment that corresponds to the one on the metrix. My initial attempt to build the madwifi utilities produced partially-broken results because I failed to do this (binaries were linked against symbols that didn't exist in the metrix-installed libraries). Here are the steps I went through to create and use the build environment.

The host for this work was a Debian/unstable system.

  • ==== Unpacking the Image ==== First, create a directory in which to work, e.g. /src/mississippi/ and download the starting image there:
      $ mkdir /src/mississippi
      $ cd /src/mississippi
      $ wget http://cornerstone.personaltelco.net/~brj/metrix-missnet.img
    The downloaded file is 64,028,672 bytes (125,056 512-byte sectors). This represents the /dev/hda flash device on the metrix. It includes the boot sector and partition table, and the root partition /dev/hda1. Grub is used as the boot loader (a rather old feature-missing version, which it would be nice to update, to, for example, be able to control the "next boot"). Before we can mount the first partition, we need to dissect the image a bit. We set up a loop block device associated with the image.
      $ losetup /dev/loop0 metrix-missnet.img
    Now, run fdisk on the loop device to figure out where the first partition begins. Use the -u option to fdisk in order to get sector units.
      $ fdisk -u /dev/loop0
    
      Command (m for help): p
    
      Disk /dev/loop0: 64 MB, 64028672 bytes
      4 heads, 32 sectors/track, 977 cylinders, total 125056 sectors
      Units = sectors of 1 * 512 = 512 bytes
    
            Device Boot      Start         End      Blocks   Id  System
      /dev/loop0p1              32      125055       62512   83  Linux
    
      Command (m for help): q
    Take particular note of the starting sector of the first partition. We'll need that in just a bit. Now disassociate /dev/loop0 from the image file.
      $ losetup -d /dev/loop0
    Now you have a choice. You can either make a copy of the first partition, which you can mount, or you can create a new loop block device offset to the start of first partition and modify it "in place". I chose the former in order to preserve the original, but for reference, you can create the offset loop device as follows. Note that 16384 bytes is the starting sector (32) multiplied by the sector size (512 bytes).
      $ losetup -o 16384 /dev/loop0 metrix-missnet.img
      $ mkdir metrix-missnet
      $ su
      # mount /dev/loop0 metrix-missnet
    Now, what I did instead:
      $ dd if=metrix-missnet.img of=metrix-missnet-part1.img skip=32
      125024+0 records in
      125024+0 records out
      64012288 bytes (64 MB) copied, 7.40427 seconds, 8.6 MB/s
      $ mkdir metrix-missnet
      $ su
      # mount -o loop metrix-missnet-part1.img metrix-missnet
    ==== Creating the Build Environment ==== Now you have access to the image's filesystem through the metrix-missnet mount point. However, the little 64Meg filesystem is too small for the build tool chain, so we are going to create a working copy next door, that we'll chroot into and install the software there. Because we're working with root owned files, we need to stay root here for a while.
      # rsync -v -a -H metrix-missnet/ metrix-missnet-build-env/
      # chroot metrix-missnet-build-env
    Now a little explanatory digression is necessary. The metrix-native environment runs with the filesystem mounted read-only. It copes with changing files by symlinking them to a /rw tmpfs filesystem. That /rw filesystem gets populated during boot from static versions in a /ro tree. You are going to be needing to install software from Debian archives, but your DNS resolution won't work until you modify the build environment's /etc/resolv.conf to something that works for you locally. However, /etc/resolv.conf is a symlink pointing at /rw/etc/resolv.conf. At this stage, that file doesn't exist, since /rw is just a mount point in the original. There are lots of potential solutions to this problem. I took the most direct one, effectively replicating what the metrix itself does:
      # rsync -v -a -H /ro/ /rw/
      # vi /etc/resolv.conf (as appropriate)
    Then ping some well-known host to confirm that your network is functioning in the chroot.
      # ping www.google.com
      PING www.l.google.com (66.102.7.147): 56 data bytes
      64 bytes from 66.102.7.147: icmp_seq=0 ttl=238 time=56.0 ms
      64 bytes from 66.102.7.147: icmp_seq=1 ttl=238 time=56.4 ms
      64 bytes from 66.102.7.147: icmp_seq=2 ttl=238 time=60.8 ms
      64 bytes from 66.102.7.147: icmp_seq=3 ttl=238 time=59.7 ms
    
      --- www.l.google.com ping statistics ---
      4 packets transmitted, 4 packets received, 0% packet loss
      round-trip min/avg/max = 56.0/58.2/60.8 ms
    ==== Install toolchain ==== For good measure, we'll sync up currently installed packages with the Debian archives, but first we'll modify the /etc/apt/sources.list to accomodate subversion we're going to need soon. Add subversion to the backports line:
      deb http://www.backports.org/debian/ stable kernel-2.6 subversion
    Then sync up:
      # apt-get update
      Hit http://debian.oregonstate.edu woody/main Packages
      Hit http://debian.oregonstate.edu woody/main Release
      Get:1 http://security.debian.org woody/updates/main Packages [245kB]
      Hit http://www.backports.org stable/kernel-2.6 Packages
      Hit http://www.backports.org stable/kernel-2.6 Release
      Get:2 http://www.backports.org stable/subversion Packages [8729B]
      Get:3 http://security.debian.org woody/updates/main Release [113B]
      Get:4 http://www.backports.org stable/subversion Release [141B]
      Fetched 254kB in 1s (186kB/s)
      Reading Package Lists...
      Building Dependency Tree...
      # apt-get upgrade
      Reading Package Lists...
      Building Dependency Tree...
      7 packages upgraded, 0 newly installed, 0 to remove and 0  not upgraded.
      Need to get 1259kB of archives. After unpacking 61.4kB will be used.
      Do you want to continue? [Y/n] y
    Say yes. Now, install the toolchain and a few tools we'll need:
      # apt-get install make gcc libncurses5-dev subversion sharutils
      Reading Package Lists...
      Building Dependency Tree...
      The following extra packages will be installed:
        binutils cpp cpp-2.95 db4.2-util gcc-2.95 libapr0 libc6-dev libdb4.2
        libexpat1 libldap2 libneon24 libpcre3 libsasl7 libsvn0 libswig1.3.22 libxml2
        patch python python2.1 
      The following NEW packages will be installed:
        binutils cpp cpp-2.95 db4.2-util gcc gcc-2.95 libapr0 libc6-dev libdb4.2
        libexpat1 libldap2 libncurses5-dev libneon24 libpcre3 libsasl7 libsvn0
        libswig1.3.22 libxml2 make patch python python2.1 sharutils subversion 
      0 packages upgraded, 24 newly installed, 0 to remove and 0  not upgraded.
      Need to get 11.7MB of archives. After unpacking 40.4MB will be used.
      Do you want to continue? [Y/n] y
    Say yes. You may get a warning while configuring binutils about a possible kernel link failure. It applies to older kernels, and we'll be using something newish, so it shouldn't affect us. ==== Building a Kernel ==== Now, download a kernel tarball and unpack. I'll use 2.6.14.2 here.
      # cd /usr/src
      # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.2.tar.bz2
      # tar xjvf linux-2.6.14.2.tar.bz2
    Start with the existing kernel config in /boot:
      # cd linux-2.6.14.2
      # cp /boot/config-2.6.12.3-metrix .config
      # make oldconfig
    I selected defaults for everything, except:
    • Automatically append version information to the version string (LOCALVERSION_AUTO) [Y/n/?] (NEW) n
    • Dell Systems Management Base Driver (DCDBAS) [M/n/y/?] (NEW) n
    • Generic IEEE 802.11 Networking Stack (IEEE80211) [N/m/y/?] (NEW) y
    • Inotify file change notification support (INOTIFY) [Y/n/?] (NEW) n
    Note that this configuration is set up for a Metrix Mark II, with a Soekris 4826 board and a Geode GX1 CPU. In order to work with the Metrix Mark I, which uses a Soekris 4526 and an AMD 486 clone, you need to modify the configuration, e.g. using "make menuconfig". Trying to boot the 4526 with a Geode compiled kernel will choke as follows:
      CPU: AMD 486 DX/4-WB stepping 04
      Kernel panic - not syncing: Kernel compiled for Pentium+, requires TSC feature!
    Next, compile the kernel:
      # make
      # make install 
      # make modules_install 
    The modules are installed in /lib/modules/2.6.14.2-metrix. Edit /boot/grub/menu.lst, adding a stanza for the new kernel. For example:
      title           Debian GNU/Linux, kernel 2.6.14.2-metrix
      root            (hd0,0)
      kernel          /boot/vmlinuz-2.6.14.2-metrix root=/dev/hda1 ro console=ttyS0,19200n8 panic=5
      savedefault
    Since we have no consoles on the metrixes in the field, and no non-volatile storage is available to record any oops messages, there isn't much purpose served by having a panic just halt the device, so I've added the panic clause to the boot options in hopes that will recover the device in the case of a fault. ==== Building the Madwifi-ng modules and utilities ==== In order to build the madwifi-ng software, we first need to check it out from SVN:
      # cd /usr/src
      # svn checkout http://svn.madwifi.org/trunk madwifi-ng
      # cd /usr/src/madwifi-ng
    Then build the madwifi-ng code. Because you are building it for the newly compiled kernel rather than the one you are running, you need to set some environment variables. As of revision 1329, I also needed to hack the Makefile slightly to get depmod to do the right thing. Maybe not the right fix, but it worked for me. Change the line with depmod to this:
              (export MODULEPATH=${MODULEPATH}; depmod -ae ${KERNELVERSION})
    [oops need to install package "sharutils" for uudecode too ... ought to move all of the apt-get installs to the beginning] Now, build madwifi with make:
      # KERNELVERSION=2.6.14.2-metrix KERNELPATH=/usr/src/linux-2.6.14.2 make
      # KERNELVERSION=2.6.14.2-metrix KERNELPATH=/usr/src/linux-2.6.14.2 make install 
    ==== Modifying /etc/network/interfaces ====

    We also need to revise the /etc/network/interfaces file to support the new madwifi drivers. Some of this configuration (e.g. wlanconfig lines) are new with the madwifi-ng code, so we've added " || true" lines where the earlier madwifi drivers will fail. Eventually we'll just purge the old madwifi stuff and the armor can go at the same time. The br0 address (10.11.104.4) is a dummy value and will need to be modified on any deployed metrix.

      auto lo
      iface lo inet loopback
      iface lo inet6 loopback
    
      auto br0
      iface br0 inet static
              address 10.11.104.4
              netmask 255.255.252.0
              broadcast 10.11.107.255
              gateway 10.11.104.1
              bridge_ports eth0
              bridge_stp on
              bridge_maxwait 0
    
      auto ath0
      iface ath0 inet static
              address 1.0.0.0
              netmask 255.255.255.255
              broadcast 255.255.255.255
              pre-up modprobe ath-pci
              pre-up wlanconfig ath0 create wlandev wifi0 wlanmode sta || true
              pre-up iwpriv ath0 wds 1 || true
              pre-up iwpriv ath0 mode 1
              up brctl addif br0 ath0
              down brctl delif br0 ath0
              post-down wlanconfig ath0 destroy
              wireless_mode managed
              wireless_essid backhaul
    
      auto ath1
      iface ath1 inet static
              address 1.0.0.0
              netmask 255.255.255.255
              broadcast 255.255.255.255
              pre-up modprobe ath-pci
              pre-up wlanconfig ath1 create wlandev wifi1 wlanmode ap || true
              pre-up iwpriv ath1 mode 3
              up brctl addif br0 ath1
              down brctl delif br0 ath1
              post-down wlanconfig ath1 destroy
              wireless_mode master
              wireless_essid www.personaltelco.net
              wireless_channel 1
    In the case of new 802.11a master nodes, we'll need to modify the ath0 stanza to:
      auto ath0
      iface ath0 inet static
              address 1.0.0.0
              netmask 255.255.255.255
              broadcast 255.255.255.255
              pre-up modprobe ath-pci
              pre-up wlanconfig ath0 create wlandev wifi0 wlanmode ap || true
              pre-up iwpriv ath0 wds 1 || true
              pre-up iwpriv ath0 mode 1
              up brctl addif br0 ath0
              down brctl delif br0 ath0
              post-down wlanconfig ath0 destroy
              wireless_mode master
              wireless_essid backhaul
              wireless_channel 165
    ==== Installing the new software ==== We are now finished with the chroot and can exit from it:
      # exit
    The steps above have installed new software in /boot, /lib/modules, and /usr/local as well as the /etc/network/interfaces file we just changed in the last step. We can use rsync to put these changes into place, but we don't want to do an rsync from the root directory as our build environment has excessive cruft. Instead, we want to explicitly rsync the trees/files indicated above. If the target of the modification is a running metrix, then you should probably rsync from there over the network, like so:
      $ slogin buick.personaltelco.net
      $ slogin root@metrix-foo
      # remountrw
      # rsync -v -a -H username@hostname:/src/mississippi/metrix-missnet-build-env/boot/ /boot/
      # rsync -v -a -H username@hostname:/src/mississippi/metrix-missnet-build-env/lib/modules/ /lib/modules/
      # rsync -v -a -H username@hostname:/src/mississippi/metrix-missnet-build-env/usr/local/ /usr/local/
      # scp username@hostname:/src/mississippi/metrix-missnet-build-env/etc/network/interfaces /etc/network/interfaces
      # remountro
    You'll need to be a little careful with /etc/network/interfaces, in particular setting the br0 address correctly and making sure you've got ath0 master/managed mode configured correctly. To install in the locally-mounted (at /src/mississippi/metrix-missnet) partition image, do similarly:
      # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/boot/ /src/mississippi/metrix-missnet/boot/
      # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/lib/modules/ /src/mississippi/metrix-missnet/lib/modules/
      # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/usr/local/ /src/mississippi/metrix-missnet/usr/local/
      # cp /src/mississippi/metrix-missnet-build-env/etc/network/interfaces /src/mississippi/metrix-missnet/etc/network/interfaces
    We are now finished with the loopback mounted partition, so we can unmount it.
      # cd /src/mississippi
      # umount metrix-missnet
    ==== Creating a new image ==== To create a new image, we can crib the first 32 sectors from the original image, then paste on our modified filesystem part. We can do this as non-root. Note, we got the 32 from our fdisk examination of the original image. Substitute a different value as necessary.
      $ dd if=/src/mississippi/metrix-missnet.img of=/src/mississippi/metrix-missnet-new.img count=32
      32+0 records in
      32+0 records out
      16384 bytes (16 kB) copied, 0.044728 seconds, 366 kB/s
      $ dd if=/src/mississippi/metrix-missnet-part1.img of=/src/mississippi/metrix-missnet-new.img seek=32
      125024+0 records in
      125024+0 records out
      64012288 bytes (64 MB) copied, 6.51654 seconds, 9.8 MB/s
    Viola! There's our new image, metrix-missnet-new.img, ready to install. ==== Installing an image ==== In the case that there is a running system on the device, the solution is easy. Log in to the device, leave /dev/hda1 mounted read-only, and execute something like this, where "hostname" is where the image lives and "username" is an account that has read access to that image:
      # ssh username@hostname 'dd if=/src/mississippi/metrix-missnet-new.img' | dd of=/dev/hda1
    Writing underneath a mounted filesystem is a little rude, but since it is read-only, the only likely result is the running system getting confused. Reboot immediately after the dd completes and you should be fine. If the running system doesn't have ssh, you can use wget instead. Something like:
      wget -O - <url-of-metrix-missnet-new.img> | dd of=/dev/hda1
    If the device does not have a running system, then things are a little more complex to bootstrap. Since the flash on the Soekris boards is soldered on, you can't simply remove it to program on a different machine. Basically, you need to netboot enough of a system to run one of the alternatives above. The approach I am going to take is to nfs-mount the root filesystem of the Soekris, and then dd directly from that nfs mount.


[CategoryDocumentation]

MississippiMetrixConfiguration (last edited 2009-01-31 02:10:15 by RussellSenior)