aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Szymaniak <jon.szymaniak@gmail.com>2013-10-26 16:26:16 -0400
committerDimitri Stolnikov <horiz0n@gmx.net>2013-10-30 18:59:59 +0100
commitb8441496288aa319f4aeaabd9df63c58be53e916 (patch)
tree04433919302c454c6fc6e3037c1c9074f6d10674
parent44bd325a86352e5869017522e0a4990c5a22c4c3 (diff)
bladerf: Don't reload the FPGA unless the force-reload param is set
-rw-r--r--lib/bladerf/bladerf_common.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc
index 3833f34..60fc95a 100644
--- a/lib/bladerf/bladerf_common.cc
+++ b/lib/bladerf/bladerf_common.cc
@@ -149,14 +149,23 @@ void bladerf_common::init(dict_t &dict, const char *type)
/* Load an FPGA */
if ( dict.count("fpga") )
{
- std::string fpga = dict["fpga"];
-
- std::cerr << _pfx << "Loading FPGA bitstream " << fpga << "..." << std::endl;
- ret = bladerf_load_fpga( _dev.get(), fpga.c_str() );
- if ( ret != 0 )
- std::cerr << _pfx << "bladerf_load_fpga has failed with " << ret << std::endl;
- else
- std::cerr << _pfx << "The FPGA bitstream has been successfully loaded." << std::endl;
+
+ if ( dict.count("fpga-reload") == 0 &&
+ bladerf_is_fpga_configured( _dev.get() ) == 1 ) {
+
+ std::cerr << _pfx << "FPGA is already loaded. Set fpga-reload=1 "
+ << "to force a reload." << std::endl;
+
+ } else {
+ std::string fpga = dict["fpga"];
+
+ std::cerr << _pfx << "Loading FPGA bitstream " << fpga << "..." << std::endl;
+ ret = bladerf_load_fpga( _dev.get(), fpga.c_str() );
+ if ( ret != 0 )
+ std::cerr << _pfx << "bladerf_load_fpga has failed with " << ret << std::endl;
+ else
+ std::cerr << _pfx << "The FPGA bitstream has been successfully loaded." << std::endl;
+ }
}
if ( bladerf_is_fpga_configured( _dev.get() ) != 1 )