commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r7981 - in usrp2/trunk/firmware: apps lib


From: eb
Subject: [Commit-gnuradio] r7981 - in usrp2/trunk/firmware: apps lib
Date: Sun, 9 Mar 2008 00:01:07 -0700 (MST)

Author: eb
Date: 2008-03-09 00:01:06 -0700 (Sun, 09 Mar 2008)
New Revision: 7981

Added:
   usrp2/trunk/firmware/apps/sd_gentest.c
   usrp2/trunk/firmware/lib/memset_wa.c
   usrp2/trunk/firmware/lib/memset_wa.h
Modified:
   usrp2/trunk/firmware/apps/
   usrp2/trunk/firmware/apps/Makefile.am
   usrp2/trunk/firmware/apps/app_common.c
   usrp2/trunk/firmware/lib/Makefile.am
   usrp2/trunk/firmware/lib/dbsm.c
Log:
work-in-progress: serdes test


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
eth_to_serdes
serdes_to_dsp

   + *-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
sd_gentest


Modified: usrp2/trunk/firmware/apps/Makefile.am
===================================================================
--- usrp2/trunk/firmware/apps/Makefile.am       2008-03-09 00:38:34 UTC (rev 
7980)
+++ usrp2/trunk/firmware/apps/Makefile.am       2008-03-09 07:01:06 UTC (rev 
7981)
@@ -41,7 +41,8 @@
        tx_only \
        tx_standalone \
        eth_to_serdes \
-       serdes_to_dsp
+       serdes_to_dsp \
+       sd_gentest
 
 
 # tx_drop_SOURCES = tx_drop.c app_common.c

Modified: usrp2/trunk/firmware/apps/app_common.c
===================================================================
--- usrp2/trunk/firmware/apps/app_common.c      2008-03-09 00:38:34 UTC (rev 
7980)
+++ usrp2/trunk/firmware/apps/app_common.c      2008-03-09 07:01:06 UTC (rev 
7981)
@@ -169,7 +169,7 @@
       //putchar('.');
     }
     else {
-      putchar('S');
+      // putchar('S');
       //printf("S%d %d ",exp_seqno,pkt->thdr.seqno);
       exp_seqno = pkt->thdr.seqno + 1;
     }

