HSMM Mesh on Raspberry Pi

Broadband-Hamnet™ (formerly called HSMM-Mesh™)  is a high speed, self discovering, self configuring, fault tolerant, wireless computer network that can run for days from a fully charged car battery, or indefinitely with the addition of a modest solar array or other supplemental power source. The focus is on emergency communications.

In its current form it is built using the Linksys WRT54G/GL/GS wireless routers and operates on channels 1-6 of the 2.4GHz ISM band, which overlaps with the upper portion of the 13cm amateur radio band. Other platforms and bands are in development at this time. Next will be Ubiquiti equipment with others supported as development resources permit.

It’s fairly easy to flash an old Linksys WRT54G router with HSMM-Mesh (now called BroadbandHamnet-v1) firmware. The downside is that the routers are fairly old and not that easy to find anymore. Plus, they are fairly limited in functionality. It would be more interesting to put mesh software on a microcomputer such as Raspberry Pi or BeagleBone which I did.

Installation

I came across a script created by Scott Kidder which does just that – it radically simplifies installation and configuration of hsmm-mesh on Raspberry Pi / Beaglebone. See installation instructions here: https://github.com/urlgrey/hsmm-pi

I used a Raspberry Pi Model B with a small USB WiFi dongle. The Ethernet port will provide LAN connectivity (DHCP) for connected computer(s).

After installing Raspbian and hsmm-pi software following instructions from Scott, all I needed was to login to the node’s web interface and change the SSIS to ‘BroadbandHamnet-v1’ – same as the currently used SSID by new linksys firmware and reboot the Pi. After reboot, the local mesh router was recognized by the Pi:

hsmmpi

WiFi dongle

For mobile WiFi, I planned to use either an ALFA 1,200 mW USB WiFi network adapter that are known to work with Raspbian.

For portable / low-power, I ordered a RT5370 USB WiFi dongle from eBay ($10):7601

Surprisingly, the chip inside was NOT RT5370 as advertised- it was Mediatek 7601T instead. The USB ID was 148f:7601 instead of 148f:5370 accordingly.

As a result, the dongle did not work in Raspbian out-of-the-box. Luckily, the source code of a driver was available from mediatek.com which I promptly downloaded to the Pi but it needed to be compiled first.

Compiling Mediatek RT7601 driver

