aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/usrp3/x300
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2016-06-23 11:15:30 -0700
committerAshish Chaudhari <ashish@ettus.com>2016-06-23 11:15:30 -0700
commitabc4790ae4be6d542ea39c8ce42045c3fec40b9d (patch)
tree7f5717ee8c48f874ff8325ef56da62367404e9e6 /firmware/usrp3/x300
parentef57ffcbbf33f16d4fecb73749e3bb0fc4cd473d (diff)
downloaduhd-abc4790ae4be6d542ea39c8ce42045c3fec40b9d.tar.gz
uhd-abc4790ae4be6d542ea39c8ce42045c3fec40b9d.tar.bz2
uhd-abc4790ae4be6d542ea39c8ce42045c3fec40b9d.zip
x300: Fixed FW debug script after N230 merge breakage
Diffstat (limited to 'firmware/usrp3/x300')
-rwxr-xr-xfirmware/usrp3/x300/x300_debug.py58
1 files changed, 17 insertions, 41 deletions
diff --git a/firmware/usrp3/x300/x300_debug.py b/firmware/usrp3/x300/x300_debug.py
index c518ba4e0..1596929ad 100755
--- a/firmware/usrp3/x300/x300_debug.py
+++ b/firmware/usrp3/x300/x300_debug.py
@@ -27,16 +27,10 @@ import struct
########################################################################
X300_FW_COMMS_UDP_PORT = 49152
-X300_FW_COMMS_FLAGS_ACK = 0x00000001
-X300_FW_COMMS_FLAGS_POKE32 = 0x00000010
-X300_FW_COMMS_FLAGS_PEEK32 = 0x00000020
-
-X300_FW_COMMS_ERR_PKT_ERROR = 0x80000000
-X300_FW_COMMS_ERR_CMD_ERROR = 0x40000000
-X300_FW_COMMS_ERR_SIZE_ERROR = 0x20000000
-
-X300_FW_COMMS_ID = 0x0000ACE3
-X300_FW_COMMS_MAX_DATA_WORDS = 16
+X300_FW_COMMS_FLAGS_ACK = 1
+X300_FW_COMMS_FLAGS_ERROR = 2
+X300_FW_COMMS_FLAGS_POKE32 = 4
+X300_FW_COMMS_FLAGS_PEEK32 = 8
#UDP_CTRL_PORT = 49183
UDP_MAX_XFER_BYTES = 1024
@@ -45,7 +39,7 @@ UDP_TIMEOUT = 3
#REG_ARGS_FMT = '!LLLLLB15x'
#REG_IP_FMT = '!LLLL20x'
-REG_PEEK_POKE_FMT = '!LLLLL'
+REG_PEEK_POKE_FMT = '!LLLL'
_seq = -1
@@ -58,33 +52,12 @@ def seq():
########################################################################
# helper functions
########################################################################
-def fw_check_error(flags):
- if flags & X300_FW_COMMS_ERR_PKT_ERROR == X300_FW_COMMS_ERR_PKT_ERROR:
- raise Exception("The fiwmware operation returned a packet error")
- if flags & X300_FW_COMMS_ERR_CMD_ERROR == X300_FW_COMMS_ERR_CMD_ERROR:
- raise Exception("The fiwmware operation returned a command error")
- if flags & X300_FW_COMMS_ERR_SIZE_ERROR == X300_FW_COMMS_ERR_SIZE_ERROR:
- raise Exception("The fiwmware operation returned a size error")
+
+def unpack_reg_peek_poke_fmt(s):
+ return struct.unpack(REG_PEEK_POKE_FMT,s) #(flags, seq, addr, data)
def pack_reg_peek_poke_fmt(flags, seq, addr, data):
- num_words = 1
- data_arr = [data]
- buf = bytes()
- buf = struct.pack('!LLLLL', X300_FW_COMMS_ID, flags, seq, num_words, addr)
- for i in range(X300_FW_COMMS_MAX_DATA_WORDS):
- if (i < num_words):
- buf += struct.pack('!L', data_arr[i])
- else:
- buf += struct.pack('!L', 0)
- return buf
-
-def unpack_reg_peek_poke_fmt(buf):
- (id, flags, seq, num_words, addr) = struct.unpack_from('!LLLLL', buf)
- fw_check_error(flags)
- data = []
- for i in xrange(20, len(buf), 4):
- data.append(struct.unpack('!L', buf[i:i+4])[0])
- return (flags, seq, addr, data[0])
+ return struct.pack(REG_PEEK_POKE_FMT, flags, seq, addr, data);
########################################################################
# Burner class, holds a socket and send/recv routines
@@ -122,7 +95,8 @@ class ctrl_socket(object):
out_pkt = pack_reg_peek_poke_fmt(X300_FW_COMMS_FLAGS_PEEK32|X300_FW_COMMS_FLAGS_ACK, seq(), 0xA000+256+((in_prt*8+out_prt)*4), 0)
in_pkt = self.send_and_recv(out_pkt)
(flags, rxseq, addr, data) = unpack_reg_peek_poke_fmt(in_pkt)
- fw_check_error(flags)
+ if flags & X300_FW_COMMS_FLAGS_ERROR == X300_FW_COMMS_FLAGS_ERROR:
+ raise Exception("X300 peek returns error code")
print("%10d " % (data)),
print
print
@@ -134,14 +108,16 @@ class ctrl_socket(object):
out_pkt = pack_reg_peek_poke_fmt(X300_FW_COMMS_FLAGS_PEEK32|X300_FW_COMMS_FLAGS_ACK, seq(), peek_addr, 0)
in_pkt = self.send_and_recv(out_pkt)
(flags, rxseq, addr, data) = unpack_reg_peek_poke_fmt(in_pkt)
- fw_check_error(flags)
+ if flags & X300_FW_COMMS_FLAGS_ERROR == X300_FW_COMMS_FLAGS_ERROR:
+ raise Exception("X300 peek of address %d returns error code" % (addr))
print("PEEK of address %d(0x%x) reads %d(0x%x)" % (addr,addr,data,data))
def poke(self,poke_addr,poke_data):
out_pkt = pack_reg_peek_poke_fmt(X300_FW_COMMS_FLAGS_POKE32|X300_FW_COMMS_FLAGS_ACK, seq(), poke_addr, poke_data)
in_pkt = self.send_and_recv(out_pkt)
(flags, rxseq, addr, data) = unpack_reg_peek_poke_fmt(in_pkt)
- fw_check_error(flags)
+ if flags & X300_FW_COMMS_FLAGS_ERROR == X300_FW_COMMS_FLAGS_ERROR:
+ raise Exception("X300 peek of address %d returns error code" % (addr))
print("POKE of address %d(0x%x) with %d(0x%x)" % (poke_addr,poke_addr,poke_data,poke_data) )
@@ -150,12 +126,12 @@ class ctrl_socket(object):
########################################################################
def get_options():
parser = optparse.OptionParser()
- parser.add_option("--addr", type="string", help="USRP-X300 device address", default='')
+ parser.add_option("--addr", type="string", help="USRP-X3X0 device address", default='')
parser.add_option("--list", action="store_true", help="list possible network devices", default=False)
parser.add_option("--peek", type="int", help="Read from memory map", default=None)
parser.add_option("--poke", type="int", help="Write to memory map", default=None)
parser.add_option("--data", type="int", help="Data for poke", default=None)
- parser.add_option("--stats", action="store_true", help="Display SuperMIMO Network Stats", default=False)
+ parser.add_option("--stats", action="store_true", help="Display SuperMIMO Network Stats", default=False)
(options, args) = parser.parse_args()
return options