summaryrefslogtreecommitdiff
path: root/usrp2/firmware
diff options
context:
space:
mode:
authorjcorgan2008-12-27 21:09:26 +0000
committerjcorgan2008-12-27 21:09:26 +0000
commit297479844e3d9a6eea54fa69147e6a20c0bfc412 (patch)
tree786591a2e3c8aa77d8149630a6a5d00974585af7 /usrp2/firmware
parenta09700c26a39ebddbeb56b5ecddedf50f0cc7ac4 (diff)
downloadgnuradio-297479844e3d9a6eea54fa69147e6a20c0bfc412.tar.gz
gnuradio-297479844e3d9a6eea54fa69147e6a20c0bfc412.tar.bz2
gnuradio-297479844e3d9a6eea54fa69147e6a20c0bfc412.zip
Implements USRP2 peek() command, allowing arbitrary reads from the internal
Wishbone bus. Minor fix for USRP2 sync_to_pps() (uses correct packet type.) Example: >>> from gnuradio import usrp2 >>> u = usrp2.source_32fc() >>> u.peek(0x1234, 4) # Read four bytes at offset 0x1234 (code) (185, 244, 253, 164) >>> The return value will be zero length upon error. The read address must be 32-bit aligned, and only the lower 16 bits are significant. The length must be an integral multiple of 4 bytes. There is currently a read limit of 176 bytes per read; to change requires some additional firmware changes to allocate a larger reply packet. WARNING: Trying to read from memory locations not serviced by RAM or by a Wishbone peripheral may result in a hang requiring a USRP2 power cycle. The USRP2 internal memory map is documented in usrp2/firmware/lib/memory_map.h. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10172 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'usrp2/firmware')
-rw-r--r--usrp2/firmware/apps/app_common_v2.c28
-rw-r--r--usrp2/firmware/include/usrp2_eth_packet.h23
2 files changed, 43 insertions, 8 deletions
diff --git a/usrp2/firmware/apps/app_common_v2.c b/usrp2/firmware/apps/app_common_v2.c
index 9bb5e4d74..b51c3b23c 100644
--- a/usrp2/firmware/apps/app_common_v2.c
+++ b/usrp2/firmware/apps/app_common_v2.c
@@ -332,6 +332,30 @@ dboard_info_cmd(const op_generic_t *p,
}
static size_t
+peek_cmd(const op_peek_t *p,
+ void *reply_payload, size_t reply_payload_space)
+{
+ op_generic_t *r = (op_generic_t *) reply_payload;
+
+ putstr("peek: addr="); puthex32(p->addr);
+ printf(" bytes=%u\n", p->bytes);
+
+ if (reply_payload_space < (sizeof(*r) + p->bytes)) {
+ putstr("peek: insufficient reply packet space\n");
+ return 0; // FIXME do partial read?
+ }
+
+ r->opcode = OP_PEEK_REPLY;
+ r->len = sizeof(*r)+p->bytes;
+ r->rid = p->rid;
+ r->ok = true;
+
+ memcpy_wa(reply_payload+sizeof(*r), p->addr, p->bytes);
+
+ return r->len;
+}
+
+static size_t
generic_reply(const op_generic_t *p,
void *reply_payload, size_t reply_payload_space,
bool ok)
@@ -435,6 +459,10 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
sync_to_pps((op_generic_t *) payload));
break;
+ case OP_PEEK:
+ subpktlen = peek_cmd((op_peek_t *)payload, reply_payload, reply_payload_space);
+ break;
+
default:
printf("app_common_v2: unhandled opcode = %d\n", gp->opcode);
break;
diff --git a/usrp2/firmware/include/usrp2_eth_packet.h b/usrp2/firmware/include/usrp2_eth_packet.h
index cfff0dd08..8a9994f17 100644
--- a/usrp2/firmware/include/usrp2_eth_packet.h
+++ b/usrp2/firmware/include/usrp2_eth_packet.h
@@ -185,12 +185,8 @@ typedef struct {
#define OP_DBOARD_INFO_REPLY (OP_DBOARD_INFO | OP_REPLY_BIT)
#define OP_SYNC_TO_PPS 10
#define OP_SYNC_TO_PPS_REPLY (OP_SYNC_TO_PPS | OP_REPLY_BIT)
-
-
-//#define OP_WRITE_REG xx // not implemented
-//#define OP_WRITE_REG_MASKED xx
-//#define OP_READ_REG xx
-//#define OP_READ_REG_REPLY xx
+#define OP_PEEK 11
+#define OP_PEEK_REPLY (OP_PEEK | OP_REPLY_BIT)
/*
* All subpackets are a multiple of 4 bytes long.
@@ -203,7 +199,7 @@ typedef struct {
*
* Used by:
* OP_EOP, OP_BURN_MAC_ADDR_REPLY, OP_START_RX_STREAMING_REPLY,
- * OP_STOP_RX_REPLY, OP_DBOARD_INFO
+ * OP_STOP_RX_REPLY, OP_DBOARD_INFO, OP_SYNC_TO_PPS
*/
typedef struct {
uint8_t opcode;
@@ -380,7 +376,17 @@ typedef struct {
u2_db_info_t rx_db_info;
} _AL4 op_dboard_info_reply_t;
-
+/*!
+ * \brief Read from Wishbone memory
+ */
+typedef struct {
+ uint8_t opcode;
+ uint8_t len;
+ uint8_t rid;
+ uint8_t mbz;
+ uint32_t addr;
+ uint32_t bytes;
+} _AL4 op_peek_t;
/*
* ================================================================
@@ -399,6 +405,7 @@ typedef union {
op_config_tx_v2_t op_config_tx_v2;
op_config_tx_reply_v2_t op_config_tx_reply_v2;
op_config_mimo_t op_config_mimo;
+ op_peek_t op_peek;
} u2_subpkt_t;