After googling forums, reading documentation, and some trial and error, the driver was compiled, installed (mt7601Usta.ko) and the card was finally recognized by Raspbian (3.10.33+ #656 PREEMPT armv6l GNU/Linux).

The compilation steps were as follows (in Terminal):

 # get root
 sudo bash

 # now continue as root and download latest updates
 apt-get update
 apt-get upgrade
 rpi-update

# now download linux kernel source
 cd /usr/src
 git clone --depth=1 https://github.com/raspberrypi/linux.git
 sudo ln -s /usr/src/linux /lib/modules/`uname -r`/build
 cd linux

 # test kernel sources
 make mrproper
 zcat /proc/config.gz > .config
 cp .config .config.org
 sed -i 's/^CONFIG_CROSS_COMPILE.*/CONFIG_CROSS_COMPILE=""/' .config
 make modules_prepare
 # download module symbols to avoid recompiling kernel from sources
 wget https://raw.github.com/raspberrypi/firmware/master/extra/Module.symvers
 exit

Now all prerequisites are satisfied so we can download and compile the driver:

# download the driver into your home ~ folder 

cd ~ 
tar -xvjpf DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2 
cd DPO*

# now you can modify ULONG RTDebugLevel = 0; // RT_DEBUG_TRACE; 
# as per http://ubuntuforums.org/showthread.php?t=1708767 to avoid the driver spamming into syslog
nano os/linux/rt_linux.c

# or, alternatively, can run this every time after reboot: iwpriv ra0 set Debug=0
# now build and install the driver

sudo make
sudo make install

# and, finally, reboot!

sudo reboot

After reboot, the wifi card showed up as ‘ra0’ interface in ifconfig.

I noticed that the driver writes a LOT of debug info into the logs. To avoid that, I used:

iwpriv ra0 set Debug=0

as suggested by http://ubuntuforums.org/showthread.php?t=1708767

Done! In this configuration (1 – wireless, 1 – ethernet interface), the Pi can function either as a wireless gateway to WAN (internet) for other mesh nodes, or as an individual access point to wireless mesh.  I’m planning to use it mostly for the latter – portable/mobile operation. A laptop is plugged in into the Pi’s ethernet port, and the Pi routes the network to the other wireless mesh nodes in the vicinity.

Raspberry Pi access point configured for HSMM Mesh network

Raspberry Pi access point configured for HSMM Mesh network

The Pi can be deployed either independently as part of a bigger mesh network or used as a gateway/access point. Any additional services such as shared folders, web forum/board, IRC chat, SIP client / asterisk, can be installed right on the Pi.

Update August 8th, 2014 on WiFi dongle:

The WiFi dongle was very flimsy and badly built. One of those days it stopped working probably due to some PCB circuit or SMD solder failure and was discarded.

The next iteration was ALFA clone from DX.COM. It worked fine for a bit with a standalone stock antenna but when connected to a high-gain Yagi it just died right away….

So now I use ‘$5 Dx.com original‘ WiFi dongle. It’s tiny, works well for short distances, and has a low power consumption so it didn’t require a powered USB hub for itself. Also no drivers were required for Raspbian (possibly other distros too), and it haven’t seem to hang itself after a few days as some other USB dongles did so the chipset/drivers are fairly stable. One improvement would be an external antenna connector so I could use directional / gain antennas.

Please share your experiences in the comments.

Advertisements

About va3paw
Ham radio enthusiast, software developer

34 Responses to HSMM Mesh on Raspberry Pi

  1. Paul says:

    Thank you for this. You saved me a lot of leg work.

  2. n2jtx says:

    Thanks for the detailed instructions! I just finished building a driver for 3.12.25+. I have been running with downloaded 3.12.22+ drivers but there are no 25+ drivers to be found so it was time to roll my own. I will most likely keep a separate bootable SD card with the Linux source so I can easily build new drivers as needed.

    • va3paw says:

      Congrats! Happy meshing and 73’s!

      I found cheap wifi dongles on dx.com that are supported by the kernel out-of-the-box. So no more drivers compiling for me.

      Can’t find an URL right now but remember those were white and branded as ‘dx.com brand’
      The price was in the range of $5-$10 delivered.

      Paul VA3PAW

  3. Charly says:

    Hi, thank you very much for your explanation. Good job! thanks to this I bring back to life an (almost) useless ebay wifi dongle. Now is working.
    On the other hand, you say that now you are using this one ‘$5 Dx.com original‘, but, does it work just out of the box or you need to compile drivers or something?Thank you!

    • va3paw says:

      No drivers were needed for Raspbian linux (possibly other distros will work fine too – e.g. Arch). Worked out of the box – plug&play.

  4. Wojtek says:

    Hey, yuor procedure is very good i’m just install my first MT7601U on 3.12.32+ #721 (so it’s very universal)
    one think, when I clone kernel source to my default pi I got some problem with memory. the steps in this post removes problem
    http://www.raspberrypi.org/forums/viewtopic.php?p=128303

    many thanks Paul

    • Noel says:

      root@raspbmc:/usr/src/linux# make modules_prepare
      HOSTCC scripts/basic/fixdep
      HOSTCC scripts/kconfig/conf.o
      SHIPPED scripts/kconfig/zconf.tab.c
      SHIPPED scripts/kconfig/zconf.lex.c
      SHIPPED scripts/kconfig/zconf.hash.c
      HOSTCC scripts/kconfig/zconf.tab.o
      HOSTLD scripts/kconfig/conf
      scripts/kconfig/conf –silentoldconfig Kconfig
      sound/soc/Kconfig:45: can’t open file “sound/soc/kirkwood/Kconfig”
      make[2]: *** [silentoldconfig] Error 1
      make[1]: *** [silentoldconfig] Error 2
      make: *** No rule to make target `modules_prepare’. Stop.

    • va3paw says:

      You are very welcome Wojtek!

  5. untitledlt says:

    Could someone point me to the right direction on this line?
    sudo ln -s /usr/src/linux /lib/modules/`uname -r`/build

    After git clone there is no such directory named “linux”.

    # ls /usr/src/
    linux-config-3.12 linux-patch-3.12-rt.patch.xz linux-source-3.12.tar.xz

    There is a directory called linux-config-3.12 but if I try to run “make mrproper” in it, I get:

    make: *** No rule to make target `mrproper’. Stop.

    • va3paw says:

      this command creates a symbolic link (/usr/src/linux) to the /lib/modules/3.12.28+/build or whatever version (e.g. 3.12.28+) is your Linux kernel is.
      This way /usr/src/linux will then point to the /lib/modules/…… folder.

  6. Noel says:

    Hi,

    I got some errors:

    root@raspbmc:/usr/src/linux# make modules_prepare
    HOSTCC scripts/basic/fixdep
    HOSTCC scripts/kconfig/conf.o
    SHIPPED scripts/kconfig/zconf.tab.c
    SHIPPED scripts/kconfig/zconf.lex.c
    SHIPPED scripts/kconfig/zconf.hash.c
    HOSTCC scripts/kconfig/zconf.tab.o
    HOSTLD scripts/kconfig/conf
    scripts/kconfig/conf –silentoldconfig Kconfig
    sound/soc/Kconfig:45: can’t open file “sound/soc/kirkwood/Kconfig”
    make[2]: *** [silentoldconfig] Error 1
    make[1]: *** [silentoldconfig] Error 2
    make: *** No rule to make target `modules_prepare’. Stop.

    and also

    root@raspbmc:/usr/src/linux# root@raspbmc:/usr/src/linux# rpi-update
    -bash: root@raspbmc:/usr/src/linux#: No such file or directory
    You appear to be trying to update firmware on an incompatible distribution. To force update, run the following:
    sudo -E RPI_UPDATE_UNSUPPORTED=0 rpi-update
    root@raspbmc:/usr/src/linux# You appear to be trying to update firmware on an incompatible distribution. To force update, run the following:
    -bash: You: command not found
    root@raspbmc:/usr/src/linux# sudo -E RPI_UPDATE_UNSUPPORTED=0 rpi-update
    *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
    *** Performing self-update
    /usr/bin/rpi-update: line 41: curl: command not found
    !!! Failed to download update for rpi-update!
    !!! Make sure you have ca-certificates installed and that the time is set correctly

    here is my release

    root@raspbmc:/usr/src/linux# sudo vcgencmd version
    Oct 17 2014 17:56:05
    Copyright (c) 2012 Broadcom
    version 845092531e360acd37f2f1964157f8079c77edfb (clean) (release)
    root@raspbmc:/usr/src/linux# uname -a
    Linux raspbmc 3.12.31 #2 PREEMPT Wed Oct 29 09:24:56 UTC 2014 armv6l GNU/Linux

    can you help me?

  7. Noel says:

    Kirkwood solved: Kconfig was bad formated…

    when I try sudo make I get this error:

    pi@raspbmc:~/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913$ sudo make
    make -C tools
    make[1]: Entering directory `/home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/tools’
    gcc -g bin2h.c -o bin2h
    make[1]: Leaving directory `/home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/tools’
    /home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/tools/bin2h
    cp -f os/linux/Makefile.6 /home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/Makefile
    make -C /lib/modules/3.12.31/build SUBDIRS=/home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux modules
    make[1]: Entering directory `/lib/modules/3.12.31/build’
    make[1]: *** No rule to make target `modules’. Stop.
    make[1]: Leaving directory `/lib/modules/3.12.31/build’
    make: *** [LINUX] Error 2
    pi@raspbmc:~/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913$

  8. untitledlt says:

    Did someone succeed to run RT7601 in master mode? Looks like dongle does support master mode but drivers does not.

  9. dhubax says:

    I don`t know what happens, but I cannot install this… The process seems to be right, but after I did make install, after everything works well, I tried to up the ra0 and get this message:

    root@rpiTHC:~/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913# ifup ra0
    wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
    run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
    Internet Systems Consortium DHCP Client 4.2.2
    Copyright 2004-2011 Internet Systems Consortium.
    All rights reserved.
    For info, please visit https://www.isc.org/software/dhcp/

    Cannot find device “ra0”
    Bind socket to interface: No such device
    Failed to bring up ra0.
    root@rpiTHC:~/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913# iwconfig
    lo no wireless extensions.

    eth0 no wireless extensions.

    root@rpiTHC:~/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913

    When i looked in the dmesg:

    [ 354.900653] usb 1-1.2: USB disconnect, device number 4
    [ 441.927469] usb 1-1.3: new high-speed USB device number 6 using dwc_otg
    [ 442.394049] usb 1-1.3: New USB device found, idVendor=148f, idProduct=7601
    [ 442.394082] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [ 442.439547] mt7601Usta: disagrees about version of symbol alloc_etherdev_mqs
    [ 442.439588] mt7601Usta: Unknown symbol alloc_etherdev_mqs (err -22)
    [ 442.439707] mt7601Usta: disagrees about version of symbol skb_put
    [ 442.439720] mt7601Usta: Unknown symbol skb_put (err -22)
    [ 442.439770] mt7601Usta: disagrees about version of symbol __netif_schedule
    [ 442.439783] mt7601Usta: Unknown symbol __netif_schedule (err -22)
    [ 442.439951] mt7601Usta: disagrees about version of symbol unregister_netdevice_queue
    [ 442.439965] mt7601Usta: Unknown symbol unregister_netdevice_queue (err -22)
    [ 442.439991] mt7601Usta: disagrees about version of symbol pskb_expand_head
    [ 442.440004] mt7601Usta: Unknown symbol pskb_expand_head (err -22)
    [ 442.440033] mt7601Usta: disagrees about version of symbol eth_type_trans
    [ 442.440044] mt7601Usta: Unknown symbol eth_type_trans (err -22)
    [ 442.440139] mt7601Usta: disagrees about version of symbol skb_copy_expand
    [ 442.440152] mt7601Usta: Unknown symbol skb_copy_expand (err -22)
    [ 442.440206] mt7601Usta: disagrees about version of symbol dev_kfree_skb_any
    [ 442.440219] mt7601Usta: Unknown symbol dev_kfree_skb_any (err -22)
    [ 442.440248] mt7601Usta: disagrees about version of symbol skb_pull
    [ 442.440260] mt7601Usta: Unknown symbol skb_pull (err -22)
    [ 442.440316] mt7601Usta: disagrees about version of symbol dev_close
    [ 442.440329] mt7601Usta: Unknown symbol dev_close (err -22)
    [ 442.440344] mt7601Usta: disagrees about version of symbol skb_push
    [ 442.440357] mt7601Usta: Unknown symbol skb_push (err -22)
    [ 442.440395] mt7601Usta: disagrees about version of symbol wireless_send_event
    [ 442.440407] mt7601Usta: Unknown symbol wireless_send_event (err -22)
    [ 442.440423] mt7601Usta: disagrees about version of symbol register_netdev
    [ 442.440436] mt7601Usta: Unknown symbol register_netdev (err -22)
    [ 442.440458] mt7601Usta: disagrees about version of symbol free_netdev
    [ 442.440470] mt7601Usta: Unknown symbol free_netdev (err -22)
    [ 442.440577] mt7601Usta: disagrees about version of symbol netif_rx
    [ 442.440591] mt7601Usta: Unknown symbol netif_rx (err -22)
    [ 442.440607] mt7601Usta: disagrees about version of symbol __netdev_alloc_skb
    [ 442.440619] mt7601Usta: Unknown symbol __netdev_alloc_skb (err -22)
    [ 442.440641] mt7601Usta: disagrees about version of symbol skb_trim
    [ 442.440653] mt7601Usta: Unknown symbol skb_trim (err -22)
    [ 442.440750] mt7601Usta: disagrees about version of symbol skb_clone
    [ 442.440763] mt7601Usta: Unknown symbol skb_clone (err -22)
    [ 442.440776] mt7601Usta: disagrees about version of symbol dev_get_by_name
    [ 442.440788] mt7601Usta: Unknown symbol dev_get_by_name (err -22)
    [ 442.440903] mt7601Usta: disagrees about version of symbol register_netdevice
    [ 442.440916] mt7601Usta: Unknown symbol register_netdevice (err -22)

    I don`t know what is happening. Look, the usb seems to be ok:

    pi@rpiTHC ~ $ lsusb
    Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
    Bus 001 Device 006: ID 148f:7601 Ralink Technology, Corp.
    Bus 001 Device 005: ID 0781:5567 SanDisk Corp. Cruzer Blade

    So, I have the Bus 001 Device 006: ID 148f:7601 Ralink Technology, Corp. , but it now works!

    Just to be complete:

    pi@rpiTHC ~ $ uname -a
    Linux rpiTHC 3.12.30+ #717 PREEMPT Fri Oct 17 18:46:31 BST 2014 armv6l GNU/Linux

    Can you please give me a hand on this?

    Thanks!

    • va3paw says:

      It’s clear there is a problem with the driver. Try removing and reinstalling the driver module (modprobe).
      Have you noticed any problems during compilation of the driver?

      • dhubax says:

        Thank you man.
        I just had made the entirely process again and IT WORKS ! 😀 Hehehehe… I don’t know wtf happen, but I only repeated everything!

  10. dan says:

    Hi thanks for this. Is there any chance to work this driver with hostapd? I tried under Windows and there is also mediatek app for software app and it is working good so in my opinion it should work also under linux but til now i didnt find out how.

  11. Victor says:

    use

    git clone –depth=1

    if don’t need version and to save your time to donwload head of source codes

  12. Tom va3ts says:

    Thanks for the info .. I’m going to do this on a raspi also , all I’ll need is someone else to mesh with hi… 73 Tom va3ts http://va3ts.ca/projects.php

  13. Gytis says:

    Well, this is a mess. Instead of Realtek 8188CU i got this Ralink.

    Saldy, with the 3.18.7+ your procedure no longer works. You have to edit rt_linux.h and change function signature due to recent changes in kernel (see http://unix.stackexchange.com/a/158032)
    Afther those changes, everything compiles, but compiled driver does not load 😦

    ERROR: failed to load symbols from /lib/modules/3.18.7+/kernel/drivers/net/wireless/mt7601Usta.ko: Invalid argument

    • va3paw says:

      It is a mess. I use a ‘$5 DX-original’ dongle now instead.
      Unfortunately, it has no socket for external antenna so the coverage is lesser. For larger distance or more power, I think something like ALFA would work best.

  14. LRuiz says:

    When I try sudo make I get this error:

    /home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.c:2173:21: warning: unused variable ‘net_dev’ [-Wunused-variable]
    scripts/Makefile.build:257: recipe for target ‘/home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.o’ failed
    make[2]: *** [/home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.o] Error 1
    Makefile:1381: recipe for target ‘_module_/home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux’ failed
    make[1]: *** [_module_/home/pi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux] Error 2
    make[1]: Leaving directory ‘/usr/src/linux’
    Makefile:394: recipe for target ‘LINUX’ failed
    make: *** [LINUX] Error 2

  15. LRuiz says:

    15 days I have been trying to configure the kernel to Dongle USB ID was 148f:7601 (DPO_MT7601U_LinuxSTA_3.0.0.4_20130913) and always gives me errors.

    Anybody can upload the image of Raspbian with kernel configured?

    I appreciate it.

  16. matt2005 says:

    Reblogged this on matt2005.

  17. Pingback: HSMM-Pi :: Corey ReichleCorey Reichle

  18. Denevraut says:

    The «$5 DX.com original» doesn’t work at all for me (Raspberry Pi 2 , Raspbian).
    I’m trying hard but i can’t find a way to instal it’s driver.
    I saw it on the «lsusb» but that’s all «Bus 001 Device 012: ID 148f:7601 Ralink Technology, Corp. »..
    It have the same USB ID 148f:7601 than the antena of this article but the download link is dead for the driver …
    Somebody can help me? or have the same isue?

    • va3paw says:

      Is that the new quad-core Raspberry Pi? I don’t have it so can’t tell how well it works with the wifi dongle. I’d suggest to ask on Raspbian forums.

      • Denevraut says:

        yes, the raspberry pi 2 is the quad-core one. It is suppose to be fully compatible with the normals raspberry pi softwares….

        After many hour of trying, I make a choice and i stop trying..

        I just buy a wifi dungle on ebay at the same price. It work very well. :
        « http://www.ebay.ca/itm/271720332584?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT »

        «ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter»

        Plug and play on RPI2, work well without external powered usb and my speed test give me 10mbps in, 10mbps out (I have 60mbps in 10mbps out in my home).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: