USRP2 firmware + cross compiled GNU Radio question

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=“store_true”,
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", callback=freq_callback,
                      help="set Tx and/or Rx frequency to FREQ 

[default=%default]",
metavar=“FREQ”)

/////////////////////////////////////////////////////////////////////////////

main

/////////////////////////////////////////////////////////////////////////////

def main():

def send_pkt(payload='', eof=False):
    return tb.txpath.send_pkt(payload, eof)

def rx_callback(ok, payload):
    print "ok = %r, payload = '%s'" % (ok, payload)

mods = modulation_utils.type_1_mods()

parser = OptionParser(option_class=eng_option, 

conflict_handler=“resolve”)
expert_grp = parser.add_option_group(“Expert”)

parser.add_option("-m", "--modulation", type="choice", 

choices=mods.keys(),
default=‘gmsk’,
help=“Select modulation from: %s
[default=%%default]”
% (’, '.join(mods.keys()),))
print “HERE 5”
parser.add_option("-s", “–size”, type=“eng_float”, default=1500,
help=“set packet size [default=%default]”)
parser.add_option("-M", “–megabytes”, type=“eng_float”,
default=1.0,
help=“set megabytes to transmit
[default=%default]”)
parser.add_option("","–discontinuous", action=“store_true”,
default=False,
help=“enable discontinous transmission (bursts of
5 packets)”)
parser.add_option("","–from-file", default=None,
help=“use file for packet contents”)
parser.add_option("-e", “–interface”, type=“string”,
default=“eth0”,
help=“select Ethernet interface, default is eth0”)

parser.add_option("-m", “–mac-addr”, type=“string”,

default=“00:50:c2:85:30:33”,
parser.add_option("-m", “–mac-addr”, type=“string”,
default=“auto-select”,
help=“select USRP by MAC address, default is
auto-select”)

my_top_block.add_options(parser, expert_grp)
transmit_path.add_options(parser, expert_grp)
usrp_options.add_tx_options(parser)
print "HERE 6"
for mod in mods.values():
    mod.add_options(expert_grp)
print "HERE 7"
(options, args) = parser.parse_args ()
print "HERE 8"
if len(args) != 0:
    parser.print_help()
    sys.exit(1)
print "HERE 9"
if options.tx_freq is None:
    sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
    parser.print_help(sys.stderr)
    sys.exit(1)
print "HERE 10"
if options.from_file is not None:
    source_file = open(options.from_file, 'r')
print "HERE 11"
# build the graph
tb = my_top_block(mods[options.modulation], options)
print "HERE 12"
r = gr.enable_realtime_scheduling()
print "HERE 13"
if r != gr.RT_OK:
    print "Warning: failed to enable realtime scheduling"
print "HERE 14"
tb.start()                       # start flow graph
print "HERE 15"
# generate and send packets
nbytes = int(1e6 * options.megabytes)
n = 0
pktno = 0
pkt_size = int(options.size)
print "HERE 16"
while n < nbytes:
    if options.from_file is None:
        data = (pkt_size - 2) * chr(pktno & 0xff)
    else:
        data = source_file.read(pkt_size - 2)
        if data == '':
            break;
    print "HERE 17"
    payload = struct.pack('!H', pktno & 0xffff) + data
    print "HERE 18"
    send_pkt(payload)
    print "HERE 19"
    n += len(payload)
    print "HERE 20"
    sys.stderr.write('.')
    print "HERE 21"
    if options.discontinuous and pktno % 5 == 4:
        time.sleep(1)
    pktno += 1
print "HERE 22"
send_pkt(eof=True)
print "HERE LAST"
tb.wait()                       # wait for it to finish

if name == ‘main’:
try:
main()
except KeyboardInterrupt:
pass

[email protected] wrote:

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.

First, maybe it was a mistype but the latest version of gnuradio is
3.2.2 not 3.2.1. Next, if you just want to test transmit, use
usrp2_siggen.py.

The USRP2 won’t work unless you are using a GigE network card on the
host.

Matt has put together a new ethernet MAC here:
http://gnuradio.org/trac/wiki/NewEthMAC

I don’t think this supports 10/100, maybe I’m wrong, but it may be worth
trying.

Tim

On 11/29/2009 07:52 AM, Tim N. wrote:

1000/100/10T DLink switch to do the translation.
First, maybe it was a mistype but the latest version of gnuradio is
3.2.2 not 3.2.1. Next, if you just want to test transmit, use
usrp2_siggen.py.

The slacker that supports GNURadio in OE hasn’t added a recipe for
3.2.2. Wait, that’s me! Still for this discussion 3.2.1 is fine.

Most of my time is spent on the git recipe in OE. If you comment out the
DEFAULT_PREFERENCE line in that recipe, you will get or more recent
build. I haven’t built it on an ARM9 recently, there may be some issues
with atomic operation support in boost.

The USRP2 won’t work unless you are using a GigE network card on the host.
Matt has put together a new ethernet MAC here:
http://gnuradio.org/trac/wiki/NewEthMAC

I don’t think this supports 10/100, maybe I’m wrong, but it may be worth
trying.

My understanding is the same as Tim’s, you will need some form of GigE
interface. Unfortunately, the DM6446 does not support full HS USB host,
but it still might be possible to use a USRP1 with it. A quick read of
the docs suggests this might work.

Philip

On 11/29/2009 04:52 AM, Tim N. wrote:

1000/100/10T DLink switch to do the translation.
First, maybe it was a mistype but the latest version of gnuradio is
3.2.2 not 3.2.1. Next, if you just want to test transmit, use
usrp2_siggen.py.

The USRP2 won’t work unless you are using a GigE network card on the host.
Matt has put together a new ethernet MAC here:
http://gnuradio.org/trac/wiki/NewEthMAC

I don’t think this supports 10/100, maybe I’m wrong, but it may be worth
trying.

We still require Gigabit.

Matt