From 20a959bf619943ac1cc103b11aa80cca2823f39b Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 8 Sep 2020 15:08:45 +0200 Subject: [PATCH] update mode to skip firmware checks and setupDetector, kernel check added to m3and g2 --- .../slsDetectorFunctionList.c | 10 +++-- .../slsDetectorFunctionList.c | 5 ++- .../slsDetectorFunctionList.c | 29 +++++++++++-- .../slsDetectorServer_defs.h | 1 + .../slsDetectorFunctionList.c | 12 ++++-- .../slsDetectorFunctionList.c | 10 +++-- .../slsDetectorFunctionList.c | 10 +++-- .../slsDetectorFunctionList.c | 29 +++++++++++-- .../slsDetectorServer_defs.h | 41 ++++++++++--------- .../include/slsDetectorFunctionList.h | 3 ++ .../slsDetectorServer/src/slsDetectorServer.c | 26 ++++++++---- .../src/slsDetectorServer_funcs.c | 1 + 12 files changed, 125 insertions(+), 52 deletions(-) diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 82b4445bf..5d5d88428 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -23,6 +23,7 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; +extern int updateFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -105,8 +106,9 @@ void basictests() { } // does check only if flag is 0 (by default), set by command line - if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || - (testBus() == FAIL))) { + if ((!debugflag) && (!updateFlag) && + ((checkType() == FAIL) || (testFpga() == FAIL) || + (testBus() == FAIL))) { strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. " "Dangerous to continue.\n"); LOG(logERROR, ("%s\n\n", initErrorMessage)); @@ -145,7 +147,7 @@ void basictests() { (long long int)client_sw_apiversion)); // return if flag is not zero, debug mode - if (debugflag) { + if (debugflag || updateFlag) { return; } @@ -417,7 +419,7 @@ uint32_t getDetectorIP() { /* initialization */ void initControlServer() { - if (initError == OK) { + if (!updateFlag && initError == OK) { setupDetector(); } initCheckDone = 1; diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index e15b9cd4b..2af8a70e0 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -20,6 +20,7 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; +extern int updateFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -140,7 +141,7 @@ void basictests() { return; #endif // return if debugflag is not zero, debug mode - if (debugflag) { + if (debugflag || updateFlag) { return; } @@ -319,7 +320,7 @@ u_int32_t getDetectorIP() { void initControlServer() { LOG(logINFOBLUE, ("Configuring Control server\n")); - if (initError == OK) { + if (!updateFlag && initError == OK) { readDetectorNumber(); getModuleConfiguration(); #ifndef VIRTUAL diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index e00ffd8cf..be677b186 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -22,6 +22,7 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; +extern int updateFlag; extern int checkModuleFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -92,8 +93,9 @@ void basictests() { return; } // does check only if flag is 0 (by default), set by command line - if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || - (testBus() == FAIL))) { + if ((!debugflag) && (!updateFlag) && + ((checkKernelVersion() == FAIL) || (checkType() == FAIL) || + (testFpga() == FAIL) || (testBus() == FAIL))) { sprintf(initErrorMessage, "Could not pass basic tests of FPGA and bus. Dangerous to " "continue. (Firmware version:0x%llx) \n", @@ -131,7 +133,7 @@ void basictests() { (long long int)client_sw_apiversion)); // return if flag is not zero, debug mode - if (debugflag) { + if (debugflag || updateFlag) { return; } @@ -175,6 +177,25 @@ void basictests() { #endif } +int checkKernelVersion() { +#ifdef VIRTUAL + return OK; +#endif + char output[256]; + memset(output, 0, 256); + FILE *sysFile = popen("uname -a | cut -d ' ' -f5-10", "r"); + fgets(output, sizeof(output), sysFile); + pclose(sysFile); + + if (strstr(output, KERNEL_DATE_VRSN) == NULL) { + LOG(logERROR, ("Kernel Version Incompatible! Expected: %s, Got: %s\n", + KERNEL_DATE_VRSN, output)); + return FAIL; + } + LOG(logINFO, ("Kernel Version Compatible: %s\n", output)); + return OK; +} + int checkType() { #ifdef VIRTUAL return OK; @@ -326,7 +347,7 @@ u_int32_t getDetectorIP() { /* initialization */ void initControlServer() { - if (initError == OK) { + if (!updateFlag && initError == OK) { setupDetector(); } initCheckDone = 1; diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 439817a66..8c3127f90 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -2,6 +2,7 @@ #include "sls_detector_defs.h" #define REQRD_FRMWRE_VRSN (0x200707) +#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020" #define CTRL_SRVR_INIT_TIME_US (300 * 1000) diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index efb363500..60df02ce0 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -18,6 +18,9 @@ #include #endif +// Global variable from slsDetectorServer_funcs +extern int debugflag; +extern int updateFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -91,7 +94,8 @@ void basictests() { } // does check only if flag is 0 (by default), set by command line - if (((checkType() == FAIL) || (testFpga() == FAIL) || + if ((!debugflag) && (!updateFlag) && + ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. " "Dangerous to continue.\n"); @@ -125,7 +129,9 @@ void basictests() { (long long int)fwversion, (long long int)swversion, (long long int)client_sw_apiversion)); - LOG(logINFO, ("Basic Tests - success\n")); + if (!debugflag || updateFlag) { + LOG(logINFO, ("Basic Tests - success\n")); + } #endif } @@ -343,7 +349,7 @@ u_int32_t getBoardRevision() { /* initialization */ void initControlServer() { - if (initError == OK) { + if (!updateFlag && initError == OK) { setupDetector(); } initCheckDone = 1; diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 1abd28024..f101cf97e 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -22,6 +22,7 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; +extern int updateFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -77,8 +78,9 @@ void basictests() { } // does check only if flag is 0 (by default), set by command line - if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || - (testBus() == FAIL))) { + if ((!debugflag) && (!updateFlag) && + ((checkType() == FAIL) || (testFpga() == FAIL) || + (testBus() == FAIL))) { strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. " "Dangerous to continue.\n"); LOG(logERROR, ("%s\n\n", initErrorMessage)); @@ -119,7 +121,7 @@ void basictests() { (long long int)client_sw_apiversion)); // return if flag is not zero, debug mode - if (debugflag) { + if (debugflag || updateFlag) { return; } @@ -347,7 +349,7 @@ u_int32_t getDetectorIP() { /* initialization */ void initControlServer() { - if (initError == OK) { + if (!updateFlag && initError == OK) { setupDetector(); } initCheckDone = 1; diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index a31dec027..ae8360d75 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -21,6 +21,7 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; +extern int updateFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -101,8 +102,9 @@ void basictests() { } // does check only if flag is 0 (by default), set by command line - if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || - (testBus() == FAIL))) { + if ((!debugflag) && (!updateFlag) && + ((checkType() == FAIL) || (testFpga() == FAIL) || + (testBus() == FAIL))) { strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. " "Dangerous to continue.\n"); LOG(logERROR, ("%s\n\n", initErrorMessage)); @@ -141,7 +143,7 @@ void basictests() { (long long int)client_sw_apiversion)); // return if flag is not zero, debug mode - if (debugflag) { + if (debugflag || updateFlag) { return; } @@ -413,7 +415,7 @@ uint32_t getDetectorIP() { /* initialization */ void initControlServer() { - if (initError == OK) { + if (!updateFlag && initError == OK) { setupDetector(); } initCheckDone = 1; diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index f7bc75cc0..99af87c20 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -21,6 +21,7 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; +extern int updateFlag; extern int checkModuleFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -80,8 +81,9 @@ void basictests() { return; } // does check only if flag is 0 (by default), set by command line - if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || - (testBus() == FAIL))) { + if ((!debugflag) && (!updateFlag) && + ((checkKernelVersion() == FAIL) || (checkType() == FAIL) || + (testFpga() == FAIL) || (testBus() == FAIL))) { strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. " "Dangerous to continue.\n"); LOG(logERROR, ("%s\n\n", initErrorMessage)); @@ -117,7 +119,7 @@ void basictests() { (long long int)client_sw_apiversion)); // return if flag is not zero, debug mode - if (debugflag) { + if (debugflag || updateFlag) { return; } @@ -161,6 +163,25 @@ void basictests() { #endif } +int checkKernelVersion() { +#ifdef VIRTUAL + return OK; +#endif + char output[256]; + memset(output, 0, 256); + FILE *sysFile = popen("uname -a | cut -d ' ' -f5-10", "r"); + fgets(output, sizeof(output), sysFile); + pclose(sysFile); + + if (strstr(output, KERNEL_DATE_VRSN) == NULL) { + LOG(logERROR, ("Kernel Version Incompatible! Expected: %s, Got: %s\n", + KERNEL_DATE_VRSN, output)); + return FAIL; + } + LOG(logINFO, ("Kernel Version Compatible: %s\n", output)); + return OK; +} + int checkType() { #ifdef VIRTUAL return OK; @@ -313,7 +334,7 @@ u_int32_t getDetectorIP() { /* initialization */ void initControlServer() { - if (initError == OK) { + if (!updateFlag && initError == OK) { setupDetector(); } initCheckDone = 1; diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index e02872239..024c1bc18 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -2,6 +2,7 @@ #include "sls_detector_defs.h" #define REQRD_FRMWRE_VRSN 0x190000 +#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020" #define CTRL_SRVR_INIT_TIME_US (300 * 1000) @@ -24,24 +25,25 @@ #define MAX_EXT_SIGNALS (8) /** Default Parameters */ -#define DEFAULT_PATTERN_FILE ("DefaultPattern_mythen3.txt") -#define DEFAULT_INTERNAL_GATES (1) -#define DEFAULT_EXTERNAL_GATES (1) -#define DEFAULT_DYNAMIC_RANGE (32) -#define DEFAULT_NUM_FRAMES (1) -#define DEFAULT_NUM_CYCLES (1) -#define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns -#define DEFAULT_GATE_DELAY (0) -#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns -#define DEFAULT_DELAY_AFTER_TRIGGER (0) -#define DEFAULT_HIGH_VOLTAGE (0) -#define DEFAULT_TIMING_MODE (AUTO_TIMING) -#define DEFAULT_READOUT_C0 (8) //(125000000) // rdo_clk, 125 MHz -#define DEFAULT_READOUT_C1 (8) //(125000000) // rdo_x2_clk, 125 MHz -#define DEFAULT_SYSTEM_C0 (4) //(250000000) // run_clk, 250 MHz -#define DEFAULT_SYSTEM_C1 (8) //(125000000) // sync_clk, 125 MHz -#define DEFAULT_SYSTEM_C2 (8) //(125000000) // str_clk, 125 MHz -#define DEFAULT_SYSTEM_C3 (5) //(200000000) // smp_clk, 200 MHz (only for timing receiver) +#define DEFAULT_PATTERN_FILE ("DefaultPattern_mythen3.txt") +#define DEFAULT_INTERNAL_GATES (1) +#define DEFAULT_EXTERNAL_GATES (1) +#define DEFAULT_DYNAMIC_RANGE (32) +#define DEFAULT_NUM_FRAMES (1) +#define DEFAULT_NUM_CYCLES (1) +#define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns +#define DEFAULT_GATE_DELAY (0) +#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns +#define DEFAULT_DELAY_AFTER_TRIGGER (0) +#define DEFAULT_HIGH_VOLTAGE (0) +#define DEFAULT_TIMING_MODE (AUTO_TIMING) +#define DEFAULT_READOUT_C0 (8) //(125000000) // rdo_clk, 125 MHz +#define DEFAULT_READOUT_C1 (8) //(125000000) // rdo_x2_clk, 125 MHz +#define DEFAULT_SYSTEM_C0 (4) //(250000000) // run_clk, 250 MHz +#define DEFAULT_SYSTEM_C1 (8) //(125000000) // sync_clk, 125 MHz +#define DEFAULT_SYSTEM_C2 (8) //(125000000) // str_clk, 125 MHz +#define DEFAULT_SYSTEM_C3 \ + (5) //(200000000) // smp_clk, 200 MHz (only for timing receiver) #define DEFAULT_ASIC_LATCHING_NUM_PULSES (10) #define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20) @@ -110,7 +112,8 @@ enum CLKINDEX { NUM_CLOCKS }; #define CLK_NAMES \ - "READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", "SYSTEM_C3" + "READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", \ + "SYSTEM_C3" enum PLLINDEX { READOUT_PLL, SYSTEM_PLL }; /* Struct Definitions */ diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 6f513744a..af51296d4 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -56,6 +56,9 @@ typedef struct udpStruct_s { int isInitCheckDone(); int getInitResult(char **mess); void basictests(); +#ifdefined(MYTHEN3D) || defined(GOTTHARD2D) +int checkKernelVersion(); +#endif #if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \ defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D) int checkType(); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c index fc526b52e..c47e7a18e 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c @@ -21,6 +21,7 @@ extern int ret; // Global variables from slsDetectorServer_funcs extern int sockfd; extern int debugflag; +extern int updateFlag; extern int checkModuleFlag; // Global variables from slsDetectorFunctionList @@ -41,6 +42,7 @@ int main(int argc, char *argv[]) { int portno = DEFAULT_PORTNO; isControlServer = 1; debugflag = 0; + updateFlag = 0; checkModuleFlag = 1; int version = 0; @@ -54,10 +56,12 @@ int main(int argc, char *argv[]) { "Possible arguments are:\n" "\t-v, --version : Software version\n" "\t-p, --port : TCP communication port with client. \n" - "\t-d, --devel : Developer mode. Skips firmware checks. \n" "\t-g, --nomodule : [Mythen3][Gotthard2] Generic or No " "Module mode. Skips detector type checks. \n" "\t-f, --phaseshift : [Gotthard] only. Sets phase shift. \n" + "\t-d, --devel : Developer mode. Skips firmware checks. \n" + "\t-u, --update : Update mode. Skips firmware checks and " + "initial detector setup. \n" "\t-s, --stopserver : Stop server. Do not use as created by " "control server \n\n", argv[0]); @@ -69,9 +73,10 @@ int main(int argc, char *argv[]) { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"port", required_argument, NULL, 'p'}, - {"devel", no_argument, NULL, 'd'}, {"phaseshift", required_argument, NULL, 'f'}, {"nomodule", no_argument, NULL, 'g'}, // generic + {"devel", no_argument, NULL, 'd'}, + {"update", no_argument, NULL, 'u'}, {"stopserver", no_argument, NULL, 's'}, {NULL, 0, NULL, 0}}; @@ -81,7 +86,7 @@ int main(int argc, char *argv[]) { int c = 0; while (c != -1) { - c = getopt_long(argc, argv, "hvp:df:gs", long_options, &option_index); + c = getopt_long(argc, argv, "hvp:f:gdus", long_options, &option_index); // Detect the end of the options if (c == -1) @@ -117,11 +122,6 @@ int main(int argc, char *argv[]) { LOG(logINFO, ("Detected port: %d\n", portno)); break; - case 'd': - LOG(logINFO, ("Detected developer mode\n")); - debugflag = 1; - break; - case 'f': #ifndef GOTTHARDD LOG(logERROR, @@ -142,6 +142,16 @@ int main(int argc, char *argv[]) { checkModuleFlag = 0; break; + case 'd': + LOG(logINFO, ("Detected developer mode\n")); + debugflag = 1; + break; + + case 'u': + LOG(logINFO, ("Detected update mode\n")); + updateFlag = 1; + break; + case 's': LOG(logINFO, ("Detected stop server\n")); isControlServer = 0; diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index b04b4db30..5ebd1b68e 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -42,6 +42,7 @@ extern char mess[MAX_STR_LENGTH]; // Variables that will be exported int sockfd = 0; int debugflag = 0; +int updateFlag = 0; int checkModuleFlag = 1; udpStruct udpDetails = {32410, 32411, 50001, 50002, 0, 0, 0, 0, 0, 0, 0, 0}; int configured = FAIL;