1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/usr/bin/env python
#
# Copyright 2010-2011,2015 Ettus Research LLC
#
# 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/>.
#
import optparse
import math
import os
import re
import struct
import socket
import sys
import time
import platform
import subprocess
def print_image_loader_warning(fw, fpga, reset, safe, addr):
# Newline + indent
if platform.system() == "Windows":
nl = " ^\n "
else:
nl = " \\\n "
# Generate uhd_image_loader command based on given arguments
uhd_image_loader = "uhd_image_loader --args=\"type=usrp2,addr={0}".format(addr)
if reset:
uhd_image_loader += ",reset"
if safe:
uhd_image_loader += ",overwrite-safe"
uhd_image_loader += "\""
if fw:
uhd_image_loader += "{0}--fw-path=\"{1}\"".format(nl, fw)
else:
uhd_image_loader += "{0}--no-fw".format(nl)
if fpga:
uhd_image_loader += "{0}--fpga-path=\"{1}\"".format(nl, fpga)
else:
uhd_image_loader += "{0}--no-fpga".format(nl)
print("")
print("************************************************************************************************")
print("ERROR: This utility has been removed in this version of UHD. Use this command:")
print("")
print(uhd_image_loader)
print("")
print("************************************************************************************************")
print("")
########################################################################
# Burner class, holds a socket and send/recv routines
########################################################################
class burner_socket(object):
def __init__(self, addr):
self._addr = addr
def burn_fw(self, fw, fpga, reset, safe, check_rev=True):
" Just a dummy lol "
print_image_loader_warning(fw, fpga, reset, safe, self._addr)
########################################################################
# command line options
########################################################################
def get_options():
parser = optparse.OptionParser()
parser.add_option("--addr", type="string", help="USRP-N2XX device address", default='')
parser.add_option("--fw", type="string", help="firmware image path (optional)", default='')
parser.add_option("--fpga", type="string", help="fpga image path (optional)", default='')
parser.add_option("--reset", action="store_true", help="reset the device after writing", default=False)
parser.add_option("--read", action="store_true", help="read to file instead of write from file", default=False)
parser.add_option("--overwrite-safe", action="store_true", help="never ever use this option", default=False)
parser.add_option("--dont-check-rev", action="store_true", help="disable revision checks", default=False)
parser.add_option("--list", action="store_true", help="list possible network devices", default=False)
(options, args) = parser.parse_args()
return options
########################################################################
# main
########################################################################
if __name__=='__main__':
options = get_options()
burner_socket(options.addr).burn_fw(fw=options.fw, fpga=options.fpga, reset=options.reset, safe=options.overwrite_safe, check_rev=not options.dont_check_rev)
|