check firmware version and api version upon server startup

This commit is contained in:
Dhanya Maliakal 2016-07-22 15:26:26 +02:00
parent f4a7a5a032
commit ac7063a1a5
7 changed files with 63 additions and 30 deletions

View File

@ -10,7 +10,7 @@
//#include <stdint.h> //#include <stdint.h>
#include "sls_receiver_defs.h" #include "sls_receiver_defs.h"
#define REQUIRED_FIRMWARE_VERSION 11 #define REQUIRED_FIRMWARE_VERSION 14
/** default maximum string length */ /** default maximum string length */
#define MAX_SCAN_STEPS 2000 #define MAX_SCAN_STEPS 2000
@ -276,7 +276,8 @@ enum idMode{
DETECTOR_FIRMWARE_VERSION, /**<return detector system firmware version */ DETECTOR_FIRMWARE_VERSION, /**<return detector system firmware version */
DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */ DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */
THIS_SOFTWARE_VERSION, /**<return this software version */ THIS_SOFTWARE_VERSION, /**<return this software version */
RECEIVER_VERSION /**<return receiver software version */ RECEIVER_VERSION, /**<return receiver software version */
SOFTWARE_FIRMWARE_API_VERSION /** return software firmware API version **/
}; };
/** /**
detector digital test modes detector digital test modes

View File

@ -178,22 +178,10 @@ u_int32_t Beb_GetFirmwareRevision(){
int fd = Beb_open(XPAR_VERSION,&baseaddr); int fd = Beb_open(XPAR_VERSION,&baseaddr);
if(fd < 0) if(fd < 0)
cprintf(BG_RED,"Firmware Revision Read FAIL\n"); cprintf(BG_RED,"Firmware Revision Read FAIL\n");
else{ else{
//read revision existing bit value = Beb_Read32(baseaddr, FIRMWARE_VERSION_OFFSET);
value = Beb_Read32(baseaddr, REVISION_EXISTING_OFFSET); if(!value)
//printf("Firmware Revision Read OK\n");
//error reading
if(!(value&REVISION_EXISTING_BIT)){
cprintf(BG_RED,"Firmware Revision Number does not exist in this version\n"); cprintf(BG_RED,"Firmware Revision Number does not exist in this version\n");
value = 0;
}else{
//read revision number
value = Beb_Read32(baseaddr, 0);
//printf("Firmware Revision Number Read OK\n");
//printf("Rev: 0x%x.%x\n\n",value & REVISION_MASK,value & SUB_REVISION_MASK);
value &= REVISION_MASK;
}
} }
//close file pointer //close file pointer
@ -204,6 +192,27 @@ u_int32_t Beb_GetFirmwareRevision(){
} }
u_int32_t Beb_GetFirmwareSoftwareAPIVersion(){
//mapping new memory
u_int32_t baseaddr, value = 0;
//open file pointer
int fd = Beb_open(XPAR_VERSION,&baseaddr);
if(fd < 0)
cprintf(BG_RED,"Firmware Revision Read FAIL\n");
else{
value = Beb_Read32(baseaddr, FIRMWARESOFTWARE_API_OFFSET);
if(!value)
cprintf(BG_RED,"Firmware Software API Version does not exist in this version\n");
}
//close file pointer
if(fd > 0)
Beb_close(fd);
return value;
}
void Beb_ResetFrameNumber(){ void Beb_ResetFrameNumber(){
//mapping new memory to read master top module configuration //mapping new memory to read master top module configuration
u_int32_t baseaddr; u_int32_t baseaddr;

View File

@ -49,6 +49,7 @@ struct BebInfo{
void Beb_GetModuleCopnfiguration(int* master, int* top); void Beb_GetModuleCopnfiguration(int* master, int* top);
u_int32_t Beb_GetFirmwareRevision(); u_int32_t Beb_GetFirmwareRevision();
u_int32_t Beb_GetFirmwareSoftwareAPIVersion();
void Beb_ResetFrameNumber(); void Beb_ResetFrameNumber();
int Beb_WriteTo(unsigned int index); int Beb_WriteTo(unsigned int index);

View File

@ -131,11 +131,9 @@
#define TWO_REQUESTS_OFFSET 0x1c #define TWO_REQUESTS_OFFSET 0x1c
#define TWO_REQUESTS_BIT 0x80000000 #define TWO_REQUESTS_BIT 0x80000000
//firmware version //version
#define REVISION_EXISTING_OFFSET 8 #define FIRMWARE_VERSION_OFFSET 0x4
#define REVISION_EXISTING_BIT 0x80000000 #define FIRMWARESOFTWARE_API_OFFSET 0x0
#define REVISION_MASK 0x0FFFFFFF
#define SUB_REVISION_MASK 0xF0000000
#define FRAME_NUM_RESET_OFFSET 0xA0 #define FRAME_NUM_RESET_OFFSET 0xA0

View File

@ -240,6 +240,8 @@ int64_t getDetectorId(enum idMode arg){
break; break;
case DETECTOR_FIRMWARE_VERSION: case DETECTOR_FIRMWARE_VERSION:
return (int64_t)Beb_GetFirmwareRevision(); return (int64_t)Beb_GetFirmwareRevision();
case SOFTWARE_FIRMWARE_API_VERSION:
return (int64_t)Beb_GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
retval= SVNREV; retval= SVNREV;
retval= (retval <<32) | SVNDATE; retval= (retval <<32) | SVNDATE;

View File

@ -23,12 +23,12 @@ int main(int argc, char *argv[]){
int retval=OK; int retval=OK;
int sd, fd; int sd, fd;
checkFirmwareCompatibility();
#ifdef STOP_SERVER #ifdef STOP_SERVER
char cmd[100]; char cmd[100];
#endif #endif
if (argc==1) { if (argc==1) {
checkFirmwareCompatibility();
//#endif //#endif
portno = DEFAULT_PORTNO; portno = DEFAULT_PORTNO;
printf("opening control server on port %d\n",portno ); printf("opening control server on port %d\n",portno );

View File

@ -44,18 +44,40 @@ int dataBytes = 10;
void checkFirmwareCompatibility(){ 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" cprintf(BLUE,"\n\n********************************************************\n"
"**********************EIGER Server**********************\n" "**********************EIGER Server**********************\n"
"********************************************************\n"); "********************************************************\n");
cprintf(BLUE,"\nFirmware Version: %lld\nSoftware Version: %llx\n\n", cprintf(BLUE,"\n"
getDetectorId(DETECTOR_FIRMWARE_VERSION), getDetectorId(DETECTOR_SOFTWARE_VERSION)); "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 //cant read versions
if(getDetectorId(DETECTOR_FIRMWARE_VERSION) < REQUIRED_FIRMWARE_VERSION){ 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" cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
"Please update it to v%d to be compatible with this server\n\n", "Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION);
REQUIRED_FIRMWARE_VERSION);
cprintf(RED,"Exiting Server. Goodbye!\n\n"); cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1); exit(-1);
} }