Commit graph

739 commits

Author SHA1 Message Date
Martin Braun
0a0c1bb7de mpm: sysutils: mount: Check both mount point and data path
This will return False on ismounted() if a Mount class is mounted, but
in the wrong spot.
2021-04-21 15:20:24 -05:00
Martin Braun
595264854f mpm: mount: Demote already-mounted warning
The class Mount defines a mount point and device path. It currently
warns if mount() is called twice, but that warning is at odds with the
contract of that API. It even returns 'True' (== success) after printing
the warning, and the outcome is the desired one. For that reason, we
demote the warning to a debug statement.
2021-04-21 15:19:59 -05:00
Martin Braun
87b65cf7ab mpm: periph_mgr: Demote "no SPI nodes" warning
When there are SPI nodes declared for a daughterboard, MPM will emit
a warning: "No SPI nodes for dboard". The warning is misleading, because
this only occurs when no SPI nodes where *declared*, not when they were
declared but not found. This is entirely normal for USRPs where the
daughterboards do not have SPI nodes, and thus, not even worth a debug
statement.
2021-04-21 15:19:46 -05:00
mattprost
38980b2e49 mpm: mg: periphs: Read lowband lo lock status from cpld
Fix the issue where N310 did not correctly read the lo lock status
from the cpld.

Signed-off-by: mattprost <matt.prost@ni.com>
2021-04-19 12:42:33 -05:00
Martin Braun
89f99fac00 mpm: Remove references to rfnoc_num_blocks
rfnoc_num_blocks is a device arg that could be used in UHD 3.15 (and
below) to artificially skip enumeration of RFNoC blocks. Since the block
enumeration works very differently in UHD 4, this arg was never
supported there.

This removes references to this arg in some BIST files. It is not
harmful, but also serves no purpose, and could be construed as being
useful upon lecture of these codes.
2021-04-12 15:14:45 -05:00
Martin Braun
5d3a6d2044 mpm: periph manager: Fix get_mb_eeprom() return value formatting
The get_mb_eeprom() RPC call is supposed to return a string -> string
map and thus converts all EEPROM entries to strings. However, for raw
strings, the existing conversion (using str()) was not correct (we need
to decode raw strings first).

This would lead to things like the serial being returned as b'ABCD123'
instead of just ABCD123.
2021-03-25 07:56:30 -05:00
Thomas Vogel
2000bbf17e mpm: rpc: don't expose reset_mgr call via RPC 2021-03-11 09:29:31 -06:00
Toni Jones
909b434e1e mpm: Add i2c_dev lookup using sys_name
Add i2c_dev adapter device lookup which uses a the sys_name value
instead of OF_NAME to find the adapter. OF_NAME is not unique for some
i2c device nodes. The logic for finding the adapter from the parent
node was pulled into a helper function and is shared across both
lookup functions.

Co-authored-by: Michael Auchter <michael.auchter@ni.com>
Co-authored-by: Toni Jones <toni.jones@ni.com>
2021-03-08 16:17:48 -06:00
Toni Jones
5fc01186d3 mpm: rpc: Use contextmanager for claim timeouts
Modify the RPC claim timeout mechanism to use a contextmanager
helper function when enabling/disabling timeouts.
2021-03-04 12:13:13 -06:00
Ciro Nishiguchi
760071a0be mpm: add helper for symbol lookup
Add a helper that can lookup a device via a device tree symbol.

