hardware version (#580)

* hardware version for all dets except eiger
Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
This commit is contained in:
Dhanya Thattil 2022-11-24 11:24:05 +01:00 committed by GitHub
parent cd270160d8
commit 2ff5291f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 359 additions and 156 deletions

View File

@ -127,6 +127,7 @@ This document describes the differences between v7.0.0 and v6.x.x
- gui nios temperature added
- detector header change (bunchid, reserved, debug, roundRnumber) ->detSpec1 - 4
-ctb and moench (allowing all clkdivs (totaldiv was a float instead of int))
- hardwareversion
- jungfrau connected moduleid to detid_jungfrau.txt on board

View File

@ -229,6 +229,14 @@ class Detector(CppDetectorApi):
"""
return self.getDetectorServerVersion()
@property
@element
def hardwareversion(self):
"""
[Jungfrau][Gotthard2][Myhten3][Gotthard][Ctb][Moench] Hardware version of detector.
"""
return ut.lhex(self.getHardwareVersion())
@property
@element
def kernelversion(self):
@ -1721,6 +1729,7 @@ class Detector(CppDetectorApi):
'client': self.clientversion,
'firmware': self.firmwareversion,
'detectorserver': self.detectorserverversion,
'hardware':self.hardwareversion,
'kernel': self.kernelversion,
'receiver': self.rx_version}

View File

@ -66,6 +66,11 @@ void init_det(py::module &m) {
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getDetectorServerVersion,
py::arg() = Positions{});
CppDetectorApi.def(
"getHardwareVersion",
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getHardwareVersion,
py::arg() = Positions{});
CppDetectorApi.def(
"getKernelVersion",
(Result<std::string>(Detector::*)(sls::Positions) const) &

View File

@ -116,7 +116,9 @@ void basictests() {
return;
}
#endif
uint16_t hversion = getHardwareVersionNumber();
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
@ -130,7 +132,7 @@ void basictests() {
sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Version:\t\t %s\n"
"Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
@ -341,9 +343,24 @@ uint64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
uint16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0;
return 0x3f;
#endif
return ((bus_r(MOD_SERIAL_NUMBER_REG) & MOD_SERIAL_NUMBER_VRSN_MSK) >>
MOD_SERIAL_NUMBER_VRSN_OFST);

View File

@ -7,10 +7,90 @@
#define MIN_REQRD_VRSN_T_RD_API 0x181130
#define REQRD_FRMWR_VRSN 0x220825
#define NUM_HARDWARE_VERSIONS (1)
#define HARDWARE_VERSION_NUMBERS \
{ 0x3f }
#define HARDWARE_VERSION_NAMES \
{ "5.1" }
#define LINKED_SERVER_NAME "ctbDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
/* Hardware Definitions */
#define NCHAN (36)
#define NCHAN_ANALOG (32)
#define NCHAN_DIGITAL (64)
#define NCHIP (1)
#define NDAC (24)
#define NPWR (6)
#define NDAC_ONLY (NDAC - NPWR)
#define DYNAMIC_RANGE (16)
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) // MHz
#define I2C_POWER_VIO_DEVICE_ID (0x40)
#define I2C_POWER_VA_DEVICE_ID (0x41)
#define I2C_POWER_VB_DEVICE_ID (0x42)
#define I2C_POWER_VC_DEVICE_ID (0x43)
#define I2C_POWER_VD_DEVICE_ID (0x44)
#define I2C_SHUNT_RESISTER_OHMS (0.005)
/** Default Parameters */
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_NUM_SAMPLES (1)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_RUN_CLK (200) // 40
#define DEFAULT_ADC_CLK (40) // 20
#define DEFAULT_SYNC_CLK (40) // 20
#define DEFAULT_DBIT_CLK (200)
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
#define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200) // min dac val
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500)
#define VCHIP_MIN_MV (1673)
#define VCHIP_MAX_MV (2668) // min dac val
#define POWER_RGLTR_MIN (636)
#define POWER_RGLTR_MAX \
(2638) // min dac val (not vchip-max) because of dac conversions
#define VCHIP_POWER_INCRMNT (200)
#define VIO_MIN_MV (1200) // for fpga to function
/* Defines in the Firmware */
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
#define MAX_PHASE_SHIFTS_STEPS (8)
#define WAIT_TME_US_FR_ACQDONE_REG \
(100) // wait time in us after acquisition done to ensure there is no data
// in fifo
#define WAIT_TIME_US_PLL (10 * 1000)
#define WAIT_TIME_US_STP_ACQ (100)
#define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000)
#define WAIT_TIME_PATTERN_READ (10)
#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin
/* MSB & LSB DEFINES */
#define MSB_OF_64_BIT_REG_OFST (32)
#define LSB_OF_64_BIT_REG_OFST (0)
#define BIT32_MSK (0xFFFFFFFF)
#define BIT16_MASK (0xFFFF)
#define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800)
/* Struct Definitions */
typedef struct udp_header_struct {
uint32_t udp_destmac_msb;
@ -88,77 +168,3 @@ enum DACINDEX {
};
enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "sync", "dbit"
/* Hardware Definitions */
#define NCHAN (36)
#define NCHAN_ANALOG (32)
#define NCHAN_DIGITAL (64)
#define NCHIP (1)
#define NDAC (24)
#define NPWR (6)
#define NDAC_ONLY (NDAC - NPWR)
#define DYNAMIC_RANGE (16)
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) // MHz
#define I2C_POWER_VIO_DEVICE_ID (0x40)
#define I2C_POWER_VA_DEVICE_ID (0x41)
#define I2C_POWER_VB_DEVICE_ID (0x42)
#define I2C_POWER_VC_DEVICE_ID (0x43)
#define I2C_POWER_VD_DEVICE_ID (0x44)
#define I2C_SHUNT_RESISTER_OHMS (0.005)
/** Default Parameters */
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_NUM_SAMPLES (1)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_RUN_CLK (200) // 40
#define DEFAULT_ADC_CLK (40) // 20
#define DEFAULT_SYNC_CLK (40) // 20
#define DEFAULT_DBIT_CLK (200)
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
#define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200) // min dac val
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500)
#define VCHIP_MIN_MV (1673)
#define VCHIP_MAX_MV (2668) // min dac val
#define POWER_RGLTR_MIN (636)
#define POWER_RGLTR_MAX \
(2638) // min dac val (not vchip-max) because of dac conversions
#define VCHIP_POWER_INCRMNT (200)
#define VIO_MIN_MV (1200) // for fpga to function
/* Defines in the Firmware */
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
#define MAX_PHASE_SHIFTS_STEPS (8)
#define WAIT_TME_US_FR_ACQDONE_REG \
(100) // wait time in us after acquisition done to ensure there is no data
// in fifo
#define WAIT_TIME_US_PLL (10 * 1000)
#define WAIT_TIME_US_STP_ACQ (100)
#define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000)
#define WAIT_TIME_PATTERN_READ (10)
#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin
/* MSB & LSB DEFINES */
#define MSB_OF_64_BIT_REG_OFST (32)
#define LSB_OF_64_BIT_REG_OFST (0)
#define BIT32_MSK (0xFFFFFFFF)
#define BIT16_MASK (0xFFFF)
#define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800)

View File

@ -113,7 +113,9 @@ void basictests() {
return;
}
#endif
uint16_t hversion = getHardwareVersionNumber();
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
@ -125,7 +127,7 @@ void basictests() {
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Version:\t\t %s\n"
"Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n\n"
@ -267,14 +269,34 @@ u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0;
return 0x2;
#endif
return ((bus_r(MCB_SERIAL_NO_REG) & MCB_SERIAL_NO_VRSN_MSK) >>
MCB_SERIAL_NO_VRSN_OFST);
}
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;

View File

@ -7,6 +7,11 @@
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
#define ID_FILE "detid_gotthard2.txt"
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS {0x0, 0x2};
#define HARDWARE_VERSION_NAMES \
{ "1.0", "1.2" }
#define LINKED_SERVER_NAME "gotthard2DetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -103,7 +103,9 @@ void basictests() {
return;
}
#endif
uint32_t boardrev = getBoardRevision();
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
@ -113,7 +115,7 @@ void basictests() {
LOG(logINFOBLUE,
("**************************************************\n"
"Board Revision : 0x%x\n"
"Hardware Revision : %s\n"
"Detector IP Addr : 0x%x\n"
"Detector MAC Addr : 0x%llx\n\n"
@ -121,7 +123,7 @@ void basictests() {
"Firmware Version : 0x%llx\n"
"Software Version : %s\n"
"********************************************************\n",
boardrev,
hversion,
ipadd, (long long unsigned int)macadd,
@ -335,14 +337,34 @@ u_int32_t getDetectorIP() {
return res;
}
u_int32_t getBoardRevision() {
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0;
return 0x2;
#endif
return ((bus_r(BOARD_REVISION_REG) & BOARD_REVISION_MSK) >>
BOARD_REVISION_OFST);
}
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
/* initialization */
void initControlServer() {
@ -394,7 +416,7 @@ void setupDetector() {
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
// adc
if (getBoardRevision() == 1) {
if (isHardwareVersion_1_0()) {
AD9252_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK,
ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK,
ADC_SPI_SRL_DT_OTPT_OFST);
@ -579,7 +601,7 @@ void setDAQRegister() {
// 0x1f16(board rev 1) 0x1f0f(board rev 2)
u_int32_t tokenTiming =
((getBoardRevision() == 1) ? DAQ_TKN_TMNG_BRD_RVSN_1_VAL
((isHardwareVersion_1_0()) ? DAQ_TKN_TMNG_BRD_RVSN_1_VAL
: DAQ_TKN_TMNG_BRD_RVSN_2_VAL);
// 0x13f(no roi), 0x7f(roi)

View File

@ -4,6 +4,12 @@
#include "sls/sls_detector_defs.h"
#include <stdlib.h>
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \
{ 0x1, 0x2 }
#define HARDWARE_VERSION_NAMES \
{ "1.0", "2.0" }
#define LINKED_SERVER_NAME "gotthardDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -61,7 +61,6 @@
#define HARDWARE_SERIAL_NUM_MSK (0x000000FF << HARDWARE_SERIAL_NUM_OFST)
#define HARDWARE_VERSION_NUM_OFST (16)
#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST)
#define HARDWARE_VERSION_2_VAL ((0x2 << HARDWARE_VERSION_NUM_OFST) & HARDWARE_VERSION_NUM_MSK)
/* API Version Register */
#define API_VERSION_REG (0x0F << MEM_MAP_SHIFT)

View File

@ -98,7 +98,9 @@ void basictests() {
return;
}
#endif
uint16_t hversion = getHardwareVersionNumber();
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
@ -108,14 +110,15 @@ void basictests() {
getServerVersion(swversion);
int64_t sw_fw_apiversion = 0;
uint32_t requiredFirmwareVersion =
(isHardwareVersion2() ? REQRD_FRMWRE_VRSN_BOARD2 : REQRD_FRMWRE_VRSN);
(isHardwareVersion_1_0() ? REQRD_FRMWRE_VRSN_BOARD2
: REQRD_FRMWRE_VRSN);
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
("************ Jungfrau Server *********************\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Version:\t\t %s\n"
"Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
@ -274,9 +277,24 @@ u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0;
return 0x3;
#endif
return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >>
HARDWARE_VERSION_NUM_OFST);
@ -290,15 +308,9 @@ u_int16_t getHardwareSerialNumber() {
HARDWARE_SERIAL_NUM_OFST);
}
// is board 1.0?, with value 2 (resistor network)
int isHardwareVersion2() {
#ifdef VIRTUAL
return 0;
#endif
return (((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) ==
HARDWARE_VERSION_2_VAL)
? 1
: 0);
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
int getChipVersion() {
@ -504,7 +516,7 @@ void setupDetector() {
alignDeserializer();
configureASICTimer();
bus_w(ADC_PORT_INVERT_REG,
(isHardwareVersion2() ? ADC_PORT_INVERT_BOARD2_VAL
(isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL));
initReadoutConfiguration();
@ -537,7 +549,7 @@ void setupDetector() {
setFilterResistor(DEFAULT_FILTER_RESISTOR);
setNumberOfFilterCells(DEFAULT_FILTER_CELL);
}
if (!isHardwareVersion2()) {
if (!isHardwareVersion_1_0()) {
setFlipRows(DEFAULT_FLIP_ROWS);
setReadNRows(MAX_ROWS_PER_READOUT);
}
@ -776,11 +788,11 @@ int readConfigFile() {
version, line);
break;
}
// version 1.1 and HW 1.0 (version reg value = 2) is incompatible
if (version == 11 && isHardwareVersion2()) {
// chipversion 1.1 and HW 1.0 is incompatible
if (version == 11 && isHardwareVersion_1_0()) {
strcpy(initErrorMessage,
"Chip version 1.1 (from on-board config file) is "
"incompatible with old board (v1.0). Please update "
"incompatible with hardware version v1.0. Please update "
"board or correct on-board config file.\n");
break;
}
@ -855,7 +867,8 @@ int getDynamicRange(int *retval) {
void setADCInvertRegister(uint32_t val) {
LOG(logINFO, ("Setting ADC Port Invert Reg to 0x%x\n", val));
uint32_t defaultValue = (isHardwareVersion2() ? ADC_PORT_INVERT_BOARD2_VAL
uint32_t defaultValue =
(isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL);
uint32_t changeValue = defaultValue ^ val;
LOG(logINFO, ("\t default: 0x%x, final:0x%x\n", defaultValue, changeValue));
@ -864,7 +877,7 @@ void setADCInvertRegister(uint32_t val) {
uint32_t getADCInvertRegister() {
uint32_t readValue = bus_r(ADC_PORT_INVERT_REG);
int32_t defaultValue = (isHardwareVersion2() ? ADC_PORT_INVERT_BOARD2_VAL
int32_t defaultValue = (isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL);
uint32_t val = defaultValue ^ readValue;
LOG(logDEBUG1, ("\tread:0x%x, default:0x%x returned:0x%x\n", readValue,
@ -1779,9 +1792,9 @@ int setReadNRows(int value) {
LOG(logERROR, ("Invalid number of rows %d\n", value));
return FAIL;
}
if (isHardwareVersion2()) {
if (isHardwareVersion_1_0()) {
LOG(logERROR, ("Could not set number of rows. Only available for "
"Hardware Board version 2.0.\n"));
"Hardware Board version v2.0.\n"));
return FAIL;
}
@ -1804,7 +1817,7 @@ int setReadNRows(int value) {
int getReadNRows() {
// cannot set it in old board
if (isHardwareVersion2()) {
if (isHardwareVersion_1_0()) {
return MAX_ROWS_PER_READOUT;
}
int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK);
@ -1977,7 +1990,7 @@ int setReadoutSpeed(int val) {
switch (val) {
case FULL_SPEED:
if (isHardwareVersion2()) {
if (isHardwareVersion_1_0()) {
LOG(logERROR, ("Cannot set full speed. Should not be here\n"));
return FAIL;
}
@ -1998,7 +2011,7 @@ int setReadoutSpeed(int val) {
case HALF_SPEED:
LOG(logINFO, ("Setting Half Speed (20 MHz):\n"));
if (isHardwareVersion2()) {
if (isHardwareVersion_1_0()) {
adcOfst = ADC_OFST_HALF_SPEED_BOARD2_VAL;
sampleAdcSpeed = SAMPLE_ADC_HALF_SPEED_BOARD2;
adcPhase = ADC_PHASE_HALF_SPEED_BOARD2;
@ -2019,7 +2032,7 @@ int setReadoutSpeed(int val) {
case QUARTER_SPEED:
LOG(logINFO, ("Setting Half Speed (10 MHz):\n"));
if (isHardwareVersion2()) {
if (isHardwareVersion_1_0()) {
adcOfst = ADC_OFST_QUARTER_SPEED_BOARD2_VAL;
sampleAdcSpeed = SAMPLE_ADC_QUARTER_SPEED_BOARD2;
adcPhase = ADC_PHASE_QUARTER_SPEED_BOARD2;
@ -2279,7 +2292,7 @@ int getFlipRows() {
}
void setFlipRows(int arg) {
if (isHardwareVersion2()) {
if (isHardwareVersion_1_0()) {
LOG(logERROR, ("Could not set flip rows. Only available for "
"Hardware Board version 2.0.\n"));
return;

View File

@ -8,8 +8,13 @@
#define REQRD_FRMWRE_VRSN_BOARD2 0x220421 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x220422 // 2.0 pcb (version = 011)
#define ID_FILE "detid_jungfrau.txt"
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \
{ 0x2, 0x3 }
#define HARDWARE_VERSION_NAMES \
{ "1.0", "2.0" }
#define ID_FILE "detid_jungfrau.txt"
#define LINKED_SERVER_NAME "jungfrauDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -120,7 +120,9 @@ void basictests() {
return;
}
#endif
uint16_t hversion = getHardwareVersionNumber();
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
@ -134,7 +136,7 @@ void basictests() {
sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Version:\t\t %s\n"
"Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
@ -345,9 +347,24 @@ uint64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
uint16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0;
return 0x1;
#endif
return ((bus_r(MOD_SERIAL_NUMBER_REG) & MOD_SERIAL_NUMBER_VRSN_MSK) >>
MOD_SERIAL_NUMBER_VRSN_OFST);

View File

@ -7,6 +7,12 @@
#define MIN_REQRD_VRSN_T_RD_API 0x180314
#define REQRD_FRMWR_VRSN 0x220825
#define NUM_HARDWARE_VERSIONS (1)
#define HARDWARE_VERSION_NUMBERS \
{ 0x1 }
#define HARDWARE_VERSION_NAMES \
{ "1.0" }
#define LINKED_SERVER_NAME "moenchDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)

View File

@ -106,7 +106,9 @@ void basictests() {
return;
}
#endif
uint16_t hversion = getHardwareVersionNumber();
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
@ -118,7 +120,7 @@ void basictests() {
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Version:\t\t %s\n"
"Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n\n"
@ -259,14 +261,34 @@ u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0;
return 0x2;
#endif
return ((bus_r(MCB_SERIAL_NO_REG) & MCB_SERIAL_NO_VRSN_MSK) >>
MCB_SERIAL_NO_VRSN_OFST);
}
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;

View File

@ -7,6 +7,11 @@
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
#define ID_FILE "detid_mythen3.txt"
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS {0x0, 0x2};
#define HARDWARE_VERSION_NAMES \
{ "1.0", "1.2" }
#define LINKED_SERVER_NAME "mythen3DetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -78,15 +78,18 @@ int getTestImageMode();
void getServerVersion(char *version);
u_int64_t getFirmwareVersion();
u_int64_t getFirmwareAPIVersion();
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
defined(MYTHEN3D) || defined(GOTTHARD2D)
#ifndef EIGERD
void getHardwareVersion(char *version);
u_int16_t getHardwareVersionNumber();
#endif
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
u_int16_t getHardwareSerialNumber();
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARD2D) || defined(MYTHEN3D) || \
defined(GOTTHARDD)
int isHardwareVersion_1_0();
#endif
#ifdef JUNGFRAUD
int isHardwareVersion2();
int getChipVersion();
void setChipVersion(int version);
#endif
@ -105,9 +108,6 @@ void setModuleId(int modid);
u_int64_t getDetectorMAC();
u_int32_t getDetectorIP();
#ifdef GOTTHARDD
u_int32_t getBoardRevision();
#endif
// initialization
void initControlServer();

View File

@ -305,3 +305,4 @@ int set_digital_pulsing(int);
int get_module(int);
int get_synchronization(int);
int set_synchronization(int);
int get_hardware_version(int);

View File

@ -469,6 +469,7 @@ void function_table() {
flist[F_GET_MODULE] = &get_module;
flist[F_GET_SYNCHRONIZATION] = &get_synchronization;
flist[F_SET_SYNCHRONIZATION] = &set_synchronization;
flist[F_GET_HARDWARE_VERSION] = &get_hardware_version;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -3449,7 +3450,7 @@ int write_adc_register(int file_des) {
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
AD9257_Set(addr, val);
#elif GOTTHARDD
if (getBoardRevision() == 1) {
if (isHardwareVersion_1_0()) {
AD9252_Set(addr, val);
} else {
AD9257_Set(addr, val);
@ -4217,7 +4218,7 @@ int reboot_controller(int file_des) {
#elif VIRTUAL
ret = GOODBYE;
#elif defined(MYTHEN3D) || defined(GOTTHARD2D)
if (getHardwareVersionNumber() == 0) {
if (isHardwareVersion_1_0()) {
ret = FAIL;
strcpy(mess, "Old board version, reboot by yourself please!\n");
LOG(logINFORED, (mess));
@ -4702,9 +4703,7 @@ int set_read_n_rows(int file_des) {
"of %d\n",
arg, READ_N_ROWS_MULTIPLE);
LOG(logERROR, (mess));
}
// only for HW 2.0 (version = 3)
else if (isHardwareVersion2()) {
} else if (isHardwareVersion_1_0()) {
ret = FAIL;
strcpy(mess, "Could not set number of rows. Only available for "
"Hardware Board version 2.0.\n");
@ -8801,8 +8800,7 @@ int get_flip_rows(int file_des) {
functionNotImplemented();
#else
// get only
// only for HW 2.0 (version = 3)
if (isHardwareVersion2()) {
if (isHardwareVersion_1_0()) {
ret = FAIL;
strcpy(mess, "Could not get flip rows. Only available for "
"Hardware Board version 2.0.\n");
@ -8835,9 +8833,7 @@ int set_flip_rows(int file_des) {
sprintf(mess, "Could not set flip rows. Invalid argument %d.\n",
arg);
LOG(logERROR, (mess));
}
// only for HW 2.0 (version = 3)
else if (isHardwareVersion2()) {
} else if (isHardwareVersion_1_0()) {
ret = FAIL;
strcpy(mess, "Could not set flip rows. Only available for "
"Hardware Board version 2.0.\n");
@ -9355,7 +9351,7 @@ int set_readout_speed(int file_des) {
// only set
if (Server_VerifyLock() == OK) {
#ifdef JUNGFRAUD
if (arg == (int)FULL_SPEED && isHardwareVersion2()) {
if (arg == (int)FULL_SPEED && isHardwareVersion_1_0()) {
ret = FAIL;
strcpy(
mess,
@ -10172,3 +10168,17 @@ int set_synchronization(int file_des) {
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_hardware_version(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
char retvals[MAX_STR_LENGTH];
memset(retvals, 0, MAX_STR_LENGTH);
#ifdef EIGERD
functionNotImplemented();
#else
getHardwareVersion(retvals);
LOG(logDEBUG1, ("hardware version retval: %s\n", retvals));
#endif
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
}

View File

@ -80,6 +80,9 @@ class Detector {
Result<std::string> getDetectorServerVersion(Positions pos = {}) const;
/** [Jungfrau][Gotthard2][Myhten3][Gotthard][Ctb][Moench] */
Result<std::string> getHardwareVersion(Positions pos = {}) const;
Result<std::string> getKernelVersion(Positions pos = {}) const;
/* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */

View File

@ -275,21 +275,24 @@ std::string CmdProxy::Versions(int action) {
WrongNumberOfParameters(0);
}
auto t = det->getFirmwareVersion(std::vector<int>{det_id});
os << "\nDetector Type: " << OutString(det->getDetectorType())
<< "\nPackage Version: " << det->getPackageVersion() << std::hex
<< "\nClient Version: " << det->getClientVersion();
os << "\nType : " << OutString(det->getDetectorType())
<< "\nRelease : " << det->getPackageVersion() << std::hex
<< "\nClient : " << det->getClientVersion();
os << "\nFirmware : ";
if (det->getDetectorType().squash() == defs::EIGER) {
os << "\nFirmware Version: " << OutString(t);
os << OutString(t);
} else {
os << "\nFirmware Version: " << OutStringHex(t);
os << OutStringHex(t);
}
os << "\nDetector Server Version: "
os << "\nServer : "
<< OutString(
det->getDetectorServerVersion(std::vector<int>{det_id}));
os << "\nDetector Kernel Version: "
os << "\nHardware : "
<< OutString(det->getHardwareVersion(std::vector<int>{det_id}));
os << "\nKernel : "
<< OutString(det->getKernelVersion({std::vector<int>{det_id}}));
if (det->getUseReceiverFlag().squash(true)) {
os << "\nReceiver Version: "
os << "\nReceiver : "
<< OutString(det->getReceiverVersion(std::vector<int>{det_id}));
}
os << std::dec << '\n';

View File

@ -767,6 +767,7 @@ class CmdProxy {
{"packageversion", &CmdProxy::PackageVersion},
{"clientversion", &CmdProxy::ClientVersion},
{"firmwareversion", &CmdProxy::FirmwareVersion},
{"hardwareversion", &CmdProxy::hardwareversion},
{"detectorserverversion", &CmdProxy::detectorserverversion},
{"kernelversion", &CmdProxy::kernelversion},
{"rx_version", &CmdProxy::rx_version},
@ -1235,6 +1236,10 @@ class CmdProxy {
GET_COMMAND(detectorserverversion, getDetectorServerVersion,
"\n\tOn-board detector server software version");
GET_COMMAND(hardwareversion, getHardwareVersion,
"\n\tJungfrau][Gotthard2][Myhten3][Gotthard][Ctb][Moench] "
"Hardware version of detector.");
GET_COMMAND(
kernelversion, getKernelVersion,
"\n\tGet kernel version on the detector including time and date.");

View File

@ -128,6 +128,10 @@ Result<std::string> Detector::getDetectorServerVersion(Positions pos) const {
return pimpl->Parallel(&Module::getDetectorServerVersion, pos);
}
Result<std::string> Detector::getHardwareVersion(Positions pos) const {
return pimpl->Parallel(&Module::getHardwareVersion, pos);
}
Result<std::string> Detector::getKernelVersion(Positions pos) const {
return pimpl->Parallel(&Module::getKernelVersion, pos);
}
@ -2300,6 +2304,7 @@ void Detector::setAdditionalJsonParameter(const std::string &key,
void Detector::programFPGA(const std::string &fname,
const bool forceDeleteNormalFile, Positions pos) {
LOG(logINFO) << "Updating Firmware...";
LOG(logINFO) << "Hardware Version: " << getHardwareVersion();
std::vector<char> buffer = pimpl->readProgrammingFile(fname);
pimpl->Parallel(&Module::programFPGA, pos, buffer, forceDeleteNormalFile);
rebootController(pos);

View File

@ -109,6 +109,12 @@ std::string Module::getDetectorServerVersion() const {
return v.concise();
}
std::string Module::getHardwareVersion() const {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_HARDWARE_VERSION, nullptr, retval);
return retval;
}
std::string Module::getKernelVersion() const {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_KERNEL_VERSION, nullptr, retval);

View File

@ -93,6 +93,7 @@ class Module : public virtual slsDetectorDefs {
std::string getControlServerLongVersion() const;
std::string getStopServerLongVersion() const;
std::string getDetectorServerVersion() const;
std::string getHardwareVersion() const;
std::string getKernelVersion() const;
int64_t getSerialNumber() const;
int getModuleId() const;

View File

@ -114,6 +114,13 @@ TEST_CASE("detectorserverversion", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("detectorserverversion", {"0"}, -1, PUT));
}
TEST_CASE("hardwareversion", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_NOTHROW(proxy.Call("hardwareversion", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("hardwareversion", {"0"}, -1, PUT));
}
TEST_CASE("kernelversion", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -273,6 +273,7 @@ enum detFuncs {
F_GET_MODULE,
F_GET_SYNCHRONIZATION,
F_SET_SYNCHRONIZATION,
F_GET_HARDWARE_VERSION,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
@ -651,6 +652,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_MODULE: return "F_GET_MODULE";
case F_GET_SYNCHRONIZATION: return "F_GET_SYNCHRONIZATION";
case F_SET_SYNCHRONIZATION: return "F_SET_SYNCHRONIZATION";
case F_GET_HARDWARE_VERSION: return "F_GET_HARDWARE_VERSION";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -2,12 +2,12 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */
#define RELEASE "developer"
#define APICTB "developer 0x221108"
#define APIGOTTHARD "developer 0x221108"
#define APIGOTTHARD2 "developer 0x221108"
#define APIMYTHEN3 "developer 0x221108"
#define APIMOENCH "developer 0x221108"
#define APIEIGER "developer 0x221108"
#define APILIB "developer 0x221108"
#define APIRECEIVER "developer 0x221108"
#define APIJUNGFRAU "developer 0x221118"
#define APICTB "developer 0x221124"
#define APIGOTTHARD "developer 0x221124"
#define APIGOTTHARD2 "developer 0x221124"
#define APIJUNGFRAU "developer 0x221124"
#define APIMYTHEN3 "developer 0x221124"
#define APIMOENCH "developer 0x221124"