diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2017-11-10 17:34:24 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:43 -0800 |
commit | a2029b0439e6474b25c189c3f1741caac8006c11 (patch) | |
tree | 1f4e558f714b6ee3bf9f08528ecd387e45dbc065 /host/lib/usrp/mpmd/mpmd_impl.cpp | |
parent | 61774a09613eed51a42496f8689b707417b360f2 (diff) | |
download | uhd-a2029b0439e6474b25c189c3f1741caac8006c11.tar.gz uhd-a2029b0439e6474b25c189c3f1741caac8006c11.tar.bz2 uhd-a2029b0439e6474b25c189c3f1741caac8006c11.zip |
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.
Diffstat (limited to 'host/lib/usrp/mpmd/mpmd_impl.cpp')
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index 58b5682c1..f0498cf99 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -36,6 +36,7 @@ #include <mutex> #include <random> #include <string> +#include <vector> using namespace uhd; @@ -52,20 +53,37 @@ namespace { /************************************************************************* * Helper functions ************************************************************************/ - uhd::usrp::component_file_t _update_component( - const uhd::usrp::component_file_t& comp, + uhd::usrp::component_files_t _update_component( + const uhd::usrp::component_files_t& comps, 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]; + // Construct the arguments to update component + std::vector<std::vector<uint8_t>> all_data; + std::vector<std::map<std::string, std::string>> all_metadata; + // Also construct a copy of just the metadata to store in the property tree + uhd::usrp::component_files_t all_comps_copy; + + for (const auto& comp : comps) { + // Make a map for update components args + std::map<std::string, std::string> metadata; + // Make a component copy to add to the property tree + uhd::usrp::component_file_t comp_copy; + // Copy the metadata + for (const auto& key : comp.metadata.keys()) { + metadata[key] = comp.metadata[key]; + comp_copy.metadata[key] = comp.metadata[key]; + } + // Copy to the update component args + all_data.push_back(comp.data); + all_metadata.push_back(metadata); + // Copy to the property tree + all_comps_copy.push_back(comp_copy); } - mb->rpc->notify_with_token("update_component", metadata, data); - uhd::usrp::component_file_t comp_copy; - comp_copy.metadata = comp.metadata; - return comp_copy; + // Now call update component + mb->rpc->notify_with_token("update_component", all_metadata, all_data); + + return all_comps_copy; } @@ -174,16 +192,17 @@ namespace { mb->rpc->request<std::vector<std::string>>( "list_updateable_components" ); + // TODO: Check the 'id' against the registered property 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) { + tree->create<uhd::usrp::component_files_t>(mb_path / "components" / comp_name) + .set_coercer([mb](const uhd::usrp::component_files_t& comp_files) { return _update_component( - comp_file, + comp_files, mb ); }) |