This commit is contained in:
maliakal_d 2019-11-11 18:03:13 +01:00
commit 2fff9f5bfe
20 changed files with 506 additions and 294 deletions

View File

@ -0,0 +1,43 @@
if [ $# -eq 0 ]; then
declare -a det=("ctbDetectorServer"
"gotthardDetectorServer"
"gotthard2DetectorServer"
"jungfrauDetectorServer"
"mythen3DetectorServer"
)
else
declare -a det=("${1}")
echo "got something"
fi
declare -a deterror=("OK" "OK" "OK" "OK")
for ((i=0;i<${#det[@]};++i))
do
dir=${det[i]}
file="${det[i]}_developer"
echo -e "Compiling $dir [$file]"
cd $dir
make clean
if make ; then
deterror[i]="OK"
else
deterror[i]="FAIL"
fi
mv bin/$dir bin/$file
git add -f bin/$file
cp bin/$file /tftpboot/
cd ..
echo -e "\n\n"
done
echo -e "Results:"
for ((i=0;i<${#det[@]};++i))
do
printf "%s\t\t= %s\n" "${det[i]}" "${deterror[i]}"
done

View File

@ -0,0 +1,30 @@
declare -a det=("eigerDetectorServer")
declare -a deterror=("OK" "OK" "OK" "OK")
for ((i=0;i<${#det[@]};++i))
do
dir=${det[i]}
file="${det[i]}_developer"
echo -e "Compiling $dir [$file]"
cd $dir
make clean
if make ; then
deterror[i]="OK"
else
deterror[i]="FAIL"
fi
mv bin/$dir bin/$file
git add -f bin/$file
cp bin/$file /tftpboot/
cd ..
echo -e "\n\n"
done
echo -e "Results:"
for ((i=0;i<${#det[@]};++i))
do
printf "%s\t\t= %s\n" "${det[i]}" "${deterror[i]}"
done

View File

@ -31,9 +31,9 @@ extern udpStruct udpDetails;
extern uint64_t udpFrameNumber; extern uint64_t udpFrameNumber;
extern uint32_t udpPacketNumber; extern uint32_t udpPacketNumber;
int firmware_compatibility = OK; int initError = OK;
int firmware_check_done = 0; int initCheckDone = 0;
char firmware_message[MAX_STR_LENGTH]; char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL #ifdef VIRTUAL
pthread_t pthread_virtual_tid; pthread_t pthread_virtual_tid;
@ -66,51 +66,46 @@ int naSamples = 1;
int ndSamples = 1; int ndSamples = 1;
int detPos[2] = {0, 0}; int detPos[2] = {0, 0};
int isFirmwareCheckDone() { int isInitCheckDone() {
return firmware_check_done; return initCheckDone;
} }
int getFirmwareCheckResult(char** mess) { int getInitResult(char** mess) {
*mess = firmware_message; *mess = initErrorMessage;
return firmware_compatibility; return initError;
} }
void basictests() { void basictests() {
firmware_compatibility = OK; initError = OK;
firmware_check_done = 0; initCheckDone = 0;
memset(firmware_message, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
FILE_LOG(logINFOBLUE, ("******** Chip Test Board Virtual Server *****************\n")); FILE_LOG(logINFOBLUE, ("******** Chip Test Board Virtual Server *****************\n"));
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return;
} }
firmware_check_done = 1;
return; return;
#else #else
defineGPIOpins(); defineGPIOpins();
resetFPGA(); resetFPGA();
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not pass basic tests of FPGA and bus. Dangerous to continue.\n"); "Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
@ -151,7 +146,6 @@ void basictests() {
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag) { if (debugflag) {
firmware_check_done = 1;
return; return;
} }
@ -159,41 +153,37 @@ void basictests() {
//cant read versions //cant read versions
FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n")); FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n"));
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
strcpy(firmware_message, strcpy(initErrorMessage,
"Cant read versions from FPGA. Please update firmware.\n"); "Cant read versions from FPGA. Please update firmware.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > REQRD_FRMWR_VRSN){ if(sw_fw_apiversion > REQRD_FRMWR_VRSN){
sprintf(firmware_message, sprintf(initErrorMessage,
"This detector software software version (0x%llx) is incompatible.\n" "This detector software software version (0x%llx) is incompatible.\n"
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n", "Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
(long long int)sw_fw_apiversion, (long long int)sw_fw_apiversion,
(long long int)REQRD_FRMWR_VRSN); (long long int)REQRD_FRMWR_VRSN);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( REQRD_FRMWR_VRSN > fwversion) { if( REQRD_FRMWR_VRSN > fwversion) {
sprintf(firmware_message, sprintf(initErrorMessage,
"This firmware version (0x%llx) is incompatible.\n" "This firmware version (0x%llx) is incompatible.\n"
"Please update firmware (min. 0x%llx) to be compatible with this server.\n", "Please update firmware (min. 0x%llx) to be compatible with this server.\n",
(long long int)fwversion, (long long int)fwversion,
(long long int)REQRD_FRMWR_VRSN); (long long int)REQRD_FRMWR_VRSN);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
FILE_LOG(logINFO, ("\tCompatibility - success\n")); FILE_LOG(logINFO, ("\tCompatibility - success\n"));
firmware_check_done = 1;
#endif #endif
} }
@ -420,7 +410,10 @@ uint32_t getDetectorIP(){
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
setupDetector(); if (initError == OK) {
setupDetector();
}
initCheckDone = 1;
} }
void initStopServer() { void initStopServer() {

View File

@ -25,9 +25,9 @@ extern int isControlServer;
extern void getMacAddressinString(char* cmac, int size, uint64_t mac); extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
extern void getIpAddressinString(char* cip, uint32_t ip); extern void getIpAddressinString(char* cip, uint32_t ip);
int firmware_compatibility = OK; int initError = OK;
int firmware_check_done = 0; int initCheckDone = 0;
char firmware_message[MAX_STR_LENGTH]; char initErrorMessage[MAX_STR_LENGTH];
const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"}; const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"};
@ -92,19 +92,19 @@ int eiger_virtual_detPos[2] = {0, 0};
int isFirmwareCheckDone() { int isInitCheckDone() {
return firmware_check_done; return initCheckDone;
} }
int getFirmwareCheckResult(char** mess) { int getInitResult(char** mess) {
*mess = firmware_message; *mess = initErrorMessage;
return firmware_compatibility; return initError;
} }
void basictests() { void basictests() {
firmware_compatibility = OK; initError = OK;
firmware_check_done = 0; initCheckDone = 0;
memset(firmware_message, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
FILE_LOG(logINFOBLUE, ("************ EIGER Virtual Server *****************\n\n")); FILE_LOG(logINFOBLUE, ("************ EIGER Virtual Server *****************\n\n"));
#endif #endif
@ -139,49 +139,43 @@ void basictests() {
udpDetails.srcmac = macadd; udpDetails.srcmac = macadd;
#ifdef VIRTUAL #ifdef VIRTUAL
firmware_check_done = 1;
return; return;
#endif #endif
// return if debugflag is not zero, debug mode // return if debugflag is not zero, debug mode
if (debugflag) { if (debugflag) {
firmware_check_done = 1;
return; return;
} }
//cant read versions //cant read versions
if (!fwversion || !sw_fw_apiversion) { if (!fwversion || !sw_fw_apiversion) {
strcpy(firmware_message, "Cant read versions from FPGA. Please update firmware.\n"); strcpy(initErrorMessage, "Cant read versions from FPGA. Please update firmware.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for API compatibility - old server //check for API compatibility - old server
if (sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION) { if (sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION) {
sprintf(firmware_message, "This detector software software version (%lld) is incompatible.\n" sprintf(initErrorMessage, "This detector software software version (%lld) is incompatible.\n"
"Please update detector software (min. %lld) to be compatible with this firmware.\n", "Please update detector software (min. %lld) to be compatible with this firmware.\n",
(long long int)sw_fw_apiversion, (long long int)sw_fw_apiversion,
(long long int)REQUIRED_FIRMWARE_VERSION); (long long int)REQUIRED_FIRMWARE_VERSION);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if ( REQUIRED_FIRMWARE_VERSION > fwversion) { if ( REQUIRED_FIRMWARE_VERSION > fwversion) {
sprintf(firmware_message, "This firmware version (%lld) is incompatible.\n" sprintf(initErrorMessage, "This firmware version (%lld) is incompatible.\n"
"Please update firmware (min. %lld) to be compatible with this server.\n", "Please update firmware (min. %lld) to be compatible with this server.\n",
(long long int)fwversion, (long long int)fwversion,
(long long int)REQUIRED_FIRMWARE_VERSION); (long long int)REQUIRED_FIRMWARE_VERSION);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
FILE_LOG(logINFO, ("Compatibility - success\n")); FILE_LOG(logINFO, ("Compatibility - success\n"));
firmware_check_done = 1;
} }
@ -292,27 +286,32 @@ u_int32_t getDetectorIP() {
void initControlServer() { void initControlServer() {
#ifdef VIRTUAL #ifdef VIRTUAL
getModuleConfiguration(); if (initError == OK) {
setupDetector(); getModuleConfiguration();
return; setupDetector();
#else
//Feb and Beb Initializations
getModuleConfiguration();
Feb_Interface_FebInterface();
Feb_Control_FebControl();
Feb_Control_Init(master,top,normal, getDetectorNumber());
//master of 9M, check high voltage serial communication to blackfin
if (master && !normal) {
if (Feb_Control_OpenSerialCommunication())
;// Feb_Control_CloseSerialCommunication();
} }
FILE_LOG(logDEBUG1, ("Control server: FEB Initialization done\n")); initCheckDone = 1;
Beb_Beb(detid); return;
Beb_SetDetectorNumber(getDetectorNumber()); #else
FILE_LOG(logDEBUG1, ("Control server: BEB Initialization done\n")); if (initError == OK) {
//Feb and Beb Initializations
getModuleConfiguration();
Feb_Interface_FebInterface();
Feb_Control_FebControl();
Feb_Control_Init(master,top,normal, getDetectorNumber());
//master of 9M, check high voltage serial communication to blackfin
if (master && !normal) {
if (Feb_Control_OpenSerialCommunication())
;// Feb_Control_CloseSerialCommunication();
}
FILE_LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
Beb_Beb(detid);
Beb_SetDetectorNumber(getDetectorNumber());
FILE_LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
setupDetector();
setupDetector(); }
initCheckDone = 1;
#endif #endif
} }

View File

@ -0,0 +1,23 @@
#onchip dacs chip index value
vchip_comp_fe -1 0x137
vchip_opa_1st -1 0x000
vchip_opa_fd -1 0x134
vchip_comp_adc -1 0x3FF
vchip_ref_comp_fe -1 0x100
vchip_cs -1 0x0D0
#dacs
vref_h_adc 2099
vb_comp_fe 0
vb_comp_adc 0
vcom_cds 1400
vref_restore 640
vb_opa_1st 0
vref_comp_fe 0
vcom_adc1 1400
vref_prech 1720
vref_l_adc 700
vref_cds 1200
vb_cs 2799
vb_opa_fd 0
vcom_adc2 1400

View File

@ -24,9 +24,9 @@
extern int debugflag; extern int debugflag;
extern udpStruct udpDetails; extern udpStruct udpDetails;
int firmware_compatibility = OK; int initError = OK;
int firmware_check_done = 0; int initCheckDone = 0;
char firmware_message[MAX_STR_LENGTH]; char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL #ifdef VIRTUAL
pthread_t pthread_virtual_tid; pthread_t pthread_virtual_tid;
@ -38,50 +38,48 @@ int32_t clkPhase[NUM_CLOCKS] = {0, 0, 0, 0, 0, 0};
uint32_t clkFrequency[NUM_CLOCKS] = {0, 0, 0, 0, 0, 0}; uint32_t clkFrequency[NUM_CLOCKS] = {0, 0, 0, 0, 0, 0};
int highvoltage = 0; int highvoltage = 0;
int dacValues[NDAC] = {0}; int dacValues[NDAC] = {0};
int onChipdacValues[ONCHIP_NDAC][NCHIP + 1] = {0}; int onChipdacValues[ONCHIP_NDAC][NCHIP] = {0};
int defaultDacValues[NDAC] = {0};
int defaultOnChipdacValues[ONCHIP_NDAC][NCHIP] = {0};
int detPos[2] = {0, 0}; int detPos[2] = {0, 0};
int isFirmwareCheckDone() { int isInitCheckDone() {
return firmware_check_done; return initCheckDone;
} }
int getFirmwareCheckResult(char** mess) { int getInitResult(char** mess) {
*mess = firmware_message; *mess = initErrorMessage;
return firmware_compatibility; return initError;
} }
void basictests() { void basictests() {
firmware_compatibility = OK; initError = OK;
firmware_check_done = 0; initCheckDone = 0;
memset(firmware_message, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
FILE_LOG(logINFOBLUE, ("******** Gotthard2 Virtual Server *****************\n")); FILE_LOG(logINFOBLUE, ("******** Gotthard2 Virtual Server *****************\n"));
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
firmware_check_done = 1;
return; return;
#else #else
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && ((testFpga() == FAIL) || (testBus() == FAIL))) { if ((!debugflag) && ((testFpga() == FAIL) || (testBus() == FAIL))) {
sprintf(firmware_message, sprintf(initErrorMessage,
"Could not pass basic tests of FPGA and bus. Dangerous to continue. (Firmware version:0x%llx) \n", getFirmwareVersion()); "Could not pass basic tests of FPGA and bus. Dangerous to continue. (Firmware version:0x%llx) \n", getFirmwareVersion());
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
@ -118,48 +116,44 @@ void basictests() {
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag) { if (debugflag) {
firmware_check_done = 1;
return; return;
} }
//cant read versions //cant read versions
FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n")); FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n"));
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
strcpy(firmware_message, strcpy(initErrorMessage,
"Cant read versions from FPGA. Please update firmware.\n"); "Cant read versions from FPGA. Please update firmware.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > requiredFirmwareVersion){ if(sw_fw_apiversion > requiredFirmwareVersion){
sprintf(firmware_message, sprintf(initErrorMessage,
"This detector software software version (0x%llx) is incompatible.\n" "This detector software software version (0x%llx) is incompatible.\n"
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n", "Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
(long long int)sw_fw_apiversion, (long long int)sw_fw_apiversion,
(long long int)requiredFirmwareVersion); (long long int)requiredFirmwareVersion);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( requiredFirmwareVersion > fwversion) { if( requiredFirmwareVersion > fwversion) {
sprintf(firmware_message, sprintf(initErrorMessage,
"This firmware version (0x%llx) is incompatible.\n" "This firmware version (0x%llx) is incompatible.\n"
"Please update firmware (min. 0x%llx) to be compatible with this server.\n", "Please update firmware (min. 0x%llx) to be compatible with this server.\n",
(long long int)fwversion, (long long int)fwversion,
(long long int)requiredFirmwareVersion); (long long int)requiredFirmwareVersion);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
FILE_LOG(logINFO, ("Compatibility - success\n")); FILE_LOG(logINFO, ("Compatibility - success\n"));
firmware_check_done = 1;
#endif #endif
} }
@ -311,7 +305,10 @@ u_int32_t getDetectorIP(){
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
setupDetector(); if (initError == OK) {
setupDetector();
}
initCheckDone = 1;
} }
void initStopServer() { void initStopServer() {
@ -347,7 +344,7 @@ void setupDetector() {
dacValues[i] = 0; dacValues[i] = 0;
} }
for (i = 0; i < ONCHIP_NDAC; ++i) { for (i = 0; i < ONCHIP_NDAC; ++i) {
for (j = 0; j < NCHIP + 1; ++j) for (j = 0; j < NCHIP; ++j)
onChipdacValues[i][j] = -1; onChipdacValues[i][j] = -1;
} }
} }
@ -368,8 +365,7 @@ void setupDetector() {
// Default values // Default values
setHighVoltage(DEFAULT_HIGH_VOLTAGE); setHighVoltage(DEFAULT_HIGH_VOLTAGE);
setDefaultDacs(); readConfigFile(); // also sets default dac and on chip dac values
setDefaultOnChipDacs();
// Initialization of acquistion parameters // Initialization of acquistion parameters
setNumFrames(DEFAULT_NUM_FRAMES); setNumFrames(DEFAULT_NUM_FRAMES);
@ -382,10 +378,9 @@ int setDefaultDacs() {
int ret = OK; int ret = OK;
FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n")); FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n"));
{ {
int i = 0; int idac = 0;
const int defaultvals[NDAC] = DEFAULT_DAC_VALS; for(idac = 0; idac < NDAC; ++idac) {
for(i = 0; i < NDAC; ++i) { setDAC((enum DACINDEX)idac, defaultDacValues[idac], 0);
setDAC((enum DACINDEX)i,defaultvals[i],0);
} }
} }
return ret; return ret;
@ -395,16 +390,161 @@ int setDefaultOnChipDacs() {
int ret = OK; int ret = OK;
FILE_LOG(logINFOBLUE, ("Setting Default On chip Dac values\n")); FILE_LOG(logINFOBLUE, ("Setting Default On chip Dac values\n"));
{ {
int i = 0; int idac = 0, ichip = 0;
const int defaultOnChipVals[ONCHIP_NDAC] = DEFAULT_ONCHIP_DAC_VALS; for(idac = 0; idac < ONCHIP_NDAC; ++idac) {
for(i = 0; i < ONCHIP_NDAC; ++i) { for(ichip = 0; ichip < NCHIP; ++ichip) {
setOnChipDAC((enum ONCHIP_DACINDEX)i, -1, defaultOnChipVals[i]); setOnChipDAC((enum ONCHIP_DACINDEX)idac, ichip, defaultOnChipdacValues[idac][ichip]);
}
} }
} }
return ret; return ret;
} }
int readConfigFile() {
if (initError == FAIL) {
return initError;
}
FILE* fd = fopen(CONFIG_FILE, "r");
if(fd == NULL) {
sprintf(initErrorMessage, "Could not open on-board detector server config file [%s].\n", CONFIG_FILE);
initError = FAIL;
FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
return FAIL;
}
FILE_LOG(logINFOBLUE, ("Reading config file %s\n", CONFIG_FILE));
// Initialization
const size_t LZ = 256;
char line[LZ];
memset(line, 0, LZ);
char command[LZ];
// keep reading a line
while (fgets(line, LZ, fd)) {
// ignore comments
if (line[0] == '#') {
FILE_LOG(logDEBUG1, ("Ignoring Comment\n"));
continue;
}
// ignore empty lines
if (strlen(line) <= 1) {
FILE_LOG(logDEBUG1, ("Ignoring Empty line\n"));
continue;
}
FILE_LOG(logDEBUG1, ("Command to process: (size:%d) %s\n", strlen(line), line));
memset(command, 0, LZ);
// vchip command
if (!strncmp(line, "vchip_", strlen("vchip_"))) {
enum ONCHIP_DACINDEX idac = 0;
int ichip = -1;
int value = 0;
// cannot scan values
if (sscanf(line, "%s %d 0x%x", command, &ichip, &value) != 3) {
sprintf(initErrorMessage, "Could not scan on-chip dac commands from on-board server config file. Line:[%s].\n", line);
break;
}
if (!strcmp(command,"vchip_comp_fe")) {
idac = G2_VCHIP_COMP_FE;
} else if (!strcasecmp(command,"vchip_opa_1st")) {
idac = G2_VCHIP_OPA_1ST;
} else if (!strcasecmp(command,"vchip_opa_fd")) {
idac = G2_VCHIP_OPA_FD;
} else if (!strcasecmp(command,"vchip_comp_adc")) {
idac = G2_VCHIP_COMP_ADC;
} else if (!strcasecmp(command,"vchip_ref_comp_fe")) {
idac = G2_VCHIP_REF_COMP_FE;
} else if (!strcasecmp(command,"vchip_cs")) {
idac = G2_VCHIP_CS;
} else {
sprintf(initErrorMessage, "Unknown on-chip dac command in on-board server config file. Command:[%s].\n", command);
break;
}
// set on chip dac
if (setOnChipDAC(idac, ichip, value) == FAIL) {
sprintf(initErrorMessage, "Set on-chip dac failed from on-board server config file. Command:[%s].\n", command);
break;
}
}
// dac command
else {
enum DACINDEX idac = 0;
int value = 0;
// cannot scan values
if (sscanf(line, "%s %d", command, &value) != 2) {
sprintf(initErrorMessage, "Could not scan dac commands from on-board server config file. Line:[%s].\n", line);
break;
}
if (!strcmp(command,"vref_h_adc")) {
idac = G2_VREF_H_ADC;
} else if (!strcasecmp(command,"vb_comp_fe")) {
idac = G2_VB_COMP_FE;
} else if (!strcasecmp(command,"vb_comp_adc")) {
idac = G2_VB_COMP_ADC;
} else if (!strcasecmp(command,"vcom_cds")) {
idac = G2_VCOM_CDS;
} else if (!strcasecmp(command,"vref_restore")) {
idac = G2_VREF_RESTORE;
} else if (!strcasecmp(command,"vb_opa_1st")) {
idac = G2_VB_OPA_1ST;
} else if (!strcasecmp(command,"vref_comp_fe")) {
idac = G2_VREF_COMP_FE;
} else if (!strcasecmp(command,"vcom_adc1")) {
idac = G2_VCOM_ADC1;
} else if (!strcasecmp(command,"vref_prech")) {
idac = G2_VREF_PRECH;
} else if (!strcasecmp(command,"vref_l_adc")) {
idac = G2_VREF_L_ADC;
} else if (!strcasecmp(command,"vref_cds")) {
idac = G2_VREF_CDS;
} else if (!strcasecmp(command,"vb_cs")) {
idac = G2_VB_CS;
} else if (!strcasecmp(command,"vb_opa_fd")) {
idac = G2_VB_OPA_FD;
} else if (!strcasecmp(command,"vcom_adc2")) {
idac = G2_VCOM_ADC2;
} else {
sprintf(initErrorMessage, "Unknown command in on-board server config file. Command:[%s].\n", command);
break;
}
// set dac
setDAC(idac, value, 0);
int retval = getDAC(idac, 0);
if (retval != value) {
sprintf(initErrorMessage, "Set dac %s failed from on-board server config file. Set %d, got %d.\n", command, value, retval);
break;
}
}
memset(line, 0, LZ);
}
fclose(fd);
if (strlen(initErrorMessage)) {
initError = FAIL;
FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
} else {
FILE_LOG(logINFOBLUE, ("Successfully read config file\n"));
}
return initError;
}
/* set parameters - dr, roi */ /* set parameters - dr, roi */
int setDynamicRange(int dr){ int setDynamicRange(int dr){
@ -506,6 +646,8 @@ int setOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex, int val) {
FILE_LOG(logERROR, ("Invalid val %d\n", val)); FILE_LOG(logERROR, ("Invalid val %d\n", val));
return FAIL; return FAIL;
} }
FILE_LOG(logINFO, ("Setting on chip dac[%d - %s]: 0x%x\n", (int)ind, names[ind], val));
char buffer[2]; char buffer[2];
buffer[1] = ((val & 0xF) << 4) | (((int)ind) & 0xF); // LSB (4 bits) + ADDR (4 bits) buffer[1] = ((val & 0xF) << 4) | (((int)ind) & 0xF); // LSB (4 bits) + ADDR (4 bits)
@ -514,18 +656,36 @@ int setOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex, int val) {
if (ASIC_Driver_Set(chipIndex, sizeof(buffer), buffer) == FAIL) { if (ASIC_Driver_Set(chipIndex, sizeof(buffer), buffer) == FAIL) {
return FAIL; return FAIL;
} }
onChipdacValues[ind][chipIndex + 1] = val; // all chips
if (chipIndex == -1) { if (chipIndex == -1) {
int i; int ichip = 0;
for (i = 1; i < NCHIP + 1; ++i) { for (ichip = 0; ichip < NCHIP; ++ichip) {
onChipdacValues[ind][i] = val; onChipdacValues[ind][ichip] = val;
} }
}
// specific chip
else {
onChipdacValues[ind][chipIndex] = val;
} }
return OK; return OK;
} }
int getOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex) { int getOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex) {
return onChipdacValues[ind][chipIndex + 1]; // all chips
if (chipIndex == -1) {
int retval = onChipdacValues[ind][0];
int ichip = 0;
// check if same value for remaining chips
for (ichip = 1; ichip < NCHIP; ++ichip) {
if (onChipdacValues[ind][ichip] != retval) {
return -1;
}
}
return retval;
}
// specific chip
return onChipdacValues[ind][chipIndex];
} }
void setDAC(enum DACINDEX ind, int val, int mV) { void setDAC(enum DACINDEX ind, int val, int mV) {

View File

@ -16,6 +16,7 @@
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac") #define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac") #define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac") #define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac")
#define CONFIG_FILE ("config.txt")
#define DAC_MAX_MV (2048) #define DAC_MAX_MV (2048)
#define ONCHIP_DAC_MAX_VAL (0x3FF) #define ONCHIP_DAC_MAX_VAL (0x3FF)
@ -60,23 +61,6 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
G2_VCOM_ADC2 /* 15*/ \ G2_VCOM_ADC2 /* 15*/ \
}; };
#define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2" #define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2"
#define DEFAULT_DAC_VALS {2099, /* 0 (1050 mV) VREF_H_ADC*/ \
0, /* 1 (0 mV) DAC_UNUSED*/ \
0, /* 2 (0 mV) VB_COMP_FE*/ \
0, /* 3 (0 mV) VB_COMP_ADC*/ \
1400, /* 4 (700 mV) VCOM_CDS*/ \
640, /* 5 (320 mV) VREF_RESTORE*/ \
0, /* 6 (0 mV) VB_OPA_1ST*/ \
0, /* 7 (0 mV) VREF_COMP_FE*/ \
1400, /* 8 (700 mV) VCOM_ADC1*/ \
1720, /* 9 (860 mV) VREF_PRECH*/ \
700, /* 10 (350 mV) VREF_L_ADC*/ \
1200, /* 11 (600 mV) VREF_CDS*/ \
2799, /* 12 (1400 mV) VB_CS*/ \
0, /* 13 (0 mV) VB_OPA_FD*/ \
0, /* 14 (0 mV) DAC_UNUSED2*/ \
1400 /* 15 (700 mV) VCOM_ADC2*/ \
};
enum ONCHIP_DACINDEX {G2_VCHIP_COMP_FE, /* 0 */ \ enum ONCHIP_DACINDEX {G2_VCHIP_COMP_FE, /* 0 */ \
G2_VCHIP_OPA_1ST, /* 1 */ \ G2_VCHIP_OPA_1ST, /* 1 */ \
@ -87,13 +71,6 @@ enum ONCHIP_DACINDEX {G2_VCHIP_COMP_FE, /* 0 */ \
}; };
#define ONCHIP_DAC_NAMES "vchip_comp_fe", "vchip_opa_1st", "vchip_opa_fd", "vchip_comp_adc", "vchip_ref_comp_fe", "vchip_cs" #define ONCHIP_DAC_NAMES "vchip_comp_fe", "vchip_opa_1st", "vchip_opa_fd", "vchip_comp_adc", "vchip_ref_comp_fe", "vchip_cs"
#define DEFAULT_ONCHIP_DAC_VALS {0x137, /* 0 G2_VCHIP_COMP_FE*/ \
0x000, /* 1 G2_VCHIP_OPA_1ST*/ \
0x134, /* 2 G2_VCHIP_OPA_FD*/ \
0x3FF, /* 3 G2_VCHIP_COMP_ADC*/ \
0x100, /* 4 G2_VCHIP_REF_COMP_FE*/ \
0x0D0 /* 5 G2_VCHIP_CS*/ \
};
enum CLKINDEX {READOUT_C0, READOUT_C1, SYSTEM_C0, SYSTEM_C1, SYSTEM_C2, SYSTEM_C3, NUM_CLOCKS}; enum CLKINDEX {READOUT_C0, READOUT_C1, SYSTEM_C0, SYSTEM_C1, SYSTEM_C2, SYSTEM_C3, NUM_CLOCKS};
#define CLK_NAMES "READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", "SYSTEM_C3" #define CLK_NAMES "READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", "SYSTEM_C3"

View File

@ -20,9 +20,9 @@ extern udpStruct udpDetails;
// Variables that will be exported // Variables that will be exported
int phaseShift = DEFAULT_PHASE_SHIFT; int phaseShift = DEFAULT_PHASE_SHIFT;
int firmware_compatibility = OK; int initError = OK;
int firmware_check_done = 0; int initCheckDone = 0;
char firmware_message[MAX_STR_LENGTH]; char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL #ifdef VIRTUAL
pthread_t pthread_virtual_tid; pthread_t pthread_virtual_tid;
@ -53,48 +53,43 @@ int slaveadcphase = 0;
int rsttosw1delay = 2; int rsttosw1delay = 2;
int startacqdelay = 1; int startacqdelay = 1;
int isFirmwareCheckDone() { int isInitCheckDone() {
return firmware_check_done; return initCheckDone;
} }
int getFirmwareCheckResult(char** mess) { int getInitResult(char** mess) {
*mess = firmware_message; *mess = initErrorMessage;
return firmware_compatibility; return initError;
} }
void basictests() { void basictests() {
firmware_compatibility = OK; initError = OK;
firmware_check_done = 0; initCheckDone = 0;
memset(firmware_message, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
FILE_LOG(logINFOBLUE, ("******** Gotthard Virtual Server *****************\n")); FILE_LOG(logINFOBLUE, ("******** Gotthard Virtual Server *****************\n"));
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return;
} }
firmware_check_done = 1;
return; return;
#else #else
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if (((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { if (((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not pass basic tests of FPGA and bus. Dangerous to continue.\n"); "Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
@ -126,7 +121,6 @@ void basictests() {
)); ));
FILE_LOG(logINFO, ("Basic Tests - success\n")); FILE_LOG(logINFO, ("Basic Tests - success\n"));
firmware_check_done = 1;
#endif #endif
} }
@ -343,7 +337,10 @@ u_int32_t getBoardRevision() {
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
setupDetector(); if (initError == OK) {
setupDetector();
}
initCheckDone = 1;
} }
void initStopServer() { void initStopServer() {

View File

@ -25,9 +25,9 @@
extern int debugflag; extern int debugflag;
extern udpStruct udpDetails; extern udpStruct udpDetails;
int firmware_compatibility = OK; int initError = OK;
int firmware_check_done = 0; int initCheckDone = 0;
char firmware_message[MAX_STR_LENGTH]; char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL #ifdef VIRTUAL
pthread_t pthread_virtual_tid; pthread_t pthread_virtual_tid;
@ -43,51 +43,46 @@ int detPos[4] = {0, 0, 0, 0};
int numUDPInterfaces = 1; int numUDPInterfaces = 1;
int isFirmwareCheckDone() { int isInitCheckDone() {
return firmware_check_done; return initCheckDone;
} }
int getFirmwareCheckResult(char** mess) { int getInitResult(char** mess) {
*mess = firmware_message; *mess = initErrorMessage;
return firmware_compatibility; return initError;
} }
void basictests() { void basictests() {
firmware_compatibility = OK; initError = OK;
firmware_check_done = 0; initCheckDone = 0;
memset(firmware_message, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
FILE_LOG(logINFOBLUE, ("******** Jungfrau Virtual Server *****************\n")); FILE_LOG(logINFOBLUE, ("******** Jungfrau Virtual Server *****************\n"));
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return;
} }
firmware_check_done = 1;
return; return;
#else #else
defineGPIOpins(); defineGPIOpins();
resetFPGA(); resetFPGA();
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not pass basic tests of FPGA and bus. Dangerous to continue.\n"); "Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
@ -129,7 +124,6 @@ void basictests() {
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag) { if (debugflag) {
firmware_check_done = 1;
return; return;
} }
@ -137,41 +131,37 @@ void basictests() {
//cant read versions //cant read versions
FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n")); FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n"));
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
strcpy(firmware_message, strcpy(initErrorMessage,
"Cant read versions from FPGA. Please update firmware.\n"); "Cant read versions from FPGA. Please update firmware.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > requiredFirmwareVersion){ if(sw_fw_apiversion > requiredFirmwareVersion){
sprintf(firmware_message, sprintf(initErrorMessage,
"This detector software software version (0x%llx) is incompatible.\n" "This detector software software version (0x%llx) is incompatible.\n"
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n", "Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
(long long int)sw_fw_apiversion, (long long int)sw_fw_apiversion,
(long long int)requiredFirmwareVersion); (long long int)requiredFirmwareVersion);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( requiredFirmwareVersion > fwversion) { if( requiredFirmwareVersion > fwversion) {
sprintf(firmware_message, sprintf(initErrorMessage,
"This firmware version (0x%llx) is incompatible.\n" "This firmware version (0x%llx) is incompatible.\n"
"Please update firmware (min. 0x%llx) to be compatible with this server.\n", "Please update firmware (min. 0x%llx) to be compatible with this server.\n",
(long long int)fwversion, (long long int)fwversion,
(long long int)requiredFirmwareVersion); (long long int)requiredFirmwareVersion);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
FILE_LOG(logINFO, ("Compatibility - success\n")); FILE_LOG(logINFO, ("Compatibility - success\n"));
firmware_check_done = 1;
#endif #endif
} }
@ -347,7 +337,10 @@ u_int32_t getDetectorIP(){
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
setupDetector(); if (initError == OK) {
setupDetector();
}
initCheckDone = 1;
} }

View File

@ -23,9 +23,9 @@
extern int debugflag; extern int debugflag;
extern udpStruct udpDetails; extern udpStruct udpDetails;
int firmware_compatibility = OK; int initError = OK;
int firmware_check_done = 0; int initCheckDone = 0;
char firmware_message[MAX_STR_LENGTH]; char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL #ifdef VIRTUAL
pthread_t pthread_virtual_tid; pthread_t pthread_virtual_tid;
@ -40,48 +40,43 @@ int highvoltage = 0;
int dacValues[NDAC] = {0}; int dacValues[NDAC] = {0};
int detPos[2] = {0, 0}; int detPos[2] = {0, 0};
int isFirmwareCheckDone() { int isInitCheckDone() {
return firmware_check_done; return initCheckDone;
} }
int getFirmwareCheckResult(char** mess) { int getInitResult(char** mess) {
*mess = firmware_message; *mess = initErrorMessage;
return firmware_compatibility; return initError;
} }
void basictests() { void basictests() {
firmware_compatibility = OK; initError = OK;
firmware_check_done = 0; initCheckDone = 0;
memset(firmware_message, 0, MAX_STR_LENGTH); memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL #ifdef VIRTUAL
FILE_LOG(logINFOBLUE, ("******** Mythen3 Virtual Server *****************\n")); FILE_LOG(logINFOBLUE, ("******** Mythen3 Virtual Server *****************\n"));
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return;
} }
firmware_check_done = 1;
return; return;
#else #else
FILE_LOG(logINFOBLUE, ("******** Mythen3 Server: do the checks *****************\n")); FILE_LOG(logINFOBLUE, ("******** Mythen3 Server: do the checks *****************\n"));
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not map to memory. Dangerous to continue.\n"); "Could not map to memory. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
// does check only if flag is 0 (by default), set by command line // does check only if flag is 0 (by default), set by command line
if ((!debugflag) && ((testFpga() == FAIL)|| (testBus() == FAIL))) { if ((!debugflag) && ((testFpga() == FAIL)|| (testBus() == FAIL))) {
strcpy(firmware_message, strcpy(initErrorMessage,
"Could not pass basic tests of FPGA and bus. Dangerous to continue.\n"); "Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
FILE_LOG(logERROR, ("%s\n\n", firmware_message)); FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
uint16_t hversion = getHardwareVersionNumber(); uint16_t hversion = getHardwareVersionNumber();
@ -120,7 +115,6 @@ void basictests() {
// return if flag is not zero, debug mode // return if flag is not zero, debug mode
if (debugflag) { if (debugflag) {
firmware_check_done = 1;
return; return;
} }
@ -128,41 +122,37 @@ void basictests() {
//cant read versions //cant read versions
FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n")); FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n"));
if(!fwversion || !sw_fw_apiversion){ if(!fwversion || !sw_fw_apiversion){
strcpy(firmware_message, strcpy(initErrorMessage,
"Cant read versions from FPGA. Please update firmware.\n"); "Cant read versions from FPGA. Please update firmware.\n");
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for API compatibility - old server //check for API compatibility - old server
if(sw_fw_apiversion > requiredFirmwareVersion){ if(sw_fw_apiversion > requiredFirmwareVersion){
sprintf(firmware_message, sprintf(initErrorMessage,
"This detector software software version (0x%llx) is incompatible.\n" "This detector software software version (0x%llx) is incompatible.\n"
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n", "Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
(long long int)sw_fw_apiversion, (long long int)sw_fw_apiversion,
(long long int)requiredFirmwareVersion); (long long int)requiredFirmwareVersion);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
//check for firmware compatibility - old firmware //check for firmware compatibility - old firmware
if( requiredFirmwareVersion > fwversion) { if( requiredFirmwareVersion > fwversion) {
sprintf(firmware_message, sprintf(initErrorMessage,
"This firmware version (0x%llx) is incompatible.\n" "This firmware version (0x%llx) is incompatible.\n"
"Please update firmware (min. 0x%llx) to be compatible with this server.\n", "Please update firmware (min. 0x%llx) to be compatible with this server.\n",
(long long int)fwversion, (long long int)fwversion,
(long long int)requiredFirmwareVersion); (long long int)requiredFirmwareVersion);
FILE_LOG(logERROR, (firmware_message)); FILE_LOG(logERROR, (initErrorMessage));
firmware_compatibility = FAIL; initError = FAIL;
firmware_check_done = 1;
return; return;
} }
FILE_LOG(logINFO, ("Compatibility - success\n")); FILE_LOG(logINFO, ("Compatibility - success\n"));
firmware_check_done = 1;
#endif #endif
} }
@ -315,7 +305,10 @@ u_int32_t getDetectorIP(){
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
setupDetector(); if (initError == OK) {
setupDetector();
}
initCheckDone = 1;
} }
void initStopServer() { void initStopServer() {

View File

@ -31,8 +31,8 @@ typedef struct udpStruct_s {
// basic tests // basic tests
int isFirmwareCheckDone(); int isInitCheckDone();
int getFirmwareCheckResult(char** mess); int getInitResult(char** mess);
void basictests(); void basictests();
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D) #if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int checkType(); int checkType();
@ -89,6 +89,7 @@ int setDefaultDacs();
#endif #endif
#ifdef GOTTHARD2D #ifdef GOTTHARD2D
int setDefaultOnChipDacs(); int setDefaultOnChipDacs();
int readConfigFile();
#endif #endif
@ -123,6 +124,7 @@ int readConfigFile();
void setMasterSlaveConfiguration(); void setMasterSlaveConfiguration();
#endif #endif
// parameters - dr, roi // parameters - dr, roi
int setDynamicRange(int dr); int setDynamicRange(int dr);
#ifdef GOTTHARDD #ifdef GOTTHARDD

View File

@ -26,20 +26,22 @@ void ASIC_Driver_SetDefines(char* driverfname) {
} }
int ASIC_Driver_Set (int index, int length, char* buffer) { int ASIC_Driver_Set (int index, int length, char* buffer) {
FILE_LOG(logDEBUG1, ("\tchip index: %d length: %d\n", index, length));
{
FILE_LOG(logDEBUG1, ("\tvalues:\n"));
int i;
for (i = 0; i < length; ++i) {
FILE_LOG(logDEBUG1, ("\t\t0x%02hhx\n", buffer[i]));
}
FILE_LOG(logDEBUG1, ("\n"));
}
char fname[MAX_STR_LENGTH]; char fname[MAX_STR_LENGTH];
sprintf(fname, "%s%d", ASIC_Driver_DriverFileName, index + 1); sprintf(fname, "%s%d", ASIC_Driver_DriverFileName, index + 1);
FILE_LOG(logDEBUG1, ("fname %s\n",fname)); FILE_LOG(logDEBUG1, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
{
char printbuffer[2 * length + 15];
memset(printbuffer, 0, 2 * length);
strcpy(printbuffer, "\t values: [");
int i;
for (i = 0; i < length; ++i) {
char bytes[10]="";
sprintf(bytes, "\t0x%02hhx", buffer[i]);
strcat(printbuffer, bytes);
}
strcat(printbuffer, "]");
FILE_LOG(logDEBUG1, ("%s\n", printbuffer));
}
int fd=open(fname, O_RDWR); int fd=open(fname, O_RDWR);
if (fd == -1) { if (fd == -1) {

View File

@ -3991,9 +3991,9 @@ int check_version(int file_des) {
FILE_LOG(logDEBUG1, ("Checking software-firmware compatibility and basic test result\n")); FILE_LOG(logDEBUG1, ("Checking software-firmware compatibility and basic test result\n"));
// check if firmware check is done // check if firmware check is done
if (!isFirmwareCheckDone()) { if (!isInitCheckDone()) {
usleep(3 * 1000 * 1000); usleep(3 * 1000 * 1000);
if (!isFirmwareCheckDone()) { if (!isInitCheckDone()) {
ret = FAIL; ret = FAIL;
strcpy(mess,"Firmware Software Compatibility Check (Server Initialization) " strcpy(mess,"Firmware Software Compatibility Check (Server Initialization) "
"still not done done in server. Unexpected.\n"); "still not done done in server. Unexpected.\n");
@ -4003,7 +4003,7 @@ int check_version(int file_des) {
// check firmware check result // check firmware check result
if (ret == OK) { if (ret == OK) {
char* firmware_message = NULL; char* firmware_message = NULL;
if (getFirmwareCheckResult(&firmware_message) == FAIL) { if (getInitResult(&firmware_message) == FAIL) {
ret = FAIL; ret = FAIL;
strcpy(mess, firmware_message); strcpy(mess, firmware_message);
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));

View File

@ -4,9 +4,9 @@
#define APIRECEIVER 0x190722 #define APIRECEIVER 0x190722
#define APIGUI 0x190723 #define APIGUI 0x190723
#define APIMOENCH 0x190820 #define APIMOENCH 0x190820
#define APIGOTTHARD 0x191106 #define APICTB 0x191111
#define APICTB 0x191106 #define APIGOTTHARD 0x191111
#define APIJUNGFRAU 0x191106 #define APIJUNGFRAU 0x191111
#define APIEIGER 0x191106 #define APIEIGER 0x191111
#define APIGOTTHARD2 0x191108 #define APIGOTTHARD2 0x191111
#define APIMYTHEN3 0x191111 #define APIMYTHEN3 0x191111