LimeUtil: use LMS7_Device::Program() to flash GW/FW (resolves
#include <fstream>
#include "Logger.h"
#include "LMS64CProtocol.h"
+#include "lms7_device.h"
+#include "device_constants.h"
using namespace lime;
@@ -217,7 +219,7 @@ static int programGateware(const std::string &argStr)
return EXIT_FAILURE;
}
std::cout << "Connected to [" << handles[0].ToString() << "]" << std::endl;
- auto conn = ConnectionRegistry::makeConnection(handles[0]);
+ auto device = LMS7_Device::CreateDevice(handles[0]);
auto progCallback = [](int bsent, int btotal, const char* progressMsg)
{
@@ -226,23 +228,11 @@ static int programGateware(const std::string &argStr)
return 0;
};
- int device = LMS64CProtocol::FPGA; //Altera FPGA
- int progMode = 1; //Bitstream to FLASH
- auto status = conn->ProgramWrite(progData.data(), progData.size(), progMode, device, progCallback);
-
+ auto status = device->Program(program_mode::fpgaFlash, progData.data(), progData.size(), progCallback);
std::cout << std::endl;
- if(status == 0)
- {
- //boot from FLASH
- status = conn->ProgramWrite(nullptr, 0, 2, device, nullptr);
- if(status == 0)
- std::cout << "FPGA boot from FLASH completed!" << std::endl;
- else
- std::cout << "FPGA boot from FLASH failed!"<< GetLastErrorMessage() << std::endl;
- }
- else
+ if(status != 0)
std::cout << "Programming failed! : " << GetLastErrorMessage() << std::endl;
- ConnectionRegistry::freeConnection(conn);
+ delete device;
return (status==0)?EXIT_SUCCESS:EXIT_FAILURE;
}
@@ -274,7 +264,7 @@ static int programFirmware(const std::string &argStr)
return EXIT_FAILURE;
}
std::cout << "Connected to [" << handles[0].ToString() << "]" << std::endl;
- auto conn = ConnectionRegistry::makeConnection(handles[0]);
+ auto device = LMS7_Device::CreateDevice(handles[0]);
auto progCallback = [](int bsent, int btotal, const char* progressMsg)
{
@@ -283,23 +273,11 @@ static int programFirmware(const std::string &argStr)
return 0;
};
- int device = LMS64CProtocol::FX3; //FX3
- int progMode = 2; //Firmware to FLASH
- auto status = conn->ProgramWrite(progData.data(), progData.size(), progMode, device, progCallback);
-
+ auto status = device->Program(program_mode::fx3Flash, progData.data(), progData.size(), progCallback);
std::cout << std::endl;
- if(status == 0)
- {
- //Reset device
- status = conn->ProgramWrite(nullptr, 0, 0, device, nullptr);
- if(status == 0)
- std::cout << "FX3 firmware uploaded, device has been reset" << std::endl;
- else
- std::cout << "FX3 firmware uploaded, failed to reset device" << std::endl;
- }
- else
+ if(status != 0)
std::cout << "Programming failed! : " << GetLastErrorMessage() << std::endl;
- ConnectionRegistry::freeConnection(conn);
+ delete device;
return (status==0)?EXIT_SUCCESS:EXIT_FAILURE;
}
