diff options
author | Josh Blum <josh@joshknows.com> | 2010-09-30 15:03:04 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-09-30 15:03:04 -0700 |
commit | ccb7adcb150ae481ce08d4e0fa32641b5aec4e6e (patch) | |
tree | 111e27a507d711f890f99ea47c57f25757482e03 /host/lib/usrp/usrp1/usrp1_ctrl.cpp | |
parent | 507283b3d43d653bf7ff1b2aa04f3d642297c9b1 (diff) | |
parent | 790a5ac665144180cde712d46b799a115bb74e46 (diff) | |
download | uhd-ccb7adcb150ae481ce08d4e0fa32641b5aec4e6e.tar.gz uhd-ccb7adcb150ae481ce08d4e0fa32641b5aec4e6e.tar.bz2 uhd-ccb7adcb150ae481ce08d4e0fa32641b5aec4e6e.zip |
Merge branch 'master' into usrp_e_next
Diffstat (limited to 'host/lib/usrp/usrp1/usrp1_ctrl.cpp')
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_ctrl.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.cpp b/host/lib/usrp/usrp1/usrp1_ctrl.cpp index 1dc6e6e25..5043aed7d 100644 --- a/host/lib/usrp/usrp1/usrp1_ctrl.cpp +++ b/host/lib/usrp/usrp1/usrp1_ctrl.cpp @@ -38,6 +38,8 @@ enum firmware_code { #define FX2_FIRMWARE_LOAD 0xa0 +static const bool load_img_msg = true; + /*********************************************************************** * Helper Functions **********************************************************************/ @@ -178,6 +180,7 @@ public: unsigned char reset_n = 0; //hit the reset line + if (load_img_msg) std::cout << "Loading firmware image: " << filestring << "..." << std::flush; usrp_control_write(FX2_FIRMWARE_LOAD, 0xe600, 0, &reset_y, 1); @@ -206,14 +209,14 @@ public: } //type 0x01 is end else if (type == 0x01) { + usrp_set_firmware_hash(hash); //set hash before reset usrp_control_write(FX2_FIRMWARE_LOAD, 0xe600, 0, &reset_n, 1); - usrp_set_firmware_hash(hash); file.close(); //wait for things to settle boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - + if (load_img_msg) std::cout << " done" << std::endl; return USRP_FIRMWARE_LOAD_SUCCESS; } //type anything else is unhandled @@ -249,6 +252,7 @@ public: unsigned char buf[ep0_size]; int ret; + if (load_img_msg) std::cout << "Loading FPGA image: " << filestring << "..." << std::flush; std::ifstream file; file.open(filename, std::ios::in | std::ios::binary); if (not file.good()) { @@ -263,11 +267,12 @@ public: return -1; } - ssize_t n; - while ((n = file.readsome((char *)buf, sizeof(buf))) > 0) { + while (not file.eof()) { + file.read((char *)buf, sizeof(buf)); + size_t n = file.gcount(); ret = usrp_control_write(VRQ_FPGA_LOAD, 0, FL_XFER, buf, n); - if (ret != n) { + if (ret < 0 or size_t(ret) != n) { std::cerr << "fpga load error " << ret << std::endl; file.close(); return -1; @@ -282,6 +287,7 @@ public: usrp_set_fpga_hash(hash); file.close(); + if (load_img_msg) std::cout << " done" << std::endl; return 0; } |