test if special file when updating kernel(solution: reboot only), --force-delete-normal-file used to force delete bfin fpga drive if normal file and create proper device tree

This commit is contained in:
2022-03-22 16:44:12 +01:00
parent f538b8b10b
commit 0f4bcf3a9d
11 changed files with 194 additions and 57 deletions

View File

@ -2866,19 +2866,31 @@ std::string CmdProxy::ProgramFpga(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[fname.pof | fname.rbf (full path)]\n\t[Jungfrau][Ctb][Moench] "
"Programs FPGA from pof file (full path). Then, detector "
"controller is rebooted \n\t[Mythen3][Gotthard2] Programs FPGA "
"from rbf file (full path). Then, detector controller is "
"rebooted."
os << "[fname.pof | fname.rbf (full "
"path)][(opitonal)--force-delete-normal-file]\n\t[Jungfrau][Ctb]["
"Moench] Programs FPGA from pof file (full path). Then, detector "
"controller is rebooted. \n\t\tUse --force-delete-normal-file "
"argument, if normal file found in device tree, it must be "
"deleted, a new device drive created and programming "
"continued.\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file "
"(full path). Then, detector controller is rebooted."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
bool forceDeteleNormalFile = false;
if (args.size() == 2) {
if (args[1] != "--force-delete-normal-file") {
throw sls::RuntimeError(
"Could not scan second argument. Did you "
"mean --force-delete-normal-file?");
}
forceDeteleNormalFile = true;
} else if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->programFPGA(args[0], std::vector<int>{det_id});
det->programFPGA(args[0], forceDeteleNormalFile,
std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");

View File

@ -2182,10 +2182,11 @@ void Detector::setAdditionalJsonParameter(const std::string &key,
// Advanced
void Detector::programFPGA(const std::string &fname, Positions pos) {
void Detector::programFPGA(const std::string &fname,
const bool forceDeleteNormalFile, Positions pos) {
LOG(logINFO) << "Updating Firmware...";
std::vector<char> buffer = pimpl->readProgrammingFile(fname);
pimpl->Parallel(&Module::programFPGA, pos, buffer);
pimpl->Parallel(&Module::programFPGA, pos, buffer, forceDeleteNormalFile);
rebootController(pos);
}
@ -2230,7 +2231,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
programFPGA(fname, pos);
programFPGA(fname, false, pos);
}
void Detector::updateFirmwareAndServer(const std::string &sname,
@ -2241,7 +2242,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
std::string filename = sls::getFileNameFromFilePath(sname);
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
programFPGA(fname, pos);
programFPGA(fname, false, pos);
}
Result<bool> Detector::getUpdateMode(Positions pos) const {

View File

@ -2551,12 +2551,14 @@ void Module::setAdditionalJsonParameter(const std::string &key,
}
// Advanced
void Module::programFPGA(std::vector<char> buffer) {
void Module::programFPGA(std::vector<char> buffer,
const bool forceDeleteNormalFile) {
switch (shm()->detType) {
case JUNGFRAU:
case CHIPTESTBOARD:
case MOENCH:
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware");
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware", "",
forceDeleteNormalFile);
break;
case MYTHEN3:
case GOTTHARD2:
@ -3547,7 +3549,8 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
void Module::sendProgram(bool blackfin, std::vector<char> buffer,
const int functionEnum,
const std::string &functionType,
const std::string serverName) {
const std::string serverName,
const bool forceDeleteNormalFile) {
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending " << functionType;
@ -3571,6 +3574,11 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
client.Send(sname);
}
// send forceDeleteNormalFile flag
if (blackfin) {
client.Send(static_cast<int>(forceDeleteNormalFile));
}
// validate memory allocation etc in detector
if (client.Receive<int>() == FAIL) {
std::ostringstream os;

View File

@ -544,7 +544,8 @@ class Module : public virtual slsDetectorDefs {
* Advanced *
* *
* ************************************************/
void programFPGA(std::vector<char> buffer);
void programFPGA(std::vector<char> buffer,
const bool forceDeleteNormalFile);
void resetFPGA();
void copyDetectorServer(const std::string &fname,
const std::string &hostname);
@ -760,7 +761,8 @@ class Module : public virtual slsDetectorDefs {
bool trimbits = true);
void sendProgram(bool blackfin, std::vector<char> buffer,
const int functionEnum, const std::string &functionType,
const std::string serverName = "");
const std::string serverName = "",
const bool forceDeleteNormalFile = false);
void simulatingActivityinDetector(const std::string &functionType,
const int timeRequired);