Commit graph

196 commits

Author SHA1 Message Date
Martin Braun
06f6156f85 mpm: utils: Add string conversion utilities
Adds conversions for:
- Any-to-binary
- Any-to-UTF8
- Any-to-native
2017-12-22 15:05:57 -08:00
Trung N Tran
73334b188a mpm: close unused pyroute objects
Current code have couple places that open pyroute2 without closing it.
That seems to cause the file descriptor leakage.
This change effectively fix the issue #1964
2017-12-22 15:05:57 -08:00
Steven Bingler
0cb800e001 mpm: Fix python2 vs python3 zlib.crc32 output difference
Zlib's crc32 outputs signed values in python2 and unsigned values in
python3. As per this page (https://docs.python.org/2/library/zlib.html)
0xffffffff can be AND'd to the result to get the same value between
Python versions
2017-12-22 15:05:57 -08:00
Martin Braun
1e4e90d240 mpm: n310: Compile .dts files to .dtbo on update
Reviewed-By: Brent Stapleton <brent.stapleton@ettus.com>
2017-12-22 15:05:57 -08:00
Martin Braun
d5d7b84ac8 mpm: mg: Refactor init(), limit object scopes
- ClockSynchronizer object has no more permanent lifetime
- DboardClockControl object lives within `with' statement
- dboard_ctrl_regs are limited to init()
2017-12-22 15:05:57 -08:00
Martin Braun
b3662efeb3 mpm: Add temporary failure for FPGA reload
Note: This is subject to removal, but makes the FPGA reloading code
available to all until we fix the reload bug.
2017-12-22 15:05:57 -08:00
Brent Stapleton
19cdfb4148 mpm: Reset periph manager on update
Upon updating certain components (the FPGA, for example), the
Peripheral Manager is restarted, and the overlay is reapplied. In order
to facilitate this, the RPC server intercepts and handles the
update_component function.

Tested on the RJ45 ethernet connection. It probably won't work as well
if the SFP connection goes down when the overlay is removed.
2017-12-22 15:05:57 -08:00
Brent Stapleton
48d5d72fd7 mpm: adding destructor for UIO
UIO object now has an explicit destructor to properly tear down.
2017-12-22 15:05:57 -08:00
Brent Stapleton
d0cb6de410 mpm: PeriphManager decides and applies overlay
Previously, the daughterboard requested an overlay file based on SFP
preference using magic values. This commit moves the decision making to
the peripheral manager, which uses our singular name (ie 'n3xx' for the
N310).
2017-12-22 15:05:57 -08:00
Brent Stapleton
2eb1a5cfc3 fpga load: Components file paths in component dict
Paths to the component files is now stored in the updateable_components
dictionary. This makes them accessible in the base class, and generally cleans
up the member variables.
2017-12-22 15:05:57 -08:00
Brent Stapleton
a2029b0439 fpga load: Atomic updating of multiple components
- The MPM function update_component now accepts multiple components to
  be updated in one RPC call.
- Updated the property tree and image loader to match this change.
- Also added DTS loading to the image loader.
2017-12-22 15:05:43 -08:00
Martin Braun
44b117be95 mpm: mg: Add ref lock sensor
Note: The sensor API for this lives in n310, but it queries the dboards
for a ref lock status, which is now no longer a stub.
2017-12-22 15:05:07 -08:00
Martin Braun
c22ba82562 mpm: lmk04828: Fix docstring
Says check_plls_locked() would throw an exception. That's not true.
2017-12-22 15:05:07 -08:00
Martin Braun
d2594f9a92 mpm: mg: Add flag to see if master clock rate is being changed
Note: On the first run, this flag will always assert.
2017-12-22 15:05:07 -08:00
Martin Braun
064faf09c3 mpm: mg: Fix linter errors, compacted SPI factories 2017-12-22 15:05:07 -08:00
Martin Braun
ee00c0384e mpm: mg: Move some class attributes to local scopes
The clock_synchronizer, jesdcore, and dboard_clk_control objects don't
need to exist for the full lifetime of the Magnesium class. Having them
around complicates management of UIO file descriptors.
2017-12-22 15:05:07 -08:00
Martin Braun
4205c7b3da mpm: n310: Remove unused imports (linter warnings) 2017-12-22 15:05:07 -08:00
Trung N Tran
d8ebabaa12 mpm: mg: Remove unused spi_factories key 2017-12-22 15:05:07 -08:00
Trung Tran
201761cfa6 mpm: mg: Set default master_clock_rate to 125 MHz at every init 2017-12-22 15:05:07 -08:00
Trung N Tran
2467deeb17 mpm: mykonos: Add API to change master clock rate 2017-12-22 15:05:07 -08:00
djepson1
bf09c9c79b jesd: add reset routine and make portions more generic for various links 2017-12-22 15:05:07 -08:00
Martin Braun
f14b49ff5b n3xx: add support for 122.88 and 153.6 MHz sample clock rates
- re-wrote portions of the LMK driver for flexible rates and configuration
 - tweaked TDC driver for compatibility and ease of debugging
 - updated comments and log statements throughout for uniformity
2017-12-22 15:05:07 -08:00
Martin Braun
63f4049a10 mg: Enable variable master clock rates
The master_clock_rate argument is passed to init() during
initialization; this change allows to query the correct MCR at
initialization time. It does not allow changing the MCR while a session
is active.

The MCR also affects the LO settings; it is the reference clock for the
lowband LOs.
2017-12-22 15:05:07 -08:00
Martin Braun
b14cafd90c mpm: mg: Add dboard sensors for low- and highband LO lock status
- Add LO locked APIs to Magnesium
- Add LO locked sensor APIs for RX/TX and highband/lowband LOs
- Poll all those sensors from magnesium_radio_ctrl_impl

Reviewed-By: Steven Bingler <steven.bingler@ni.com>
Reviewed-By: Trung Tran <trung.tran@ettus.com>
2017-12-22 15:05:07 -08:00
Martin Braun
afe889af2b mpm: mg: Optionally parallelize init calls to dboard
Default is to run in parallel. serialize_init=1 will run them serially.

Reviewed-By: Brent Stapleton <brent.stapleton@ettus.com>
2017-12-22 15:05:06 -08:00
Martin Braun
ba6e9e801c mpm: n310: Made n310.__init__() more exception-safe 2017-12-22 15:05:06 -08:00
Martin Braun
2ab5a0f6aa mpm: Made PeriphManagerBase.__init__ more exception-safe 2017-12-22 15:05:06 -08:00
Brent Stapleton
23e1187538 mpm: discovery returns 'product' information
- Added 'product' information to N310
- MPM discovery checks for 'product' field
2017-12-22 15:05:06 -08:00
Trung N Tran
07ef7e3e61 n3xx_bist: remove unused python package
This tqdm is not using anywhere and causing trouble for the sdimage; so
I remove it.
2017-12-22 15:05:06 -08:00
Martin Braun
50a8624a4b mpm: mg: Make Magnesium __init__ exception-safe 2017-12-22 15:05:06 -08:00
Martin Braun
0fdf93748a mpm: Make dboard manager __init__ exception-safe 2017-12-22 15:05:06 -08:00
Martin Braun
e75497921e mpm: net: Add ip_addr_to_iface() function
Reviewed-By: Trung Tran <trung.tran@ettus.com>
2017-12-22 15:05:06 -08:00
Martin Braun
ecaa81beaf mpm: n310: Allow Ethernet connections to both SFPs
Reviewed-By: Trung Tran <trung.tran@ettus.com>
2017-12-22 15:05:06 -08:00
Trung N Tran
db7039f8be mpm: enable RX external LO set through args
This change allow user to set RX LO of ad9371 to external or internal from args
constructor of usrp device.
 new args is rx_lo_source value can be either internal or external:
 If there's no rx_lo_source specified or invalid value, default rx_lo is used;  which is internal LO.
Usage example:
 usrp_application --args "rx_lo_source=external"
2017-12-22 15:05:06 -08:00
Trung Tran
9ea0d6da9e mg: enable init and track calibration API
Currently, AD9371 turned on most of the calibration and hard coding the turning
on process during bringup time.
This change enables users to pass in a mask field for init ARM calibration and
tracking arm calibration at the time creating USRP device reference.
This mask field can be passed through device arguments of:
 1/ init_cals : for init ARM  calibration masks. This is defined in AD9371 UG-992
table 65. Default to 0x4DFF
 2/ tracking_cals : for tracking calibration masks. This is defined in AD9371
UG-992 table 66. Default to 0xC3

Example of pasing in init calibration and tracking calibration mask
      usrp_application --args "init_cals=0x4f, tracking_cals=0xC3"
NOTE: UHD currently expect user to input the correct init_cals and
tracking_cals. There's no mechanism to check if init mask and tracking mask are
valid. For example if the init mask field not mask 0x4f, the AD9371 will failed
to setup.
2017-12-22 15:05:06 -08:00
Martin Braun
fa765de7db mpm: Run C++ logger through central logging
Reviewed-By: Mark Meserve <mark.meserve@ni.com>
2017-12-22 15:05:06 -08:00
Martin Braun
96f209a561 mpm: mg: Add lowband LO lock and AD9371 lock sensors
Note: The AD9371 lock sensors are only stubbed out for now.
2017-12-22 15:05:06 -08:00
Martin Braun
b12b9465ed mpm/mpmd: Move to request_xport()/commit_xport() architecture
This commit combines code from various branches to finally enable both
UDP and Liberio transports.
2017-12-22 15:05:06 -08:00
Martin Braun
d327a93530 mpm: Lower logging level for PeriphManagerBase.deinit() 2017-12-22 15:05:06 -08:00
Martin Braun
03e088ed49 mpm: n310: Load Liberio dispatcher
Note: The dispatcher is not yet used at this point. However, it will
check the existence of certain devices.
2017-12-22 15:05:06 -08:00
Martin Braun
61aac1dd72 mpm: mg: Refactor some periph inits into __init__
SPI interfaces and -lock, user EEPROM, radio regs, CPLD, dboard clock
control and GPIO expander can be initialized in Magnesium.__init__().
This shaves a little time off of the actual init() call and allows for
earlier failures.
2017-12-22 15:05:06 -08:00
Martin Braun
ba25633132 mpm: mg: Fix linting issues and warnings
- Removed superfluous code
- Fixed most PyLint warnings
- Reordered methods to match call order
2017-12-22 15:05:06 -08:00
Martin Braun
e9a7db19ab mpm: Fix minor logging issues with LMK04828 code
Log prefixes weren't properly being set.
2017-12-22 15:05:05 -08:00
Martin Braun
08d8a34a2a mpm: mg: Move CPLD controls to dedicated class 2017-12-22 15:05:05 -08:00
Martin Braun
eccd185efb mpm: Add configurable log levels 2017-12-22 15:05:05 -08:00
Martin Braun
fb5e10a8e4 mpm: Cache connection type in PeriphManagerBase
Now, when claiming a device, the connection type will be stored as a
string in PeriphManagerBase. This way we can read out the current
connection type even when not currently inside an RPC call.
2017-12-22 15:05:05 -08:00
Trung Tran
db121800e7 mpm: Add LiberioDispatcherTable 2017-12-22 15:05:05 -08:00
Martin Braun
16da5da375 mpm: Remove leading _ from _get_device_info()
Use @norpc instead. This fixes some linting issues.
2017-12-22 15:05:05 -08:00
Martin Braun
a972069f07 mpm: Make list_updateable_components return something 2017-12-22 15:05:05 -08:00
Martin Braun
bcf3f28e15 mpm: Improve exception/error handling
- Any RPC call with uncaught exceptions will result in additional
  logging on MPM side
- Adds get_last_error() API call
- get_last_error() is populated by various methods within rpc_server.py,
  but also from every uncaught exception
2017-12-22 15:05:05 -08:00