diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2017-11-06 09:54:06 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:05 -0800 |
commit | 7cab06dd395928f3cc68560ec3947c181046f017 (patch) | |
tree | 30718507616f8756592663cce4a38638fc3039e6 /host/lib | |
parent | db6264c28e2f460e605fd5781f5188067ab4743b (diff) | |
download | uhd-7cab06dd395928f3cc68560ec3947c181046f017.tar.gz uhd-7cab06dd395928f3cc68560ec3947c181046f017.tar.bz2 uhd-7cab06dd395928f3cc68560ec3947c181046f017.zip |
fpga load: adding updateable components to mpmd property tree
The FPGA image, and other components, can now be set from the property tree. The registered function expects a component_file_t, which combines the data file and metadata dictionary.
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index fa10c74e8..6285ca11c 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -27,6 +27,7 @@ #include <uhd/utils/tasks.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/eeprom.hpp> +#include <uhd/types/component_file.hpp> #include <uhd/usrp/mboard_eeprom.hpp> #include <boost/algorithm/string.hpp> #include <boost/asio.hpp> @@ -52,6 +53,23 @@ namespace { /************************************************************************* * Helper functions ************************************************************************/ + uhd::usrp::component_file_t _update_component( + const uhd::usrp::component_file_t& comp, + mpmd_mboard_impl *mb + ) { + std::vector<uint8_t> data = comp.data; + std::map<std::string, std::string> metadata; + for (const auto& key : comp.metadata.keys()) { + metadata[key] = comp.metadata[key]; + } + mb->rpc->notify_with_token("update_component", metadata, data); + + uhd::usrp::component_file_t comp_copy; + comp_copy.metadata = comp.metadata; + return comp_copy; + } + + void init_property_tree( uhd::property_tree::sptr tree, fs_path mb_path, @@ -151,6 +169,26 @@ namespace { return mb_eeprom_dict; }) ; + + /*** Updateable Components ******************************************/ + std::vector<std::string> updateable_components = {"fpga"}; + //TODO: get with "list_updateable_components" + UHD_LOG_DEBUG("MPMD", + "Found " << updateable_components.size() << " updateable motherboard components." + ); + for (const auto& comp_name : updateable_components) { + UHD_LOG_TRACE("MPMD", + "Adding motherboard component: " << comp_name); + tree->create<uhd::usrp::component_file_t>(mb_path / "components" / comp_name) + .set_coercer([mb](const uhd::usrp::component_file_t& comp_file) { + return _update_component( + comp_file, + mb + ); + }) + ; + } + } void reset_time_synchronized(uhd::property_tree::sptr tree) |