Co-authored-by: Lars Amsel <lars.amsel@ni.com>
Co-authored-by: Michael Auchter <michael.auchter@ni.com>
2021-03-04 12:10:08 -06:00
Toni Jones
1a9033b3e9 mpm: Add DboardIface for MB DB driver control
Add DboardIface class which will act as an interface to bridge the gap
between MB and DB drivers in MPM. The DboardIface will be implemented
by each Motherboard with MB specific information. Dboard objects
will then instantiate the class in order to utilize the implemented
control functions.
2021-03-04 12:09:39 -06:00
Toni Jones
f2ae3e93f7 ic_reg_maps: Add SPCC reg map
Add SPCC reg map for reference and testing.
2021-03-01 15:57:01 -06:00
Toni Jones
902f458137 cmake: Add RegMaps build component to MPM
Add RegMaps build component to MPM. The PYTHON_CHECK_MODULE is
included from UHDPython in order to look up the presence of Mako.
Mako is required for generating the regmaps and RegMap will be
disabled without it. The RegMaps component creates custom commands for
generating all regmaps, creates a Python submodule "ic_reg_maps" with a
custom __init__.py file, and creates a target "ic_reg_maps" which gets
installed with usrp_mpm.
2021-03-01 15:57:01 -06:00
Toni Jones
394530777b mpm: Add an LMK03328 base chip driver
Added an LMK03328 base chip driver which does basic register access, ID
validation, and PLL lock validation. This will act as the base class for
device specific drivers which control the chip. The code it similar to
the LMK04828 and LMK04832 base driver classes but has a different
register map structure. Register bitfield definitions were omitted and
will be added on an as needed basis.
2021-02-22 10:15:13 -06:00
Toni Jones
2e441d296b mpm: Add an LMK04832 base chip driver
Added an LMK04832 base chip driver which does basic register access, ID
validation, and PLL lock validation. This will act as the base class for
device specific drivers which control the chip. The code is similar to
the LMK04828 base driver class, but has a different register map
structure.
2021-02-22 10:15:13 -06:00
Lars Amsel
ecbb24505d MPM: prevent dead lock in timer kill during unclaim
MPM server needs to be reclaimed in regular intervals. This is
monitored by the server using a timer. If the timer hits, the server
unclaims itself assuming the client process died for whatever
reason. In previous versions of `gevent.greenlet` the timer was
killed in a non blocking manner. This changed in version 0.13.0
(see
http://www.gevent.org/api/gevent.greenlet.html#gevent.Greenlet.kill)
which now leads to a dead lock in `timer.kill`. The kill command
is therefore now called explicitly with `block=False`.
2021-02-18 07:26:05 -06:00
Virendra Kakade
91073787b1 mpm: Add support to safely reset peripheral manager from uhd
Provide a way to safely reset the peripheral manager from uhd and as
a result, a mechanism to reload the fpga/dts components.

Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
2021-02-18 07:25:46 -06:00
Toni Jones
f11fa1bff7 mpm: Create Mock classes for unit testing
Create Mock classes which mimic the behavior of a register interface
and logger to facilitate unit testing needs.
2021-02-18 07:25:34 -06:00
Michael Auchter
5ef29d9396 mpm: deduplicate dboard eeprom handling
The _get_dboard_eeprom_info implementations are the same with the
exception of how the dboard eeprom is actually read. Break that out into
a _read_dboard_eeprom method to reduce code duplication.

The base class now defines a lambda expression for the eeprom reader
which can be changed in subclasses.

Co-authored-by: Lars Amsel <lars.amsel@ni.com>
Co-authored-by: Michael Auchter <michael.auchter@ni.com>
2021-02-11 12:26:10 -06:00
Joerg Hofrichter
9ffdd46974 mpm: added DBFlash class
Class for accessing (mounting) the daughterboard flash
2021-02-11 07:19:14 -06:00
Joerg Hofrichter
3f3006e0b4 mpm: added Mount class
Class for creating a mount point
2021-02-11 07:18:45 -06:00
Michael Auchter
fa6e7a7430 mpm: filesystem_status: tolerate absence of mender
If the mender utility is not installed or exits with a failure, return
NULL for the artifact rather than raising an exception (and disrupting
device initialization).
2021-02-09 07:36:08 -06:00
Lane Kolbly
5471a1f521 mpm: Implement get_sync_source and get_sync_sources. 2021-01-25 15:27:49 -06:00
Aaron Rossetto
7b43614846 sim: Ignore mender artifact file on sim devices 2021-01-21 12:47:54 -06:00
Virendra Kakade
fab4a5dd17 mpmd: Add support to delay and trigger fpga/dts load after update
Add a new image_loader argument delay_reload to provide a way to update
components but optionally delay the actual load.
Similarly add a new argument, just_reload, to enable uhd to reload
the fpga/dts components.

Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
2021-01-11 13:18:22 -06:00
Martin Braun
3b9ced8f07 mpm: rpc server: Fix unclaim sequence
Sequence is now:
1. Get _state lock
2. Kill reclaim timeout
3. Run deinit sequence
4. Clear claim token and session ID
5. Release _state lock

Before, we were not locking the mutex, and the timer was killed after
the deinit sequence. If the deinit sequence stalls for whatever reason,
that doesn't have to cause a claimer loss to be reported. UHD will
already have stopped the reclaim loop before unclaim() is called.

In the stall case, it would also have been possible the to acquire a new
claim while the deinit() is still running. This is prevented with the
combination of actually acquiring the mutex (like claim() and reclaim()
do) and moving the token/session ID clearing to the end.
2020-12-21 15:28:24 -08:00
Martin Braun
d72041827a mpm: rpc server: Remove Python2 compat code
MPM is Python3-only, but contains some remaining compatibility code for
Python2. Because this code requires extra dependencies (like six) and
could become obsolete in the future, we remove it to preempt that.

No functional changes.
2020-12-08 16:08:48 -08:00
Joerg Hofrichter
eaf0062254 mpm: rpc_server: fix get_log_buf for MPM Shell
Fix the issue that the method 'get_log_buf' was not accessible from
MPM Shell.
2020-12-04 12:08:13 -08:00
Joerg Hofrichter
f96ffb2218 fixup! mpm: Use prefs API in logging module 2020-12-04 12:07:16 -08:00
Aaron Rossetto
e9d7100b10 sim: Check for unit test prereqs and disable if unsatisfied 2020-10-28 15:25:48 -05:00
Samuel O'Brien
0003d990bb sim: Move SelectableQueue and SendWrapper
This commit moves these two classes from chdr_stream.py to
chdr_endpoint.py.

ChdrEndpoint needs to be aware of the specific implementation of these
classes, while ChdrInputStream and ChdrOutputStream treats them like
black boxes. Therefore, it makes more sense to have these classes
together with ChdrEndpoint

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
a5091cd526 sim: Support Out of Tree Sources and Sinks
This commit adds the ability to specify a path to an arbitrary python
file in a simulator config file, which will be imported and used to
construct a SampleSink or SampleSource for use with data streaming.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
a56f4f63e2 sim: Implement Sim > UHD Flow Control
This commit adds flow control support when streaming data from the
Simulator to UHD. It no longer ignores STRS packets.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
5df8202c0c sim: Move Hardware Specific to Config File
This commit moves various magic numbers and hardware specific settings
into the configuration file. It also provides default presets for said
configuration files which can be inherited from.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
687ed5bba0 sim: Implement UHD > Simulator Flow Control
When sending data to the simulator, python simply cannot process the
data as fast as UHD can send it. Flow control ensures that uhd doesn't
overwhelm the simulator. Simulator > UHD flow control isn't implemented
yet.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
e4517deef3 sim: Support Timed Streams
The only difference between a standard and timed stream is that the
first data packet of a timed stream contains a timestamp. This commit
adds the necessary fields to StreamSpec to accomplish this.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
00c306d5c4 sim: Integrate simulator into UHD
This commit adds a device::register_device which allows uhd to start up
a simulator when uhd is called with the arguments type=sim. Creating the
device object creates a subprocess using pybind and an embedded
interpreter, and destroying the object cleans up those subprocesses.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
bd278a4b93 sim: Support Configuration Files
This commit adds support for configuration files to the simulator. As of
now, these files only change the source and sink of data samples, but
they are easily extensible to add more configuration to the simulator.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
d42ddc8041 sim: Support Streaming
This commit add support for both Tx and Rx streams to the simulator.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Lane Kolbly
31872fa3b9 mpm: Add dependency on pyusrp_periphs to MPM
This change makes it so that changing the USRP periphs will cause a
`make install` to reinstall the libpyusrp_periphs.so library.
2020-10-15 07:51:52 -05:00
Samuel O'Brien
267365c945 sim: Clarify Naming of Streams
ChdrSniffer is renamed to ChdrEndpoint to clarify its function as the
actual destination of chdr packets, rather than just an observer.
TxWorker has been renamed to OutputStream and RxWorker has been renamed
to InputStream to avoid ambiguities regarding Tx and Rx terminology.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-08 07:44:12 -05:00
Samuel O'Brien
ee9085a494 sim: Simulator CHDR Parsing and RFNoC Graph
This commit adds a simulated RFNoC Graph to the simulator. It is also
able to process management and control packets which can traverse the
graph and read from simulated registers. Stub callbacks for creating
streams have been provided but are not implemented yet.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-08 07:44:12 -05:00
Samuel O'Brien
f54a22c60a sim: Embed MPM into libpyuhd
When ENABLE_SIM and ENABLE_PYTHON_API are set, this commit embeds MPM
(Built with -DMPM_DEVICE=sim) into the pyuhd package.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Samuel O'Brien
bfff8b79b9 sim: Add Daughterboard Methods
This commit adds daughterboard simulation to the simulator. There is a
sim_dboard class which registers it's methods with the rpc server. These
methods are visible over mpm as well as the mpm_shell.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Samuel O'Brien
6394a7c6ea sim: Lay Groundwork for Simulator
At this point, only about half of the mpm methods work on the simulator
    over the mpm shell, and it hasn't been tested with uhd at all.
    If you want to give it a try, first install all of the python
    dependencies of mpm (The simulator doesn't require libusrp or any of
    the C++ deps). In addition, running mpm on a desktop machine requires
    the python lib netifaces. Next, make an /mpm/build directory and open
    it. Run `cmake .. -DMPM_DEVICE=sim`, then `make`. Finally, run
    `python3 python/usrp_hwd.py`. You should be able to open another
    terminal and run `mpm/tools/mpm_shell.py localhost` to connect to the
    mpm server.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Samuel O'Brien
1bb603fffd mpm: Cleanup rpc_server.py
This commit fixes a spelling mistake, moves logic for checking if a
connection is local to its own method, and calls gevent.signal.signal
instead of its deprecated alias gevent.signal.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Joerg Hofrichter
a37413055e mpm: use filesystem_status from sys_utils
Use the utility functions for getting the filesystem version string
and for getting the Mender artifact which are now available in
usrp_mpm.sys_utils.
2020-10-06 15:21:27 -05:00
Joerg Hofrichter
86cadf12c5 mpm: added check-filesystem utility 2020-10-06 15:21:27 -05:00
Steven Koo
be53058a47 mpm: e31x: Accept FF terminated strings in eeprom
Older revisions of the e31x used FF terminated strings in the EEPROM.
The eeprom implementation didn't take this into account and would
fail on ascii conversion. This change resolves mpm bring up on the
older revisions by replacing FF with null. This didn't affect newer
revisions because they used null terminated strings.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2020-09-04 11:38:27 -07:00
mattprost
3d5d136534 mpm: Return 10 Gbs link speed on failure
The sysfs call used to determine link speed occasionally will fail and
return -1. In order to mitigate side effects from this behavior, return
10 Gbs link speed instead of 1 Gbs. This mitigates problems that occur
when this issue is seen on 10GbE ports. This approach was elected over
returning -1 to be handled on the host side in order to avoid breaking
mpm compatibility.

Signed-off-by: ettus <matt.prost@ni.com>
2020-09-01 15:19:30 -05:00
Steven Koo
92b2127909 mpm: exclude internal nic for network hosts
Sometimes the internal nic address is routable in network mode. This
causes mpm find to incorrectly set it as the addr. This commit removes
the internal interfaces from the routable list. This also sets the
forwarding interface as the last resort. mpm will prefer the SFP ports
since they can be higher throughput.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2020-08-19 18:05:10 -05:00
Martin Braun
31cafbb3ed rh: Enable inverse sinc filter for DAC37J82
This enables the inv_sinc_ab and inv_sinc_cd flags for the DAC,
turning on the inverse sinc filter.
2020-08-12 15:19:56 -05:00
Martin Braun
29394e2994 mpm: n3xx: Remove eth1, eth2 from interface list
These interfaces are renamed to sfp0 and sfp1 and thus don't exist. They
were kept in MPM for a while after the rename, but that was many
versions of UHD ago, and the current filesystem (which does the rename)
is not compatible with older versions of UHD anyway (and vice versa).

These aliases are thus dead code and can be removed.
2020-08-07 07:25:30 -05:00
Martin Braun
d05bacf120 mpm: Remove SID class
This class is a remnant of UHD 3, and is no longer used anywhere. SID is
no longer used at all in UHD, in fact, which means the class did not
represent a valid data structure.
2020-08-07 07:25:08 -05:00
Steven Koo
d81816a225 mpm: Reenable forward interfaces for remote hosts
The forward interfaces are able to forward CHDR packets with MPM
iptables routing. This reenables forward interfaces as a CHDR option.
2020-08-04 15:46:22 -05:00
Steve Czabaniuk
5e0cebdc19 mpm: n3xx: bist: Read mboard and dboard eeprom to determine product
The routine to identify products currently only reads the motherboard
EEPROM. The N310 and N320/N321 use the same motherboard so these devices
can't be distinguished using the motherboard EEPROM alone. This change
makes get_product_id() read both the motherboard and daughterboard
EEPROM in order to determine which N3xx it actually is.
2020-07-31 14:32:54 -05:00
Steven Koo
25a0e462dd mpm: Default virtual NIC CHDR IP selection
This change adds detection for setting the correct internal
fpga CHDR IP address when using embedded mode.
2020-07-30 11:39:00 -05:00
Samuel O'Brien
c91cf54766 mpm: Fix more gevent errors on SIGTERM
Sometimes when running usrp_hwd.py in a terminal and then canceling it
with Ctrl+C, it prints a really large stacktrace into the terminal
resulting from an uncaught gevent BlockingSwitchOutError. This comes
from trying to block on Process#join inside a gevent signal handler.

This commit resolves this issue by simply triggering an event in the
signal handler which prompts a different non-daemon thread to join the
subprocesses and end the parent process.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-28 16:16:54 -05:00
Martin Braun
31a107747a mpm: Fix documentation and minor issues in sys_utils.GPIOBank
- GPIOBank made the assumption that all bits used where contiguous. This amends
  the documentation to make that more clear, and adds an assert
  statement to check for that.
- reset_all() would reset all pins, regardless of DDR value, rendering
  it useless for any GPIO bank that would want to have readable pins.
  Fixed that by checking DDR value before resetting.
- Minor amendments to various docstrings; improve PyLint score by
  removing superfluous inheritance from object.
2020-07-28 15:57:00 -05:00
Samuel O'Brien
97852aba23 mpm: Fix gevent errors on SIGTERM
Sometimes when running usrp_hwd.py in a terminal and then canceling it
with Ctrl+C, it prints a really large stacktrace into the terminal
resulting from an uncaught gevent BlockingSwitchOutError. It seems like
there was an attempt to catch this in usrp_hwd.py:kill_time(). This
try-except was surrounding a call to Process.join() which, to the best
of my knowledge, can't ever throw this exception.

Based on my troubleshooting, this error comes from the SIGTERM signal
handler of the RPC process. The handler (defined in
rpc_server.py:_rpc_server_process), is just a direct call to
RPCServer.stop(). When the server's backed is a thread pool, this call
may block when joining the thread pool, causing gevent to complain about
execution attempting to block in a signal handler.

This commit resolves this issue by simply triggering an event in the
signal handler which prompts a different thread to clean up the server
and end the process.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-24 15:26:36 -05:00
RobertWalstab
54d698e370 fpga, mpm: Bump FPGA compat number 2020-07-24 15:24:14 -05:00
Aaron Rossetto
5023e66b2d mpm: Don't index empty forwarding interface list
If no internal interfaces are found to which to forward CHDR packets,
return after printing the warning instead of attempting to index the
empty list and generating an exception.
2020-07-24 15:24:14 -05:00
Aaron Rossetto
ad707ab22d mpm, mpmd: Bump MPM compat number 2020-07-24 15:24:14 -05:00
RobertWalstab
1d3866bef4 uhd: remove liberio 2020-07-20 16:01:03 -05:00
RobertWalstab
1182144336 mpm: remove class N3xxXportMgrLiberio 2020-07-16 10:00:12 -05:00
RobertWalstab
616bcbc4dd mpm: Fix a logging message 2020-07-16 10:00:12 -05:00
RobertWalstab
dc1ecbb8f0 mpm: Enable internal NIC on the N3xx 2020-07-16 10:00:12 -05:00
RobertWalstab
692249f2d2 mpm: remove class E310XportMgrLiberio 2020-07-16 10:00:12 -05:00
RobertWalstab
cc06b4dde6 mpm: Enable internal NIC on the E310 2020-07-16 10:00:12 -05:00
RobertWalstab
217ec54c7a mpm: remove class E320XportMgrLiberio 2020-07-16 10:00:12 -05:00
RobertWalstab
2dd09111cf mpm: support forwarding CHDR packets 2020-07-16 10:00:12 -05:00
Alex Williams
acafbd6055 mpm: Enable internal NIC on the E320
Add an entry for the internal NIC to E320.
2020-07-16 10:00:12 -05:00
Alex Williams
419d7dafa5 mpm,mpmd: Add iface type and mtu info for UDP links
This changes MTU handling for the "internal" UDP type. Because MPM
echo packets will not be returned for internal NICs, use the iface's
programmed MTU instead.
2020-07-16 10:00:12 -05:00
Andrew Lynch
eadbc21982 mpm: Add support for internal Ethernet interface 2020-07-16 10:00:12 -05:00
Alex Williams
40b563387b mpm: Detect number of liberio channels
Instead of using hard-coded values, detect the number of liberio
channels, and only offer liberio links if they exist.
2020-07-16 10:00:12 -05:00
Joerg Hofrichter
b252771600 mpm: utils: print error on minor compat number mismatch conditionally
If the minor compat number does not match (older than expected), then
generate an error message only if argument fail_on_old_minor is True;
generate a warning otherwise.
2020-07-13 15:22:59 -05:00
Martin Braun
5f79b8e378 docs: Add comments on mpm.conf
This adds some more details on mpm.conf, what it does, how it works, and
which keys it accepts.
2020-07-09 00:39:11 -07:00
Martin Braun
a252a2f3d8 mpm: Fix various Pylint issues
No functional changes. Fixes for things that PyLint complains about, but
are safe to change anyway, as well as a minor improvement to a docstring
that referenced non-existant args.

This touches files that are mpm.conf-related.
2020-07-09 00:39:11 -07:00
Steven Koo
e244764ffa mpm: Look for pca953x based devices by device/name
The pca953x driver introduced a change for how the "label" property
populates. Instead of using the device model, it gives a device specific
name. As a replacement, use device/name. This affects the tca6424
and tca6408.

For the kernel change that causes this see:
5128f8d445
2020-06-11 10:39:05 -05:00
Lane Kolbly
6aa090b7fd mpm: Return filesystem info from get_device_info
This commit returns information on the filesystem and mender artifact
versions to clients of the MPM RPC connection.
2020-06-05 15:03:08 -05:00
Lane Kolbly
512fd1151f mpm: Return dboard_info in get_device_info
Though this information is also returned via usrp_probe, it can be
useful to provide this information to trackers which scrape the
get_device_info RPC call.

The dboard information is split up and cast to string just to
simplify parsing on the receiving end.
2020-06-05 15:03:08 -05:00
Lane Kolbly
655b32fc1c mpm: Return build info in mpm_sw_version
The mpm_version key was being overridden by the MPM_COMPAT field in
rpc_server::get_device_info.
2020-05-27 09:45:41 -05:00
Joerg Hofrichter
9a45d4449f mpm: rpc_server: set correct default unpacker params for msgpack 0.6.1
msgpack 0.6.1 suggests new default parameters which ensures compatibility
with the upcoming msgpack 1.0 release which will have breaking changes.

The parameter changes are described in
https://github.com/msgpack/msgpack-python/blob/v0.6.1/README.rst

The default parameters for msgpack 1.0 will be:
- packer: use_bin_type=True
- unpacker: raw=False

The packer use_bin_type=True option is already set in the client
(mpm_shell.py) but the unpacker option raw=False needs to be set
in the server (rpc_server.py)

This change allows the usage of a patched version of python3-mprpc
0.1.17 which removes passing the encoding option to the Packer and
Unpacker

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
2020-03-05 12:07:25 -06:00
Andrew Lynch
5e7a2458a8 mpm: explicitly set max buffer size for msgpack unpacker
Msgpack version 0.6 reduced the default max buffer size to 1MB which is
smaller than the bitfiles. This change sets the max buffer size to 50MB
which is larger than the bitfiles.
2020-03-05 12:07:25 -06:00
Lane Kolbly
11bc3fa3a8 mpm: Make contextmanagers exception-safe
When making context managers in Python, the yield statement has to be wrapped in a try/finally clause in order to properly clean up after exceptions happen.
2020-03-03 15:16:06 -06:00
Toni Jones
f73f608d95 mpm: rpc: Use contextmanager for claim timeouts
Modify the RPC claim timeout mechanism to use a contextmanager
helper function when enabling/disabling timeouts.
2020-03-03 08:52:34 -06:00
Martin Braun
c74c56ef94 e320/e310: Fix get_gpio_srcs() MPM API call
The Python code contained a typo which would cause a call to
get_gpio_srcs() to throw an exception.
2020-02-26 08:41:34 -06:00
Martin Braun
657cc4c062 fixup! mpm: e320/e310: Expose APIs to drive GPIO source via UHD 2020-01-28 14:33:28 -08:00
Martin Braun
354886ed4c mpm: e320/e310: Expose APIs to drive GPIO source via UHD
This enables the *gpio_src* APIs for the E320 and the E31x.
2020-01-23 11:37:51 -08:00
Martin Braun
0cf54ce073 mpm/mpmd: Expose APIs to drive GPIO sources
The N310 has a feature that allows the front panel GPIOs to be driven by
various sources: The PS, or any of the radio channels. The MPM-based
APIs did not expose any way to change that.

Changes:
- Add MPM APIs to PeripheralManagerBase and n3xx classes
- Improve comments and explanations
- Add host-side hooks into these new APIs in mpmd_mb_controller
- Implement these APIs for N3xx

The N3xx devices will have the option to set the GPIO source to "PS", or
to one of "RF0", "RF1", "RF2", "RF3" (if there are four channels; the
N300 and N320 can only go up to RF1).

Note: The N310 radio does not have separate FP-GPIO banks for channels
0 and 1, which needs to be fixed in a separate commit.
2020-01-23 11:37:51 -08:00
Joerg Hofrichter
6ee886cfe2 mpm: optionally generate XML report when running unittests
If the unittests are invoked with an extra argument -x, an XML report
is generated if the xmlrunner module is installed
2020-01-22 12:19:03 -08:00
Martin Braun
1c3c7bddff mpm: mg: Make set_master_clock_rate() an async call
The ad9371 call set_master_clock_rate() can take a while depending on
the rate change, so make it asynchronous in order not to lock out the
reclaimer loop.
2019-11-26 12:21:35 -08:00
Martin Braun
e4c72d53d6 mpm: e31x: Remove superfluous code from e31x_periphs
- ref_locked failure would throw a warning, even though this can happen
  in normal operations, and the return value of the get_ref_locked()
  function is all the info needed
- get_fpga_type() doesn't need to be called from e31x_periphs, because
  it is not read from the motherboard registers (is read from the
  EEPROM)
2019-11-26 12:21:34 -08:00
Martin Braun
c481e32026 mpm: e31x: Fix setting of clock source
The clock source on E310 is always internal. This patch removes the
variables regarding the clock source (since they are superfluous). This
fixes a bug where self._clock_source on the e31x class would never get
initialized.
2019-11-26 12:21:34 -08:00
Martin Braun
9ede696528 mpm: e310: Enable GPS sensors
The GPS sensors are pulled in via gpsd_iface.
2019-11-26 12:21:34 -08:00
Martin Braun
14fb3cc6f4 e310: Fix issues in MPM and UHD
- Remove superfluous INFO logging
- Improve formatting in many places
- Improve Pylint score in various places
- Add tear_down to DB object
- Simplify custom EEPROM code for E310
- Fix time source selection code
- Remove references to GPS_CTRL and GPS_STATUS (are E320 only)
- Move clock source control out of MboardRegs object
2019-11-26 12:21:33 -08:00
Martin Braun
d60e4d87d8 mpm: Clean up code, improve Pylint score
Many small cleanups:
- Fix copyright headers
- Fix superfluous imports
- Pull some constants out of classes where appropriate
- Fix formatting
- Improve/fix some docstrings
- Disable specific Pylint warnings where appropriate
- Global catches use BaseException instead of Exception
- Don't use len() for empty checks
- Make sure to declare all self attributes in __init__ (note: this is
  particularly of interest for E310, becuase its regular init happens
  outside of __init__)
- Compacted some E310 code that had multi-DB checks
2019-11-26 12:21:33 -08:00
Martin Braun
ec488d49c0 mpm/mpmd: Remove token requirement for device info
This removes the token requirement for get_proto_ver() and
get_chdr_width().
2019-11-26 12:21:33 -08:00
Martin Braun
025ffdce34 mpm: Move common mboard regs code to common location
This assumes an existence of mboard_regs_control in PeriphManagerBase
and implements most TK controls there. All the *_periphs.py files can
now use a common class for registers, including the TK access, but also
git hash, build date, and device ID access.

This also fixes two issues:
- set_timekeeper_time() and set_tick_period() had a bug that would
  incorrectly calculate the upper 32 bits of their respective registers.
- N3xx had a bug that would swap around set time now and next PPS. This
  got auto-fixed because the common code never had this bug.
2019-11-26 12:21:33 -08:00
Martin Braun
d76cca76dd mpm: n3xx: Improve Pylint score
- Replace some `if len(seq)` with `if seq`
- Replace some `lambda: f()` with `f`
- Formatting
- Add some pylint: disable where appropriate
2019-11-26 12:21:33 -08:00
Aaron Rossetto
2da39536bb mpm: Fix calculation of link_rate for UDP xports 2019-11-26 12:21:32 -08:00
Alex Williams
f3a86a3294 rfnoc: Unify endianness of transports
Ethernet now uses the same serialization of the RFNoC stream as all
the other transports.
2019-11-26 12:21:31 -08:00
Martin Braun
7d69dcdcc3 Remove proto-RFNoC files
This commit removes all files and parts of files that are used by
proto-RFNoC only.

uhd: Fix include CMakeLists.txt, add missing files
2019-11-26 12:16:25 -08:00
Martin Braun
c256b9df65 x300/mpmd: Port all RFNoC devices to the new RFNoC framework
Co-Authored-By: Alex Williams <alex.williams@ni.com>
Co-Authored-By: Sugandha Gupta <sugandha.gupta@ettus.com>
Co-Authored-By: Brent Stapleton <brent.stapleton@ettus.com>
Co-Authored-By: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
2019-11-26 12:16:25 -08:00
Martin Braun
3b161d6f49 mpm: gpsd_iface: Sanitize return values for get_gps_info()
get_gps_info() can time out, or fail for other reasons. This adds some
checks to see if the return value is as expected.
2019-11-21 15:02:39 -08:00
Martin Braun
9d75460d36 mpm: rpc_server: Reenable timeouts after components have been updated
When updating a component like the FPGA, the timeouts for reclaiming get
disabled, because the update can potentially take a long time, during
which the RPC server might not be available.
There was a bug that didn't re-enable the timeouts. The most common case
where this causes issues was when the Ethernet connection was severed
during FPGA reloading, which could lead to UHD losing connection with
MPM altogether (for example because SFPs would come up with a different
IP address). In that case, MPM would remain unreachable until the next
reboot.
2019-10-28 14:39:16 -07:00
michael-west
c2f1f21d41 MPM: Add check for valid EEPROM address
Provides a more useful error message if the EEPROM cannot be found at
the specified address.  Without this change a generic index out of range
error is raised.

Signed-off-by: michael-west <michael.west@ettus.com>
2019-10-15 15:21:52 -07:00
Michael West
4042a319fd N3xx: Remove close-in noise on TX
Some close-in noise was observed on TX when using external references.
This change reduces the noise by changing U19 to select the GPSDO when
references are set to external.  Also included is a change to properly
read and apply settings from the configuration file.  This allows the
user to further quiet the transmission by adding 'enable_gps=False' to
the configuration file in order to power off the GPSDO.

Signed-off-by: Michael West <michael.west@ettus.com>
2019-10-11 12:26:12 -07:00
Martin Braun
96dd54c77a n3xx: Disable gpsdo reference source when enable_gps=0
When using enable_gps=0, the power to the LTE-Lite GPS chip is turned
off, and neither the reference sources (time/clock) nor the
location/time data (via gpsd) can be used.

This commit disables the gpsdo options for the set_time_source,
set_clock_source, and set_sync_source when enable_gps=0 is used, and
adds logging to inform the user about this.

This behaviour is consistent with X310, where `gpsdo` is only a valid
reference if the GPSDO module is plugged in.

The manual was also updated accordingly.
2019-10-11 12:25:52 -07:00
Martin Braun
da6bf176aa mpm: periph manager: Fix typo in docstring (update default args) 2019-10-11 12:25:52 -07:00
Joerg Hofrichter
3c38411bb6 mpm: usrp_hwd: fix for gevent 1.4.0
Openembedded release warrior includes python3-gevent 1.4.0 which
leads to the following error when starting usrp-hwd.py:

ImportError: cannot import name 'BlockingSwitchOutError' from 'gevent.hub'

This commit fixes the issue.

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
2019-10-08 12:03:47 -07:00
michael-west
abedbfe548 MPM: Increase E320 max rev to 4
Increase to currently shipping rev.

Signed-off-by: michael-west <michael.west@ettus.com>
2019-09-24 17:23:44 -07:00
Matthew Crymble
f47d805cc3 mpm: fixed mboard_max_revision value
This value should be 9 to correspond with the rev J motherboards.
This property was renamed to mboard_last_rev_compat in a previous commit.
But mboard_max_rev is actually a more accurate description,
since it specifies the latest hardware revision that the software
is aware of.  I renamed all references back to mboard_max_rev.
2019-09-24 17:23:44 -07:00
Martin Braun
227fe34217 n3xx: mg: Make set_freq() call asynchronous
This does not change the MPM/UHD API, but it makes the set_freq() call
asynchronous on the MPM side. The upside is that it will release the GIL
if the set_freq() call takes too long, e.g., because of MPM
calibrations.
2019-08-22 10:35:13 -07:00
Martin Braun
78f453f8b5 mpm: mg: Only import AD9371 API calls if not yet on Magnesium
This will avoid importing API calls from the self.mykonos object onto
the Magnesium class if the Magnesium class already has such a method.
2019-08-22 10:35:13 -07:00
Mark Meserve
0280a82aa0 e320: fix time source clobbering ref source
- Fixes a case where the e320 would be unable to lock to an external 10 MHz
  reference
- Previously, calling set_time_source would set the reference clock source to
  internal as a side effect
2019-08-15 09:00:09 -07:00
Martin Braun
e8b3319531 mpm: net: Fix typo in docstring 2019-07-20 14:41:00 -07:00
Patrick Sisterhen
c0f34ddf82 mpm: cmake: removing unnecessary destination prefix
Removing unnecessary CMAKE_INSTALL_PREFIX to destination for usrp mpm
python dir
2019-07-17 11:44:47 -07:00
Thomas Vogel
b89f76bd4d n3xx: bugfix for mpm set_db_eeprom access via network
access or data as bytes instead of str was not possible due to unconditional assert check for str
2019-06-13 09:00:46 -07:00
Trung Tran
75dc7a1d64 mpm: Change SW/HW compat check to use last_rev_compat
Newer revisions of the E320 and N3xx motherboards use EEPROM version 3,
and store a rev_compat field. The rev_compat is the last revision that
this hardware is compatible with. We now use that instead of simply the
revision.
2019-05-10 16:59:58 -07:00
Martin Braun
0812a5f6bf mpm: Add MB-EEPROMv3
This includes a rev_compat field, which we can use to identify the last
hardware revision this hardware is compatible with. Example: Say the
current hardware revision is 7, but it is compatible with version 5,
then we store 7 as the current rev, and 5 as the rev_compat. Software
can now check the rev_compat rather than the current rev for
compatibility. This makes MPM more future-proof against minor,
compatible hardware changes.
2019-05-10 16:59:58 -07:00
michael-west
436df1087b E320: Add support for rev E
- No driver changes required

Signed-off-by: michael-west <michael.west@ettus.com>
2019-05-02 08:35:59 -07:00
Sugandha Gupta
178b35569b e310/e320: Move E310 to MPM architecture and refactor
- Turns the E310 into an MPM device (like N3xx, E320)
- Factor out common code between E320 and E310, maximize sharing between
  the two devices
- Remove all pre-MPM E310 code that is no longer needed
- Modify MPM to remove all existing overlays before applying new ones
  (this is necessary to enable idle image mode for E310)

Co-authored-by: Virendra Kakade <virendra.kakade@ni.com>
Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
2019-05-01 15:17:23 -07:00
Sugandha Gupta
8a400f6a30 mpm: Add option for muxed data stream for liberio transport
If the number of channels for embedded mode streaming is 4
(1 for ctrl, 1 for async messages and 2 for data ), we need to
mux the data transport. This is needed for E310
2019-05-01 15:17:23 -07:00
Sugandha Gupta
b709c03e8b mpm: sys_utils: Remove hardcoded 'subsystem' for temp sensor
This is needed for E31x with thermal sensors on different
subsystems e.g. iio, hwmon.
2019-05-01 15:17:23 -07:00
Toni Jones
3642ac013e mpm: Generalize unittest Test Case functionality
Pull some general functionality out of a specific test case and create
a TestBase class. Future test cases will inherit from TestBase and have
access to this general functionality.
2019-04-11 09:11:43 -07:00
Martin Braun
164d76dcfd mpm: python: Move from Boost.Python to PyBind11 2019-04-02 10:39:57 -07:00
Toni Jones
8b080a8a14 cmake: Add unit testing framework to MPM
Add unit testing framework to MPM which can be run by calling
"make test". The testing is done using the built in unittest Python
module. Tests can be run on a dev machine or on the USRP itself when
compiling natively.
2019-03-26 15:15:05 -07:00
Martin Braun
d399ff0ac8 mpm: python: Clean out cruft
Remove some unused files.
2019-03-21 12:06:26 -07:00
Brent Stapleton
431deb855b uhd: mpm: update all license header w/ "-or-later"
Updating all SPDX license identifiers to include "-or-later"
2019-03-08 00:43:07 +01:00
Martin Braun
435a1f13b8 mpm: rpc_server: Improve error message on double-claim
The error message will now include the IP address of the client trying
to double-claim a device.
2019-02-22 16:12:23 -08:00
Martin Braun
2a4f196068 mpm: rhodium: Fix clock value log formatting
Before, the log messages would occasionally print 6 digits worth of
precision for sample clock values that only require 2.
2019-02-22 16:12:23 -08:00
Martin Braun
0c658067bd mpm: rhodium: Fix typo in log message 2019-02-22 09:20:10 -08:00
Martin Braun
f0da25b14d mpm: n320: Update FPGA type if QSFP board is available
The N320 has FPGA types (XQ, AQ) which cannot be derived from the mboard
regs in the same way as the non-QSFP variants. We therefore bite the
bullet and hardcode those.
2019-02-22 09:20:10 -08:00
Martin Braun
356d623c23 mpm: n320: Demote warning on absence of QSFP board
The QSFP board can't be detected if support for it is not baked into
the current FPGA image, so the warning on its absence may be incorrect.
2019-02-22 09:20:10 -08:00
Martin Braun
1e5674967d mpm: bist: DDR3 test only enumerates first block 2019-02-20 12:31:49 -08:00
Martin Braun
fa52c97c00 mpm: n3xx: bist: Auto-load the AA image for the ddr3 BIST
When running

    $ n3xx_bist ddr3

The test will now load the AA image if the BIST fails, unless the user
specifies

    $ n3xx_bist ddr3 -o skip_load_fpga=1

The rationale is that by default, the AA image is the only one that
includes the DmaFIFO block.
2019-02-20 12:31:49 -08:00
Martin Braun
694538f595 mpm: n3xx: BIST: Improve DDR3 BIST to check for DmaFIFO
The capability to run the DDR3 BIST is built into the DmaFIFO RFNoC
block, which is not always available. This change performs a quick check
before for its existence before retrieving the throughput values, and
thus can provide a better error message in that case.
2019-02-20 12:31:49 -08:00
Martin Braun
564a106bd8 mpm: n3xx: Remove DDR3 from standard BIST collection
We can't guarantee that there is actually a DDR3/DRAM FIFO block on the
image. So, don't run that test by default.
In order to run the DDR3 bist, running `n3xx_bist ddr3` is still valid.
However, it requires an image with the DRAM FIFO enabled.
2019-02-20 12:31:49 -08:00
Sugandha Gupta
effa0dacad e320: add fpga_version_hash to e320 device info
Fixes uhd_usrp_probe FPGA version githash to report the
correct hash and not 'UNKNOWN'.
2019-02-19 18:12:11 -08:00
Martin Braun
94bc1897c9 mpm: n320: Properly check for the LO distribution board
Without this patch, the N320 code will rely on an error to occur to
determine the non-existence of the N321 LO distribution board. While
this works, it forces an error message where there's no error. This will
first check for the existence of the board before trying to initialize
it.
2019-02-19 15:33:05 -08:00
michael-west
a8109bc170 N3xx: Update max rev to 7
Hardware revision was increased due to new firmware.  No software
changes are required.

Signed-off-by: michael-west <michael.west@ettus.com>
2019-02-19 13:58:39 -08:00
Brent Stapleton
6bc92ce1e2 mpm: xport: add commit_xport docstring 2019-02-11 17:12:52 -08:00
Trung Tran
3fb8cfe96c n3xx: init peripherals before loading FPGA
Issue: Current code loads FPGA too early while many
essential peripherals such as net clocks are not brought up.

This change will make sure those are got init before FPGA loaded.

Signed-off-by: Trung Tran<trung.tran@ettus.com>
2019-02-01 15:28:35 -08:00
Alex Williams
6e8b0ec413 mpm: Parameterize max UDP link allocation
Add an argument to the UDP xport_mgr to adjust the xport sorting. This
enables Rhodium to use a different limit from Magnesium. Previously, the
sorting method would overload a link with both of Rhodium's higher-rate
streams.
2019-01-25 15:01:03 -08:00
Alex Williams
10ad1a6626 mpm: Fix up Rhodium EEPROM handling for BfrfsEEPROM
Fixes Rhodium for changes introduced in b7bab6a. The constructor call
for BfrfsEEPROM didn't match the signature, and Rhodium's EEPROM map
referred to the wrong revision.
2019-01-23 13:21:15 -08:00
Martin Braun
9e14b14485 rhodium: Fix some Pylint warnings
Remove some semicolons and superfluous imports.
2019-01-21 13:41:22 -08:00
Ryan Marlow
18cfd25129 mpm: n3xx: e320: Add bridge mode support 2019-01-17 15:38:23 -08:00
Sugandha Gupta
a4289bca10 mpm: xportmgr_udp: Add bridge mode support 2019-01-17 15:38:23 -08:00
Sugandha Gupta
169e3c4bef mpm: ethtable: Add support for bridge mode to Ethernet dispatcher
In bridge mode, packets may be arriving at the Ethernet device which
aren't meant for this device, and thus need different routing
instructions.
2019-01-17 15:38:23 -08:00