Commit 893535ed authored by Basil Schneider's avatar Basil Schneider
Browse files

Merge remote-tracking branch 'upstream/Dev' into Dev

parents dc7ab290 0987f639
......@@ -9,10 +9,10 @@ html/
latex/
logs/
logs/*
build/*
*.bin
*.raw
Results/
Results/**
Results
tags
# just for G. Auzingers sanity
......
......@@ -18,13 +18,16 @@ before_script:
- yum -y -q install root
- yum -y -q install root-net-http root-montecarlo-eg root-graf3d-eve root-geom root-physics root-graf3d-gl
- yum -y -q install zeromq
- yum -y -q install cmake
build_Ph2_ACF:
script:
- source setup.sh
- cd build/
- cmake ..
- make
- cd ..
only:
- Dev
- master
after_script:
- source setup.sh
......
Objs = Amc13Description.o Amc13Interface.o Amc13Controller.o
CC = g++
CXX = g++
CCFlags = -g -O1 -w -Wall -pedantic -fPIC -Wcpp
IncludeDirs = ../
LibraryDirs = $(CACTUSLIB) ../ ../lib
ExternalObjects =
ifneq ("$(wildcard $(AMC13DIR))","")
AMC13INSTALLED = 'Building AMC13 related Objects'
ExternalObjects += -lcactus_amc13_amc13
IncludeDirs += $(AMC13DIR)/..
else
AMC13INSTALLED = 'This feature can only be built if the AMC13 libraries are installed with cactus!'
endif
IncludePaths = $(IncludeDirs:%=-I%)
LibraryPaths = $(LibraryDirs:%=-L%)
.PHONY: clean print
%.o: %.cc %.h
$(CXX) -std=c++0x $(CCFlags) $(IncludePaths) $(LibraryPaths) $(ExternalObjects) -c -o $@ $<
all:print $(Objs)
$(CC) -std=c++0x -shared -o libPh2_Amc13.so $(Objs)
mv libPh2_Amc13.so ../lib
print:
@echo '****************************************'
@echo $(AMC13INSTALLED)
@echo '****************************************'
clean:
rm -f *.o
......@@ -190,3 +190,8 @@
- 21.07.2017
- merged changes required for OTSDAQ
- migrated project to CMAKE: instructions: cd build/ cmake .. make
- 17.11.2017 major cleanup of project repository and many added features related to CBC3
- dropped normal makefiles - project builds only with cmake
- signal scans added
- some minor bug fixes
- new DQM code based on SLink Data format to avoid having to read HWDescription files
YEL='\033[1m\033[33m'
RED='\033[1m\033[31m'
BLU='\033[1m\033[35m'
RESET='\033[0m'
Objs = FrontEndDescription.o BeBoard.o Cbc.o MPA.o Module.o
CC = g++
CXX = g++
CCFlags = -g -O1 -Wall -fPIC -pedantic
IncludeDirs =
IncludePaths = $(IncludeDirs:%=-I%)
.PHONY: clean print
%.o: %.cc %.h
$(CXX) -std=c++11 $(CCFlags) $(IncludePaths) -c -o $@ $<
all: print $(Objs)
$(CC) -shared -o libPh2_Description.so $(Objs)
mv libPh2_Description.so ../lib
print:
@echo -e ${YEL}'****************************'${RESET}
@echo -e ${YEL}'Building HWDescription objects'${RESET}
@echo -e ${YEL}'****************************'${RESET}
clean:
rm -f *.o
......@@ -220,6 +220,9 @@ namespace Ph2_HwInterface {
}
this->DataClockTimingTune (pBoard);
fTriggerSourceWord = this->ReadReg ("cbc_system_cnfg.fast_signal_manager.fast_signal_enable");
LOG (INFO) << BOLDBLUE << "The following trigger sources are enabled: External L1A: " << bool (fTriggerSourceWord & 0x1) << " FMC: " << bool (fTriggerSourceWord & 0x2) << " IPBUS: " << bool (fTriggerSourceWord & 0x4) << " Internal Generator: " << bool (fTriggerSourceWord & 0x8) << RESET;
}
void Cbc3Fc7FWInterface::DataClockTimingTune (const BeBoard* pBoard)
......@@ -322,16 +325,21 @@ namespace Ph2_HwInterface {
//then start the triggers
WriteReg ("cbc_system_ctrl.fast_signal_manager.start_trigger", 0x1);
//if (fTriggerSourceWord & 0x8)
//{
//reload the config of the fast_command_manager
WriteReg ("cbc_system_ctrl.fast_signal_manager.fast_signal_generator_load_config", 0x1);
std::this_thread::sleep_for (std::chrono::microseconds (100) );
//start the periodic fast signals if enabled
WriteReg ("cbc_system_ctrl.fast_signal_manager.fast_signal_generator_start", 0x1);
//}
}
void Cbc3Fc7FWInterface::Stop()
{
//if (fTriggerSourceWord & 0x8)
WriteReg ("cbc_system_ctrl.fast_signal_manager.fast_signal_generator_stop", 0x1);
WriteReg ("cbc_system_ctrl.fast_signal_manager.stop_trigger", 0x1);
}
......@@ -366,8 +374,8 @@ namespace Ph2_HwInterface {
else
std::this_thread::sleep_for (std::chrono::milliseconds (100) );
LOG (DEBUG) << cNWords;
LOG (DEBUG) << "Data frame counter Cbc0: " << static_cast<int> (ReadReg ("cbc_system_stat.cbc_data_processors.cbc1.data_frame_counter") ) << " Data frame counter Cbc1: " << static_cast<int> (ReadReg ("cbc_system_stat.cbc_data_processors.cbc2.data_frame_counter") );
//LOG (DEBUG) << cNWords;
//LOG (DEBUG) << "Data frame counter Cbc0: " << static_cast<int> (ReadReg ("cbc_system_stat.cbc_data_processors.cbc1.data_frame_counter") ) << " Data frame counter Cbc1: " << static_cast<int> (ReadReg ("cbc_system_stat.cbc_data_processors.cbc2.data_frame_counter") );
}
pData = ReadBlockRegValue ("data", cNWords);
......@@ -398,11 +406,16 @@ namespace Ph2_HwInterface {
// configure fast signal generator
std::vector< std::pair<std::string, uint32_t> > cVecReg;
// configure the fast command cycle to send triggers
cVecReg.push_back ({"cbc_system_cnfg.fast_signal_manager.fast_signal_generator.enable.trigger", 0x1});
cVecReg.push_back ({"cbc_system_cnfg.fast_signal_manager.fast_signal_generator.Ncycle", pNEvents});
WriteStackReg ( cVecReg );
cVecReg.clear();
// but only if the internal trigger generator is enabled
if (fTriggerSourceWord & 0x8)
{
cVecReg.push_back ({"cbc_system_cnfg.fast_signal_manager.fast_signal_generator.enable.trigger", 0x1});
cVecReg.push_back ({"cbc_system_cnfg.fast_signal_manager.fast_signal_generator.Ncycle", pNEvents});
WriteStackReg ( cVecReg );
cVecReg.clear();
}
this->Start();
......@@ -412,16 +425,26 @@ namespace Ph2_HwInterface {
while (cNWords < pNEvents * cEventSize )
{
std::this_thread::sleep_for (std::chrono::milliseconds (100) );
std::this_thread::sleep_for (std::chrono::microseconds (100) );
cNWords = ReadReg ("cbc_system_stat.data_buffer.nword_events");
}
if (cNWords != pNEvents * cEventSize) LOG (ERROR) << "Error, did not read correct number of words for " << pNEvents << " Events! (read value= " << cNWords << "; expected= " << pNEvents* cEventSize << ")";
//if the internal trigger is enabled, we need to throw this error when the numbers don't match since then clearly something is wrong
if (fTriggerSourceWord & 0x8)
if (cNWords != pNEvents * cEventSize) LOG (ERROR) << "Error, did not read correct number of words for " << pNEvents << " Events! (read value= " << cNWords << "; expected= " << pNEvents* cEventSize << ")";
//disable triggers
this->Stop();
//and read data
pData = ReadBlockRegValue ("data", cNWords);
if (fTriggerSourceWord & 0x8)
pData = ReadBlockRegValue ("data", cNWords);
else
{
//in case of external triggers we don't have control over the frequency, so the buffer might already have more events than requested during the polling interval - in this case just read what we requested and discard the rest via a DAQ reset
pData = ReadBlockRegValue ("data", pNEvents * cEventSize);
//WriteReg ("cbc_system_ctrl.global.daq_reset", 0x1);
}
if ( fSaveToFile )
fFileHandler->set ( pData );
......
......@@ -47,6 +47,7 @@ namespace Ph2_HwInterface {
uint32_t fBroadcastCbcId;
uint32_t fNCbc;
uint32_t fFMCId;
uint32_t fTriggerSourceWord;
std::map<uint16_t, uint8_t> fIDMap;
std::map<uint8_t, uint16_t> fIDMapReverse;
......
This diff is collapsed.
......@@ -51,9 +51,13 @@ namespace Ph2_HwInterface {
// number of chips and hybrids defined in firmware (compiled for)
int fFWNHybrids;
int fFWNChips;
ChipType fFirwmareChipType;
bool fCBC3Emulator;
const uint32_t SINGLE_I2C_WAIT = 200; //used for 1MHz I2C
// some useful stuff
int fResetAttempts;
public:
/*!
*
......@@ -138,6 +142,11 @@ namespace Ph2_HwInterface {
*/
void ResetReadout();
/*!
* \brief Tune the 320MHz buses phase shift
*/
void PhaseTuning(const BeBoard *pBoard);
/*!
* \brief Read data from DAQ
* \param pBreakTrigger : if true, enable the break trigger
......@@ -165,6 +174,10 @@ namespace Ph2_HwInterface {
void PowerOnDIO5();
// get fmc card name
std::string getFMCCardName (uint32_t id);
// convert code of the chip from firmware
std::string getChipName(uint32_t pChipCode);
ChipType getChipType(uint32_t pChipCode);
//template to copy every nth element out of a vector to another vector
template<class in_it, class out_it>
......@@ -262,7 +275,7 @@ namespace Ph2_HwInterface {
/*! \brief Delete one Fpga configuration (or firmware image)*/
void DeleteFpgaConfig ( const std::string& strId);
/*! \brief Reboot the board */
void RebootBoard() {}
void RebootBoard();
/*! \brief Set or reset the start signal */
void SetForceStart ( bool bStart) {}
......
YEL='\033[1m\033[33m'
RED='\033[1m\033[31m'
BLU='\033[1m\033[35m'
RESET='\033[0m'
DEPENDENCIES := Utils HWDescription HWInterface RootWeb
ANTENNAINSTALLED = no
AMC13INSTALLED = no
USBINSTINSTALLED = no
ROOTVERSION := $(shell root-config --version)
ifneq ("$(wildcard $(ANTENNADIR))","")
DEPENDENCIES := CMSPh2_AntennaDriver $(DEPENDENCIES)
ANTENNAINSTALLED = yes
else
ANTENNAINSTRUCTIONS = To use the USB Antenna, please download the Driver from 'https://gitlab.cern.ch/cms_tk_ph2/CMSPh2_AntennaDriver.git' and make sure that libusb-devel is installed!
endif
ifneq ("$(wildcard $(AMC13DIR))","")
DEPENDENCIES := AMC13 $(DEPENDENCIES)
AMC13INSTALLED = yes
else
AMC13INSTRUCTIONS = This feature can only be built if the AMC13 libraries are installed with cactus!
endif
ifneq ("$(wildcard $(USBINSTDIR))","")
USBINSTINSTALLED = yes
USBINSTINSTRUCTIONS =
else
USBINSTINSTRUCTIONS = To use the Ph2_USBInstDriver please download it from 'https://gitlab.cern.ch/cms_tk_ph2/Ph2_USBInstDriver.git'.
endif
.PHONY: print dependencies $(DEPENDENCIES) clean src miniDAQ tools
all: src miniDAQ
dependencies: print $(DEPENDENCIES)
$(DEPENDENCIES):
$(MAKE) -C $@
System: dependencies
$(MAKE) -C System
tools: System
$(MAKE) -C tools
src miniDAQ: tools
$(MAKE) -C $@
print:
@echo -e ' '
@echo -e ${YEL}'*****************************'
@echo -e 'BUILDING PH2 ACF FRAMEWORK'
@echo -e 'with the following Dependencies:'${RESET}
@echo -e ${BLU}$(DEPENDENCIES)${RESET}
@echo -e ${YEL}'ROOT Version: '${RED} $(ROOTVERSION)${RESET}
@echo -e ${YEL}'*****************************'${RESET}
@echo -e ${YEL}'Amc13 SW installed:'${RED} $(AMC13INSTALLED)${RESET}
@echo -e $(AMC13INSTRUCTIONS)
@echo -e ${YEL}'*****************************'${RESET}
@echo -e ${YEL}'Antenna Driver installed:' ${RED}$(ANTENNAINSTALLED)${RESET}
@echo -e $(ANTENNAINSTRUCTIONS)
@echo -e ${YEL}'*****************************'${RESET}
@echo -e ${YEL}'Ph2 USB Inst Driver installed:' ${RED}$(USBINSTINSTALLED)${RESET}
@echo -e $(USBINSTINSTRUCTIONS)
@echo -e ${YEL}'*****************************'${RESET}
clean:
(cd System; make clean)
(cd Utils; make clean)
(cd HWInterface; make clean)
(cd HWDescription; make clean)
(cd tools; make clean)
(cd RootWeb; make clean)
(cd miniDAQ; make clean)
(cd AMC13; make clean)
(rm -f lib/* bin/*)
......@@ -26,7 +26,7 @@ You'll need Xilinx Impact and a [Xilinx Platform Cable USB II] (http://uk.farnel
#### Setup on SLC6
1. Install the latest gcc compiler:
1. Install a gcc compiler version > 4.8 - on scientific linux you can obtain this by installing devtoolset-2 or devtoolset-2.1:
$> sudo wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
$> sudo yum install devtoolset-2
......@@ -38,9 +38,9 @@ You'll need Xilinx Impact and a [Xilinx Platform Cable USB II] (http://uk.farnel
$> gcc --version
Alternatively you can use a gcc version > 4.7 from AFS
2. Alternatively you can use a gcc version > 4.8 from AFS
1. Install uHAL version 2.3:
3. Install uHAL (latest version, instructions below for v2.3):
$> wget http://svnweb.cern.ch/trac/cactus/export/28265/tags/ipbus_sw/uhal_2_3_0/scripts/release/cactus.slc6.x86_64.repo
......@@ -53,52 +53,48 @@ You'll need Xilinx Impact and a [Xilinx Platform Cable USB II] (http://uk.farnel
$> sudo yum clean all
$> sudo yum groupinstall uhal
1. Install CERN ROOT version 5.34.32: [Instructions](http://root.cern.ch/drupal/content/installing-root-source) - make sure to use "fixed location installation" when building yourself. If root is installed on a CERN computer of virtual machine you can use:
4. Install CERN ROOT version 5.34.32(SLC6) or 6.10(CC7): [Instructions](http://root.cern.ch/drupal/content/installing-root-source) - make sure to use "fixed location installation" when building yourself. If root is installed on a CERN computer of virtual machine you can use:
$> sudo yum install root
$> sudo yum install root-net-http root-graf3d-gl root-physics libusb-devel root-montecarlo-eg root-graf3d-eve root-geom
$> sudo yum install root-net-http root-graf3d-gl root-physics root-montecarlo-eg root-graf3d-eve root-geom libusb-devel xorg-x11-xauth.x86_64
1. If you are working on a remote machine, you need these packages for the Canvases to show
5. Install CMAKE > 2.8. On SLC6 the default is cmake 2.8
$> sudo yum install xorg-x11-xauth.x86_64
$> sudo yum install cmake
Note: You may also need to set the environment variables (or source setup.sh):
6. On CC7 you also need to install boost v1.53 headers (default on this system) as they don't ship with uHAL any more:
$> export LD_LIBRARY_PATH=/opt/cactus/lib:$LD_LIBRARY_PATH
$> export PATH=/opt/cactus/bin:$PATH
$> sudo yum install boost-devel
### The Ph2_ACF Software :
Follow these instructions to install and compile the libraries:
(provided you installed the latest version of gcc, µHal, boost as mentioned above).
(provided you installed the latest version of gcc, µHal, mentioned above).
1. Clone the GitHub repo and run setup.sh
1. Clone the GitHub repo and run cmake
$> git clone https://:@gitlab.cern.ch:8443/cms_tk_ph2/Ph2_ACF.git
$> source setup.sh
$> cd Ph2_ACF/build
$> cmake ..
1. Do a `make` in the root of the repo (make sure you have all µHal, root libraries on your computer).
2. Do a `make -jN` in the build/ directory or alternatively do `make -C build/ -jN` in the Ph2_ACF root directory.
1. Alternatively you can use CMAKE (you will still need to source setup.sh to put the binaries in the path):
3. Don't forget to `source setup.sh` to set all the environment variables correctly.
$> cd build/
$> cmake ..
$> make -jN
$> cd .. & source setup.sh
1. Launch
4. Launch
$> systemtest --help
command if you want to test the parsing of the HWDescription.xml file.
1. Launch
5. Launch
$> datatest --help
command if you want to test if you can correctly read data
1. Launch
6. Launch
$> calibrate --help
......@@ -120,25 +116,25 @@ Follow these instructions to install and compile the libraries:
to apply a configuration to the CBCs
1. Launch
7. Launch
$> commission --help
to do latency & threshold scans
1. Launch
8. Launch
$> fpgaconfig --help
to upload a new FW image to the GLIB
1. Launch
9. Launch
$> miniDAQ --help
to save binary data from the GLIB to file
1. Launch
10. Launch
$> miniDQM --help
......@@ -293,9 +289,6 @@ In order to use external Clock and Trigger functionality, a DIO5 mezzanine is re
### Known Issues:
Several bugs / problematic behavior has been reported by various users that is not direclty linked to the Ph2_ACF libraries, however, some workarounds are provided:
- When configuring a CBC object (writing all registers at once), the MSB of the Register "FrontEncControl" is read back incorrectly. This only manifests in electron mode (0xC3 instead of 0x43). The cause of this problem is identified as a FW artefact and the error itself can be safely ignored until the problem is solved. The chips will still properly configure and data quality should not be affected.
- uHAL exceptions and UDP timeouts when reading larger packet sizes from the GLIB board:
this can happen for some users (cause not yet identified) but can be circumvented by changing the line
......@@ -312,12 +305,6 @@ in the connections.xml file to
This uses TCP protocol instead of UDP which accounts for packet loss but decreases the performance.
- SegmentationViolations on lines that contain
gStyle->Set ... ;
statements. This has been observed by several users on the VM and can be fixed by re-compiling ROOT using GCC 4.8
### Support, Suggestions ?
......
YEL='\033[1m\033[33m'
RED='\033[1m\033[31m'
BLU='\033[1m\033[35m'
RESET='\033[0m'
ROOTFLAGS=`root-config --cflags`
ROOTLIBDIR=`root-config --libdir`
ROOTLIBFLAGS=`root-config --libs`
ROOTLIBFLAGS+=-lHistPainter
ifneq ($(strip $(BOOST_INCLUDE)),)
INCLUDEFLAGS=-I$(BOOST_INCLUDE)
endif
ifneq ($(strip $(BOOST_LIB)),)
BOOSTLIBFLAGS=-L$(BOOST_LIB)
endif
BOOSTLIBFLAGS+=-lboost_system$(BOOST_SUFFIX) -lboost_filesystem$(BOOST_SUFFIX) -lboost_program_options$(BOOST_SUFFIX)
GLIBFLAGS=`root-config --glibs`
INCLUDEFLAGS+=-Iinclude/
SRCDIR=src
INCDIR=include
LIBDIR=lib
# BINDIR=bin
# TESTDIR=test
COMPILERFLAGS+=-std=c++11
COMPILERFLAGS+=-g -fPIC
COMPILERFLAGS+=-fpermissive
LINKERFLAGS+=-Wl,--copy-dt-needed-entries
CXX := g++
COMP=$(CXX) $(COMPILERFLAGS) $(INCLUDEFLAGS)
LINK=$(CXX) $(LINKERFLAGS)
.PHONY: clean print
all: print lib
# ROOT-related stuff
$(LIBDIR)/rootweb.o: $(SRCDIR)/rootweb.cpp $(INCDIR)/rootweb.hh
$(COMP) $(ROOTFLAGS) -c -o $(LIBDIR)/rootweb.o $(SRCDIR)/rootweb.cpp
# Binary
lib: $(LIBDIR)/rootweb.o
$(COMP) -shared -o $(LIBDIR)/libRootWeb.so $(LIBDIR)/rootweb.o -pthread $(BOOSTLIBFLAGS)
print:
@echo -e ${YEL}'****************************'
@echo -e ${YEL}'Building RootWeb'
@echo -e ${YEL}'****************************'${RESET}
#CLEANUP
cleanall:
@rm -rf $(LIBDIR)/*
clean: cleanall
YEL='\033[1m\033[33m'
RED='\033[1m\033[31m'
BLU='\033[1m\033[35m'
RESET='\033[0m'
Objs = FileParser.o SystemController.o
CC = g++
CXX = g++
CCFlags = -g -O1 -w -Wall -pthread -pedantic -fPIC
.PHONY: clean print
IncludeDirs = ../ $(CACTUSINCLUDE)
LibraryDirs = ../lib
ExternalObjects = -lPh2_Interface -lPh2_Description -lPh2_Utils
IncludePaths = $(IncludeDirs:%=-I%)
LibraryPaths = $(LibraryDirs:%=-L%)
%.o: %.cc %.h
$(CXX) -std=c++0x $(CCFlags) $(IncludePaths) $(LibraryPaths) -c -o $@ $<
all: print $(Objs)
$(CC) -std=c++0x -shared -o libPh2_System.so $(Objs)
mv libPh2_System.so ../lib
print:
@echo -e${YEL}'****************************'
@echo -e'Building System Components '
@echo -e'****************************'${RESET}
clean:
rm -f *.o
......@@ -150,9 +150,9 @@ namespace Ph2_System {
for (auto& cBoard : fBoardVector)
{
fBeBoardInterface->ConfigureBoard ( cBoard );
fBeBoardInterface->CbcFastReset ( cBoard );
//fBeBoardInterface->CbcHardReset ( cBoard );
fBeBoardInterface->ConfigureBoard ( cBoard );
//fBeBoardInterface->CbcFastReset ( cBoard );
if ( cCheck && cBoard->getBoardType() == BoardType::GLIB)
{
......
......@@ -282,6 +282,11 @@ namespace Ph2_HwInterface {
std::vector<Stub> Cbc2Event::StubVector (uint8_t pFeId, uint8_t pCbcId) const
{
std::vector<Stub> cStubVec;
//dirty workaround to keep code compatible with CBC2
if (this->StubBit (pFeId, pCbcId) )
cStubVec.emplace_back (0, 0);
return cStubVec;
}
......
......@@ -51,10 +51,24 @@ namespace Ph2_HwInterface {
fBunch = 0;
fOrbit = 0;
fLumi = 0;
fEventCount = 0x1FFFFFFF & list.at (2);
//TODO: get the value from 1 CBC here?
fEventCountCBC = 0;
fTDC = (0xE0000000 & list.at (2) ) >> 29;
//normal version
//{
//fEventCount = 0x1FFFFFFF & list.at (2);
//}
//version with TDC
{
fEventCount = 0xFFFFFFFF & list.at (2);
if ( (list.at (2) & 0xF8) >> 3 != 0)
fTDC = list.at (2) & 0xFF;
else fTDC = 0;
fOR254Trigger = (list.at (2) >> 8) & 0x1;
}
// standard code
//fBeId = ( (0x0FE00000 & list.at (0) ) >> 21) - 1;
fBeId = ( (0x03E00000 & list.at (0) ) >> 21) - 1;
......@@ -206,6 +220,22 @@ namespace Ph2_HwInterface {
return 0;