Building Serval DNA for OpenWRT

Since OpenWRT is installed as a complete firmware image that contains the Linux kernel and all selected components, Serval DNA for OpenWRT can only be built as part of a whole OpenWRT build.

This process can also be used to produce the servald binary for openwrt for use elsewhere, for example including in a Mesh Extender firmware build. But note that the Mesh Extender firmware build process is different (and simpler) compared to that described here.

The Serval DNA build instructions for OpenWRT describe this process in detail.

  1. Choose a version of Serval DNA to build:
  2. Select your target device (architecture) and other configuration options:
    • in the menuconfig step of the build instructions:
      • select the target platform (Dragino MS12 is used in the examples below)
      • select the serval-dna package as a module: [M]
  3. The build should produce an IPK file under the bin/arch/packages directory, eg:
    $ ls -sh bin/atheros/packages/serval*
    840K bin/atheros/packages/serval-dna_START-2967-gdc588e9-4_atheros.ipk
    $
  4. Copy the IPK file onto your OpenWRT device, and install it using opkg. For example:
    $ scp bin/atheros/packages/serval-dna_START-2967-gdc588e9-4_atheros.ipk
    root@192.168.255.1:/tmp/root@192.168.255.1's password:
    serval-dna_START-2967-gdc588e9-4_atheros.ipk       100%  840KB 635.6KB/s   00:02
    $ ssh root@192.168.255.1
    root@192.168.255.1's password:
    
    BusyBox v1.15.3 (2012-11-26 07:01:41 CST) built-in shell (ash)
    Enter 'help' for a list of built-in commands.
      ___   ___   ___   ___  _ _  ___   ___
     |   \ |___\ |___| | __   |  |   | |   |        [  www.dragino.com  ]
     |___/ |   | |   | |___| _|_ |   | |___|        [  www.flukso.net   ]
     ------------------------------------------     [  www.rowetel.com  ]
     W i F i, L i n u x, M C U, E m b e d d e d
    
     OpenWRT Backfire [10.03.1, r33081]
     Dragino MS12 2.1-beta-2, Build Mon Nov 26 07:30:30 CST 2012
    
    root@dragino:~# cd /tmp
    root@dragino:/tmp# ls *ipk
    serval-dna_START-2967-gdc588e9-4_atheros.ipk
    root@dragino:/tmp# df -h
    Filesystem                Size      Used Available Use% Mounted on
    /dev/root                 2.9M      2.9M         0 100% /rom
    tmpfs                    14.6M    716.0K     13.9M   5% /tmp
    tmpfs                   512.0K         0    512.0K   0% /dev
    root                      2.9M      2.9M         0 100% /tmp/root
    mini_fo:/tmp/root         2.9M      2.9M         0 100% /tmp/root
    /dev/mtdblock3            3.9M    272.0K      3.7M   7% /overlay
    mini_fo:/overlay          2.9M      2.9M         0 100% /
    root@dragino:/tmp# opkg install serval-dna_START-2967-gdc588e9-4_atheros.ipk
    Installing serval-dna (START-2967-gdc588e9-4) to root...
    Configuring serval-dna.
    root@dragino:/tmp# which servald
    /usr/bin/servald
    root@dragino:/tmp# servald help
    Serval Mesh version <version>.
    Usage:
     dna lookup <did> [<timeout>]
    ...
    root@dragino:/tmp#

You should now be able to use servald on your OpenWRT device.

Building OpenWRT firmware for Dragrove

Our initial prototype hardware target is the Dragrove MS12.

Flashing New Firmware From a Mac

On a Mac, you can flash the firmware as follows:

  1. Make the firmware files available by TFTP:
    $ cp bin/atheros/openwrt-atheros-vmlinux.lzma /private/tftpboot
    $ cp bin/atheros/openwrt-atheros-root.squashfs /private/tftpboot
    $
  2. Manually configure eth0 (wired ethernet) on the Mac to 192.168.255.2, subnet 255.255.255.0, with no router.
  3. Start the TFTP server on the Mac, e.g.:
    $ sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
    $ sudo launchctl start com.apple.tftpd
    $
  4. Connect the Dragrove to the Mac via ethernet cable
  5. Create ~/.telnetrc with the contents:
    192.168.255.1<NEWLINE>
    <TAB>mode line<NEWLINE>

    Obviously, replace <NEWLINE> by pressing Enter and <TAB> with a single TAB character when creating the file using your favourite editor.

  6. Power down the Dragrove
  7. On the Mac, be ready to type telnet 192.168.255.1 9000 as soon as the Dragrove powers up. You may need to type it several times to make sure you get in. If you don't get in within a few seconds, go back to step 6.
  8. Once you see something like == Executing boot script in 4.580 seconds - enter ^C to abort do press control C. You should be greeted with a RedBoot> prompt.
  9. Type the following redboot commands:
    fis init
    load -r -b %{FREEMEMLO} openwrt-atheros-vmlinux.lzma
    fis create -e 0x80041000 -r 0x80041000 vmlinux.bin.l7
    load -r -b %{FREEMEMLO} openwrt-atheros-root.squashfs
    fis create rootfs
    reset

    For example, a successful conversation might end up looking like:

    $ telnet 192.168.255.1 9000
    Trying 192.168.255.1...
    Connected to 192.168.255.1.
    Escape character is '^]'.
    == Executing boot script in 4.580 seconds - enter ^C to abort
    ^C^C
    RedBoot> fis init
    About to initialize [format] FLASH image system - continue (y/n)? y
    *** Initialize FLASH Image System
    ... Erase from 0xa87d0000-0xa87e0000: .
    ... Program from 0x80ff0000-0x81000000 at 0xa87d0000: .
    RedBoot> load -r -b %{FREEMEMLO} openwrt-atheros-vmlinux.lzma
    Using default protocol (TFTP)
    Raw file loaded 0x8003e000-0x8010dfff, assumed entry at 0x8003e000
    RedBoot> fis create -e 0x80041000 -r 0x80041000 vmlinux.bin.l7
    ... Erase from 0xa8030000-0xa8100000: .............
    ... Program from 0x8003e000-0x8010e000 at 0xa8030000: .............
    ... Erase from 0xa87d0000-0xa87e0000: .
    ... Program from 0x80ff0000-0x81000000 at 0xa87d0000: .
    RedBoot> load -r -b %{FREEMEMLO} openwrt-atheros-root.squashfs
    Using default protocol (TFTP)
    Raw file loaded 0x8003e000-0x8033dfff, assumed entry at 0x8003e000
    RedBoot> fis create rootfs
    ... Erase from 0xa8100000-0xa8400000: ................................................
    ... Program from 0x8003e000-0x8033e000 at 0xa8100000: ................................................
    ... Erase from 0xa87d0000-0xa87e0000: .
    ... Program from 0x80ff0000-0x81000000 at 0xa87d0000: .
    RedBoot> reset

    Note that when you hit Enter after reset, the Dragrove will begin resetting, and you will not get any confirmation back that this has occurred, other than by watching the LEDs on the Dragrove. You can assume the firmware update proceeded successfully if you get to the point where the WIFI LED is blinking again, or you can login using ssh root@192.168.255.1 (default password is root).

  10. When all done, stop the TFTP server on the Mac:
    $ sudo launchctl stop com.apple.tftpd;
    $ sudo launchctl unload -F /System/Library/LaunchDaemons/tftp.plist
    $

Login