[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7139 - in usrp2/trunk: firmware firmware/apps firmwar
From: |
eb |
Subject: |
[Commit-gnuradio] r7139 - in usrp2/trunk: firmware firmware/apps firmware/include firmware/lib fpga/control_lib fpga/top/u2_fpga host host/apps host/lib |
Date: |
Wed, 12 Dec 2007 18:41:46 -0700 (MST) |
Author: eb
Date: 2007-12-12 18:41:45 -0700 (Wed, 12 Dec 2007)
New Revision: 7139
Added:
usrp2/trunk/firmware/include/usrp2_bytesex.h
usrp2/trunk/host/apps/find_usrps.cc
Modified:
usrp2/trunk/firmware/apps/blink_leds.c
usrp2/trunk/firmware/apps/blink_leds2.c
usrp2/trunk/firmware/apps/gen_eth_packets.c
usrp2/trunk/firmware/apps/rcv_eth_packets.c
usrp2/trunk/firmware/apps/rx_only.c
usrp2/trunk/firmware/bootstrap
usrp2/trunk/firmware/configure.ac
usrp2/trunk/firmware/include/usrp2_eth_packet.h
usrp2/trunk/firmware/lib/memory_map.h
usrp2/trunk/fpga/control_lib/buffer_pool.v
usrp2/trunk/fpga/top/u2_fpga/u2_fpga.ise
usrp2/trunk/fpga/top/u2_fpga/u2_fpga_top.prj
usrp2/trunk/host/Makefile.common
usrp2/trunk/host/apps/
usrp2/trunk/host/apps/Makefile.am
usrp2/trunk/host/configure.ac
usrp2/trunk/host/lib/usrp2_basic.cc
usrp2/trunk/host/lib/usrp2_basic.h
Log:
Work-in-progress: host can now locate usrps over the ethernet
Modified: usrp2/trunk/firmware/apps/blink_leds.c
===================================================================
--- usrp2/trunk/firmware/apps/blink_leds.c 2007-12-12 23:38:08 UTC (rev
7138)
+++ usrp2/trunk/firmware/apps/blink_leds.c 2007-12-13 01:41:45 UTC (rev
7139)
@@ -15,6 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "u2_init.h"
#include "memory_map.h"
#include "hal_io.h"
Modified: usrp2/trunk/firmware/apps/blink_leds2.c
===================================================================
--- usrp2/trunk/firmware/apps/blink_leds2.c 2007-12-12 23:38:08 UTC (rev
7138)
+++ usrp2/trunk/firmware/apps/blink_leds2.c 2007-12-13 01:41:45 UTC (rev
7139)
@@ -15,6 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "u2_init.h"
#include "memory_map.h"
#include "hal_io.h"
Modified: usrp2/trunk/firmware/apps/gen_eth_packets.c
===================================================================
--- usrp2/trunk/firmware/apps/gen_eth_packets.c 2007-12-12 23:38:08 UTC (rev
7138)
+++ usrp2/trunk/firmware/apps/gen_eth_packets.c 2007-12-13 01:41:45 UTC (rev
7139)
@@ -15,6 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "u2_init.h"
#include "memory_map.h"
#include "spi.h"
Modified: usrp2/trunk/firmware/apps/rcv_eth_packets.c
===================================================================
--- usrp2/trunk/firmware/apps/rcv_eth_packets.c 2007-12-12 23:38:08 UTC (rev
7138)
+++ usrp2/trunk/firmware/apps/rcv_eth_packets.c 2007-12-13 01:41:45 UTC (rev
7139)
@@ -15,6 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "u2_init.h"
#include "memory_map.h"
#include "spi.h"
Modified: usrp2/trunk/firmware/apps/rx_only.c
===================================================================
--- usrp2/trunk/firmware/apps/rx_only.c 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/firmware/apps/rx_only.c 2007-12-13 01:41:45 UTC (rev 7139)
@@ -15,6 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "u2_init.h"
#include "memory_map.h"
#include "spi.h"
@@ -76,23 +80,23 @@
}
static void
-handle_control_chan_frame(int bufno, u2_eth_packet_t *pkt)
+handle_control_chan_frame(int bufno, u2_eth_packet_t *pkt, size_t len)
{
- unsigned char buf[512];
- unsigned char reply[sizeof(u2_eth_packet_t) + sizeof(u2_subpkt_t)] _AL4;
+ static unsigned char buf[256] _AL4;
+ static unsigned char reply[sizeof(u2_eth_packet_t) + sizeof(u2_subpkt_t)]
_AL4;
unsigned char *s = &reply[sizeof(u2_eth_packet_t)];
size_t reply_len = 0;
- // FIXME check packet length...
// copy 512 bytes of payload into stack buffer
unsigned char *src =
- (unsigned char *) buffer_ram(bufno) + offsetof(u2_eth_packet_t,
fixed.payload);
-
+ (unsigned char *) buffer_ram(bufno) + offsetof(u2_eth_packet_t,
+ fixed.payload);
memcpy_wordaligned(buf, src, sizeof(buf));
unsigned char *p = buf;
int opcode = p[0];
+
switch(opcode){
case OP_ID:
memset(reply, 0, sizeof(reply));
@@ -100,10 +104,12 @@
{
op_id_reply_t *r = (op_id_reply_t *) s;
reply_len = sizeof(u2_eth_packet_t) + sizeof(op_id_reply_t);
+ if (reply_len < 64)
+ reply_len = 64;
r->opcode = OP_ID_REPLY;
r->len = sizeof(op_id_reply_t);
r->rid_mbz = 0; // FIXME
- memcpy(r->mac_addr, eth_mac_addr(), sizeof(r->mac_addr));
+ memcpy(r->mac_addr, eth_mac_addr(), 6);
r->hw_rev = 0x0000; // FIXME
// r->serial_no = ; // FIXME
// r->fpga_md5sum = ; // FIXME
@@ -116,11 +122,6 @@
memcpy_wordaligned(buffer_ram(CPU_TX_BUF), reply, reply_len);
bp_send_from_buf(CPU_TX_BUF, PORT_ETH, 1, 0, reply_len / 4);
-
- // FIXME shouldn't really wait here
- while ((buffer_pool_status->status & BPS_DONE(CPU_TX_BUF)) == 0)
- ;
- bp_clear_buf(CPU_TX_BUF);
break;
@@ -135,26 +136,51 @@
handle_rcvd_eth_frame(int bufno)
{
u2_eth_packet_t pkt;
+ int i;
+ size_t byte_len = (buffer_pool_status->last_line[bufno] - 1) * 4;
+ hal_toggle_leds(0x1);
+
// inspect rcvd frame and figure out what do do.
// copy first part of frame to stack buffer so we can byte address it
- memcpy_wordaligned(&pkt, (void *)buffer_ram(bufno), sizeof(pkt));
+ memcpy_wordaligned(&pkt, buffer_ram(bufno), sizeof(pkt));
+#if 1
if (pkt.ehdr.ethertype != U2_ETHERTYPE)
return; // ignore, probably bogus PAUSE frame from MAC
+
int chan = u2p_chan(&pkt.fixed);
-
switch (chan){
case CONTROL_CHAN:
- handle_control_chan_frame(bufno, &pkt);
+ hal_toggle_leds(0x2);
+ handle_control_chan_frame(bufno, &pkt, byte_len);
break;
case 0: // to Tx DSP
default:
break;
}
+#else
+
+ if (pkt.ehdr.ethertype != U2_ETHERTYPE)
+ return; // ignore, probably bogus PAUSE frame from MAC
+
+ // copy src to dst, and send it back
+ for (i = 0; i < 6; i++)
+ pkt.ehdr.dst_addr[i] = pkt.ehdr.src_addr[i];
+
+ memcpy_wordaligned((void *)buffer_ram(bufno), &pkt, sizeof(pkt));
+
+ bp_send_from_buf(CPU_RX_BUF, PORT_ETH, 1,
+ 0, byte_len / 4);
+
+ while((buffer_pool_status->status & BPS_DONE(CPU_RX_BUF)) == 0)
+ ;
+
+ bp_clear_buf(CPU_RX_BUF);
+#endif
}
void
@@ -169,11 +195,15 @@
// FIXME probably ought to round-robin the check for done
if (status & BPS_DONE(CPU_RX_BUF)){ // we've rcvd a frame from ethernet
- bp_clear_buf(0);
+ bp_clear_buf(CPU_RX_BUF);
handle_rcvd_eth_frame(CPU_RX_BUF);
bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, 255);
}
+ if (status & BPS_DONE(CPU_TX_BUF)){
+ bp_clear_buf(CPU_TX_BUF);
+ }
+
// FIXME if we're streaming...
}
@@ -208,6 +238,8 @@
bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, 255);
while(1){
+ // buffer_irq_handler(0);
+
// FIXME perhaps handle low-pri stuff here
}
}
@@ -251,7 +283,7 @@
hal_gpio_set_tx(v, LS_MASK); /* set debug bits on d'board */
- hal_set_leds(link_is_up ? 0x2 : 0x0, 0x2);
+ // hal_set_leds(link_is_up ? 0x2 : 0x0, 0x2);
putstr("\neth link changed: speed = ");
puthex16_nl(speed);
Modified: usrp2/trunk/firmware/bootstrap
===================================================================
--- usrp2/trunk/firmware/bootstrap 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/firmware/bootstrap 2007-12-13 01:41:45 UTC (rev 7139)
@@ -24,7 +24,7 @@
aclocal
autoconf
-# autoheader
+autoheader
# libtoolize --automake
automake --add-missing -Wno-portability
Modified: usrp2/trunk/firmware/configure.ac
===================================================================
--- usrp2/trunk/firmware/configure.ac 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/firmware/configure.ac 2007-12-13 01:41:45 UTC (rev 7139)
@@ -17,7 +17,7 @@
AC_INIT
AC_PREREQ(2.57)
-dnl AM_CONFIG_HEADER(config.h)
+AM_CONFIG_HEADER(config.h)
AC_CONFIG_SRCDIR([lib/u2_init.c])
AM_INIT_AUTOMAKE(u2f,0.0svn)
@@ -32,6 +32,9 @@
dnl AC_PROG_RANLIB([mb-ranlib])
+AC_CHECK_HEADERS(arpa/inet.h netinet/in.h byteswap.h)
+AC_C_BIGENDIAN
+
AC_CONFIG_FILES([\
Makefile \
apps/Makefile \
Added: usrp2/trunk/firmware/include/usrp2_bytesex.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_bytesex.h
(rev 0)
+++ usrp2/trunk/firmware/include/usrp2_bytesex.h 2007-12-13 01:41:45 UTC
(rev 7139)
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_USRP2_BYTESEX_H
+#define INCLUDED_USRP2_BYTESEX_H
+
+// The USRP2 speaks big-endian...
+// Use the standard include files or provide substitutions for
+// htons and friends
+
+#if defined(HAVE_ARPA_INET_H)
+#include <arpa/inet.h>
+#elif defined(HAVE_NETINET_IN_H)
+#include <netinet/in.h>
+#else
+#include <stdint.h>
+
+#ifdef WORDS_BIGENDIAN // nothing to do...
+
+static inline uint32_t htonl(uint32_t x){ return x; }
+static inline uint16_t htons(uint16_t x){ return x; }
+static inline uint32_t ntohl(uint32_t x){ return x; }
+static inline uint16_t ntohs(uint16_t x){ return x; }
+
+#else
+
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#else
+
+static inline uint16_t
+bswap_16 (uint16_t x)
+{
+ return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
+}
+
+static inline uint32_t
+bswap_32 (uint32_t x)
+{
+ return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
+ | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
+}
+#endif
+
+static inline uint32_t htonl(uint32_t x){ return bswap_32(x); }
+static inline uint16_t htons(uint16_t x){ return bswap_16(x); }
+static inline uint32_t ntohl(uint32_t x){ return bswap_32(x); }
+static inline uint16_t ntohs(uint16_t x){ return bswap_16(x); }
+
+#endif
+#endif
+#endif /* INCLUDED_USRP2_BYTESEX_H */
Property changes on: usrp2/trunk/firmware/include/usrp2_bytesex.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: usrp2/trunk/firmware/include/usrp2_eth_packet.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_eth_packet.h 2007-12-12 23:38:08 UTC
(rev 7138)
+++ usrp2/trunk/firmware/include/usrp2_eth_packet.h 2007-12-13 01:41:45 UTC
(rev 7139)
@@ -20,6 +20,7 @@
#define INCLUDED_USRP2_ETH_PACKET_H
#include "usrp2_cdefs.h"
+#include "usrp2_bytesex.h"
#include <stdint.h>
__U2_BEGIN_DECLS
@@ -98,16 +99,34 @@
static inline int
u2p_chan(u2_eth_fixed_hdr_t *p)
{
- return (p->word0 >> U2P_CHAN_SHIFT) & U2P_CHAN_MASK;
+ return (ntohl(p->word0) >> U2P_CHAN_SHIFT) & U2P_CHAN_MASK;
}
+inline static uint32_t
+u2p_word0(u2_eth_fixed_hdr_t *p)
+{
+ return ntohl(p->word0);
+}
+
+inline static uint32_t
+u2p_timestamp(u2_eth_fixed_hdr_t *p)
+{
+ return ntohl(p->timestamp);
+}
+
inline static void
u2p_set_word0(u2_eth_fixed_hdr_t *p, int flags, int chan)
{
- p->word0 = ((flags & U2P_ALL_FLAGS)
- | ((chan & U2P_CHAN_MASK) << U2P_CHAN_SHIFT));
+ p->word0 = htonl((flags & U2P_ALL_FLAGS)
+ | ((chan & U2P_CHAN_MASK) << U2P_CHAN_SHIFT));
}
+inline static void
+u2p_set_timestamp(u2_eth_fixed_hdr_t *p, uint32_t ts)
+{
+ p->timestamp = htonl(ts);
+}
+
/*
* consolidated packet: ethernet header + pad + payload
*/
Modified: usrp2/trunk/firmware/lib/memory_map.h
===================================================================
--- usrp2/trunk/firmware/lib/memory_map.h 2007-12-12 23:38:08 UTC (rev
7138)
+++ usrp2/trunk/firmware/lib/memory_map.h 2007-12-13 01:41:45 UTC (rev
7139)
@@ -169,29 +169,39 @@
#define buffer_pool_status ((buffer_pool_status_t *) BUFFER_POOL_STATUS_BASE)
-#define BPS_DONE_0 0x0001 // buffer 0 xfer is done
-#define BPS_DONE_1 0x0002 // buffer 1 xfer is done
-#define BPS_DONE_2 0x0004 // buffer 2 xfer is done
-#define BPS_DONE_3 0x0008 // buffer 3 xfer is done
-#define BPS_DONE_4 0x0010 // buffer 4 xfer is done
-#define BPS_DONE_5 0x0020 // buffer 5 xfer is done
-#define BPS_DONE_6 0x0040 // buffer 6 xfer is done
-#define BPS_DONE_7 0x0080 // buffer 7 xfer is done
-#define BPS_DONE(n) (BPS_DONE_0 << (n))
+#define BPS_DONE(n) (0x00000001 << (n)) // buffer n xfer is done
+#define BPS_DONE_0 BPS_DONE(0)
+#define BPS_DONE_1 BPS_DONE(1)
+#define BPS_DONE_2 BPS_DONE(2)
+#define BPS_DONE_3 BPS_DONE(3)
+#define BPS_DONE_4 BPS_DONE(4)
+#define BPS_DONE_5 BPS_DONE(5)
+#define BPS_DONE_6 BPS_DONE(6)
+#define BPS_DONE_7 BPS_DONE(7)
+#define BPS_ERROR(n) (0x00000100 << (n)) // buffer n had error
+#define BPS_ERROR_0 BPS_ERROR(0)
+#define BPS_ERROR_1 BPS_ERROR(1)
+#define BPS_ERROR_2 BPS_ERROR(2)
+#define BPS_ERROR_3 BPS_ERROR(3)
+#define BPS_ERROR_4 BPS_ERROR(4)
+#define BPS_ERROR_5 BPS_ERROR(5)
+#define BPS_ERROR_6 BPS_ERROR(6)
+#define BPS_ERROR_7 BPS_ERROR(7)
-#define BPS_ERROR_0 0x0100 // buffer 0 xfer had error
-#define BPS_ERROR_1 0x0200 // buffer 1 xfer had error
-#define BPS_ERROR_2 0x0400 // buffer 2 xfer had error
-#define BPS_ERROR_3 0x0800 // buffer 3 xfer had error
-#define BPS_ERROR_4 0x1000 // buffer 4 xfer had error
-#define BPS_ERROR_5 0x2000 // buffer 5 xfer had error
-#define BPS_ERROR_6 0x4000 // buffer 6 xfer had error
-#define BPS_ERROR_7 0x8000 // buffer 7 xfer had error
-#define BPS_ERROR(n) (BPS_ERROR_0 << (n))
+#define BPS_IDLE(n) (0x00010000 << (n)) // buffer n is idle
+#define BPS_IDLE_0 BPS_IDLE(0)
+#define BPS_IDLE_1 BPS_IDLE(1)
+#define BPS_IDLE_2 BPS_IDLE(2)
+#define BPS_IDLE_3 BPS_IDLE(3)
+#define BPS_IDLE_4 BPS_IDLE(4)
+#define BPS_IDLE_5 BPS_IDLE(5)
+#define BPS_IDLE_6 BPS_IDLE(6)
+#define BPS_IDLE_7 BPS_IDLE(7)
-#define BPS_DONE_ALL 0x00ff // mask of all done
-#define BPS_ERROR_ALL 0xff00 // mask of all errors
+#define BPS_DONE_ALL 0x000000ff // mask of all dones
+#define BPS_ERROR_ALL 0x0000ff00 // mask of all errors
+#define PBS_IDLE_ALL 0x00ff0000 // mask of all idles
// The hw_config register
Modified: usrp2/trunk/fpga/control_lib/buffer_pool.v
===================================================================
--- usrp2/trunk/fpga/control_lib/buffer_pool.v 2007-12-12 23:38:08 UTC (rev
7138)
+++ usrp2/trunk/fpga/control_lib/buffer_pool.v 2007-12-13 01:41:45 UTC (rev
7139)
@@ -63,7 +63,6 @@
wire [7:0] done;
wire [7:0] error;
- wire [7:0] idle;
wire [31:0] buf_doa[0:7];
@@ -87,7 +86,7 @@
wire [7:0] rd_sop_o;
wire [7:0] rd_eop_o;
- assign status = {8'd0,idle[7:0],error[7:0],done[7:0]};
+ assign status = {16'd0,error[7:0],done[7:0]};
assign s0 = {23'd0,buf_addrb[0]};
assign s1 = {23'd0,buf_addrb[1]};
@@ -134,11 +133,18 @@
generate
for(i=0;i<8;i=i+1)
begin : gen_buffer
- ram_2port #(.DWIDTH(32),.AWIDTH(9)) buffer
+ RAMB16_S36_S36 dpram
+
(.DOA(buf_doa[i]),.ADDRA(buf_addra),.CLKA(wb_clk_i),.DIA(wb_dat_i),.DIPA(4'h0),
+ .ENA(wb_stb_i & sel_a[i]),.SSRA(),.WEA(wb_we_i),
+
.DOB(buf_dob[i]),.ADDRB(buf_addrb[i]),.CLKB(stream_clk),.DIB(buf_dib[i]),.DIPB(4'h0),
+ .ENB(buf_enb[i]),.SSRB(),.WEB(buf_web[i]) );
+
+ /* ram_2port #(.DWIDTH(32),.AWIDTH(9)) buffer
(.clka(wb_clk_i),.ena(wb_stb_i & sel_a[i]),.wea(wb_we_i),
.addra(buf_addra),.dia(wb_dat_i),.doa(buf_doa[i]),
.clkb(stream_clk),.enb(buf_enb[i]),.web(buf_web[i]),
- .addrb(buf_addrb[i]),.dib(buf_dib[i]),.dob(buf_dob[i]));
+ .addrb(buf_addrb[i]),.dib(buf_dib[i]),.dob(buf_dob[i])); */
+
buffer_int #(.BUFF_NUM(i)) fifo_int
(.clk(stream_clk),.rst(stream_rst),
.ctrl_word(fifo_ctrl),.go(go & (fifo_ctrl[31:28]==i)),
Modified: usrp2/trunk/fpga/top/u2_fpga/u2_fpga.ise
===================================================================
(Binary files differ)
Modified: usrp2/trunk/fpga/top/u2_fpga/u2_fpga_top.prj
===================================================================
--- usrp2/trunk/fpga/top/u2_fpga/u2_fpga_top.prj 2007-12-12 23:38:08 UTC
(rev 7138)
+++ usrp2/trunk/fpga/top/u2_fpga/u2_fpga_top.prj 2007-12-13 01:41:45 UTC
(rev 7139)
@@ -26,7 +26,6 @@
verilog work "../../eth/rtl/verilog/Reg_int.v"
verilog work "../../eth/rtl/verilog/RMON/RMON_ctrl.v"
verilog work "../../eth/rtl/verilog/RMON/RMON_addr_gen.v"
-verilog work "../../eth/rtl/verilog/MAC_tx/flow_ctrl.v"
verilog work "../../eth/rtl/verilog/MAC_tx/Ramdon_gen.v"
verilog work "../../eth/rtl/verilog/MAC_tx/MAC_tx_ctrl.v"
verilog work "../../eth/rtl/verilog/MAC_tx/MAC_tx_addr_add.v"
@@ -56,6 +55,8 @@
verilog work "../../opencores/spi/rtl/verilog/spi_clgen.v"
verilog work "../../opencores/i2c/rtl/verilog/i2c_master_byte_ctrl.v"
verilog work "../../opencores/aemb/rtl/verilog/aeMB_edk32.v"
+verilog work "../../eth/rtl/verilog/flow_ctrl_tx.v"
+verilog work "../../eth/rtl/verilog/flow_ctrl_rx.v"
verilog work "../../eth/rtl/verilog/eth_miim.v"
verilog work "../../eth/rtl/verilog/RMON.v"
verilog work "../../eth/rtl/verilog/Phy_int.v"
Modified: usrp2/trunk/host/Makefile.common
===================================================================
--- usrp2/trunk/host/Makefile.common 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/host/Makefile.common 2007-12-13 01:41:45 UTC (rev 7139)
@@ -16,4 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-STD_DEFINES_AND_INCLUDES = -I$(top_srcdir)/../firmware/include
+STD_DEFINES_AND_INCLUDES = \
+ -I$(top_srcdir)/../firmware/include \
+ -I$(top_srcdir)/lib
Property changes on: usrp2/trunk/host/apps
___________________________________________________________________
Name: svn:ignore
- *-stamp
*.a
*.bin
*.dump
*.log
*.rom
.deps
Makefile
Makefile.in
aclocal.m4
autom4te.cache
blink_leds
blink_leds2
build
compile
config.h
config.h.in
config.log
config.status
configure
depcomp
eth_test
gen_eth_packets
ibs_rx_test
ibs_tx_test
install-sh
libtool
ltmain.sh
missing
py-compile
rcv_eth_packets
run_tests.sh
stamp-h1
test1
test_phy_comm
timer_test
buf_ram_test
buf_ram_zero
hello
+ *-stamp
*.a
*.bin
*.dump
*.log
*.rom
.deps
Makefile
Makefile.in
aclocal.m4
autom4te.cache
blink_leds
blink_leds2
build
compile
config.h
config.h.in
config.log
config.status
configure
depcomp
eth_test
gen_eth_packets
ibs_rx_test
ibs_tx_test
install-sh
libtool
ltmain.sh
missing
py-compile
rcv_eth_packets
run_tests.sh
stamp-h1
test1
test_phy_comm
timer_test
buf_ram_test
buf_ram_zero
hello
find_usrps
Modified: usrp2/trunk/host/apps/Makefile.am
===================================================================
--- usrp2/trunk/host/apps/Makefile.am 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/host/apps/Makefile.am 2007-12-13 01:41:45 UTC (rev 7139)
@@ -17,3 +17,12 @@
include $(top_srcdir)/Makefile.common
+INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES)
+
+LDADD = ../lib/libusrp2.la
+
+bin_PROGRAMS = \
+ find_usrps
+
+find_usrps_SOURCES = find_usrps.cc
+
Added: usrp2/trunk/host/apps/find_usrps.cc
===================================================================
--- usrp2/trunk/host/apps/find_usrps.cc (rev 0)
+++ usrp2/trunk/host/apps/find_usrps.cc 2007-12-13 01:41:45 UTC (rev 7139)
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "usrp2_basic.h"
+#include <iostream>
+
+
+int
+main(int argc, char **argv)
+{
+ const char *interface = "eth0";
+ usrp2_basic *u2 = new usrp2_basic();
+
+ if (!u2->open(interface)){
+ std::cerr << "couldn't open " << interface << std::endl;
+ return 0;
+ }
+
+ std::vector<op_id_reply_t> r = u2->find_usrps();
+
+ for (size_t i = 0; i < r.size(); i++){
+ std::cout << r[i] << std::endl;
+ }
+
+}
Property changes on: usrp2/trunk/host/apps/find_usrps.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: usrp2/trunk/host/configure.ac
===================================================================
--- usrp2/trunk/host/configure.ac 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/host/configure.ac 2007-12-13 01:41:45 UTC (rev 7139)
@@ -115,6 +115,8 @@
dnl AC_CHECK_HEADERS(linux/ppdev.h sys/mman.h sys/select.h sys/types.h)
dnl AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/syscall.h)
+AC_CHECK_HEADERS(arpa/inet.h netinet/in.h byteswap.h)
+
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
Modified: usrp2/trunk/host/lib/usrp2_basic.cc
===================================================================
--- usrp2/trunk/host/lib/usrp2_basic.cc 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/host/lib/usrp2_basic.cc 2007-12-13 01:41:45 UTC (rev 7139)
@@ -22,7 +22,10 @@
#include "usrp2_basic.h"
#include "gri_ethernet.h"
#include "gri_pktfilter.h"
+#include <arpa/inet.h>
+#include <time.h> // debug
+
usrp2_basic::usrp2_basic()
: d_ethernet(new gri_ethernet()), d_pf(0)
{
@@ -57,7 +60,7 @@
}
std::vector<op_id_reply_t>
-usrp2_basic::find_usrp2s()
+usrp2_basic::find_usrps()
{
static const uint8_t broadcast_mac_addr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -74,13 +77,22 @@
op_id_reply_t op_id_reply;
};
- command command;
- memset(&command, 0, sizeof(command));
- command.h.ehdr.ethertype = U2_ETHERTYPE;
- memcpy(command.h.ehdr.dst_addr, broadcast_mac_addr,
sizeof(broadcast_mac_addr));
- command.op_id.opcode = OP_ID;
- command.op_id.len = sizeof(op_id_t);
- if (d_ethernet->write_packet(&command, sizeof(command)) != sizeof(command)){
+ uint8_t buf[128]; // FIXME clean this up
+ memset(buf, 0, sizeof(buf));
+
+ command *c = (command *) buf;
+ memset(c, 0, sizeof(command));
+ c->h.ehdr.ethertype = htons(U2_ETHERTYPE);
+ c->h.ehdr._pad = time(0);
+ memcpy(c->h.ehdr.dst_addr, broadcast_mac_addr, 6);
+ memcpy(c->h.ehdr.src_addr, d_ethernet->mac(), 6);
+ u2p_set_word0(&c->h.fixed, 0, CONTROL_CHAN);
+ u2p_set_timestamp(&c->h.fixed, -1);
+
+ c->op_id.opcode = OP_ID;
+ c->op_id.len = sizeof(op_id_t);
+ int len = std::max(sizeof(buf), sizeof(command));
+ if (d_ethernet->write_packet(c, len) != len){
goto bail;
}
@@ -92,3 +104,17 @@
bail:
return r;
}
+
+std::ostream& operator<<(std::ostream &os, const op_id_reply_t &r)
+{
+ char buf[512];
+
+ snprintf(buf, sizeof(buf),
+ "%02x:%02x:%02x:%02x:%02x:%02x hw_rev = 0x%04x serial_no = %.8s",
+ r.mac_addr[0],r.mac_addr[1],r.mac_addr[2],
+ r.mac_addr[3],r.mac_addr[4],r.mac_addr[5],
+ r.hw_rev, r.serial_no);
+
+ os << buf;
+ return os;
+}
Modified: usrp2/trunk/host/lib/usrp2_basic.h
===================================================================
--- usrp2/trunk/host/lib/usrp2_basic.h 2007-12-12 23:38:08 UTC (rev 7138)
+++ usrp2/trunk/host/lib/usrp2_basic.h 2007-12-13 01:41:45 UTC (rev 7139)
@@ -42,9 +42,10 @@
bool open(std::string ifname = "eth0");
bool close();
- std::vector<op_id_reply_t> find_usrp2s();
+ std::vector<op_id_reply_t> find_usrps();
};
+std::ostream& operator<<(std::ostream &os,
+ const op_id_reply_t &r);
-
#endif /* INCLUDED_USRP2_BASIC_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7139 - in usrp2/trunk: firmware firmware/apps firmware/include firmware/lib fpga/control_lib fpga/top/u2_fpga host host/apps host/lib,
eb <=