Added: usrp2/trunk/firmware/apps/sd_gentest.c
===================================================================
--- usrp2/trunk/firmware/apps/sd_gentest.c                              (rev 0)
+++ usrp2/trunk/firmware/apps/sd_gentest.c      2008-03-09 07:01:06 UTC (rev 
7981)
@@ -0,0 +1,178 @@
+/*
+ * 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 "nonstdio.h"
+#include "memset_wa.h"
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+// ----------------------------------------------------------------
+
+int packet_number = 0;
+volatile bool send_packet_now = 0;
+
+#define SERDES_TX_BUF  0
+#define        SERDES_RX_BUF   1
+
+
+#define NLINES_PER_PKT 380
+
+
+// ----------------------------------------------------------------
+
+static int timer_delta = (int)(MASTER_CLK_RATE * 100e-6);
+
+void
+timer_irq_handler(unsigned irq)
+{
+  hal_set_timeout(timer_delta);        // schedule next timeout
+  send_packet_now = true;
+}
+
+
+static void
+init_packet(int *buf)
+{
+  int i = 0;
+  for (i = 0; i < BP_NLINES; i++){
+    buf[i] = (i << 16) | i;
+  }
+}
+
+static bool
+check_packet(int *buf, int nlines)
+{
+  bool ok = true;
+  int i = 0;
+  for (i = 0; i < nlines; i++){
+    int expected = (i << 16) | i;
+    if (buf[i] != expected){
+      ok = false;
+      printf("buf[%d] = 0x%x  expected = 0x%x\n", i, buf[i], expected);
+    }
+  }
+  return ok;
+}
+
+static void
+zero_buffer(int bufno)
+{
+  memset_wa(buffer_ram(bufno), 0, BP_NLINES * 4);
+}
+
+static void
+init_packets(void)
+{
+  // init just the one we're using
+  init_packet(buffer_ram(SERDES_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);
+
+  putstr("\nsd_gentest\n");
+  
+  init_packets();
+
+  // pic_register_handler(IRQ_TIMER, timer_irq_handler);
+
+  //if (hwconfig_simulation_p())
+  //  timer_delta = sim_timer_delta;
+
+  // start a receive from sd
+  zero_buffer(SERDES_RX_BUF);
+  bp_receive_to_buf(SERDES_RX_BUF, PORT_SERDES, 1, 0, BP_LAST_LINE);
+  hal_set_timeout(timer_delta);
+
+  // fire off the first packet
+  bp_send_from_buf(SERDES_TX_BUF, PORT_SERDES, 1, 0, NLINES_PER_PKT);
+
+  while(1){
+    uint32_t status = buffer_pool_status->status;
+
+    if (status & (BPS_DONE(SERDES_RX_BUF))){
+      bp_clear_buf(SERDES_RX_BUF);
+
+      hal_toggle_leds(0x2);
+
+      // check packet
+      int last_line = buffer_pool_status->last_line[SERDES_RX_BUF]-1;
+      bool ok = check_packet(buffer_ram(SERDES_RX_BUF), last_line);
+      
+      if (ok)
+       putchar('.');
+      else
+       putchar('P');
+
+      // start a receive from sd
+      zero_buffer(SERDES_RX_BUF);
+      bp_receive_to_buf(SERDES_RX_BUF, PORT_SERDES, 1, 0, BP_LAST_LINE);
+      hal_set_timeout(timer_delta);
+    }
+
+    if (status & (BPS_ERROR(SERDES_RX_BUF))){
+      bp_clear_buf(SERDES_RX_BUF);
+      putchar('E');
+
+      // start a receive from sd
+      zero_buffer(SERDES_RX_BUF);
+      bp_receive_to_buf(SERDES_RX_BUF, PORT_SERDES, 1, 0, BP_LAST_LINE);
+      hal_set_timeout(timer_delta);
+    }
+
+    if (status & (BPS_DONE(SERDES_TX_BUF))){
+      bp_clear_buf(SERDES_TX_BUF);
+
+      hal_toggle_leds(0x1);
+
+      // send another packet
+      bp_send_from_buf(SERDES_TX_BUF, PORT_SERDES, 1, 0, NLINES_PER_PKT);
+    }
+
+    if (status & BPS_ERROR(SERDES_TX_BUF)){
+      bp_clear_buf(SERDES_TX_BUF);
+      putchar('e');
+      bp_send_from_buf(SERDES_TX_BUF, PORT_SERDES, 1, 0, NLINES_PER_PKT);
+    }
+
+    int pending = pic_regs->pending;
+    if (pending & PIC_TIMER_INT){              // are we missing a packet?
+      hal_set_timeout(timer_delta);
+      pic_regs->pending = PIC_TIMER_INT;       // clear pending interrupt
+      putchar('T');
+    }
+  }
+
+  return 1;
+}


Property changes on: usrp2/trunk/firmware/apps/sd_gentest.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: usrp2/trunk/firmware/lib/Makefile.am
===================================================================
--- usrp2/trunk/firmware/lib/Makefile.am        2008-03-09 00:38:34 UTC (rev 
7980)
+++ usrp2/trunk/firmware/lib/Makefile.am        2008-03-09 07:01:06 UTC (rev 
7981)
@@ -35,6 +35,7 @@
        lsdac.c \
        mdelay.c \
        memcpy_wa.c \
+       memset_wa.c \
        nonstdio.c \
        pic.c \
        print_mac_addr.c \

Modified: usrp2/trunk/firmware/lib/dbsm.c
===================================================================
--- usrp2/trunk/firmware/lib/dbsm.c     2008-03-09 00:38:34 UTC (rev 7980)
+++ usrp2/trunk/firmware/lib/dbsm.c     2008-03-09 07:01:06 UTC (rev 7981)
@@ -156,7 +156,7 @@
     return;
 
   if (status & (BPS_ERROR(sm->buf0) | BPS_ERROR(sm->buf0 ^ 1))){
-    putchar('E');
+    // putchar('E');
     // Most likely an ethernet Rx error.  We just restart the transfer.
     if (status & (BPS_ERROR(sm->buf0)))
       dbsm_error_helper(sm, sm->buf0);

Copied: usrp2/trunk/firmware/lib/memset_wa.c (from rev 7959, 
usrp2/trunk/firmware/lib/memcpy_wa.c)
===================================================================
--- usrp2/trunk/firmware/lib/memset_wa.c                                (rev 0)
+++ usrp2/trunk/firmware/lib/memset_wa.c        2008-03-09 07:01:06 UTC (rev 
7981)
@@ -0,0 +1,45 @@
+/* -*- 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/>.
+ */
+
+#include "memset_wa.h"
+#include <stdint.h>
+#include <stdlib.h>
+
+/*
+ * For setting non-byte-adressable memory, such as
+ * the buffers.  dst and nbytes must all satisfy (x % 4 == 0)
+ */
+void *
+memset_wa(void *dst, int c, size_t nbytes)
+{
+  if (((intptr_t) dst & 0x3)
+      || (nbytes & 0x3))
+    exit(1);                   /* die! */
+
+  int *dp = (int *) dst;
+
+  c &= 0xff;
+  int v = (c << 24) | (c << 16) | (c << 8) | c;
+  unsigned  nw = nbytes/4;
+
+  unsigned i;
+  for (i = 0; i < nw; i++)
+    dp[i] = v;
+
+  return dst;
+}

Added: usrp2/trunk/firmware/lib/memset_wa.h
===================================================================
--- usrp2/trunk/firmware/lib/memset_wa.h                                (rev 0)
+++ usrp2/trunk/firmware/lib/memset_wa.h        2008-03-09 07:01:06 UTC (rev 
7981)
@@ -0,0 +1,27 @@
+/* -*- 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_MEMSET_WA_H
+#define INCLUDED_MEMSET_WA_H
+
+#include <stdlib.h>
+
+void *memset_wa(void *s, int c, size_t n);
+
+
+#endif /* INCLUDED_MEMSET_WA_H */


Property changes on: usrp2/trunk/firmware/lib/memset_wa.h
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]