From ac7063a1a5044fefaba6d29bdab3bbc927b98a95 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Fri, 22 Jul 2016 15:26:26 +0200 Subject: [PATCH] check firmware version and api version upon server startup --- .../commonFiles/sls_detector_defs.h | 5 ++- slsDetectorSoftware/eigerDetectorServer/Beb.c | 37 ++++++++++++------- slsDetectorSoftware/eigerDetectorServer/Beb.h | 1 + .../eigerDetectorServer/FebRegisterDefs.h | 8 ++-- .../slsDetectorFunctionList.c | 2 + .../slsDetectorServer/slsDetectorServer.c | 4 +- .../slsDetectorServer_funcs.c | 36 ++++++++++++++---- 7 files changed, 63 insertions(+), 30 deletions(-) diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index 45ad39766..e6d11e0e9 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -10,7 +10,7 @@ //#include #include "sls_receiver_defs.h" -#define REQUIRED_FIRMWARE_VERSION 11 +#define REQUIRED_FIRMWARE_VERSION 14 /** default maximum string length */ #define MAX_SCAN_STEPS 2000 @@ -276,7 +276,8 @@ enum idMode{ DETECTOR_FIRMWARE_VERSION, /** 0) + Beb_close(fd); + + return value; +} + void Beb_ResetFrameNumber(){ //mapping new memory to read master top module configuration u_int32_t baseaddr; diff --git a/slsDetectorSoftware/eigerDetectorServer/Beb.h b/slsDetectorSoftware/eigerDetectorServer/Beb.h index 59782c2a6..0d62fcd67 100644 --- a/slsDetectorSoftware/eigerDetectorServer/Beb.h +++ b/slsDetectorSoftware/eigerDetectorServer/Beb.h @@ -49,6 +49,7 @@ struct BebInfo{ void Beb_GetModuleCopnfiguration(int* master, int* top); u_int32_t Beb_GetFirmwareRevision(); + u_int32_t Beb_GetFirmwareSoftwareAPIVersion(); void Beb_ResetFrameNumber(); int Beb_WriteTo(unsigned int index); diff --git a/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h b/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h index 77c5cb95b..417c148f1 100644 --- a/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h +++ b/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h @@ -131,11 +131,9 @@ #define TWO_REQUESTS_OFFSET 0x1c #define TWO_REQUESTS_BIT 0x80000000 -//firmware version -#define REVISION_EXISTING_OFFSET 8 -#define REVISION_EXISTING_BIT 0x80000000 -#define REVISION_MASK 0x0FFFFFFF -#define SUB_REVISION_MASK 0xF0000000 +//version +#define FIRMWARE_VERSION_OFFSET 0x4 +#define FIRMWARESOFTWARE_API_OFFSET 0x0 #define FRAME_NUM_RESET_OFFSET 0xA0 diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c index ba022ede0..5b48f8cb7 100644 --- a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c @@ -240,6 +240,8 @@ int64_t getDetectorId(enum idMode arg){ break; case DETECTOR_FIRMWARE_VERSION: return (int64_t)Beb_GetFirmwareRevision(); + case SOFTWARE_FIRMWARE_API_VERSION: + return (int64_t)Beb_GetFirmwareSoftwareAPIVersion(); case DETECTOR_SOFTWARE_VERSION: retval= SVNREV; retval= (retval <<32) | SVNDATE; diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c index acda828c2..f3f9b2631 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c @@ -23,12 +23,12 @@ int main(int argc, char *argv[]){ int retval=OK; int sd, fd; - checkFirmwareCompatibility(); - #ifdef STOP_SERVER char cmd[100]; #endif if (argc==1) { + + checkFirmwareCompatibility(); //#endif portno = DEFAULT_PORTNO; printf("opening control server on port %d\n",portno ); diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c index c48621929..f06b2aa51 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c @@ -44,18 +44,40 @@ int dataBytes = 10; void checkFirmwareCompatibility(){ + int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); + int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION); + int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); + cprintf(BLUE,"\n\n********************************************************\n" "**********************EIGER Server**********************\n" "********************************************************\n"); - cprintf(BLUE,"\nFirmware Version: %lld\nSoftware Version: %llx\n\n", - getDetectorId(DETECTOR_FIRMWARE_VERSION), getDetectorId(DETECTOR_SOFTWARE_VERSION)); + cprintf(BLUE,"\n" + "Firmware Version:\t\t %lld\n" + "Software Version:\t\t %llx\n" + "F/w-S/w API Version:\t\t %lld\n" + "Required Firmware Version:\t %d\n" + "\n********************************************************\n", + fwversion,swversion,sw_fw_apiversion,REQUIRED_FIRMWARE_VERSION); - //check for firmware version compatibility - if(getDetectorId(DETECTOR_FIRMWARE_VERSION) < REQUIRED_FIRMWARE_VERSION){ + //cant read versions + if(!fwversion || !sw_fw_apiversion){ + cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n"); + cprintf(RED,"Exiting Server. Goodbye!\n\n"); + exit(-1); + } + + //check for API compatibility - old server + if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){ + cprintf(RED,"FATAL ERROR: This software version is incompatible.\n" + "Please update it to be compatible with this firmware\n\n"); + cprintf(RED,"Exiting Server. Goodbye!\n\n"); + exit(-1); + } + + //check for firmware compatibility - old firmware + if( REQUIRED_FIRMWARE_VERSION > fwversion){ cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n" - "Please update it to v%d to be compatible with this server\n\n", - REQUIRED_FIRMWARE_VERSION); - + "Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION); cprintf(RED,"Exiting Server. Goodbye!\n\n"); exit(-1); }