aboutsummaryrefslogtreecommitdiffstats
path: root/host/apps
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-18 08:15:15 +0000
committerJosh Blum <josh@joshknows.com>2010-03-18 08:15:15 +0000
commitd105f614477c7f2a4f24a4efc802de7eb750bd7a (patch)
tree6c5f6e615f153862e546e5fb3879a400b73bfec1 /host/apps
parent5de235715b36ef9a98ea418832a5382cbf25d4d6 (diff)
parentf2a86eb6389210a8ebd475782ab707f814c6e49c (diff)
downloaduhd-d105f614477c7f2a4f24a4efc802de7eb750bd7a.tar.gz
uhd-d105f614477c7f2a4f24a4efc802de7eb750bd7a.tar.bz2
uhd-d105f614477c7f2a4f24a4efc802de7eb750bd7a.zip
Merge branch 'master' of git@ettus.sourcerepo.com:ettus/uhd into u1e_uhd
Diffstat (limited to 'host/apps')
-rw-r--r--host/apps/usrp2_burner.cpp1
-rwxr-xr-xhost/apps/usrp2_recovery.py52
2 files changed, 53 insertions, 0 deletions
diff --git a/host/apps/usrp2_burner.cpp b/host/apps/usrp2_burner.cpp
index 08ec8daf9..941e71d0c 100644
--- a/host/apps/usrp2_burner.cpp
+++ b/host/apps/usrp2_burner.cpp
@@ -79,5 +79,6 @@ int main(int argc, char *argv[]){
std::cout << " Done" << std::endl;
}
+ std::cout << "Power-cycle the usrp2 for the changes to take effect." << std::endl;
return 0;
}
diff --git a/host/apps/usrp2_recovery.py b/host/apps/usrp2_recovery.py
new file mode 100755
index 000000000..48c1121cb
--- /dev/null
+++ b/host/apps/usrp2_recovery.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+"""
+The usrp2 recovery app:
+
+When the usrp2 has an unknown or bad ip address in its eeprom,
+it may not be possible to communicate with the usrp2 over ip/udp.
+
+This app will send a raw ethernet packet to bypass the ip layer.
+The packet will contain a known ip address to burn into eeprom.
+Because the recovery packet is sent with a broadcast mac address,
+only one usrp2 should be present on the interface upon execution.
+
+This app requires super-user privileges and only works on linux.
+"""
+
+import socket
+import struct
+import optparse
+
+BCAST_MAC_ADDR = 'ff:ff:ff:ff:ff:ff'
+RECOVERY_ETHERTYPE = 0xbeee
+IP_RECOVERY_CODE = 'addr'
+
+def mac_addr_repr_to_binary_string(mac_addr):
+ return ''.join(map(lambda x: chr(int(x, 16)), mac_addr.split(':')))
+
+if __name__ == '__main__':
+ parser = optparse.OptionParser(usage='usage: %prog [options]\n'+__doc__)
+ parser.add_option('--ifc', type='string', help='ethernet interface name [default=%default]', default='eth0')
+ parser.add_option('--new-ip', type='string', help='ip address to set [default=%default]', default='192.168.10.2')
+ (options, args) = parser.parse_args()
+
+ #create the raw socket
+ print "Opening raw socket on interface:", options.ifc
+ soc = socket.socket(socket.PF_PACKET, socket.SOCK_RAW)
+ soc.bind((options.ifc, RECOVERY_ETHERTYPE))
+
+ #create the recovery packet
+ print "Loading packet with ip address:", options.new_ip
+ packet = struct.pack(
+ '!6s6sH4s4s',
+ mac_addr_repr_to_binary_string(BCAST_MAC_ADDR),
+ mac_addr_repr_to_binary_string(BCAST_MAC_ADDR),
+ RECOVERY_ETHERTYPE,
+ IP_RECOVERY_CODE,
+ socket.inet_aton(options.new_ip),
+ )
+
+ print "Sending packet (%d bytes)"%len(packet)
+ soc.send(packet)
+ print "Done"