[Discuss-gnuradio] USRP2 firmware + cross compiled GNU Radio question
From:
alfayez
Subject:
[Discuss-gnuradio] USRP2 firmware + cross compiled GNU Radio question
Date:
Sun, 29 Nov 2009 01:51:35 -0500
Hi, I've been working on cross compiling the latest stable GNU Radio release, 3.2.1, onto the TI Davinci DM6446 board using OpenEmbedded as my build environment and Angstrom as my Linux Distro. I've managed to cross compile and download gnuradio onto the board, though I'm going with a console only Linux image so I don't have any of the gnuradio python GUI stuff. Anyways, I am using a USRP2 and the board I'm using doesn't have has 100T ethernet and not 1000T, so I'm using a 1000/100/10T DLink switch to do the translation.
While I am successful in running "find_usrps" and I am successful in detecting my USRP2 I'm having a problem transmitting from the USRP2.
I am running the latest USRP2 firmware txrx_edk10.1_r11370.bin and u2_rev3_ise10.1sp3_r11370.bin. Now I am trying to run one of the USRP2 non-GUI transmit code so I can look at my spectrum analyzer and see if it's working. However, since the usrp2_fft script requires a GUI i cannot use for testing, so I am modifiying benchmark_tx.py and test with it. Whenever I run my benchmark I receive the following error "RuntimeError: Unable to retrieve daughterboard info", I am appending to the message my modified benchmark. Searching past emails, some people recommended using "ethtool" to make sure that autonegotion is enable for the Ethernet interface, while I was able to put Ethtool on my Davinci board, ethtool was not able to modify any of my ethernet interface settings because the davinci board ethernet IC doesn't support it.
Now I am wondering if it's possible to modify the firmware code so I can make my board work with the USRP2. I haven't looked at the firmware code nor do I have the software tools necessary to do so, but is there a way to "dumb it" down in case there is some autonegotiation going on that my board's ethernet interface doesn't support? thanks
al fayez
#!/usr/bin/env python
#
# Copyright 2005,2006,2007,2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# GNU Radio 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, or (at your option)
# any later version.
#
# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
from gnuradio import gr, gru, modulation_utils
from gnuradio import usrp2
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import random, time, struct, sys
# from current dir
from transmit_path import transmit_path
from pick_bitrate import pick_tx_bitrate
import usrp_options
#import os
#print os.getpid()
#raw_input('Attach and press enter')
class my_top_block(gr.top_block):
def __init__(self, modulator, options):
gr.top_block.__init__(self)
print "HERE a"
self._tx_freq = options.tx_freq # tranmitter's center frequency
self._interp = options.interp # interpolating rate for the USRP (prelim)
self._bitrate = options.bitrate
self._samples_per_symbol = options.samples_per_symbol
self._modulator_class = modulator
# options.interface = "eth0"
# options.mac_addr = "00:50:c2:85:30:33"
options.mac_addr = ""
print "HERE b"
if self._tx_freq is None:
sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
raise SystemExit
print "HERE c"
# Set up USRP sink; also adjusts interp, and bitrate
#self._setup_usrp_sink(options)
self.u = usrp2.sink_32fc(options.interface, options.mac_addr)
self._setup_usrp_sink(options)
print "HERE d"
# copy the final answers back into options for use by modulator
options.samples_per_symbol = self._samples_per_symbol
options.bitrate = self._bitrate
options.interp = self._interp
print "HERE e"
# Set center frequency of USRP
ok = self.set_freq(self._tx_freq)
print "HERE f"
if not ok:
print "Failed to set Tx frequency to %s" % (eng_notation.num_to_str(self._tx_freq),)
raise ValueError
print "HERE g"
# Set the USRP for maximum transmit gain
# (Note that on the RFX cards this is a nop.)
self.set_gain(self.u.gain_range()[1])
self.txpath = transmit_path(modulator, options)
self.connect(self.txpath, self.u)
print "HERE h"
def _setup_usrp_sink(self, options):
"""
Creates a USRP sink, determines the settings for best bitrate,
and attaches to the transmitter's subdevice.
"""
print "HERE i"
self.u = usrp_options.create_usrp_sink(options)
print "HERE j"
dac_rate = self.u.dac_rate()
print "HERE k"
(self._bitrate, self._samples_per_symbol, self._interp) = \
pick_tx_bitrate(self._bitrate, self._modulator_class.bits_per_symbol(), \
self._samples_per_symbol, self._interp, dac_rate, \
self.u.get_interp_rates())
print "HERE l"
self.u.set_interp(self._interp)
print "HERE m"
self.set_auto_tr(True) # enable Auto Transmit/Receive switching
print "HERE n"
def set_freq(self, target_freq):
"""
Set the center frequency we're interested in.
@param target_freq: frequency in Hz
@rypte: bool
Tuning is a two step process. First we ask the front-end to
tune as close to the desired frequency as it can. Then we use
the result of that operation and our target_frequency to
determine the value for the digital up converter.
"""
return self.u.set_center_freq(target_freq)
def set_gain(self, gain):
"""
Sets the analog gain in the USRP
"""
self.gain = gain
self.u.set_gain(gain)
def set_auto_tr(self, enable):
"""
Turns on auto transmit/receive of USRP daughterboard (if exits; else ignored)
"""
return self.u.set_auto_tr(enable)
def interp(self):
return self._interp
def add_options(normal, expert):
"""
Adds usrp-specific options to the Options Parser
"""
add_freq_option(normal)
normal.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
help="select USRP Tx side A or B")
normal.add_option("-v", "--verbose", action="", default=False)
expert.add_option("", "--tx-freq", type="eng_float", default=None,
help="set transmit frequency to FREQ [default=%default]", metavar="FREQ")
expert.add_option("-i", "--interp", type="intx", default=256,
help="set fpga interpolation rate to INTERP [default=%default]")
# expert.add_option("-d", "--decim", type="intx", default=16,
# help="set fpga interpolation rate to DECIM [default=%default]")
# Make a static method to call before instantiation
add_options = staticmethod(add_options)
def _print_verbage(self):
"""
Prints information about the transmit path
"""
print "Using TX d'board %s" % (self.subdev.side_and_name(),)
print "modulation: %s" % (self._modulator_class.__name__)
print "interp: %3d" % (self._interp)
print "Tx Frequency: %s" % (eng_notation.num_to_str(self._tx_freq))
def add_freq_option(parser):
"""
Hackery that has the -f / --freq option set both tx_freq and rx_freq
"""
def freq_callback(option, opt_str, value, parser):
parser.values.rx_freq = value
parser.values.tx_freq = value
if not parser.has_option('--freq'):
parser.add_option('-f', '--freq', type="eng_float",
action="", callback=freq_callback,
help="set Tx and/or Rx frequency to FREQ [default=%default]",
metavar="FREQ")
# /////////////////////////////////////////////////////////////////////////////
# main
# /////////////////////////////////////////////////////////////////////////////