Netgear WGT634U-based Network Stumbler

This is a description of how RussellSenior goes about building a stumbler device based on the NetgearWgt643u and OpenWrt. This is experimental software. Follow these instructions at your own risk.

Hardware

Building OpenWrt Software

Currently, I am using the buildroot-ng svn tree. This description is based on the already obsolete r4902.

cd /src/openwrt
svn co https://svn.openwrt.org/openwrt/branches/buildroot-ng 
svn co https://svn.openwrt.org/openwrt/packages 
cd /src/openwrt/buildroot-ng/openwrt/package 
for i in $(find ../../../packages -type d | grep -v .svn | awk -F/ 'NF==6') ; do echo $i ; ln -s $i $(echo $i | awk -F/ '{ print $6 }') ; done

# add package infrastructure for an older version of gpsd (v2.9)

mkdir /src/openwrt/buildroot-ng/openwrt/package/gpsd-old
cat > /src/openwrt/buildroot-ng/openwrt/package/gpsd-old <<EOF
include $(TOPDIR)/rules.mk

PKG_NAME:=gpsd-old
PKG_VERSION:=2.9
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.personaltelco.net/~russell/
PKG_MD5SUM:=b676f6cb355d801023f08a62f11a606f
PKG_CAT:=zcat

PKG_BUILDDEP=libpthread uclibcxx

include $(INCLUDE_DIR)/package.mk

define Package/gpsd-old
  SECTION:=net
  CATEGORY:=Network
  TITLE:=gpsd
  DEPENDS:=+libpthread +uclibcxx
  DESCRIPTION:=An interface daemon for GPS receivers
endef

define Build/Configure
        ( cd $(PKG_BUILD_DIR); rm -rf config.cache; \
                $(TARGET_CONFIGURE_OPTS) \
                CFLAGS="$(TARGET_CFLAGS)" \
                CXXFLAGS="$(TARGET_CFLAGS) -fno-builtin -fno-rtti -nostdinc++ -nodefaultlibs"  \
                CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
                LDFLAGS="-nodefaultlibs -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
                LIBS="-luClibc++ -lc -lm -lnotimpl" \
                ./configure \
                        --target=$(GNU_TARGET_NAME) \
                        --host=$(GNU_TARGET_NAME) \
                        --build=$(GNU_HOST_NAME) \
                        --program-prefix="" \
                        --program-suffix="" \
                        --prefix=/usr \
                        --exec-prefix=/usr \
                        --bindir=/usr/bin \
                        --datadir=/usr/share \
                        --includedir=/usr/include \
                        --infodir=/usr/share/info \
                        --libdir=/usr/lib \
                        --libexecdir=/usr/lib \
                        --localstatedir=/var \
                        --mandir=/usr/share/man \
                        --sbindir=/usr/sbin \
                        --sysconfdir=/etc \
                        $(DISABLE_LARGEFILE) \
                        $(DISABLE_NLS) \
                        --enable-shared \
                        --enable-static \
                        --with-gnu-ld \
                        --without-x \
        );
endef

define Build/Compile
        cp $(PKG_BUILD_DIR)/libtool $(PKG_BUILD_DIR)/libtool.orig
        sed 's/-lstdc++ //' < $(PKG_BUILD_DIR)/libtool.orig > $(PKG_BUILD_DIR)/libtool
        $(MAKE) -C $(PKG_BUILD_DIR) \
                all
endef

define Package/gpsd-old/install
        install -d -m0755 $(1)/usr/lib
        install -m0755 $(PKG_BUILD_DIR)/.libs/libgps.so* $(1)/usr/lib/
        install -d -m0755 $(1)/usr/sbin/
        install -m0755 $(PKG_BUILD_DIR)/.libs/gpsd $(1)/usr/sbin/
endef

define Build/InstallDev
        mkdir -p $(STAGING_DIR)/usr/include
        $(CP) $(PKG_BUILD_DIR)/gps{,d}.h $(STAGING_DIR)/usr/include/
        mkdir -p $(STAGING_DIR)/usr/lib
        $(CP) $(PKG_BUILD_DIR)/.libs/libgps.{a,so*} $(STAGING_DIR)/usr/lib/
endef

define Build/UninstallDev
        rm -rf $(STAGING_DIR)/usr/include/gps{,d}.h \
                $(STAGING_DIR)/usr/lib/libgps.{a,so*} 
endef

$(eval $(call BuildPackage,gpsd-old))
EOF

cd /src/openwrt/buildroot-ng/openwrt
make menuconfig
make

In the menuconfig, I set the Target System to (Broadcom BCM47xx/53xx [2.6]), and for kicks I also "Select all packages by default" and enable a few things (which I am currently forgetting) that don't automatically get configured in. Often, you will find packages that won't build for some reason or another. In those cases, open a ticket, deconfigure the package in menuconfig and try again. Run make alone to see abbreviated messages, or make V=99 to get lots of information. The configuration I used for r4902 can be found [http://www.personaltelco.net/~russell/buildroot-ng/config-r4902 here].

When the build is complete, the resulting files will be found thusly:

Additionally, as of my recent attempts, the Packages file that is needed for the ipkg utility to function properly later on is apparently not constructed (maybe I missed it), but I developed a script that does it for me:

TOPDIR="/src/openwrt/buildroot-ng/openwrt"

CTRLDIR="${TOPDIR}/build_mipsel"
PKGSDIR="${TOPDIR}/bin/packages"
PKGSFIL="${PKGSDIR}/Packages"

rm -f ${PKGSFIL}

for i in $(find ${CTRLDIR} -name 'control' | grep CONTROL) ; 
  do echo $i ; 
  PACKAGE=$(grep ^Package: $i | cut -d' ' -f2) ; 
  VERSION=$(grep ^Version: $i | cut -d' ' -f2) ; 
  ARCH=$(grep ^Architecture: $i | cut -d' ' -f2) ; 
  FILENAME="${PACKAGE}_${VERSION}_${ARCH}.ipk" ;
  IPKG="${PKGSDIR}/${FILENAME}"
  if [ -f ${IPKG} ] ; then
      SIZE=$(wc -c ${IPKG} | cut -d' ' -f1) ; 
      MD5=$(md5sum ${IPKG} | cut -d' ' -f1) ; 
      cat $i >> ${PKGSFIL} ; 
      echo "Filename: ${FILENAME}" >> ${PKGSFIL} ; 
      echo "Size: ${SIZE}" >> ${PKGSFIL} ; 
      echo "MD5Sum: ${MD5}" >> ${PKGSFIL} ; 
      echo "" >> ${PKGSFIL} ; 
  else
      echo "${FILENAME} NOT FOUND!"
  fi
done

Now, you can copy the ipkg repository somewhere wget'able, e.g.:

rsync -v -a -H /src/openwrt/buildroot-ng/openwrt/bin/packages/ donk.personaltelco.net:public_html/buildroot-ng/r4902/

Checking out the WGT634U

If this is a new device, it is probably a good idea to check it out on the stock firmware first to make sure it functions.

The Flash Environment

There is more than one way to flash the newly-built image onto the WGT634U.

CFE TFTP Flash-From-Console Method

This is the method I tend to use. For this, you will need a TFTP server and a serial console cable. On my debian/unstable box, I use the tftpd-hpa package.

Configuration

Adding Sound

For this, you need a usb-audio device and some additional software: