[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7760 - in usrp2/trunk/firmware: . apps
From: |
eb |
Subject: |
[Commit-gnuradio] r7760 - in usrp2/trunk/firmware: . apps |
Date: |
Wed, 20 Feb 2008 18:32:39 -0700 (MST) |
Author: eb
Date: 2008-02-20 18:32:39 -0700 (Wed, 20 Feb 2008)
New Revision: 7760
Added:
usrp2/trunk/firmware/apps/app_passthru.c
usrp2/trunk/firmware/apps/app_passthru.h
usrp2/trunk/firmware/apps/eth_to_serdes.c
usrp2/trunk/firmware/apps/serdes_to_dsp.c
Modified:
usrp2/trunk/firmware/apps/
usrp2/trunk/firmware/apps/Makefile.am
usrp2/trunk/firmware/divisors.py
Log:
new progs for testing serdes
Property changes on: usrp2/trunk/firmware/apps
___________________________________________________________________
Name: svn:ignore
- *-stamp
*.a
*.bin
*.dump
*.log
*.rom
*.map
.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
test_printf
test_spi
test_i2c
gen_pause_frames
test_serdes
rx_only
tx_only
tx_standalone
tx_drop
tx_drop2
tx_drop_rate_limited
test_lsdac
test_lsadc
read_dbids
test_db_spi
ramp_lsdac
+ *-stamp
*.a
*.bin
*.dump
*.log
*.rom
*.map
.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
test_printf
test_spi
test_i2c
gen_pause_frames
test_serdes
rx_only
tx_only
tx_standalone
tx_drop
tx_drop2
tx_drop_rate_limited
test_lsdac
test_lsadc
read_dbids
test_db_spi
ramp_lsdac
eth_to_serdes
serdes_to_dsp
Modified: usrp2/trunk/firmware/apps/Makefile.am
===================================================================
--- usrp2/trunk/firmware/apps/Makefile.am 2008-02-21 01:29:52 UTC (rev
7759)
+++ usrp2/trunk/firmware/apps/Makefile.am 2008-02-21 01:32:39 UTC (rev
7760)
@@ -39,7 +39,9 @@
test_serdes \
timer_test \
tx_only \
- tx_standalone
+ tx_standalone \
+ eth_to_serdes \
+ serdes_to_dsp
# tx_drop_SOURCES = tx_drop.c app_common.c
@@ -47,5 +49,8 @@
# tx_drop2_SOURCES = tx_drop2.c app_common.c
tx_only_SOURCES = tx_only.c app_common.c
rx_only_SOURCES = rx_only.c app_common.c
+eth_to_serdes_SOURCES = eth_to_serdes.c app_passthru.c
+serdes_to_dsp_SOURCES = serdes_to_dsp.c app_common.c
+
Copied: usrp2/trunk/firmware/apps/app_passthru.c (from rev 7756,
usrp2/trunk/firmware/apps/app_common.c)
===================================================================
--- usrp2/trunk/firmware/apps/app_passthru.c (rev 0)
+++ usrp2/trunk/firmware/apps/app_passthru.c 2008-02-21 01:32:39 UTC (rev
7760)
@@ -0,0 +1,149 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 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 "app_passthru.h"
+#include "buffer_pool.h"
+#include "memcpy_wa.h"
+#include "ethernet.h"
+#include "nonstdio.h"
+#include "print_rmon_regs.h"
+#include <string.h>
+
+volatile bool link_is_up = false; // eth handler sets this
+
+static void
+burn_mac_addr(const op_burn_mac_addr_t *p)
+{
+ ethernet_set_mac_addr(&p->addr);
+}
+
+void
+set_reply_hdr(u2_eth_packet_t *reply_pkt, u2_eth_packet_t const *cmd_pkt)
+{
+ reply_pkt->ehdr.dst = cmd_pkt->ehdr.src;
+ reply_pkt->ehdr.ethertype = U2_ETHERTYPE;
+ reply_pkt->thdr.flags = 0;
+ reply_pkt->thdr.fifo_status = 0; // written by protocol engine
+ reply_pkt->thdr.seqno = 0; // written by protocol engine
+ reply_pkt->thdr.ack = 0; // written by protocol engine
+ u2p_set_word0(&reply_pkt->fixed, 0, CONTROL_CHAN);
+ reply_pkt->fixed.timestamp = timer_regs->time;
+}
+
+bool
+handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len)
+{
+ 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;
+
+ // point to beginning of payload (subpackets)
+ unsigned char *p = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t);
+
+ // FIXME iterate over payload, handling more than a single subpacket
+
+ int opcode = p[0];
+
+ switch(opcode){
+ case OP_ID:
+ memset(reply, 0, sizeof(reply));
+ set_reply_hdr((u2_eth_packet_t *) reply, pkt);
+ {
+ 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
+ r->addr = *ethernet_mac_addr();
+ r->hw_rev = 0x0000; // FIXME
+ // r->fpga_md5sum = ; // FIXME
+ // r->sw_md5sum = ; // FIXME
+ }
+
+ // FIXME need to see if ethernet tx is busy
+
+ // copy reply into CPU_TX_BUF
+ memcpy_wa(buffer_ram(CPU_TX_BUF), reply, reply_len);
+
+ bp_send_from_buf(CPU_TX_BUF, PORT_ETH, 1, 0, reply_len / 4);
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+
+/*
+ * Called when an ethernet packet is received.
+ * Return true if we handled it here, otherwise
+ * it'll be passed on to the DSP Tx pipe
+ */
+bool
+eth_pkt_inspector(dbsm_t *sm, int bufno)
+{
+ u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno);
+ size_t byte_len = (buffer_pool_status->last_line[bufno] - 3) * 4;
+
+ // hal_toggle_leds(0x1);
+
+ // inspect rcvd frame and figure out what do do.
+
+ if (pkt->ehdr.ethertype != U2_ETHERTYPE)
+ return true; // ignore, probably bogus PAUSE frame from MAC
+
+ int chan = u2p_chan(&pkt->fixed);
+
+ switch (chan){
+ case CONTROL_CHAN:
+ return handle_control_chan_frame(pkt, byte_len);
+
+ case 0:
+ default:
+ return false; // pass it on to Tx DSP
+ break;
+ }
+}
+
+/*
+ * Called when eth phy state changes (w/ interrupts disabled)
+ */
+void
+link_changed_callback(int speed)
+{
+ link_is_up = speed != 0;
+ // hal_set_leds(link_is_up ? 0x2 : 0x0, 0x2);
+ printf("\neth link changed: speed = %d\n", speed);
+}
+
+void
+config_tx_cmd(op_config_tx_t *p)
+{
+ // printf("config_tx_cmd: interp = %d\n", p->interp);
+ // print_rmon_regs();
+
+ dsp_tx_regs->freq = p->phase_inc;
+ dsp_tx_regs->scale_iq = p->scale_iq;
+ dsp_tx_regs->interp_rate = p->interp - 1; // register gets N-1
+}
Copied: usrp2/trunk/firmware/apps/app_passthru.h (from rev 7756,
usrp2/trunk/firmware/apps/app_common.h)
===================================================================
--- usrp2/trunk/firmware/apps/app_passthru.h (rev 0)
+++ usrp2/trunk/firmware/apps/app_passthru.h 2008-02-21 01:32:39 UTC (rev
7760)
@@ -0,0 +1,54 @@
+/* -*- 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_APP_COMMON_H
+#define INCLUDED_APP_COMMON_H
+
+#include "bool.h"
+#include "usrp2_eth_packet.h"
+#include "dbsm.h"
+#include "memory_map.h"
+#include "hal_io.h"
+#include <stddef.h>
+
+#define CPU_TX_BUF 1 // cpu -> eth
+
+#define _AL4 __attribute__((aligned (4)))
+
+extern volatile bool link_is_up; // eth handler sets this
+
+void set_reply_hdr(u2_eth_packet_t *reply_pkt, u2_eth_packet_t const *cmd_pkt);
+
+/*
+ * Called when an ethernet packet is received.
+ * Return true if we handled it here, otherwise
+ * it'll be passed on to the DSP Tx pipe
+ */
+bool eth_pkt_inspector(dbsm_t *sm, int bufno);
+
+void link_changed_callback(int speed);
+
+
+// FIXME move these somewhere else?
+void start_rx_cmd(const u2_mac_addr_t *host, op_start_rx_t *p);
+void stop_rx_cmd(void);
+void config_tx_cmd(op_config_tx_t *p);
+
+bool handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len);
+
+#endif /* INCLUDED_APP_COMMON_H */
Copied: usrp2/trunk/firmware/apps/eth_to_serdes.c (from rev 7756,
usrp2/trunk/firmware/apps/tx_only.c)
===================================================================
--- usrp2/trunk/firmware/apps/eth_to_serdes.c (rev 0)
+++ usrp2/trunk/firmware/apps/eth_to_serdes.c 2008-02-21 01:32:39 UTC (rev
7760)
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2007,2008 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 "u2_init.h"
+#include "memory_map.h"
+#include "spi.h"
+#include "hal_io.h"
+#include "buffer_pool.h"
+#include "pic.h"
+#include "bool.h"
+#include "ethernet.h"
+#include "nonstdio.h"
+#include "usrp2_eth_packet.h"
+#include "dbsm.h"
+#include "app_passthru.h"
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/*
+ * This program passes everything through to the usrp2 attached to the serdes.
+ *
+ * Buffer 1 is used by the cpu to send frames to the host.
+ * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
+ * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
+ */
+//#define CPU_RX_BUF 0 // eth -> cpu
+//#define CPU_TX_BUF 1 // cpu -> eth
+
+//#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
+//#define DSP_RX_BUF_1 3 // dsp rx -> eth
+#define ETH_TO_SD_BUF_0 4 // eth -> dsp tx (double buffer)
+#define ETH_TO_SD_BUF_1 5 // eth -> dsp tx
+
+/*
+ * ================================================================
+ * configure eth to serdes double buffering state machine
+ * ================================================================
+ */
+
+// Receive from ethernet
+buf_cmd_args_t eth_to_sd_recv_args = {
+ PORT_ETH,
+ 0,
+ BP_LAST_LINE
+};
+
+// send to serdes
+buf_cmd_args_t eth_to_sd_send_args = {
+ PORT_SERDES,
+ 0, // start at first line
+ 0 // filled in from last_line register
+};
+
+dbsm_t eth_to_sd_sm; // the state machine
+
+
+// ----------------------------------------------------------------
+
+
+// The mac address of the host we're sending to.
+u2_mac_addr_t host_mac_addr;
+
+
+void
+start_rx_cmd(const u2_mac_addr_t *host, op_start_rx_t *p)
+{
+}
+
+void
+stop_rx_cmd(void)
+{
+}
+
+
+inline static void
+buffer_irq_handler(unsigned irq)
+{
+ //hal_toggle_leds(0x2);
+
+ uint32_t status = buffer_pool_status->status;
+
+ dbsm_process_status(ð_to_sd_sm, status);
+
+ if (status & BPS_DONE(CPU_TX_BUF)){
+ bp_clear_buf(CPU_TX_BUF);
+ }
+}
+
+int
+main(void)
+{
+ u2_init();
+
+ // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
+ hal_gpio_set_tx_mode(15, 0, GPIOM_FPGA_1);
+ hal_gpio_set_rx_mode(15, 0, GPIOM_FPGA_1); // no printing...
+
+ putstr("\neth_to_serdes\n");
+
+ ethernet_register_link_changed_callback(link_changed_callback);
+ ethernet_init();
+
+ // initialize double buffering state machine for ethernet to serdes
+
+ dbsm_init(ð_to_sd_sm, ETH_TO_SD_BUF_0,
+ ð_to_sd_recv_args, ð_to_sd_send_args,
+ eth_pkt_inspector);
+
+
+ // kick off the state machine
+ dbsm_start(ð_to_sd_sm);
+
+ while(1){
+ buffer_irq_handler(0);
+
+ int pending = pic_regs->pending; // poll for under or overrun
+
+ if (pending & PIC_UNDERRUN_INT){
+ dbsm_handle_tx_underrun(ð_to_sd_sm);
+ pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
+ putchar('U');
+ }
+ }
+}
+
Copied: usrp2/trunk/firmware/apps/serdes_to_dsp.c (from rev 7756,
usrp2/trunk/firmware/apps/tx_only.c)
===================================================================
--- usrp2/trunk/firmware/apps/serdes_to_dsp.c (rev 0)
+++ usrp2/trunk/firmware/apps/serdes_to_dsp.c 2008-02-21 01:32:39 UTC (rev
7760)
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2007,2008 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 "u2_init.h"
+#include "memory_map.h"
+#include "spi.h"
+#include "hal_io.h"
+#include "buffer_pool.h"
+#include "pic.h"
+#include "bool.h"
+#include "ethernet.h"
+#include "nonstdio.h"
+#include "usrp2_eth_packet.h"
+#include "dbsm.h"
+#include "app_common.h"
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/*
+ * This program can respond to queries from the host
+ * and stream rx samples.
+ *
+ * Buffer 1 is used by the cpu to send frames to the host.
+ * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
+ * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
+ */
+//#define CPU_RX_BUF 0 // eth -> cpu
+//#define CPU_TX_BUF 1 // cpu -> eth
+
+#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
+#define DSP_RX_BUF_1 3 // dsp rx -> eth
+#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
+#define DSP_TX_BUF_1 5 // eth -> dsp tx
+
+/*
+ * ================================================================
+ * configure DSP TX double buffering state machine
+ * ================================================================
+ */
+
+// 4 lines of ethernet hdr + 1 line transport hdr + 2 lines (word0 + timestamp)
+// DSP Tx reads word0 (flags) + timestamp followed by samples
+
+#define DSP_TX_FIRST_LINE ((sizeof(u2_eth_hdr_t) +
sizeof(u2_transport_hdr_t))/4)
+
+// Receive from ethernet
+buf_cmd_args_t dsp_tx_recv_args = {
+ PORT_SERDES,
+ 0,
+ BP_LAST_LINE
+};
+
+// send to DSP Tx
+buf_cmd_args_t dsp_tx_send_args = {
+ PORT_DSP,
+ DSP_TX_FIRST_LINE, // starts just past transport header
+ 0 // filled in from last_line register
+};
+
+dbsm_t dsp_tx_sm; // the state machine
+
+
+// ----------------------------------------------------------------
+
+
+// The mac address of the host we're sending to.
+u2_mac_addr_t host_mac_addr;
+
+
+void
+start_rx_cmd(const u2_mac_addr_t *host, op_start_rx_t *p)
+{
+}
+
+void
+stop_rx_cmd(void)
+{
+}
+
+static void
+setup_tx()
+{
+ dsp_tx_regs->clear_state = 1;
+ bp_clear_buf(DSP_TX_BUF_0);
+ bp_clear_buf(DSP_TX_BUF_1);
+
+ int tx_scale = 256;
+ int interp = 32;
+
+ op_config_tx_t def_config;
+ memset(&def_config, 0, sizeof(def_config));
+ def_config.phase_inc = 408021893; // 9.5 MHz [2**32 *
fc/fsample]
+ def_config.scale_iq = (tx_scale << 16) | tx_scale;
+ def_config.interp = interp;
+
+ // setup Tx DSP regs
+ config_tx_cmd(&def_config);
+}
+
+
+inline static void
+buffer_irq_handler(unsigned irq)
+{
+ //hal_toggle_leds(0x2);
+
+ uint32_t status = buffer_pool_status->status;
+
+ dbsm_process_status(&dsp_tx_sm, status);
+
+ if (status & BPS_DONE(CPU_TX_BUF)){
+ bp_clear_buf(CPU_TX_BUF);
+ }
+}
+
+int
+main(void)
+{
+ u2_init();
+
+ // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
+ hal_gpio_set_tx_mode(15, 0, GPIOM_FPGA_1);
+ hal_gpio_set_rx_mode(15, 0, GPIOM_FPGA_1); // no printing...
+
+ putstr("\nserdes_to_dsp\n");
+
+ ethernet_register_link_changed_callback(link_changed_callback);
+ ethernet_init();
+
+ // initialize double buffering state machine for ethernet -> DSP Tx
+
+ dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
+ &dsp_tx_recv_args, &dsp_tx_send_args,
+ eth_pkt_inspector);
+
+ // program tx registers
+ setup_tx();
+
+ // kick off the state machine
+ dbsm_start(&dsp_tx_sm);
+
+ while(1){
+ buffer_irq_handler(0);
+
+ int pending = pic_regs->pending; // poll for under or overrun
+
+ if (pending & PIC_UNDERRUN_INT){
+ dbsm_handle_tx_underrun(&dsp_tx_sm);
+ pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt
+ putchar('U');
+ }
+ }
+}
+
Modified: usrp2/trunk/firmware/divisors.py
===================================================================
--- usrp2/trunk/firmware/divisors.py 2008-02-21 01:29:52 UTC (rev 7759)
+++ usrp2/trunk/firmware/divisors.py 2008-02-21 01:32:39 UTC (rev 7760)
@@ -1,9 +1,9 @@
#!/usr/bin/env python
-speeds = (9600, 19200, 38400, 57600, 119200)
+speeds = (9600, 19200, 38400, 57600, 115200, 230400)
master_clk = 100e6
-wb_clk = master_clk / 3
+wb_clk = master_clk / 2
def divisor(speed):
div0 = wb_clk // (speed * 16)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7760 - in usrp2/trunk/firmware: . apps,
eb <=