mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5a712ab42 | |||
fa931b8fca | |||
37bf3600ad | |||
96f6561080 | |||
9ca831d954 |
@ -1,12 +1,12 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(slsDetectorPackage)
|
||||
set(PROJECT_VERSION 6.1.2)
|
||||
set(PROJECT_VERSION 6.0.0)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
# cmake_policy(SET CMP0074 NEW)
|
||||
include(cmake/project_version.cmake)
|
||||
|
||||
#functions to add compiler flags
|
||||
@ -67,7 +67,10 @@ set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
||||
${CMAKE_BINARY_DIR})
|
||||
find_package(ClangFormat)
|
||||
|
||||
|
||||
#Enable LTO if available
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT SLS_LTO_AVAILABLE)
|
||||
message(STATUS "SLS_LTO_AVAILABLE:" ${SLS_LTO_AVAILABLE})
|
||||
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
@ -78,16 +81,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
endif()
|
||||
|
||||
|
||||
#Enable LTO if available
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT SLS_LTO_AVAILABLE)
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
message(STATUS "Building with link time optimization")
|
||||
else()
|
||||
message(STATUS "Building without link time optimization")
|
||||
endif()
|
||||
|
||||
|
||||
#Add two fake libraries to manage options
|
||||
add_library(slsProjectOptions INTERFACE)
|
||||
add_library(slsProjectWarnings INTERFACE)
|
||||
@ -140,10 +133,11 @@ endif()
|
||||
|
||||
# Add or disable warnings depending on if the compiler supports them
|
||||
# The function checks internally and sets HAS_warning-name
|
||||
sls_enable_cxx_warning("-Wnull-dereference")
|
||||
sls_enable_cxx_warning("-Wduplicated-cond")
|
||||
sls_disable_cxx_warning("-Wclass-memaccess")
|
||||
sls_disable_c_warning("-Wstringop-truncation")
|
||||
# sls_enable_cxx_warning("-Wnull-dereference")
|
||||
# sls_enable_cxx_warning("-Wduplicated-cond")
|
||||
# sls_disable_cxx_warning("-Wclass-memaccess")
|
||||
# sls_disable_c_warning("-Wstringop-truncation")
|
||||
# sls_disable_c_warning("-Wformat-nonliteral")
|
||||
|
||||
|
||||
if(SLS_USE_SANITIZER)
|
||||
@ -178,35 +172,35 @@ set(CMAKE_INSTALL_RPATH $ORIGIN)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
|
||||
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
||||
#Adapted from: https://github.com/zeromq/cppzmq/
|
||||
if (NOT TARGET libzmq)
|
||||
if(ZeroMQ_HINT)
|
||||
message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
||||
find_package(ZeroMQ 4
|
||||
NO_DEFAULT_PATH
|
||||
HINTS ${ZeroMQ_DIR}
|
||||
)
|
||||
else()
|
||||
find_package(ZeroMQ 4 QUIET)
|
||||
endif()
|
||||
# set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
||||
# #Adapted from: https://github.com/zeromq/cppzmq/
|
||||
# if (NOT TARGET libzmq)
|
||||
# if(ZeroMQ_HINT)
|
||||
# message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
||||
# find_package(ZeroMQ 4
|
||||
# NO_DEFAULT_PATH
|
||||
# HINTS ${ZeroMQ_DIR}
|
||||
# )
|
||||
# else()
|
||||
# find_package(ZeroMQ 4 QUIET)
|
||||
# endif()
|
||||
|
||||
# libzmq autotools install: fallback to pkg-config
|
||||
if(NOT ZeroMQ_FOUND)
|
||||
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
|
||||
find_package(ZeroMQ 4 REQUIRED)
|
||||
endif()
|
||||
# # libzmq autotools install: fallback to pkg-config
|
||||
# if(NOT ZeroMQ_FOUND)
|
||||
# message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
||||
# list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
|
||||
# find_package(ZeroMQ 4 REQUIRED)
|
||||
# endif()
|
||||
|
||||
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
||||
if(NOT ZeroMQ_FOUND)
|
||||
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
||||
endif()
|
||||
# # TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
||||
# if(NOT ZeroMQ_FOUND)
|
||||
# message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
||||
# endif()
|
||||
|
||||
if (ZeroMQ_FOUND AND NOT TARGET libzmq)
|
||||
message(FATAL_ERROR "ZeroMQ version not supported!")
|
||||
endif()
|
||||
endif()
|
||||
# if (ZeroMQ_FOUND AND NOT TARGET libzmq)
|
||||
# message(FATAL_ERROR "ZeroMQ version not supported!")
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
if (SLS_USE_TESTS)
|
||||
enable_testing()
|
||||
|
428
RELEASE.txt
428
RELEASE.txt
@ -1,183 +1,351 @@
|
||||
SLS Detector Package Patch Release 6.1.2 released on 25.11.2022
|
||||
===============================================================
|
||||
SLS Detector Package 6.0.0 released on 21.10.2021
|
||||
==================================================
|
||||
|
||||
This document describes the differences between v6.0.0 and v5.1.0.
|
||||
|
||||
This document describes the differences between v6.1.2 and v6.1.1.
|
||||
|
||||
|
||||
CONTENTS
|
||||
--------
|
||||
1. Resolved Issues
|
||||
2. On-board Detector Server Compatibility
|
||||
2. Firmware Requirements
|
||||
3. Kernel Requirements
|
||||
4. Download, Documentation & Support
|
||||
1. New or Changed Features
|
||||
2. Resolved Issues
|
||||
3. Known Issues
|
||||
4. Changes in Next Major Release
|
||||
5. Firmware Requirements
|
||||
6. Download, Documentation & Support
|
||||
|
||||
|
||||
|
||||
1. Resolved Issues
|
||||
==================
|
||||
|
||||
Detector Server
|
||||
---------------
|
||||
|
||||
1. [Jungfrau, Moench, Ctb]
|
||||
Programming Firmware
|
||||
Updating kernel was not enough to ensure seamless programming of FPGA.
|
||||
nCe signal now made high before programming blackfin.
|
||||
|
||||
Updating the on-board detector server to this version is recommended
|
||||
before updating firmware for future releases.
|
||||
|
||||
Also removed the unnecessary test to check if it is allowed to update
|
||||
kernel or on-board detector server, depending on the current kernel
|
||||
version.
|
||||
|
||||
2. [Eiger] locking for start and stop
|
||||
Since the start and stop has a few commands within the server itself,
|
||||
they are locked to ensure they dont disturb the other to have undefined
|
||||
behavior.
|
||||
|
||||
3. [Eiger] Quad Trimbits or threshold
|
||||
Loading trimbits or setting threshold will throw an incorrect exception
|
||||
for a quad as the left and right register values will not match. The fix
|
||||
only sets and monitors right fpga for chip trim signals in quad.
|
||||
|
||||
4. [Eiger] Minor refactoring
|
||||
Inconsistent reads between left and right register for read/write
|
||||
register commands now give clear error messages.
|
||||
|
||||
Fixed some minor functions returned empty error messages when failing.
|
||||
1. New or Changed Features
|
||||
==========================
|
||||
|
||||
Added License. Read COPYING for more details.
|
||||
|
||||
Client
|
||||
------
|
||||
1. Shared libraries
|
||||
They are versioned from this release on (6.0.0).
|
||||
|
||||
1. [Eiger] Stop command freezes server
|
||||
It is apparent in large detectors.
|
||||
2. [Jungfrau] Chip version
|
||||
Features for chipv1.1 incorporated
|
||||
Command line: chipversion, API: getchipVersion
|
||||
gets chip version (1.0 or 1.1)
|
||||
chipv1.1 requires config_jungfrau.txt on detector server and HW 2.0.
|
||||
|
||||
For example, if module A got a "stop" during an acquisition,
|
||||
it stops to an 'Idle' state. If module B gets a "stop" before an
|
||||
acquisition, it will return it is in 'Idle' state and continue
|
||||
to start the next acquisition, but module B then waits for "ready
|
||||
for trigger" synchronization from module A, which it will never get.
|
||||
3. [Jungfrau] Chip configuration (only chipv1.1)
|
||||
powering on the chip and changing settings will configure the chip.
|
||||
Hence, required before acquisition.
|
||||
|
||||
Since module B missed the asynchronous stop command, the workaround
|
||||
in the client is to send another "stop" command (upto 10 retries)
|
||||
till it returns Idle.
|
||||
4. [Jungfrau] Settings and Gain mode
|
||||
Settings can be gain0 and highgain0. Gain mode can be dynamicgain,
|
||||
forceswitchg1, forceswitchg2, fixg1, fixg2, fixg0. fixg0 must be
|
||||
used with EXTRA caution as you can damage the detector.
|
||||
Changing settings also changes dac values of 3 dacs
|
||||
(vref_prech, vref_ds and vref_comp) and reconfigures chip (only v1.1)
|
||||
|
||||
2. [Eiger][Jungfrau][Moench][Ctb]
|
||||
Stop results in different frame numbers
|
||||
A "stop" command will also now check for inconsistent 'nextframenumber'
|
||||
between the modules and set it to the max + 1 to ensure that they
|
||||
all start with the same frame number for the next acquisition.
|
||||
5. [Jungfrau] Storage cells (only chipv1.1)
|
||||
Additional number of storage cells not applicable for chipv1.1.
|
||||
Storage cell start is only allowed from 0 - 3 for chipv1.1
|
||||
(0 - 15 for chipv1.0).
|
||||
Command line: extrastoragecells, Previous Command line: storagecells
|
||||
API: remains the same.
|
||||
|
||||
6. [Gotthard2][Jungfrau] Filter Resistor
|
||||
Command line: filterresistor, API: getFilterResistor/ setFilterResistor
|
||||
Previous Command: filter, setFilter/ getFilter
|
||||
Set Filter resistor. Increasing values for increasing resistance.
|
||||
[Jungfrau] only for chipv1.1. Options: [0|1]. Default is 1.
|
||||
[Gotthard2] Options: [0|1|2|3]. Default is 0.
|
||||
|
||||
7. [Jungfrau] Filter cell (only chipv1.1)
|
||||
Command line: filtercells, API: getNumberOfFilterCells/ setNumberOfFilterCells
|
||||
Set filter cell. Options: [0-12]. Advanced user command.
|
||||
|
||||
8. [Jungfrau] Comparator disable time (only chipv1.1)
|
||||
Command line: compdisabletime, API: getComparatorDisableTime/
|
||||
setComparatorDisableTime
|
||||
One can customize the period to disable comparator.
|
||||
|
||||
9. [Eiger][Jungfrau] Read n rows
|
||||
Command line: readnrows, API: getReadNRows/ setReadNRows
|
||||
Previous Command: readnlines, getPartialReadout/ setPartialReadout
|
||||
[Eiger] same as before
|
||||
[Jungfrau] Options: 8 - 512, multiples of 8. Default is 512.
|
||||
|
||||
10. [Gotthard2][Jungfrau] Current source
|
||||
Command line: currentsource, API: getCurrentSource, setCurrentSource
|
||||
Enable or disable current source. Default is disabled.
|
||||
[Gotthard2] Can only enable or disable.
|
||||
[Jungfrau] Can choose to fix, select source and choose normal or low
|
||||
current. Normal/ low only for chipv1.1.
|
||||
Select source is 0-63 for chipv1.0 and a 64 bit mask for chipv1.1.
|
||||
|
||||
11. Default dac
|
||||
Command line: defaultdac, API: getDefaultDac/ setDefaultDac
|
||||
change default value of a dac
|
||||
[Jungfrau][Mythen3] Also change default value of dac for particular
|
||||
setting.
|
||||
|
||||
12. Reset dacs
|
||||
Command line: resetdacs, API: resetToDefaultDacs
|
||||
Previous command: defaultdacs
|
||||
Resets dacs to their default values or hard coded values.
|
||||
|
||||
13. [Mythen3] Gain Capacitance
|
||||
Command line: gaincaps, API: getGainCaps/ setGainCaps
|
||||
Set various gain capacitances.
|
||||
|
||||
14. [Gotthard2] Veto Streaming from chip
|
||||
Command line: veto, API: getVeto/ setVeto
|
||||
This command used to mean veto streaming from detector. Now, it means
|
||||
veto streaming from chip (New feature). Default is disabled.
|
||||
|
||||
15. [Gotthard2] Veto streaming from detector
|
||||
Command line: vetostream, API: getVetoStream, setVetoStream
|
||||
Options: None, local link interface, 10 10GbE, Both
|
||||
Default: None
|
||||
10GbE (as before) will enable 2 udp interfaces in receiver.
|
||||
|
||||
16. [Gotthard2] Veto algorithm
|
||||
Command line: vetoalg, API: getVetoAlgorithm/ setVetoAlgorithm
|
||||
Set veto algorithm for each interface.
|
||||
Options: hits, raw
|
||||
|
||||
17. [Eiger][Gotthard2][Mythen3] Module ID
|
||||
Command line: moduleid, API: getModuleId
|
||||
Previous command (Eiger only): serialnumber, getSerialNumber
|
||||
Unique id read from txt file on detector and streamed out in udp header.
|
||||
|
||||
18. [Gotthard2]
|
||||
Command line: dbitpipeline, API: getDBITPipeline/ setDBITPipeline
|
||||
Set pipeline to latch digital bits. Options: 0-7
|
||||
|
||||
19. [Eiger][Jungfrau] Round Robin commands
|
||||
Command line, udp_dstlist, API: getDestinationUDPList/
|
||||
setDestinationUDPList
|
||||
Round robin commands at the moment does not configure the receiver.
|
||||
Set multiple udp destinations in the detector to stream udp data packets
|
||||
to. Upto 32 destinations. Refer documentation for details.
|
||||
|
||||
Command line, udp_numdst, API: getNumberofUDPDestinations
|
||||
|
||||
[Jungfrau] Command line, udp_firstdst, API: getFirstUDPDestination/
|
||||
setFirstUDPDestination
|
||||
|
||||
20. Command Line Parsing
|
||||
Parsing of detector index and module index has been modified to
|
||||
integrate round robin index.
|
||||
[detector index]-[module index]:[round robin index] [command]
|
||||
|
||||
It is backwards compatible.
|
||||
For ease, one can also execute
|
||||
sls_detector_put [module index] [command]
|
||||
|
||||
21. Clear Udp Destination
|
||||
Command line, udp_cleardst, API: clearUDPDestinations
|
||||
This is useful when changing receivers for a detector or for round robin
|
||||
system.
|
||||
|
||||
22. Shared Memory Naming
|
||||
Shared memory name has been changed to reflect a more appropriate naming
|
||||
scheme.
|
||||
|
||||
23. [Eiger][Mythen3] Blocking trigger
|
||||
Command line: blockingtrigger, API: sendSoftwareTrigger
|
||||
Sends software trigger signal to detector and blocks till frames are
|
||||
sent out for that trigger.
|
||||
|
||||
24. [Eiger] Data stream enable for ports
|
||||
Command line: datastream, API: getDataStream/ setDataStream
|
||||
Enable or disable each port. Default: enabled
|
||||
|
||||
25. Changing TCP ports
|
||||
This will only affect shared memory and will not try to change the
|
||||
current tcp port of the control/stop server in detector.
|
||||
|
||||
26. [Eiger][Jungfrau][Gotthard2] Speed
|
||||
Command line: readoutspeed, readoutspeedlist API: getReadoutSpeed/ setReadoutSpeed /
|
||||
getReadoutSpeedList
|
||||
Previous command: speed, setSpeed/ getSpeed
|
||||
[Eiger][Jungfrau] same as before.
|
||||
[Gotthard2] New command to set readout speed. Options: 108, 144 (in MHz)
|
||||
|
||||
27. [Eiger][Jungfrau] Flip rows
|
||||
Command line: fliprows, API: getFlipRows/ setFlipRows
|
||||
Previous command: flippeddatax, setBottom/ getBottom
|
||||
[Jungfrau] Flips rows in detector only for HW v2.0.
|
||||
slsReceiver and slsDetectorGui will not flip them again.
|
||||
[Eiger] same as before.
|
||||
|
||||
28. [Jungfrau]
|
||||
Command line changes: autocompdisable, Previous command line: auto_comp_disable
|
||||
|
||||
|
||||
Detector servers
|
||||
----------------
|
||||
|
||||
Python
|
||||
------
|
||||
1. [Gotthard2] Bad Channels moved to a new register, default settings
|
||||
including clock frequency changed
|
||||
|
||||
1. Conda package
|
||||
Removed conda pkgs for python 3.6 and 3.7
|
||||
Added conda pkgs for python 3.11
|
||||
|
||||
2. Pybind11
|
||||
Updated pybind11 from 2.6.2 to 2.10.11
|
||||
2. [Gotthard2] Updated config file in detector server
|
||||
|
||||
|
||||
Test
|
||||
Virtual servers
|
||||
----------------
|
||||
|
||||
1. Artifical pixel values increasing by every packet, instead of every pixel.
|
||||
|
||||
2. All possible features updated.
|
||||
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. Frames caught in metadata
|
||||
Frames caught by the master receiver is added to master file metadata.
|
||||
Hdf5 and Binary version numbers changed to 6.3
|
||||
|
||||
2. Removed Padding option for Deactivated half modules.
|
||||
|
||||
3. Changing Receiver TCP ports
|
||||
This will only affect shared memory and will not try to change the
|
||||
current tcp port of the receiver.
|
||||
|
||||
Gui
|
||||
----
|
||||
|
||||
1. Updated catch to latest 2.x version due do build failure on fedora
|
||||
1. [Mythen3] counters added in settings tab
|
||||
|
||||
|
||||
|
||||
2. On-board Detector Server Compatibility
|
||||
==========================================
|
||||
|
||||
Eiger 6.1.2
|
||||
Jungfrau 6.1.2
|
||||
Gotthard 6.1.0
|
||||
Mythen3 6.1.0
|
||||
Gotthard2 6.1.0
|
||||
Moench 6.1.2
|
||||
Ctb 6.1.2
|
||||
2. Resolved Issues
|
||||
==================
|
||||
|
||||
On-board Detector Server Upgrade
|
||||
================================
|
||||
From v6.1.0 (without tftp):
|
||||
Using command 'updatedetectorserver'
|
||||
From 5.0.0 (with tftp):
|
||||
Using command 'copydetectorserver'
|
||||
Detector Servers
|
||||
----------------
|
||||
|
||||
Instructions available at
|
||||
https://slsdetectorgroup.github.io/devdoc/serverupgrade.html
|
||||
1. [Gotthard2] Tolerance in time parameters.
|
||||
Eg. 220 ns was being set to 215 ns, instead of 222ns.
|
||||
|
||||
2. [Jungfrau] Stopping in trigger mode and then switching to auto timing mode
|
||||
blocks data streaming from detector. Workaround fix made in
|
||||
detector server to reset core until next firmware release.
|
||||
|
||||
3. [Jungfrau][CTB][Moench][Gotthard][Gotthard2][Mythen3] Firmware Programming
|
||||
Firmware programming incorporates more validations such as checksum of
|
||||
program. Always ensure client and server are of same release before
|
||||
programming firmware.
|
||||
|
||||
4. [Eiger] Stop sends last frame
|
||||
Stop acquisition will now also send out all complete frames in fifo.
|
||||
|
||||
5. [Eiger] Bottom not rotated in quad mode. Fixed.
|
||||
|
||||
6. [Mythen3] counter mask effect on vthreshold
|
||||
Setting counter mask changes vth daac values (ie. disabling sets to 2800),
|
||||
vthreshold only changes for enabled counters, setting vth overwrites
|
||||
dac even if counter disabled and when counters enabled, remembers set
|
||||
values.
|
||||
|
||||
7. [Eiger] fast quad fix for loading trimbits
|
||||
|
||||
8. [Eiger] Can also use copydetectorserver command.
|
||||
[All] copydetectorserver command also creates a link to the binary copied
|
||||
with a shorter name ([detector]DetectorServer only)
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. Disabled port or deactivated (half) modules will not create files.
|
||||
|
||||
|
||||
|
||||
3. Firmware Requirements
|
||||
|
||||
3. Known Issues
|
||||
===============
|
||||
|
||||
Receiver
|
||||
--------
|
||||
1. It does not handle readnrows or partial readout. Only the summary
|
||||
is adjusted to print in red. However, it will still write complete
|
||||
images with missing data padded. Roi will be implemented in future
|
||||
that can be complemented with this feature to remove the additional
|
||||
data in files.
|
||||
|
||||
2. Round robin is not implemented in receiver side, ie. one cannot configure
|
||||
more than 1 receiver at a time. This will/might be done in the future.
|
||||
|
||||
|
||||
|
||||
|
||||
4. Changes in Next Major Release
|
||||
================================
|
||||
|
||||
1. Naming of Package
|
||||
The package might be renamed and so might the binaries, libraries,
|
||||
namespace,include paths in the next major release (which is breaking API).
|
||||
|
||||
|
||||
|
||||
|
||||
5. Firmware Requirements
|
||||
========================
|
||||
|
||||
Note: No change to 6.1.1.
|
||||
Eiger
|
||||
=====
|
||||
Compatible version : 08.10.2021 (v29)
|
||||
|
||||
Eiger 08.10.2021 (v29)
|
||||
Jungfrau 31.08.2021 (v1.2, PCB v1.0)
|
||||
08.10.2021 (v2.2, PCB v2.0)
|
||||
Gotthard 08.02.2018 (50um and 25um Master)
|
||||
09.02.2018 (25 um Slave)
|
||||
Mythen3 10.09.2021 (v1.1)
|
||||
Gotthard2 27.05.2021 (v0.1)
|
||||
Moench 05.10.2020 (v1.0)
|
||||
Ctb 05.10.2020 (v1.0)
|
||||
Jungfrau
|
||||
========
|
||||
Compatible version : 31.08.2021 (v1.2, PCB v1.0)
|
||||
: 08.10.2021 (v2.2, PCB v2.0)
|
||||
|
||||
Gotthard
|
||||
========
|
||||
Compatible version : 08.02.2018 (50um and 25um Master)
|
||||
: 09.02.2018 (25 um Slave)
|
||||
|
||||
Mythen3
|
||||
=======
|
||||
Compatible version : 10.09.2021 (v1.1)
|
||||
|
||||
Gotthard2
|
||||
=========
|
||||
Compatible version : 27.05.2021 (v0.1)
|
||||
|
||||
Moench
|
||||
======
|
||||
Compatible version : 05.10.2020 (v1.0)
|
||||
|
||||
Ctb
|
||||
===
|
||||
Compatible version : 05.10.2020 (v1.0)
|
||||
|
||||
Detector Upgrade
|
||||
================
|
||||
|
||||
Detector Firmware Upgrade
|
||||
=========================
|
||||
The following can be upgraded remotely:
|
||||
Eiger via bit files
|
||||
Jungfrau via 'programfpga' command <.pof>
|
||||
Mythen3 via 'programfpga' command <.rbf>
|
||||
Gotthard2 via 'programfpga' command <.rbf>
|
||||
Moench via 'programfpga' command <.pof>
|
||||
Ctb via 'programfpga' command <.pof>
|
||||
Jungfrau via command <.pof>
|
||||
Mythen3 via command <.rbf>
|
||||
Gotthard2 via command <.rbf>
|
||||
Moench via command <.pof>
|
||||
Ctb via command <.pof>
|
||||
|
||||
The following cannot be upgraded remotely:
|
||||
Gotthard
|
||||
|
||||
Instructions available at
|
||||
https://slsdetectorgroup.github.io/devdoc/firmware.html
|
||||
and
|
||||
https://slsdetectorgroup.github.io/devdoc/serverupgrade.html
|
||||
|
||||
|
||||
|
||||
4. Kernel Requirements
|
||||
======================
|
||||
|
||||
Note: No change to 6.1.1.
|
||||
|
||||
|
||||
Blackfin
|
||||
========
|
||||
Latest version: Fri Oct 29 00:00:00 2021
|
||||
|
||||
Older ones will work, but might have issues with programming firmware via
|
||||
the package.
|
||||
|
||||
Nios
|
||||
====
|
||||
Compatible version: Mon May 10 18:00:21 CEST 2021
|
||||
|
||||
Kernel Upgrade
|
||||
==============
|
||||
Eiger via bit files
|
||||
Others via command
|
||||
|
||||
Commands: udpatekernel, kernelversion
|
||||
Instructions available at
|
||||
https://slsdetectorgroup.github.io/devdoc/commandline.html
|
||||
https://slsdetectorgroup.github.io/devdoc/detector.html
|
||||
https://slsdetectorgroup.github.io/devdoc/pydetector.html
|
||||
|
||||
|
||||
|
||||
5. Download, Documentation & Support
|
||||
6. Download, Documentation & Support
|
||||
====================================
|
||||
|
||||
Download
|
||||
|
@ -7,9 +7,9 @@ function(enable_cxx_warning flag target)
|
||||
check_cxx_compiler_flag(${flag} ${flag_name})
|
||||
if(${flag_name})
|
||||
target_compile_options(${target} INTERFACE ${flag})
|
||||
message(STATUS "Adding: ${flag} to ${target}")
|
||||
message("Adding: ${flag} to ${target}")
|
||||
else()
|
||||
message(STATUS "Flag: ${flag} not supported")
|
||||
message("Flag: ${flag} not supported")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -18,9 +18,9 @@ function(enable_c_warning flag target)
|
||||
check_c_compiler_flag(${flag} ${flag_name})
|
||||
if(${flag_name})
|
||||
target_compile_options(${target} INTERFACE ${flag})
|
||||
message(STATUS "Adding: ${flag} to ${target}")
|
||||
message("Adding: ${flag} to ${target}")
|
||||
else()
|
||||
message(STATUS "Flag: ${flag} not supported")
|
||||
message("Flag: ${flag} not supported")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -31,10 +31,10 @@ function(disable_cxx_warning flag target)
|
||||
|
||||
if(${flag_name})
|
||||
string(REPLACE "-W" "-Wno-" neg_flag ${flag})
|
||||
message(STATUS "Adding: ${neg_flag} to ${target}")
|
||||
message("Adding: ${neg_flag} to ${target}")
|
||||
target_compile_options(${target} INTERFACE ${neg_flag})
|
||||
else()
|
||||
message(STATUS "Warning: ${flag} not supported no need to disable")
|
||||
message("Warning: ${flag} not supported no need to disable")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -43,10 +43,10 @@ function(disable_c_warning flag target)
|
||||
check_c_compiler_flag(${flag} ${flag_name})
|
||||
if(${flag_name})
|
||||
string(REPLACE "-W" "-Wno-" neg_flag ${flag})
|
||||
message(STATUS "Adding: ${neg_flag} to ${target}")
|
||||
message("Adding: ${neg_flag} to ${target}")
|
||||
target_compile_options(${target} INTERFACE ${neg_flag})
|
||||
else()
|
||||
message(STATUS "Warning: ${flag} not supported no need to disable")
|
||||
message("Warning: ${flag} not supported no need to disable")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
2
cmk.sh
2
cmk.sh
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#!/bin/bash
|
||||
CMAKE="cmake3"
|
||||
BUILDDIR="build"
|
||||
INSTALLDIR=""
|
||||
|
@ -21,4 +21,4 @@ echo "Building using: ${NCORES} cores"
|
||||
cmake --build . -- -j${NCORES}
|
||||
cmake --build . --target install
|
||||
|
||||
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 1
|
||||
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2
|
||||
|
@ -1,8 +1,8 @@
|
||||
python:
|
||||
- 3.6
|
||||
- 3.7
|
||||
- 3.8
|
||||
- 3.9
|
||||
- 3.10
|
||||
- 3.11
|
||||
|
||||
numpy:
|
||||
- 1.17
|
@ -61,6 +61,7 @@ set( HEADERS
|
||||
#set(ROOT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# ROOT dictionary generation
|
||||
include("${ROOT_DIR}/RootMacros.cmake")
|
||||
root_generate_dictionary(ctbDict ${HEADERS} LINKDEF ctbLinkDef.h)
|
||||
add_library(ctbRootLib SHARED ctbDict.cxx)
|
||||
target_include_directories(ctbRootLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@ -86,4 +87,3 @@ set_target_properties(ctbGui PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
|
||||
)
|
||||
|
||||
|
@ -305,18 +305,8 @@ Firmware Troubleshooting with blackfin
|
||||
|
||||
5. If one can't list it, read the next section to try to get the blackfin to list it.
|
||||
|
||||
How to get back mtd3 drive remotely (udpating kernel)
|
||||
How to get back mtd3 drive remotely (copying new kernel)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
You have 2 alternatives to update the kernel.
|
||||
|
||||
1. Commands via software (>= v6.0.0)
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sls_detector_put updatekernel /home/...path-to-kernel-image
|
||||
|
||||
|
||||
2. or command line
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
|
@ -247,19 +247,6 @@ Possible causes could be the following:
|
||||
* For Jungfrau, refer to :ref:`Jungfrau Power Supply Troubleshooting<Jungfrau Troubleshooting Power Supply>`.
|
||||
|
||||
|
||||
Cannot ping module (Nios)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If you executed "reboot" command on the board, you cannot ping it anymore unless you power cycle. To reboot the controller, please use the software command ("rebootcontroller"), which talks to the microcontroller.
|
||||
|
||||
Gotthard2
|
||||
---------
|
||||
|
||||
Cannot get data without a module attached
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You cannot get data without a module attached as a specific pin is floating. Attach module to get data.
|
||||
|
||||
|
||||
Gotthard
|
||||
----------
|
||||
|
5710
libs/catch/catch.hpp
5710
libs/catch/catch.hpp
File diff suppressed because it is too large
Load Diff
Submodule libs/pybind11 updated: 80dc998efc...8de7772cc7
@ -16,8 +16,8 @@ from parse import remove_comments
|
||||
allow_bitwise_op = ["M3_GainCaps"]
|
||||
allow_bitwise_op = ["streamingInterface"]
|
||||
|
||||
op_key = {"operator|": "|",
|
||||
"operator&" : "&"}
|
||||
op_key = {"operator|": "__or__",
|
||||
"operator&" : "__and__"}
|
||||
|
||||
def single_line_enum(line):
|
||||
sub = line[line.find('{')+1:line.find('}')]
|
||||
@ -92,7 +92,8 @@ def generate_enum_string(enums):
|
||||
|
||||
#Here add the operators
|
||||
for op in operators:
|
||||
data.append(f"\n\t.def(py::self {op_key[op]} slsDetectorDefs::{key}())")
|
||||
data.append(f"\n\t.def(\"{op_key[op]}\", py::overload_cast< const slsDetectorDefs::streamingInterface&, const slsDetectorDefs::streamingInterface&>(&{op}))")
|
||||
|
||||
|
||||
data.append(';\n\n')
|
||||
return ''.join(data)
|
||||
|
@ -224,19 +224,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
return ut.lhex(self.getDetectorServerVersion())
|
||||
|
||||
@property
|
||||
@element
|
||||
def kernelversion(self):
|
||||
"""
|
||||
Kernel version on the detector including time and date
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> d.kernelversion
|
||||
'#37 PREEMPT Thu Oct 13 14:51:04 CEST 2016'
|
||||
"""
|
||||
return self.getKernelVersion()
|
||||
|
||||
@property
|
||||
def clientversion(self):
|
||||
"""Client software version in format [YYMMDD]
|
||||
@ -1669,7 +1656,6 @@ class Detector(CppDetectorApi):
|
||||
'client': self.clientversion,
|
||||
'firmware': self.firmwareversion,
|
||||
'detectorserver': self.detectorserverversion,
|
||||
'kernel': self.kernelversion,
|
||||
'receiver': self.rx_version}
|
||||
|
||||
@property
|
||||
@ -2515,7 +2501,6 @@ class Detector(CppDetectorApi):
|
||||
-----
|
||||
|
||||
:getter: always returns in seconds. To get in datetime.delta, use getBurstPeriod
|
||||
:setter: Not Implemented
|
||||
|
||||
Example
|
||||
-----------
|
||||
@ -3437,7 +3422,7 @@ class Detector(CppDetectorApi):
|
||||
[Gotthard2][Mythen3] Frequency of clock in Hz.
|
||||
|
||||
Note
|
||||
----
|
||||
-----
|
||||
|
||||
:setter: Not implemented. Use clkdiv to set frequency
|
||||
|
||||
|
@ -67,10 +67,6 @@ void init_det(py::module &m) {
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getDetectorServerVersion,
|
||||
py::arg() = Positions{})
|
||||
.def("getKernelVersion",
|
||||
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getKernelVersion,
|
||||
py::arg() = Positions{})
|
||||
.def("getSerialNumber",
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getSerialNumber,
|
||||
@ -1521,14 +1517,6 @@ void init_det(py::module &m) {
|
||||
sls::Positions)) &
|
||||
Detector::copyDetectorServer,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("updateDetectorServer",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
Detector::updateDetectorServer,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("updateKernel",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
Detector::updateKernel,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("rebootController",
|
||||
(void (Detector::*)(sls::Positions)) & Detector::rebootController,
|
||||
py::arg() = Positions{})
|
||||
@ -1537,19 +1525,6 @@ void init_det(py::module &m) {
|
||||
const std::string &, sls::Positions)) &
|
||||
Detector::updateFirmwareAndServer,
|
||||
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("updateFirmwareAndServer",
|
||||
(void (Detector::*)(const std::string &, const std::string &,
|
||||
sls::Positions)) &
|
||||
Detector::updateFirmwareAndServer,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("getUpdateMode",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getUpdateMode,
|
||||
py::arg() = Positions{})
|
||||
.def("setUpdateMode",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setUpdateMode,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("readRegister",
|
||||
(Result<uint32_t>(Detector::*)(uint32_t, sls::Positions) const) &
|
||||
Detector::readRegister,
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* WARINING This file is auto generated any edits might be overwritten without
|
||||
* warning */
|
||||
/* WARINING This file is auto generated any edits might be overwritten without warning */
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
@ -43,19 +42,15 @@ void init_enums(py::module &m) {
|
||||
|
||||
py::enum_<slsDetectorDefs::frameDiscardPolicy>(Defs, "frameDiscardPolicy")
|
||||
.value("NO_DISCARD", slsDetectorDefs::frameDiscardPolicy::NO_DISCARD)
|
||||
.value("DISCARD_EMPTY_FRAMES",
|
||||
slsDetectorDefs::frameDiscardPolicy::DISCARD_EMPTY_FRAMES)
|
||||
.value("DISCARD_PARTIAL_FRAMES",
|
||||
slsDetectorDefs::frameDiscardPolicy::DISCARD_PARTIAL_FRAMES)
|
||||
.value("NUM_DISCARD_POLICIES",
|
||||
slsDetectorDefs::frameDiscardPolicy::NUM_DISCARD_POLICIES)
|
||||
.value("DISCARD_EMPTY_FRAMES", slsDetectorDefs::frameDiscardPolicy::DISCARD_EMPTY_FRAMES)
|
||||
.value("DISCARD_PARTIAL_FRAMES", slsDetectorDefs::frameDiscardPolicy::DISCARD_PARTIAL_FRAMES)
|
||||
.value("NUM_DISCARD_POLICIES", slsDetectorDefs::frameDiscardPolicy::NUM_DISCARD_POLICIES)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::fileFormat>(Defs, "fileFormat")
|
||||
.value("BINARY", slsDetectorDefs::fileFormat::BINARY)
|
||||
.value("HDF5", slsDetectorDefs::fileFormat::HDF5)
|
||||
.value("NUM_FILE_FORMATS",
|
||||
slsDetectorDefs::fileFormat::NUM_FILE_FORMATS)
|
||||
.value("NUM_FILE_FORMATS", slsDetectorDefs::fileFormat::NUM_FILE_FORMATS)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::dimension>(Defs, "dimension")
|
||||
@ -64,25 +59,19 @@ void init_enums(py::module &m) {
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::externalSignalFlag>(Defs, "externalSignalFlag")
|
||||
.value("TRIGGER_IN_RISING_EDGE",
|
||||
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_RISING_EDGE)
|
||||
.value("TRIGGER_IN_FALLING_EDGE",
|
||||
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_FALLING_EDGE)
|
||||
.value("INVERSION_ON",
|
||||
slsDetectorDefs::externalSignalFlag::INVERSION_ON)
|
||||
.value("INVERSION_OFF",
|
||||
slsDetectorDefs::externalSignalFlag::INVERSION_OFF)
|
||||
.value("TRIGGER_IN_RISING_EDGE", slsDetectorDefs::externalSignalFlag::TRIGGER_IN_RISING_EDGE)
|
||||
.value("TRIGGER_IN_FALLING_EDGE", slsDetectorDefs::externalSignalFlag::TRIGGER_IN_FALLING_EDGE)
|
||||
.value("INVERSION_ON", slsDetectorDefs::externalSignalFlag::INVERSION_ON)
|
||||
.value("INVERSION_OFF", slsDetectorDefs::externalSignalFlag::INVERSION_OFF)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::timingMode>(Defs, "timingMode")
|
||||
.value("AUTO_TIMING", slsDetectorDefs::timingMode::AUTO_TIMING)
|
||||
.value("TRIGGER_EXPOSURE",
|
||||
slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
|
||||
.value("TRIGGER_EXPOSURE", slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
|
||||
.value("GATED", slsDetectorDefs::timingMode::GATED)
|
||||
.value("BURST_TRIGGER", slsDetectorDefs::timingMode::BURST_TRIGGER)
|
||||
.value("TRIGGER_GATED", slsDetectorDefs::timingMode::TRIGGER_GATED)
|
||||
.value("NUM_TIMING_MODES",
|
||||
slsDetectorDefs::timingMode::NUM_TIMING_MODES)
|
||||
.value("NUM_TIMING_MODES", slsDetectorDefs::timingMode::NUM_TIMING_MODES)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::dacIndex>(Defs, "dacIndex")
|
||||
@ -170,16 +159,13 @@ void init_enums(py::module &m) {
|
||||
.value("HIGH_VOLTAGE", slsDetectorDefs::dacIndex::HIGH_VOLTAGE)
|
||||
.value("TEMPERATURE_ADC", slsDetectorDefs::dacIndex::TEMPERATURE_ADC)
|
||||
.value("TEMPERATURE_FPGA", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA)
|
||||
.value("TEMPERATURE_FPGAEXT",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGAEXT)
|
||||
.value("TEMPERATURE_FPGAEXT", slsDetectorDefs::dacIndex::TEMPERATURE_FPGAEXT)
|
||||
.value("TEMPERATURE_10GE", slsDetectorDefs::dacIndex::TEMPERATURE_10GE)
|
||||
.value("TEMPERATURE_DCDC", slsDetectorDefs::dacIndex::TEMPERATURE_DCDC)
|
||||
.value("TEMPERATURE_SODL", slsDetectorDefs::dacIndex::TEMPERATURE_SODL)
|
||||
.value("TEMPERATURE_SODR", slsDetectorDefs::dacIndex::TEMPERATURE_SODR)
|
||||
.value("TEMPERATURE_FPGA2",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA2)
|
||||
.value("TEMPERATURE_FPGA3",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA3)
|
||||
.value("TEMPERATURE_FPGA2", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA2)
|
||||
.value("TEMPERATURE_FPGA3", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA3)
|
||||
.value("TRIMBIT_SCAN", slsDetectorDefs::dacIndex::TRIMBIT_SCAN)
|
||||
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
|
||||
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
|
||||
@ -218,20 +204,15 @@ void init_enums(py::module &m) {
|
||||
.value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN)
|
||||
.value("G1_HIGHGAIN", slsDetectorDefs::detectorSettings::G1_HIGHGAIN)
|
||||
.value("G1_LOWGAIN", slsDetectorDefs::detectorSettings::G1_LOWGAIN)
|
||||
.value("G2_HIGHCAP_HIGHGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
|
||||
.value("G2_HIGHCAP_LOWGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
|
||||
.value("G2_LOWCAP_HIGHGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
|
||||
.value("G2_LOWCAP_LOWGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
|
||||
.value("G2_HIGHCAP_HIGHGAIN", slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
|
||||
.value("G2_HIGHCAP_LOWGAIN", slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
|
||||
.value("G2_LOWCAP_HIGHGAIN", slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
|
||||
.value("G2_LOWCAP_LOWGAIN", slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
|
||||
.value("G4_HIGHGAIN", slsDetectorDefs::detectorSettings::G4_HIGHGAIN)
|
||||
.value("G4_LOWGAIN", slsDetectorDefs::detectorSettings::G4_LOWGAIN)
|
||||
.value("GAIN0", slsDetectorDefs::detectorSettings::GAIN0)
|
||||
.value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED)
|
||||
.value("UNINITIALIZED",
|
||||
slsDetectorDefs::detectorSettings::UNINITIALIZED)
|
||||
.value("UNINITIALIZED", slsDetectorDefs::detectorSettings::UNINITIALIZED)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::clockIndex>(Defs, "clockIndex")
|
||||
@ -244,8 +225,7 @@ void init_enums(py::module &m) {
|
||||
py::enum_<slsDetectorDefs::readoutMode>(Defs, "readoutMode")
|
||||
.value("ANALOG_ONLY", slsDetectorDefs::readoutMode::ANALOG_ONLY)
|
||||
.value("DIGITAL_ONLY", slsDetectorDefs::readoutMode::DIGITAL_ONLY)
|
||||
.value("ANALOG_AND_DIGITAL",
|
||||
slsDetectorDefs::readoutMode::ANALOG_AND_DIGITAL)
|
||||
.value("ANALOG_AND_DIGITAL", slsDetectorDefs::readoutMode::ANALOG_AND_DIGITAL)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::speedLevel>(Defs, "speedLevel")
|
||||
@ -259,18 +239,14 @@ void init_enums(py::module &m) {
|
||||
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
|
||||
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
|
||||
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
|
||||
.value("CONTINUOUS_INTERNAL",
|
||||
slsDetectorDefs::burstMode::CONTINUOUS_INTERNAL)
|
||||
.value("CONTINUOUS_EXTERNAL",
|
||||
slsDetectorDefs::burstMode::CONTINUOUS_EXTERNAL)
|
||||
.value("CONTINUOUS_INTERNAL", slsDetectorDefs::burstMode::CONTINUOUS_INTERNAL)
|
||||
.value("CONTINUOUS_EXTERNAL", slsDetectorDefs::burstMode::CONTINUOUS_EXTERNAL)
|
||||
.value("NUM_BURST_MODES", slsDetectorDefs::burstMode::NUM_BURST_MODES)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::timingSourceType>(Defs, "timingSourceType")
|
||||
.value("TIMING_INTERNAL",
|
||||
slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
|
||||
.value("TIMING_EXTERNAL",
|
||||
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
|
||||
.value("TIMING_INTERNAL", slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
|
||||
.value("TIMING_EXTERNAL", slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::M3_GainCaps>(Defs, "M3_GainCaps")
|
||||
@ -289,17 +265,14 @@ void init_enums(py::module &m) {
|
||||
.value("BOTTOM", slsDetectorDefs::portPosition::BOTTOM)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::streamingInterface>(Defs, "streamingInterface",
|
||||
py::arithmetic())
|
||||
py::enum_<slsDetectorDefs::streamingInterface>(Defs, "streamingInterface", py::arithmetic())
|
||||
.value("NONE", slsDetectorDefs::streamingInterface::NONE)
|
||||
.value("LOW_LATENCY_LINK",
|
||||
slsDetectorDefs::streamingInterface::LOW_LATENCY_LINK)
|
||||
.value("ETHERNET_10GB",
|
||||
slsDetectorDefs::streamingInterface::ETHERNET_10GB)
|
||||
.value("LOW_LATENCY_LINK", slsDetectorDefs::streamingInterface::LOW_LATENCY_LINK)
|
||||
.value("ETHERNET_10GB", slsDetectorDefs::streamingInterface::ETHERNET_10GB)
|
||||
.value("ALL", slsDetectorDefs::streamingInterface::ALL)
|
||||
.export_values()
|
||||
.def(py::self | slsDetectorDefs::streamingInterface())
|
||||
.def(py::self & slsDetectorDefs::streamingInterface());
|
||||
.def("__or__", py::overload_cast<const slsDetectorDefs::streamingInterface &, const slsDetectorDefs::streamingInterface &>(&operator|))
|
||||
.def("__and__", py::overload_cast<const slsDetectorDefs::streamingInterface &, const slsDetectorDefs::streamingInterface &>(&operator&));
|
||||
|
||||
py::enum_<slsDetectorDefs::vetoAlgorithm>(Defs, "vetoAlgorithm")
|
||||
.value("ALG_HITS", slsDetectorDefs::vetoAlgorithm::ALG_HITS)
|
||||
|
@ -1,23 +0,0 @@
|
||||
from slsdet.enums import streamingInterface
|
||||
import pytest
|
||||
def test_streamingInterface_bitwise():
|
||||
"""Bitwise operations on streaming interfaces are allowed"""
|
||||
|
||||
sif_none = streamingInterface.NONE
|
||||
sif_low = streamingInterface.LOW_LATENCY_LINK
|
||||
sif_10g = streamingInterface.ETHERNET_10GB
|
||||
sif_all = streamingInterface.ALL
|
||||
|
||||
assert sif_low | sif_none == sif_low
|
||||
assert sif_10g | sif_none == sif_10g
|
||||
assert sif_low | sif_10g == sif_all
|
||||
assert sif_10g | sif_all == sif_all
|
||||
|
||||
assert sif_10g & sif_low == sif_none
|
||||
assert sif_low & sif_low == sif_low
|
||||
assert sif_all & sif_all == sif_all
|
||||
|
||||
def test_streamingInterface_bitwise_only_allowed_on_same_type():
|
||||
with pytest.raises(Exception):
|
||||
assert streamingInterface.LOW_LATENCY_LINK & 5 == 7
|
||||
|
1
serverBin/ctbDetectorServerv6.0.0
Symbolic link
1
serverBin/ctbDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.1.2
|
1
serverBin/eigerDetectorServerv6.0.0
Symbolic link
1
serverBin/eigerDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.2
|
1
serverBin/gotthard2DetectorServerv6.0.0
Symbolic link
1
serverBin/gotthard2DetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.1.0
|
1
serverBin/gotthardDetectorServerv6.0.0
Symbolic link
1
serverBin/gotthardDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.1.0
|
1
serverBin/jungfrauDetectorServerv6.0.0
Symbolic link
1
serverBin/jungfrauDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.1.2
|
1
serverBin/moenchDetectorServerv6.0.0
Symbolic link
1
serverBin/moenchDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.1.2
|
1
serverBin/mythen3DetectorServerv6.0.0
Symbolic link
1
serverBin/mythen3DetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.1.0
|
Binary file not shown.
Binary file not shown.
@ -39,7 +39,7 @@ foreach(exe ${MOENCH_EXECUTABLES})
|
||||
set_target_properties(${exe} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
if(SLS_LTO_AVAILABLE)
|
||||
set_property(TARGET ${exe} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
|
@ -110,7 +110,7 @@ target_link_libraries(slsDetectorGui PUBLIC
|
||||
set_target_properties(slsDetectorGui PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
if(SLS_LTO_AVAILABLE)
|
||||
set_property(TARGET slsDetectorGui PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
|
@ -17,7 +17,7 @@ add_executable(ctbDetectorServer_virtual
|
||||
../slsDetectorServer/src/INA226.c
|
||||
../slsDetectorServer/src/LTC2620.c
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programViaBlackfin.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../slsDetectorServer/src/loadPattern.c
|
||||
../../slsSupportLib/src/md5.c
|
||||
|
@ -16,7 +16,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programViaBlackfin.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c $(md5_dir)md5.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c $(md5_dir)md5.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
BIN
slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.0.0
Executable file
BIN
slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.0.0
Executable file
Binary file not shown.
Binary file not shown.
@ -97,14 +97,8 @@ void basictests() {
|
||||
return;
|
||||
#else
|
||||
|
||||
initError = defineGPIOpins(initErrorMessage);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
initError = resetFPGA(initErrorMessage);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
defineGPIOpins();
|
||||
resetFPGA();
|
||||
if (mapCSP0() == FAIL) {
|
||||
strcpy(initErrorMessage,
|
||||
"Could not map to memory. Dangerous to continue.\n");
|
||||
|
@ -715,7 +715,7 @@ int Feb_Control_ProcessingInProgress() {
|
||||
unsigned int regr = 0, regl = 0;
|
||||
// deactivated should return end of processing
|
||||
if (!Feb_Control_activated)
|
||||
return STATUS_IDLE;
|
||||
return IDLE;
|
||||
|
||||
if (!Feb_Interface_ReadRegister(Feb_Control_rightAddress, FEB_REG_STATUS,
|
||||
®r)) {
|
||||
@ -729,9 +729,8 @@ int Feb_Control_ProcessingInProgress() {
|
||||
"processing status\n"));
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
LOG(logDEBUG1, ("regl:0x%x regr:0x%x\n", regl, regr));
|
||||
// processing done
|
||||
if (regr & regl & FEB_REG_STATUS_ACQ_DONE_MSK) {
|
||||
if ((regr | regl) & FEB_REG_STATUS_ACQ_DONE_MSK) {
|
||||
return STATUS_IDLE;
|
||||
}
|
||||
// processing running
|
||||
@ -1047,7 +1046,6 @@ int Feb_Control_StopAcquisition() {
|
||||
// wait for feb processing to be done
|
||||
int is_processing = Feb_Control_ProcessingInProgress();
|
||||
int check_error = 0;
|
||||
int check_stuck = 0;
|
||||
while (is_processing != STATUS_IDLE) {
|
||||
usleep(500);
|
||||
is_processing = Feb_Control_ProcessingInProgress();
|
||||
@ -1059,28 +1057,12 @@ int Feb_Control_StopAcquisition() {
|
||||
break;
|
||||
check_error++;
|
||||
} // reset check_error for next time
|
||||
else {
|
||||
else
|
||||
check_error = 0;
|
||||
}
|
||||
|
||||
// check stuck only 2000 times (1s)
|
||||
if (is_processing == STATUS_RUNNING) {
|
||||
if (check_stuck == 2000) {
|
||||
LOG(logERROR, ("Unable to get feb processing done signal\n"));
|
||||
// at least it is idle
|
||||
if (Feb_Control_AcquisitionInProgress() == STATUS_IDLE) {
|
||||
return 1;
|
||||
}
|
||||
LOG(logERROR, ("Unable to get acquisition done signal\n"));
|
||||
return 0;
|
||||
}
|
||||
check_stuck++;
|
||||
} // reset check_stuck for next time
|
||||
else {
|
||||
check_stuck = 0;
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Feb: Processing done (to stop acq)\n"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1562,9 +1544,7 @@ int Feb_Control_SetChipSignalsToTrimQuad(int enable) {
|
||||
LOG(logINFO, ("%s chip signals to trim quad\n",
|
||||
enable ? "Enabling" : "Disabling"));
|
||||
unsigned int regval = 0;
|
||||
// right fpga only
|
||||
uint32_t righOffset = DAQ_REG_HRDWRE + Feb_Control_rightAddress;
|
||||
if (!Feb_Control_ReadRegister(righOffset, ®val)) {
|
||||
if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, ®val)) {
|
||||
LOG(logERROR, ("Could not set chip signals to trim quad\n"));
|
||||
return 0;
|
||||
}
|
||||
@ -1574,7 +1554,7 @@ int Feb_Control_SetChipSignalsToTrimQuad(int enable) {
|
||||
regval &= ~(DAQ_REG_HRDWRE_PROGRAM_MSK | DAQ_REG_HRDWRE_M8_MSK);
|
||||
}
|
||||
|
||||
return Feb_Control_WriteRegister(righOffset, regval);
|
||||
return Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1607,19 +1587,19 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
|
||||
|
||||
int run[2] = {0, 0};
|
||||
// both registers
|
||||
if (offset < Feb_Control_leftAddress) {
|
||||
if (offset < 0x100) {
|
||||
run[0] = 1;
|
||||
run[1] = 1;
|
||||
}
|
||||
// right registers only
|
||||
else if (offset >= Feb_Control_rightAddress) {
|
||||
else if (offset >= 0x200) {
|
||||
run[0] = 1;
|
||||
actualOffset = offset - Feb_Control_rightAddress;
|
||||
actualOffset = offset - 0x200;
|
||||
}
|
||||
// left registers only
|
||||
else {
|
||||
run[1] = 1;
|
||||
actualOffset = offset - Feb_Control_leftAddress;
|
||||
actualOffset = offset - 0x100;
|
||||
}
|
||||
|
||||
for (int iloop = 0; iloop < 2; ++iloop) {
|
||||
@ -1645,19 +1625,19 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
|
||||
uint32_t value[2] = {0, 0};
|
||||
int run[2] = {0, 0};
|
||||
// both registers
|
||||
if (offset < Feb_Control_leftAddress) {
|
||||
if (offset < 0x100) {
|
||||
run[0] = 1;
|
||||
run[1] = 1;
|
||||
}
|
||||
// right registers only
|
||||
else if (offset >= Feb_Control_rightAddress) {
|
||||
else if (offset >= 0x200) {
|
||||
run[0] = 1;
|
||||
actualOffset = offset - Feb_Control_rightAddress;
|
||||
actualOffset = offset - 0x200;
|
||||
}
|
||||
// left registers only
|
||||
else {
|
||||
run[1] = 1;
|
||||
actualOffset = offset - Feb_Control_leftAddress;
|
||||
actualOffset = offset - 0x100;
|
||||
}
|
||||
|
||||
for (int iloop = 0; iloop < 2; ++iloop) {
|
||||
@ -1678,11 +1658,11 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Inconsistent values when reading both registers
|
||||
if ((run[0] & run[1]) & (value[0] != value[1])) {
|
||||
// Inconsistent values
|
||||
if (value[0] != value[1]) {
|
||||
LOG(logERROR,
|
||||
("Inconsistent values read from %s 0x%x and %s 0x%x\n",
|
||||
side[0], value[0], side[1], value[1]));
|
||||
("Inconsistent values read from left 0x%x and right 0x%x\n",
|
||||
value[0], value[1]));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
BIN
slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.0.0
Executable file
BIN
slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.0.0
Executable file
Binary file not shown.
Binary file not shown.
@ -1158,8 +1158,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, set M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(1)) {
|
||||
sprintf(mess, "Could not set module. Could not enable chip signals to set trimbits\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1172,8 +1170,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, reset M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
|
||||
sprintf(mess, "Could not set module. Could not disable chip signals to set trimbits\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1183,8 +1179,6 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, reset M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
|
||||
sprintf(mess, "Could not set module. Could not disable chip signals to set trimbits\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -2217,44 +2211,43 @@ int setTransmissionDelayRight(int value) {
|
||||
|
||||
/* aquisition */
|
||||
|
||||
int startStateMachine() {
|
||||
sharedMemory_lockAcqFlag();
|
||||
int prepareAcquisition() {
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",
|
||||
Feb_Control_Get_Counter_Bit()));
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int startStateMachine() {
|
||||
#ifdef VIRTUAL
|
||||
// create udp socket
|
||||
if (createUDPSocket(0) != OK) {
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
if (createUDPSocket(1) != OK) {
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
sharedMemory_setStatus(IDLE);
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("Virtual Acquisition started\n"));
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return OK;
|
||||
#else
|
||||
sharedMemory_lockLocalLink();
|
||||
|
||||
LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",
|
||||
Feb_Control_Get_Counter_Bit()));
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
|
||||
|
||||
LOG(logINFO, ("Acquisition started bit toggled\n"));
|
||||
int ret = OK, prev_flag;
|
||||
// get the DAQ toggle bit
|
||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||
@ -2271,14 +2264,12 @@ int startStateMachine() {
|
||||
LOG(logERROR,
|
||||
("Acquisition did not LOG(logERROR ouble reading register\n"));
|
||||
sharedMemory_unlockLocalLink();
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
usleep(100 * 1000);
|
||||
LOG(logINFOGREEN, ("Acquisition started\n"));
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
sharedMemory_unlockAcqFlag();
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
@ -2511,10 +2502,6 @@ void *start_timer(void *arg) {
|
||||
#endif
|
||||
|
||||
int stopStateMachine() {
|
||||
|
||||
// acq lock for seamless stop
|
||||
sharedMemory_lockAcqFlag();
|
||||
|
||||
LOG(logINFORED, ("Stopping state machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
@ -2527,15 +2514,13 @@ int stopStateMachine() {
|
||||
usleep(500);
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return OK;
|
||||
#else
|
||||
sharedMemory_lockLocalLink();
|
||||
// sends last frames from fifo and wait for feb processing done
|
||||
if (!Feb_Control_StopAcquisition()) {
|
||||
if ((Feb_Control_StopAcquisition() != STATUS_IDLE)) {
|
||||
LOG(logERROR, ("failed to stop acquisition\n"));
|
||||
sharedMemory_unlockLocalLink();
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
@ -2546,7 +2531,6 @@ int stopStateMachine() {
|
||||
// wait for beb to send out all packets
|
||||
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 1) == FAIL) {
|
||||
LOG(logERROR, ("failed to stop beb acquisition\n"));
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
if (isTransmitting) {
|
||||
@ -2561,7 +2545,6 @@ int stopStateMachine() {
|
||||
sharedMemory_unlockLocalLink();
|
||||
if (!Beb_StopAcquisition()) {
|
||||
LOG(logERROR, ("failed to stop acquisition\n"));
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -2571,7 +2554,6 @@ int stopStateMachine() {
|
||||
Beb_SetNextFrameNumber(retval + 1);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Stopping state machine complete\n\n"));
|
||||
sharedMemory_unlockAcqFlag();
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
@ -2655,8 +2637,7 @@ void readFrame(int *ret, char *mess) {
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_WaitForFinishedFlag(5000, 1) == STATUS_ERROR) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
strcpy(mess, "Could not wait for finished flag\n");
|
||||
LOG(logERROR, (mess));
|
||||
LOG(logERROR, ("Waiting for finished flag\n"));
|
||||
*ret = FAIL;
|
||||
return;
|
||||
}
|
||||
@ -2672,7 +2653,6 @@ void readFrame(int *ret, char *mess) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
if (i == STATUS_ERROR) {
|
||||
strcpy(mess, "Could not read feb processing done register\n");
|
||||
LOG(logERROR, (mess));
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
@ -2684,7 +2664,6 @@ void readFrame(int *ret, char *mess) {
|
||||
// wait for beb to send out all packets
|
||||
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 1) == FAIL) {
|
||||
strcpy(mess, "Could not read delay counters\n");
|
||||
LOG(logERROR, (mess));
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
@ -2720,6 +2699,9 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
LOG(logDEBUG1, ("DACs: src %d, dest %d\n", srcMod->ndac, destMod->ndac));
|
||||
LOG(logDEBUG1, ("Chans: src %d, dest %d\n", srcMod->nchan, destMod->nchan));
|
||||
destMod->ndac = srcMod->ndac;
|
||||
destMod->nchip = srcMod->nchip;
|
||||
destMod->nchan = srcMod->nchan;
|
||||
if (srcMod->reg >= 0)
|
||||
destMod->reg = srcMod->reg;
|
||||
if (srcMod->iodelay >= 0)
|
||||
@ -2730,7 +2712,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
destMod->eV[0] = srcMod->eV[0];
|
||||
LOG(logDEBUG1, ("Copying register %x (%x)\n", destMod->reg, srcMod->reg));
|
||||
|
||||
if (destMod->nchan != 0 && srcMod->nchan != 0) {
|
||||
if (destMod->nchan != 0) {
|
||||
for (int ichan = 0; ichan < (srcMod->nchan); ichan++) {
|
||||
if (*((srcMod->chanregs) + ichan) >= 0)
|
||||
*((destMod->chanregs) + ichan) = *((srcMod->chanregs) + ichan);
|
||||
|
@ -12,7 +12,7 @@ add_executable(gotthard2DetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620_Driver.c
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/ASIC_Driver.c
|
||||
../slsDetectorServer/src/programViaNios.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../../slsSupportLib/src/md5.c
|
||||
)
|
||||
|
@ -15,7 +15,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c $(main_src)/programViaNios.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c $(main_src)/programFpgaNios.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
BIN
slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.0.0
Executable file
BIN
slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.0.0
Executable file
Binary file not shown.
Binary file not shown.
@ -101,7 +101,7 @@ void basictests() {
|
||||
}
|
||||
// does check only if flag is 0 (by default), set by command line
|
||||
if ((!debugflag) && (!updateFlag) &&
|
||||
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || (checkType() == FAIL) ||
|
||||
((checkKernelVersion() == FAIL) || (checkType() == FAIL) ||
|
||||
(testFpga() == FAIL) || (testBus() == FAIL))) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not pass basic tests of FPGA and bus. Dangerous to "
|
||||
@ -184,6 +184,13 @@ void basictests() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int checkKernelVersion() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
return Nios_checkKernelVersion(KERNEL_DATE_VRSN);
|
||||
}
|
||||
|
||||
int checkType() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
@ -2083,40 +2090,24 @@ int setReadoutSpeed(int val) {
|
||||
case G2_108MHZ:
|
||||
LOG(logINFOBLUE, ("Setting readout speed to 108 MHz\n"));
|
||||
if (setClockDivider(READOUT_C0, SPEED_108_CLKDIV_0) == FAIL) {
|
||||
LOG(logERROR, ("Could not set readout speed to 108 MHz. Failed to set readout clk 0 to %d\n", SPEED_108_CLKDIV_0));
|
||||
return FAIL;
|
||||
}
|
||||
if (setClockDivider(READOUT_C1, SPEED_108_CLKDIV_1) == FAIL) {
|
||||
LOG(logERROR, ("Could not set readout speed to 108 MHz. Failed to set readout clk 1 to %d\n", SPEED_108_CLKDIV_1));
|
||||
return FAIL;
|
||||
}
|
||||
if (setPhase(READOUT_C1, SPEED_108_CLKPHASE_DEG_1, 1) == FAIL) {
|
||||
LOG(logERROR, ("Could not set readout speed to 108 MHz. Failed to set clk phase 1 %d deg\n", SPEED_108_CLKPHASE_DEG_1));
|
||||
return FAIL;
|
||||
}
|
||||
setDBITPipeline(SPEED_144_DBIT_PIPELINE);
|
||||
if (getDBITPipeline() != SPEED_144_DBIT_PIPELINE) {
|
||||
LOG(logERROR, ("Could not set readout speed to 108 MHz. Failed to set dbitpipeline to %d \n", SPEED_144_DBIT_PIPELINE));
|
||||
return FAIL;
|
||||
}
|
||||
break;
|
||||
case G2_144MHZ:
|
||||
LOG(logINFOBLUE, ("Setting readout speed to 144 MHz\n"));
|
||||
if (setClockDivider(READOUT_C0, SPEED_144_CLKDIV_0) == FAIL) {
|
||||
LOG(logERROR, ("Could not set readout speed to 144 MHz. Failed to set readout clk 0 to %d\n", SPEED_144_CLKDIV_0));
|
||||
return FAIL;
|
||||
}
|
||||
if (setClockDivider(READOUT_C1, SPEED_144_CLKDIV_1) == FAIL) {
|
||||
LOG(logERROR, ("Could not set readout speed to 144 MHz. Failed to set readout clk 1 to %d\n", SPEED_144_CLKDIV_1));
|
||||
return FAIL;
|
||||
}
|
||||
if (setPhase(READOUT_C1, SPEED_144_CLKPHASE_DEG_1, 1) == FAIL) {
|
||||
LOG(logERROR, ("Could not set readout speed to 144 MHz. Failed to set clk phase 1 %d deg\n", SPEED_144_CLKPHASE_DEG_1));
|
||||
return FAIL;
|
||||
}
|
||||
setDBITPipeline(SPEED_144_DBIT_PIPELINE);
|
||||
if (getDBITPipeline() != SPEED_144_DBIT_PIPELINE) {
|
||||
LOG(logERROR, ("Could not set readout speed to 144 MHz. Failed to set dbitpipeline to %d \n", SPEED_144_DBIT_PIPELINE));
|
||||
return FAIL;
|
||||
}
|
||||
break;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#define REQRD_FRMWRE_VRSN (0x210527)
|
||||
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
|
||||
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
|
||||
#define ID_FILE "detid_gotthard2.txt"
|
||||
|
||||
#define LINKED_SERVER_NAME "gotthard2DetectorServer"
|
||||
@ -67,11 +67,9 @@
|
||||
#define SPEED_144_CLKDIV_0 (6)
|
||||
#define SPEED_144_CLKDIV_1 (6)
|
||||
#define SPEED_144_CLKPHASE_DEG_1 (122) // 125 not possible
|
||||
#define SPEED_144_DBIT_PIPELINE (1)
|
||||
#define SPEED_108_CLKDIV_0 (8)
|
||||
#define SPEED_108_CLKDIV_1 (8)
|
||||
#define SPEED_108_CLKPHASE_DEG_1 (268) // 270 not possible
|
||||
#define SPEED_108_DBIT_PIPELINE (1)
|
||||
|
||||
/* Firmware Definitions */
|
||||
#define FIXED_PLL_FREQUENCY (20000000) // 20MHz
|
||||
|
@ -11,7 +11,6 @@ add_executable(gotthardDetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620.c
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/commonServerFunctions.c
|
||||
../slsDetectorServer/src/programViaBlackfin.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../../slsSupportLib/src/md5.c
|
||||
|
@ -15,7 +15,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)AD9252.c $(main_src)AD9257.c $(main_src)LTC2620.c $(main_src)programViaBlackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)AD9252.c $(main_src)AD9257.c $(main_src)LTC2620.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
all: clean $(PROGS)
|
||||
|
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.0.0
Executable file
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.0.0
Executable file
Binary file not shown.
Binary file not shown.
@ -6,8 +6,6 @@
|
||||
|
||||
#define LINKED_SERVER_NAME "gotthardDetectorServer"
|
||||
|
||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||
|
||||
/* Enums */
|
||||
enum ADCINDEX { TEMP_FPGA, TEMP_ADC };
|
||||
enum DACINDEX {
|
||||
|
@ -12,7 +12,7 @@ add_executable(jungfrauDetectorServer_virtual
|
||||
../slsDetectorServer/src/ALTERA_PLL.c
|
||||
../slsDetectorServer/src/LTC2620.c
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programViaBlackfin.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../../slsSupportLib/src/md5.c
|
||||
|
@ -15,7 +15,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programViaBlackfin.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
BIN
slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.0.0
Executable file
BIN
slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.0.0
Executable file
Binary file not shown.
Binary file not shown.
@ -74,14 +74,8 @@ void basictests() {
|
||||
}
|
||||
return;
|
||||
#else
|
||||
initError = defineGPIOpins(initErrorMessage);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
initError = resetFPGA(initErrorMessage);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
defineGPIOpins();
|
||||
resetFPGA();
|
||||
if (mapCSP0() == FAIL) {
|
||||
strcpy(initErrorMessage,
|
||||
"Could not map to memory. Dangerous to continue.\n");
|
||||
@ -501,14 +495,12 @@ void setupDetector() {
|
||||
// temp threshold and reset event
|
||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||
setTemperatureEvent(0);
|
||||
setFlipRows(DEFAULT_FLIP_ROWS);
|
||||
if (getChipVersion() == 11) {
|
||||
setFilterResistor(DEFAULT_FILTER_RESISTOR);
|
||||
setNumberOfFilterCells(DEFAULT_FILTER_CELL);
|
||||
}
|
||||
if (!isHardwareVersion2()) {
|
||||
setFlipRows(DEFAULT_FLIP_ROWS);
|
||||
setReadNRows(MAX_ROWS_PER_READOUT);
|
||||
}
|
||||
}
|
||||
|
||||
int resetToDefaultDacs(int hardReset) {
|
||||
@ -1673,11 +1665,6 @@ int setReadNRows(int value) {
|
||||
LOG(logERROR, ("Invalid number of rows %d\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
if (isHardwareVersion2()) {
|
||||
LOG(logERROR, ("Could not set number of rows. Only available for "
|
||||
"Hardware Board version 2.0.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// regval is numpackets - 1
|
||||
int regval = (value / READ_N_ROWS_MULTIPLE) - 1;
|
||||
@ -1686,6 +1673,7 @@ int setReadNRows(int value) {
|
||||
bus_w(addr, bus_r(addr) & ~READ_N_ROWS_NUM_ROWS_MSK);
|
||||
bus_w(addr, bus_r(addr) | ((regval << READ_N_ROWS_NUM_ROWS_OFST) &
|
||||
READ_N_ROWS_NUM_ROWS_MSK));
|
||||
|
||||
if (value == MAX_ROWS_PER_READOUT) {
|
||||
LOG(logINFO, ("Disabling Partial Readout (#rows)\n"));
|
||||
bus_w(addr, bus_r(addr) & ~READ_N_ROWS_ENBL_MSK);
|
||||
@ -1697,10 +1685,6 @@ int setReadNRows(int value) {
|
||||
}
|
||||
|
||||
int getReadNRows() {
|
||||
// cannot set it in old board
|
||||
if (isHardwareVersion2()) {
|
||||
return MAX_ROWS_PER_READOUT;
|
||||
}
|
||||
int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK);
|
||||
int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >>
|
||||
READ_N_ROWS_NUM_ROWS_OFST);
|
||||
@ -2173,11 +2157,6 @@ int getFlipRows() {
|
||||
}
|
||||
|
||||
void setFlipRows(int arg) {
|
||||
if (isHardwareVersion2()) {
|
||||
LOG(logERROR, ("Could not set flip rows. Only available for "
|
||||
"Hardware Board version 2.0.\n"));
|
||||
return;
|
||||
}
|
||||
if (arg >= 0) {
|
||||
if (arg == 0) {
|
||||
LOG(logINFO, ("Switching off bottom row flipping\n"));
|
||||
@ -2646,7 +2625,6 @@ int stopStateMachine() {
|
||||
|
||||
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
|
||||
usleep(100 * 1000);
|
||||
resetCore();
|
||||
return OK;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ add_executable(moenchDetectorServer_virtual
|
||||
../slsDetectorServer/src/ALTERA_PLL.c
|
||||
../slsDetectorServer/src/LTC2620.c
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programViaBlackfin.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/loadPattern.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../../slsSupportLib/src/md5.c
|
||||
|
@ -16,7 +16,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programViaBlackfin.c $(main_src)loadPattern.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)loadPattern.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
BIN
slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.0.0
Executable file
BIN
slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.0.0
Executable file
Binary file not shown.
Binary file not shown.
@ -94,14 +94,8 @@ void basictests() {
|
||||
return;
|
||||
#else
|
||||
|
||||
initError = defineGPIOpins(initErrorMessage);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
initError = resetFPGA(initErrorMessage);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
defineGPIOpins();
|
||||
resetFPGA();
|
||||
if (mapCSP0() == FAIL) {
|
||||
strcpy(initErrorMessage,
|
||||
"Could not map to memory. Dangerous to continue.\n");
|
||||
|
@ -12,7 +12,7 @@ add_executable(mythen3DetectorServer_virtual
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/LTC2620_Driver.c
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/programViaNios.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/loadPattern.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../../slsSupportLib/src/md5.c
|
||||
|
@ -16,7 +16,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programViaNios.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c mythen3.c $(md5_dir)md5.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programFpgaNios.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c mythen3.c $(md5_dir)md5.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
BIN
slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.0.0
Executable file
BIN
slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.0.0
Executable file
Binary file not shown.
Binary file not shown.
@ -96,9 +96,8 @@ void basictests() {
|
||||
}
|
||||
// does check only if flag is 0 (by default), set by command line
|
||||
if ((!debugflag) && (!updateFlag) &&
|
||||
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) ||
|
||||
(checkType() == FAIL) || (testFpga() == FAIL) ||
|
||||
(testBus() == FAIL))) {
|
||||
((checkKernelVersion() == FAIL) || (checkType() == FAIL) ||
|
||||
(testFpga() == FAIL) || (testBus() == FAIL))) {
|
||||
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
|
||||
"Dangerous to continue.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
@ -178,6 +177,13 @@ void basictests() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int checkKernelVersion() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
return Nios_checkKernelVersion(KERNEL_DATE_VRSN);
|
||||
}
|
||||
|
||||
int checkType() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
@ -2488,6 +2494,9 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
LOG(logDEBUG1, ("DACs: src %d, dest %d\n", srcMod->ndac, destMod->ndac));
|
||||
LOG(logDEBUG1, ("Chans: src %d, dest %d\n", srcMod->nchan, destMod->nchan));
|
||||
destMod->ndac = srcMod->ndac;
|
||||
destMod->nchip = srcMod->nchip;
|
||||
destMod->nchan = srcMod->nchan;
|
||||
if (srcMod->reg >= 0)
|
||||
destMod->reg = srcMod->reg;
|
||||
/*
|
||||
@ -2503,7 +2512,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
LOG(logDEBUG1, ("Copying register %x (%x)\n", destMod->reg, srcMod->reg));
|
||||
|
||||
if (destMod->nchan != 0 && srcMod->nchan != 0) {
|
||||
if (destMod->nchan != 0) {
|
||||
for (int ichan = 0; ichan < (srcMod->nchan); ichan++) {
|
||||
*((destMod->chanregs) + ichan) = *((srcMod->chanregs) + ichan);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#define REQRD_FRMWRE_VRSN (0x210910)
|
||||
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
|
||||
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
|
||||
#define ID_FILE "detid_mythen3.txt"
|
||||
|
||||
#define LINKED_SERVER_NAME "mythen3DetectorServer"
|
||||
|
@ -8,18 +8,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#define UPDATE_FILE "update.txt"
|
||||
#ifdef VIRTUAL
|
||||
#define TEMP_PROG_FOLDER_NAME "/tmp/"
|
||||
#else
|
||||
#define TEMP_PROG_FOLDER_NAME "/var/tmp/"
|
||||
#define TEMP_PROG_FOLDER_NAME_ALL_FILES "/var/tmp/*"
|
||||
#endif
|
||||
|
||||
#define TEMP_PROG_FILE_NAME TEMP_PROG_FOLDER_NAME "tmp.rawbin"
|
||||
|
||||
enum numberMode { DEC, HEX };
|
||||
enum PROGRAM_INDEX { PROGRAM_FPGA, PROGRAM_KERNEL, PROGRAM_SERVER };
|
||||
|
||||
/**
|
||||
* Convert a value from a range to a different range (eg voltage to dac or vice
|
||||
@ -37,11 +26,7 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||
|
||||
int getAbsPath(char *buf, size_t bufSize, char *fname);
|
||||
|
||||
int getTimeFromString(char *buf, time_t *result);
|
||||
|
||||
int getKernelVersion(char *retvals);
|
||||
|
||||
int validateKernelVersion(char *expectedVersion);
|
||||
int GetTimeFromString(char *buf, time_t *result);
|
||||
|
||||
void validate(int *ret, char *mess, int arg, int retval, char *modename,
|
||||
enum numberMode nummode);
|
||||
@ -49,20 +34,9 @@ void validate64(int *ret, char *mess, int64_t arg, int64_t retval,
|
||||
char *modename, enum numberMode nummode);
|
||||
|
||||
int getModuleIdInFile(int *ret, char *mess, char *fileName);
|
||||
int verifyChecksumFromBuffer(char *mess, char *functionType,
|
||||
char *clientChecksum, char *buffer, ssize_t bytes);
|
||||
int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum,
|
||||
char *fname);
|
||||
int verifyChecksumFromFlash(char *mess, char *functionType,
|
||||
char *clientChecksum, char *fname, ssize_t fsize);
|
||||
int verifyChecksum(char *mess, char *functionType, char *clientChecksum,
|
||||
MD5_CTX *c, char *msg);
|
||||
int setupDetectorServer(char *mess, char *sname);
|
||||
|
||||
int writeBinaryFile(char *mess, char *fname, char *buffer,
|
||||
const uint64_t filesize, char *errorPrefix);
|
||||
|
||||
int moveBinaryFile(char *mess, char *dest, char *src, char *errorPrefix);
|
||||
|
||||
int createEmptyFile(char *mess, char *fname, char *errorPrefix);
|
||||
int deleteFile(char *mess, char *fname, char *errorPrefix);
|
||||
int verifyChecksumFromBuffer(char *mess, char *clientChecksum, char *buffer,
|
||||
ssize_t bytes);
|
||||
int verifyChecksumFromFile(char *mess, char *clientChecksum, char *fname);
|
||||
int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
||||
ssize_t fsize);
|
||||
int verifyChecksum(char *mess, char *clientChecksum, MD5_CTX *c, char *msg);
|
@ -89,3 +89,7 @@ int mapCSP0(void);
|
||||
* Get Nios base address
|
||||
*/
|
||||
u_int32_t *Nios_getBaseAddress();
|
||||
|
||||
/** check kernel version against expected version string (complain if too old)
|
||||
* @returns OK or FAIL */
|
||||
int Nios_checkKernelVersion(char *expectedVersion);
|
@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define TEMP_PROG_FILE_NAME "/var/tmp/tmp.rawbin"
|
||||
|
||||
void defineGPIOpins();
|
||||
void FPGAdontTouchFlash();
|
||||
void FPGATouchFlash();
|
||||
void resetFPGA();
|
||||
|
||||
int deleteOldFile(char *mess);
|
||||
/**
|
||||
* deletes old file
|
||||
* verify memory available to copy
|
||||
* open file to copy
|
||||
*/
|
||||
int preparetoCopyFPGAProgram(FILE **fd, uint64_t fsize, char *mess);
|
||||
int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess);
|
||||
int getDrive(char *mess);
|
||||
/** Notify fpga not to touch flash, open src and flash drive to write */
|
||||
int openFileForFlash(FILE **flashfd, FILE **srcfd, char *mess);
|
||||
int eraseFlash(char *mess);
|
||||
/* write from tmp file to flash */
|
||||
int writeToFlash(ssize_t fsize, FILE *flashfd, FILE *srcfd, char *mess);
|
||||
/** Notify fpga to pick up firmware from flash and wait for status confirmation
|
||||
*/
|
||||
int waitForFPGAtoTouchFlash(char *mess);
|
@ -2,8 +2,6 @@
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -15,10 +13,9 @@ void NotifyServerStartSuccess();
|
||||
/** reset fpga and controller(only implemented for >= v1.1 boards) */
|
||||
void rebootControllerAndFPGA();
|
||||
|
||||
int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
char *functionType, char *checksum, char *fpgasrc,
|
||||
int eraseAndWriteToFlash(char *mess, char *checksum, char *fpgasrc,
|
||||
uint64_t fsize);
|
||||
int getDrive(char *mess, enum PROGRAM_INDEX index);
|
||||
int openFileForFlash(char *mess, FILE **flashfd);
|
||||
int getDrive(char *mess);
|
||||
int openFileForFlash(FILE **flashfd, char *mess);
|
||||
int eraseFlash(char *mess);
|
||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, char *buffer);
|
||||
int writeToFlash(ssize_t fsize, FILE *flashfd, char *buffer, char *mess);
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define BLACKFIN_DEFINED
|
||||
|
||||
int defineGPIOpins(char *mess);
|
||||
int FPGAdontTouchFlash(char *mess, int programming);
|
||||
int FPGATouchFlash(char *mess, int programming);
|
||||
int resetFPGA(char *mess);
|
||||
|
||||
int emptyTempFolder(char *mess);
|
||||
/**
|
||||
* deletes old file
|
||||
* verify memory available to copy
|
||||
* open file to copy
|
||||
*/
|
||||
int preparetoCopyProgram(char *mess, char *functionType, FILE **fd,
|
||||
uint64_t fsize);
|
||||
int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
char *functionType, char *clientChecksum,
|
||||
ssize_t fsize);
|
||||
int getDrive(char *mess, enum PROGRAM_INDEX index);
|
||||
/** Notify fpga not to touch flash, open src and flash drive to write */
|
||||
int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd);
|
||||
int eraseFlash(char *mess);
|
||||
/* write from tmp file to flash */
|
||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd);
|
||||
/** Notify fpga to pick up firmware from flash and wait for status confirmation
|
||||
*/
|
||||
int waitForFPGAtoTouchFlash(char *mess);
|
@ -25,6 +25,4 @@ int sharedMemory_getScanStop();
|
||||
#ifdef EIGERD
|
||||
void sharedMemory_lockLocalLink();
|
||||
void sharedMemory_unlockLocalLink();
|
||||
void sharedMemory_lockAcqFlag();
|
||||
void sharedMemory_unlockAcqFlag();
|
||||
#endif
|
@ -12,10 +12,9 @@
|
||||
#endif
|
||||
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
#include "programViaNios.h"
|
||||
#elif defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
|
||||
defined(GOTTHARDD)
|
||||
#include "programViaBlackfin.h"
|
||||
#include "programFpgaNios.h"
|
||||
#elif defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
|
||||
#include "programFpgaBlackfin.h"
|
||||
#endif
|
||||
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
@ -61,6 +60,9 @@ typedef struct udpStruct_s {
|
||||
int isInitCheckDone();
|
||||
int getInitResult(char **mess);
|
||||
void basictests();
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
int checkKernelVersion();
|
||||
#endif
|
||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
|
||||
defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
int checkType();
|
||||
@ -600,6 +602,9 @@ int setTransmissionDelayRight(int value);
|
||||
#endif
|
||||
|
||||
// aquisition
|
||||
#ifdef EIGERD
|
||||
int prepareAcquisition();
|
||||
#endif
|
||||
int startStateMachine();
|
||||
#ifdef VIRTUAL
|
||||
void *start_timer(void *arg);
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define REBOOT (-400)
|
||||
|
||||
// initialization functions
|
||||
int updateModeAllowedFunction(int file_des);
|
||||
int printSocketReadError();
|
||||
void init_detector();
|
||||
int decode_function(int);
|
||||
@ -278,15 +277,3 @@ int get_udp_first_dest(int);
|
||||
int set_udp_first_dest(int);
|
||||
int get_readout_speed(int);
|
||||
int set_readout_speed(int);
|
||||
int get_kernel_version(int);
|
||||
int update_kernel(int);
|
||||
int update_detector_server(int);
|
||||
int receive_program(int file_des, enum PROGRAM_INDEX index);
|
||||
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName);
|
||||
void receive_program_default(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName);
|
||||
int get_update_mode(int);
|
||||
int set_update_mode(int);
|
@ -3,7 +3,6 @@
|
||||
#include "blackfin.h"
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sls/ansi.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
|
@ -4,15 +4,11 @@
|
||||
#include "common.h"
|
||||
#include "clogger.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <libgen.h> // dirname
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h> // uname
|
||||
#include <unistd.h> // readlink
|
||||
|
||||
extern int executeCommand(char *command, char *result, enum TLogLevel level);
|
||||
|
||||
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||
int outputMax, int inputValue, int *outputValue) {
|
||||
LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
|
||||
@ -68,105 +64,15 @@ int getAbsPath(char *buf, size_t bufSize, char *fname) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getTimeFromString(char *buf, time_t *result) {
|
||||
char buffer[255] = {0};
|
||||
strcpy(buffer, buf);
|
||||
// remove timezone as strptime cannot validate timezone despite
|
||||
// documentation (for blackfin)
|
||||
LOG(logDEBUG, ("kernel v %s\n", buffer));
|
||||
const char *timezone = {"CEST"};
|
||||
char *res = strstr(buffer, timezone);
|
||||
if (res != NULL) {
|
||||
size_t cestPos = res - buffer;
|
||||
size_t pos = cestPos + strlen(timezone) + 1;
|
||||
while (pos != strlen(buffer)) {
|
||||
buffer[cestPos] = buffer[pos];
|
||||
++cestPos;
|
||||
++pos;
|
||||
}
|
||||
buffer[cestPos] = '\0';
|
||||
}
|
||||
LOG(logDEBUG, ("kernel v after removing CEST %s\n", buffer));
|
||||
|
||||
// convert to time structure
|
||||
int GetTimeFromString(char *buf, time_t *result) {
|
||||
struct tm t;
|
||||
if (NULL == strptime(buffer, "%a %b %d %H:%M:%S %Y", &t)) {
|
||||
if (NULL == strptime(buf, "%a %b %d %H:%M:%S %Z %Y", &t)) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// print time structure
|
||||
LOG(logDEBUG,
|
||||
("%d %d %d %d:%d:%d %d (day date month H:M:S year)\n", t.tm_wday,
|
||||
t.tm_mday, t.tm_mon, t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec));
|
||||
|
||||
*result = mktime(&t);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getKernelVersion(char *retvals) {
|
||||
struct utsname buf;
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
if (uname(&buf) == -1) {
|
||||
strcpy(retvals, "Failed to get utsname structure from uname\n");
|
||||
LOG(logERROR, (retvals));
|
||||
return FAIL;
|
||||
}
|
||||
strcpy(retvals, buf.version);
|
||||
LOG(logINFOBLUE, ("Kernel Version: %s\n", retvals));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int validateKernelVersion(char *expectedVersion) {
|
||||
// extract kernel date string
|
||||
char version[255] = {0};
|
||||
if (getKernelVersion(version) == FAIL) {
|
||||
LOG(logERROR, ("Could not validate kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG, ("utsname.version:%s\n", version));
|
||||
|
||||
char currentVersion[255] = {0};
|
||||
#ifdef VIRTUAL
|
||||
strcpy(currentVersion, expectedVersion);
|
||||
#else
|
||||
// remove first word (#version number)
|
||||
const char *ptr = strchr(version, ' ');
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
strcpy(currentVersion, version + (ptr - version + 1));
|
||||
#endif
|
||||
|
||||
// convert kernel date string into time
|
||||
time_t kernelDate;
|
||||
if (getTimeFromString(currentVersion, &kernelDate) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not parse retrieved kernel date, %s\n", currentVersion));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// convert expected date into time
|
||||
time_t expDate;
|
||||
if (getTimeFromString(expectedVersion, &expDate) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// compare if kernel time is older than expected time
|
||||
if (kernelDate < expDate) {
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
||||
"Got [%s]\n",
|
||||
expectedVersion, currentVersion));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n",
|
||||
currentVersion, expectedVersion));
|
||||
return OK;
|
||||
}
|
||||
|
||||
void validate(int *ret, char *mess, int arg, int retval, char *modename,
|
||||
enum numberMode nummode) {
|
||||
if (*ret == OK && arg != GET_FLAG && retval != arg) {
|
||||
@ -242,39 +148,30 @@ int getModuleIdInFile(int *ret, char *mess, char *fileName) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int verifyChecksumFromBuffer(char *mess, char *functionType,
|
||||
char *clientChecksum, char *buffer,
|
||||
int verifyChecksumFromBuffer(char *mess, char *clientChecksum, char *buffer,
|
||||
ssize_t bytes) {
|
||||
LOG(logINFO, ("\tVerifying Checksum from memory...\n"));
|
||||
LOG(logINFO, ("\tVerifying Checksum...\n"));
|
||||
MD5_CTX c;
|
||||
if (!MD5_Init_SLS(&c)) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to calculate checksum (MD5_Init_SLS)\n",
|
||||
functionType);
|
||||
strcpy(mess, "Unable to calculate checksum (MD5_Init_SLS)\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (!MD5_Update_SLS(&c, buffer, bytes)) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to calculate checksum (MD5_Update_SLS)\n",
|
||||
functionType);
|
||||
strcpy(mess, "Unable to calculate checksum (MD5_Update_SLS)\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
return verifyChecksum(mess, functionType, clientChecksum, &c,
|
||||
"copied program (buffer)");
|
||||
return verifyChecksum(mess, clientChecksum, &c, "copied program");
|
||||
}
|
||||
|
||||
int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum,
|
||||
char *fname) {
|
||||
LOG(logINFO, ("\tVerifying Checksum of file...\n"));
|
||||
int verifyChecksumFromFile(char *mess, char *clientChecksum, char *fname) {
|
||||
LOG(logINFO, ("\tVerifying Checksum...\n"));
|
||||
|
||||
FILE *fp = fopen(fname, "r");
|
||||
if (fp == NULL) {
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not %s. Unable to open %s in read mode to get checksum\n",
|
||||
functionType, fname);
|
||||
sprintf(mess, "Unable to open %s in read mode to get checksum\n",
|
||||
fname);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -282,9 +179,7 @@ int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum,
|
||||
MD5_CTX c;
|
||||
if (!MD5_Init_SLS(&c)) {
|
||||
fclose(fp);
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to calculate checksum (MD5_Init_SLS)\n",
|
||||
functionType);
|
||||
strcpy(mess, "Unable to calculate checksum (MD5_Init_SLS)\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -295,10 +190,7 @@ int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum,
|
||||
while (bytes > 0) {
|
||||
if (!MD5_Update_SLS(&c, buf, bytes)) {
|
||||
fclose(fp);
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not %s. Unable to calculate checksum (MD5_Update_SLS)\n",
|
||||
functionType);
|
||||
strcpy(mess, "Unable to calculate checksum (MD5_Update_SLS)\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -307,20 +199,17 @@ int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum,
|
||||
}
|
||||
LOG(logINFO, ("\tRead %lu bytes to calculate checksum\n", totalBytesRead));
|
||||
fclose(fp);
|
||||
return verifyChecksum(mess, functionType, clientChecksum, &c,
|
||||
"copied program (file)");
|
||||
return verifyChecksum(mess, clientChecksum, &c, "copied program");
|
||||
}
|
||||
|
||||
int verifyChecksumFromFlash(char *mess, char *functionType,
|
||||
char *clientChecksum, char *fname, ssize_t fsize) {
|
||||
LOG(logINFO, ("\tVerifying Checksum from flash...\n"));
|
||||
int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
||||
ssize_t fsize) {
|
||||
LOG(logINFO, ("\tVerifying FlashChecksum...\n"));
|
||||
|
||||
FILE *fp = fopen(fname, "r");
|
||||
if (fp == NULL) {
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not %s. Unable to open %s in read mode to get checksum\n",
|
||||
functionType, fname);
|
||||
sprintf(mess, "Unable to open %s in read mode to get checksum\n",
|
||||
fname);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -328,9 +217,7 @@ int verifyChecksumFromFlash(char *mess, char *functionType,
|
||||
MD5_CTX c;
|
||||
if (!MD5_Init_SLS(&c)) {
|
||||
fclose(fp);
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to calculate checksum (MD5_Init_SLS)\n",
|
||||
functionType);
|
||||
strcpy(mess, "Unable to calculate checksum (MD5_Init_SLS)\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -350,39 +237,33 @@ int verifyChecksumFromFlash(char *mess, char *functionType,
|
||||
|
||||
if (!MD5_Update_SLS(&c, buf, bytes)) {
|
||||
fclose(fp);
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not %s. Unable to calculate checksum (MD5_Update_SLS)\n",
|
||||
functionType);
|
||||
strcpy(mess, "Unable to calculate checksum (MD5_Update_SLS)\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// read only until a particular size (drive)
|
||||
if (fsize != 0 && totalBytesRead >= fsize) {
|
||||
LOG(logINFO,
|
||||
("\tReached %lu bytes. Not reading more\n", totalBytesRead));
|
||||
break;
|
||||
}
|
||||
// for less than 128 bytes
|
||||
ssize_t bytesToRead = readUnitSize;
|
||||
if ((readUnitSize + totalBytesRead) > fsize) {
|
||||
bytesToRead = fsize - totalBytesRead;
|
||||
}
|
||||
bytes = fread(buf, 1, bytesToRead, fp);
|
||||
bytes = fread(buf, 1, readUnitSize, fp);
|
||||
totalBytesRead += bytes;
|
||||
}
|
||||
LOG(logINFO, ("\tRead %lu bytes to calculate checksum\n", totalBytesRead));
|
||||
fclose(fp);
|
||||
return verifyChecksum(mess, functionType, clientChecksum, &c, "flash");
|
||||
int ret = verifyChecksum(mess, clientChecksum, &c, "flash");
|
||||
if (ret == OK) {
|
||||
LOG(logINFO, ("Checksum in Flash verified\n"));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int verifyChecksum(char *mess, char *functionType, char *clientChecksum,
|
||||
MD5_CTX *c, char *msg) {
|
||||
int verifyChecksum(char *mess, char *clientChecksum, MD5_CTX *c, char *msg) {
|
||||
unsigned char out[MD5_DIGEST_LENGTH];
|
||||
if (!MD5_Final_SLS(out, c)) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to calculate checksum (MD5_Final_SLS)\n",
|
||||
functionType);
|
||||
strcpy(mess, "Unable to calculate checksum (MD5_Final_SLS)\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -402,265 +283,12 @@ int verifyChecksum(char *mess, char *functionType, char *clientChecksum,
|
||||
// compare checksum
|
||||
if (strcmp(clientChecksum, checksum)) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Checksum of %s does not match. Client "
|
||||
"checksum:%s, copied checksum:%s. Please try again before "
|
||||
"rebooting.\n",
|
||||
functionType, msg, clientChecksum, checksum);
|
||||
"Checksum of %s does not match. Client "
|
||||
"checksum:%s, copied checksum:%s\n",
|
||||
msg, clientChecksum, checksum);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tChecksum of %s verified\n", msg));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setupDetectorServer(char *mess, char *sname) {
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
// give permissions
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "chmod 777 %s", sname) >=
|
||||
MAX_STR_LENGTH) {
|
||||
strcpy(mess, "Could not copy detector server. Command to give "
|
||||
"permissions to server is too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (permissions). %s\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tPermissions modified\n"));
|
||||
|
||||
// symbolic link
|
||||
const int fileNameSize = 128;
|
||||
char linkname[fileNameSize];
|
||||
if (getAbsPath(linkname, fileNameSize, LINKED_SERVER_NAME) == FAIL) {
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not copy detector server. Could not get abs path of current "
|
||||
"process\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "ln -sf %s %s", sname, linkname) >=
|
||||
MAX_STR_LENGTH) {
|
||||
strcpy(mess, "Could not copy detector server. Command to "
|
||||
"create symbolic link too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (symbolic link). %s\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tSymbolic link created\n"));
|
||||
|
||||
// blackfin boards (respawn) (only kept for backwards compatibility)
|
||||
#ifndef VIRTUAL
|
||||
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
|
||||
defined(GOTTHARDD)
|
||||
// delete every line with DetectorServer in /etc/inittab
|
||||
strcpy(cmd, "sed -i '/DetectorServer/d' /etc/inittab");
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (del respawning). %s\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tinittab: DetectoServer line deleted\n"));
|
||||
|
||||
// add new link name to /etc/inittab
|
||||
if (snprintf(cmd, MAX_STR_LENGTH,
|
||||
"echo 'ttyS0::respawn:/./%s' >> /etc/inittab",
|
||||
linkname) >= MAX_STR_LENGTH) {
|
||||
strcpy(mess, "Could not copy detector server. Command "
|
||||
"to add new server for spawning is too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (respawning). %s\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tinittab: updated for respawning\n"));
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// sync
|
||||
strcpy(cmd, "sync");
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (sync). %s\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tsync\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int writeBinaryFile(char *mess, char *fname, char *buffer,
|
||||
const uint64_t filesize, char *errorPrefix) {
|
||||
LOG(logINFO, ("\tWriting Detector Server Binary...\n"));
|
||||
|
||||
FILE *fp = fopen(fname, "wb");
|
||||
if (fp == NULL) {
|
||||
sprintf(mess,
|
||||
"Could not %s. (opening file to write(%s). "
|
||||
"Maybe it is being used? Try another name?\n",
|
||||
errorPrefix, fname);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
size_t bytesWritten = 0;
|
||||
size_t unitSize = 128;
|
||||
int oldProgress = 0;
|
||||
|
||||
while (bytesWritten < filesize) {
|
||||
// print progress
|
||||
int progress = (int)(((double)(bytesWritten) / filesize) * 100);
|
||||
if (oldProgress != progress) {
|
||||
printf("%d%%\r", progress);
|
||||
fflush(stdout);
|
||||
oldProgress = progress;
|
||||
}
|
||||
|
||||
// for less than 128 bytes
|
||||
ssize_t writeSize = unitSize;
|
||||
if ((unitSize + bytesWritten) > filesize) {
|
||||
writeSize = filesize - bytesWritten;
|
||||
}
|
||||
size_t bytes = fwrite((char *)buffer + bytesWritten, 1, writeSize, fp);
|
||||
|
||||
// write
|
||||
if (bytes != (size_t)writeSize) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Expected to write %lu "
|
||||
"bytes, wrote %lu bytes). No space left? \n",
|
||||
errorPrefix, (long unsigned int)filesize,
|
||||
(long unsigned int)bytesWritten);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
bytesWritten += bytes;
|
||||
LOG(logDEBUG1,
|
||||
("bytesWritten:%lu filesize:%lu\n", bytesWritten, filesize));
|
||||
}
|
||||
if (fclose(fp) != 0) {
|
||||
sprintf(mess, "Could not %s. (closing file pointer)\n", errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tWritten binary to %s (%lu bytes)\n", fname,
|
||||
(long unsigned int)bytesWritten));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int moveBinaryFile(char *mess, char *dest, char *src, char *errorPrefix) {
|
||||
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
// one can move into the current process binary (will not interfere in
|
||||
// kernel mode)
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "mv %s %s", src, dest) >=
|
||||
MAX_STR_LENGTH) {
|
||||
sprintf(mess, "Could not %s. Command to move binary is too long\n",
|
||||
errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH, "Could not %s. (moving). %s\n",
|
||||
errorPrefix, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tMoved file from %s to %s\n", src, dest));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int createEmptyFile(char *mess, char *fname, char *errorPrefix) {
|
||||
const int fileNameSize = 128;
|
||||
char fullname[fileNameSize];
|
||||
if (getAbsPath(fullname, fileNameSize, fname) == FAIL) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Could not get abs path of current "
|
||||
"process\n",
|
||||
errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "touch %s", fullname) >= MAX_STR_LENGTH) {
|
||||
sprintf(mess, "Could not %s. Command to create is too long\n",
|
||||
errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not %s. (creating empty file %s): %s\n", errorPrefix,
|
||||
fullname, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tEmpty file created: %s (%s)\n", fullname, errorPrefix));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int deleteFile(char *mess, char *fname, char *errorPrefix) {
|
||||
const int fileNameSize = 128;
|
||||
char fullname[fileNameSize];
|
||||
if (getAbsPath(fullname, fileNameSize, fname) == FAIL) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Could not get abs path of current "
|
||||
"process\n",
|
||||
errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (access(fullname, F_OK) == 0) {
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "rm %s", fullname) >=
|
||||
MAX_STR_LENGTH) {
|
||||
sprintf(mess, "Could not %s. Command to delete is too long\n",
|
||||
errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not %s. (deleting file %s). %s\n", errorPrefix,
|
||||
fullname, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tDeleted file: %s (%s)\n", fullname, errorPrefix));
|
||||
} else {
|
||||
LOG(logINFO,
|
||||
("\tFile does not exist anyway: %s (%s)\n", fullname, errorPrefix));
|
||||
}
|
||||
LOG(logINFO, ("\tChecksum verified\n"));
|
||||
return OK;
|
||||
}
|
@ -8,7 +8,9 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <fcntl.h> // open
|
||||
#include <string.h>
|
||||
#include <sys/mman.h> // mmap
|
||||
#include <sys/utsname.h> // uname
|
||||
|
||||
/* global variables */
|
||||
u_int32_t *csp0base = 0;
|
||||
@ -130,3 +132,49 @@ int mapCSP0(void) {
|
||||
}
|
||||
|
||||
u_int32_t *Nios_getBaseAddress() { return csp0base; }
|
||||
|
||||
int Nios_checkKernelVersion(char *expectedVersion) {
|
||||
// extract kernel date string
|
||||
struct utsname buf;
|
||||
if (uname(&buf) == -1) {
|
||||
LOG(logERROR, ("Could not get kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// remove first word (#version number)
|
||||
const char *ptr = strchr(buf.version, ' ');
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
char output[256];
|
||||
memset(output, 0, 256);
|
||||
strcpy(output, buf.version + (ptr - buf.version + 1));
|
||||
|
||||
// convert kernel date string into time
|
||||
time_t kernelDate;
|
||||
if (GetTimeFromString(output, &kernelDate) == FAIL) {
|
||||
LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// convert expected date into time
|
||||
time_t expDate;
|
||||
if (GetTimeFromString(expectedVersion, &expDate) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// compare if kernel time is older than expected time
|
||||
if (kernelDate < expDate) {
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
||||
"Got [%s]\n",
|
||||
expectedVersion, output));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output,
|
||||
expectedVersion));
|
||||
return OK;
|
||||
}
|
381
slsDetectorServers/slsDetectorServer/src/programFpgaBlackfin.c
Normal file
381
slsDetectorServers/slsDetectorServer/src/programFpgaBlackfin.c
Normal file
@ -0,0 +1,381 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "programFpgaBlackfin.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sls/ansi.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
/* global variables */
|
||||
// clang-format off
|
||||
#define MAX_TIME_FPGA_TOUCH_FLASH_US (10 * 1000 * 1000) // 10s
|
||||
#define CMD_GET_FLASH "awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd"
|
||||
#define CMD_FPGA_PICKED_STATUS "cat /sys/class/gpio/gpio7/value"
|
||||
#define FLASH_BUFFER_MEMORY_SIZE (128 * 1024) // 500 KB
|
||||
// clang-format on
|
||||
|
||||
#define FLASH_DRIVE_NAME_SIZE 16
|
||||
char flashDriveName[FLASH_DRIVE_NAME_SIZE] = {0};
|
||||
int gpioDefined = 0;
|
||||
|
||||
extern int executeCommand(char *command, char *result, enum TLogLevel level);
|
||||
|
||||
void defineGPIOpins() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
if (!gpioDefined) {
|
||||
// define the gpio pins
|
||||
system("echo 7 > /sys/class/gpio/export");
|
||||
system("echo 9 > /sys/class/gpio/export");
|
||||
// define their direction
|
||||
system("echo in > /sys/class/gpio/gpio7/direction");
|
||||
system("echo out > /sys/class/gpio/gpio9/direction");
|
||||
LOG(logINFO, ("gpio pins defined\n"));
|
||||
gpioDefined = 1;
|
||||
} else
|
||||
LOG(logDEBUG1, ("gpio pins already defined earlier\n"));
|
||||
}
|
||||
|
||||
void FPGAdontTouchFlash() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
// tell FPGA to not touch flash
|
||||
system("echo 0 > /sys/class/gpio/gpio9/value");
|
||||
// usleep(100*1000);
|
||||
}
|
||||
|
||||
void FPGATouchFlash() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
// tell FPGA to touch flash to program itself
|
||||
system("echo 1 > /sys/class/gpio/gpio9/value");
|
||||
}
|
||||
|
||||
void resetFPGA() {
|
||||
LOG(logINFOBLUE, ("Reseting FPGA\n"));
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
FPGAdontTouchFlash();
|
||||
FPGATouchFlash();
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
}
|
||||
|
||||
int deleteOldFile(char *mess) {
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
char *format = "rm -fr %s";
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, format, TEMP_PROG_FILE_NAME) >=
|
||||
MAX_STR_LENGTH) {
|
||||
strcpy(
|
||||
mess,
|
||||
"Could not program fpga. Command to delete old file is too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not program fpga. (could not delete old file: %s)\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO,
|
||||
("\tDeleted old programming file (%s)\n", TEMP_PROG_FILE_NAME));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int preparetoCopyFPGAProgram(FILE **fd, uint64_t fsize, char *mess) {
|
||||
|
||||
if (deleteOldFile(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// check available memory to copy program
|
||||
{
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
if (fsize >= info.freeram) {
|
||||
sprintf(mess,
|
||||
"Could not program fpga. Not enough memory to copy "
|
||||
"program. [File size:%ldMB, free RAM: %ldMB]\n",
|
||||
(long int)(fsize / (1024 * 1024)),
|
||||
(long int)(info.freeram / (1024 * 1024)));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
// open file to copy program
|
||||
*fd = fopen(TEMP_PROG_FILE_NAME, "w");
|
||||
if (*fd == NULL) {
|
||||
sprintf(mess, "Unable to open %s in write mode\n", TEMP_PROG_FILE_NAME);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tGoing to copy program to %s\n", TEMP_PROG_FILE_NAME));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess) {
|
||||
|
||||
if (getDrive(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE *flashfd = NULL;
|
||||
FILE *srcfd = NULL;
|
||||
if (openFileForFlash(&flashfd, &srcfd, mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (eraseFlash(mess) == FAIL) {
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (writeToFlash(fsize, flashfd, srcfd, mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (deleteOldFile(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/* ignoring this until a consistent way to read from bfin flash
|
||||
if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize)
|
||||
== FAIL) { return FAIL;
|
||||
}
|
||||
*/
|
||||
if (waitForFPGAtoTouchFlash(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getDrive(char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
strcpy(flashDriveName, "/tmp/SLS_mtd3");
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Finding flash drive...\n"));
|
||||
// getting the drive
|
||||
// root:/> cat /proc/mtd
|
||||
// dev: size erasesize name
|
||||
// mtd0: 00040000 00020000 "bootloader(nor)"
|
||||
// mtd1: 00100000 00020000 "linux kernel(nor)"
|
||||
// mtd2: 002c0000 00020000 "file system(nor)"
|
||||
// mtd3: 01000000 00010000 "bitfile(spi)"
|
||||
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
strcpy(cmd, CMD_GET_FLASH);
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not program fpga. (could not get flash drive: %s)\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
char *pch = strtok(retvals, ":");
|
||||
if (pch == NULL) {
|
||||
strcpy(mess, "Could not get mtd drive to flash (strtok fail).\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
memset(flashDriveName, 0, sizeof(flashDriveName));
|
||||
strcpy(flashDriveName, "/dev/");
|
||||
strcat(flashDriveName, pch);
|
||||
LOG(logINFO, ("\tFlash drive found: %s\n", flashDriveName));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int openFileForFlash(FILE **flashfd, FILE **srcfd, char *mess) {
|
||||
FPGAdontTouchFlash();
|
||||
|
||||
// open src file
|
||||
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
|
||||
if (*srcfd == NULL) {
|
||||
sprintf(mess,
|
||||
"Could not flash. Unable to open temp program file %s in read "
|
||||
"mode\n",
|
||||
TEMP_PROG_FILE_NAME);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG1, ("Temp file ready for reading\n"));
|
||||
|
||||
// open flash drive for writing
|
||||
*flashfd = fopen(flashDriveName, "w");
|
||||
if (*flashfd == NULL) {
|
||||
fclose(*srcfd);
|
||||
sprintf(mess, "Unable to open flash drive %s in write mode\n",
|
||||
flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tFlash ready for writing\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int eraseFlash(char *mess) {
|
||||
LOG(logINFO, ("\tErasing Flash...\n"));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
char *format = "flash_eraseall %s";
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, format, flashDriveName) >=
|
||||
MAX_STR_LENGTH) {
|
||||
strcpy(mess,
|
||||
"Could not program fpga. Command to erase flash is too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not program fpga. (could not erase flash: %s)\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tFlash erased\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int writeToFlash(ssize_t fsize, FILE *flashfd, FILE *srcfd, char *mess) {
|
||||
LOG(logDEBUG1, ("writing to flash\n"));
|
||||
|
||||
char *buffer = malloc(FLASH_BUFFER_MEMORY_SIZE);
|
||||
if (buffer == NULL) {
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
strcpy(mess, "Could not program fpga. Memory allocation to write to "
|
||||
"flash failed.\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tWriting to Flash...\n"));
|
||||
|
||||
int oldProgress = 0;
|
||||
ssize_t totalBytes = 0;
|
||||
ssize_t bytes =
|
||||
fread((void *)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE, srcfd);
|
||||
|
||||
while (bytes > 0) {
|
||||
|
||||
ssize_t bytesWritten =
|
||||
fwrite((void *)buffer, sizeof(char), bytes, flashfd);
|
||||
totalBytes += bytesWritten;
|
||||
|
||||
if (bytesWritten != bytes) {
|
||||
free(buffer);
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
sprintf(mess,
|
||||
"Could not write to flash (bytes written:%ld, expected: "
|
||||
"%ld, total written:%ld)\n",
|
||||
(long int)bytesWritten, (long int)bytes,
|
||||
(long int)totalBytes);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// print progress
|
||||
if (fsize > 0) {
|
||||
int progress = (int)(((double)(totalBytes) / fsize) * 100);
|
||||
if (oldProgress != progress) {
|
||||
printf("%d%%\r", progress);
|
||||
fflush(stdout);
|
||||
oldProgress = progress;
|
||||
}
|
||||
} else
|
||||
printf(".");
|
||||
|
||||
bytes = fread((void *)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE,
|
||||
srcfd);
|
||||
}
|
||||
if (fsize <= 0) {
|
||||
printf("\n");
|
||||
}
|
||||
free(buffer);
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
LOG(logINFO, ("\tWrote %ld bytes to flash\n", totalBytes));
|
||||
|
||||
if (totalBytes != fsize) {
|
||||
sprintf(mess,
|
||||
"Could not program fpga. Incorrect bytes written to flash %lu "
|
||||
"[expected: %lu]\n",
|
||||
totalBytes, fsize);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int waitForFPGAtoTouchFlash(char *mess) {
|
||||
// touch and program
|
||||
FPGATouchFlash();
|
||||
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFO, ("\tWaiting for FPGA to program from flash\n"));
|
||||
int timeSpent = 0;
|
||||
|
||||
int result = 0;
|
||||
while (result == 0) {
|
||||
// time taken for fpga to pick up from flash
|
||||
usleep(1000);
|
||||
timeSpent += 1000;
|
||||
if (timeSpent >= MAX_TIME_FPGA_TOUCH_FLASH_US) {
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not program fpga. (exceeded max time allowed: %ds)\n",
|
||||
MAX_TIME_FPGA_TOUCH_FLASH_US / (1000 * 1000));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// read gpio status
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
if (FAIL ==
|
||||
executeCommand(CMD_FPGA_PICKED_STATUS, retvals, logDEBUG1)) {
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not program fpga. (could not read gpio status: %s)\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// convert to int
|
||||
if (sscanf(retvals, "%d\n", &result) != 1) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not program fpga. (could not scan int for gpio "
|
||||
"status: [%s])\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG1, ("gpi07 returned %d\n", result));
|
||||
}
|
||||
LOG(logINFO, ("\tFPGA has picked up the program from flash\n"));
|
||||
return OK;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "programViaNios.h"
|
||||
#include "programFpgaNios.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sls/ansi.h"
|
||||
@ -11,19 +11,10 @@
|
||||
|
||||
/* global variables */
|
||||
|
||||
#define CMD_GET_FPGA_FLASH_DRIVE \
|
||||
"awk \'$5== \"Application\" {print $1}\' /proc/mtd"
|
||||
#define CMD_GET_KERNEL_FLASH_DRIVE \
|
||||
"awk \'$5== \"Linux\" && $9 != \"Backup\\\"\" {print $1}\' /proc/mtd"
|
||||
#define CMD_GET_FLASH "awk \'$5== \"Application\" {print $1}\' /proc/mtd"
|
||||
|
||||
#define FLASH_DRIVE_NAME_SIZE 16
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char flashDriveName[FLASH_DRIVE_NAME_SIZE] = "/tmp/SLS_mtd3";
|
||||
#else
|
||||
char flashDriveName[FLASH_DRIVE_NAME_SIZE] = {0};
|
||||
#endif
|
||||
|
||||
char messageType[SHORT_STR_LENGTH] = {0};
|
||||
#define MICROCONTROLLER_FILE "/dev/ttyAL0"
|
||||
|
||||
extern int executeCommand(char *command, char *result, enum TLogLevel level);
|
||||
@ -44,19 +35,19 @@ void rebootControllerAndFPGA() {
|
||||
system(command);
|
||||
}
|
||||
|
||||
int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
char *functionType, char *checksum, char *fpgasrc,
|
||||
int eraseAndWriteToFlash(char *mess, char *checksum, char *fpgasrc,
|
||||
uint64_t fsize) {
|
||||
|
||||
memset(messageType, 0, sizeof(messageType));
|
||||
strcpy(messageType, functionType);
|
||||
if (verifyChecksumFromBuffer(mess, checksum, fpgasrc, fsize) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (getDrive(mess, index) == FAIL) {
|
||||
if (getDrive(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE *flashfd = NULL;
|
||||
if (openFileForFlash(mess, &flashfd) == FAIL) {
|
||||
if (openFileForFlash(&flashfd, mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -65,33 +56,21 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (writeToFlash(mess, fsize, flashfd, fpgasrc) == FAIL) {
|
||||
if (writeToFlash(fsize, flashfd, fpgasrc, mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/* remove condition when flash fpga fixed */
|
||||
if (index == PROGRAM_KERNEL) {
|
||||
if (verifyChecksumFromFlash(mess, messageType, checksum, flashDriveName,
|
||||
fsize) == FAIL) {
|
||||
/* ignoring this until a consistent way to read from nios flash
|
||||
if (verifyChecksumFromFlash(mess, checksum, flashDriveName, fsize) ==
|
||||
FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == PROGRAM_KERNEL) {
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
if (executeCommand("sync", retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not update %s. (could not sync)\n", messageType);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
int getDrive(char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
strcpy(flashDriveName, "/tmp/SLS_mtd3");
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Finding flash drive...\n"));
|
||||
@ -107,33 +86,18 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (index == PROGRAM_FPGA) {
|
||||
strcpy(cmd, CMD_GET_FPGA_FLASH_DRIVE);
|
||||
} else {
|
||||
strcpy(cmd, CMD_GET_KERNEL_FLASH_DRIVE);
|
||||
}
|
||||
strcpy(cmd, CMD_GET_FLASH);
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not %s. (could not get flash drive: %s)\n", messageType,
|
||||
"Could not program fpga. (could not get flash drive: %s)\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (strlen(retvals) == 0) {
|
||||
LOG(logERROR, ("Could not %s. Could not get mtd drive, script returned "
|
||||
"empty string\n",
|
||||
messageType));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
char *pch = strtok(retvals, ":");
|
||||
if (pch == NULL) {
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not %s. Could not get mtd drive to flash (strtok fail).\n",
|
||||
messageType);
|
||||
strcpy(mess, "Could not get mtd drive to flash (strtok fail).\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -145,12 +109,11 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int openFileForFlash(char *mess, FILE **flashfd) {
|
||||
int openFileForFlash(FILE **flashfd, char *mess) {
|
||||
*flashfd = fopen(flashDriveName, "w");
|
||||
if (*flashfd == NULL) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to open flash drive %s in write mode\n",
|
||||
messageType, flashDriveName);
|
||||
sprintf(mess, "Unable to open flash drive %s in write mode\n",
|
||||
flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
@ -167,16 +130,17 @@ int eraseFlash(char *mess) {
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "flash_erase %s 0 0", flashDriveName) >=
|
||||
char *format = "flash_erase %s 0 0";
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, format, flashDriveName) >=
|
||||
MAX_STR_LENGTH) {
|
||||
sprintf(mess, "Could not %s. Command to erase flash is too long\n",
|
||||
messageType);
|
||||
strcpy(mess,
|
||||
"Could not program fpga. Command to erase flash is too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not %s. (could not erase flash: %s)\n", messageType,
|
||||
"Could not program fpga. (could not erase flash: %s)\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
@ -186,20 +150,19 @@ int eraseFlash(char *mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, char *buffer) {
|
||||
int writeToFlash(ssize_t fsize, FILE *flashfd, char *buffer, char *mess) {
|
||||
LOG(logINFO, ("\tWriting to Flash...\n"));
|
||||
|
||||
ssize_t bytesWritten = fwrite((void *)buffer, sizeof(char), fsize, flashfd);
|
||||
if (bytesWritten != fsize) {
|
||||
fclose(flashfd);
|
||||
sprintf(mess,
|
||||
"Could not %s. Incorrect bytes written to flash %lu "
|
||||
"Could not program fpga. Incorrect bytes written to flash %lu "
|
||||
"[expected: %lu]\n",
|
||||
messageType, (long int)bytesWritten, (long int)fsize);
|
||||
(long int)bytesWritten, (long int)fsize);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
fclose(flashfd);
|
||||
LOG(logINFO, ("\tWrote %ld bytes to flash\n", bytesWritten));
|
||||
LOG(logINFO, ("\tWritten to Flash\n"));
|
||||
return OK;
|
||||
}
|
@ -1,587 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "programViaBlackfin.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sls/ansi.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
/* global variables */
|
||||
// clang-format off
|
||||
#define MAX_TIME_FPGA_TOUCH_FLASH_US (10 * 1000 * 1000) // 10s
|
||||
|
||||
#define CMD_GPIO7_DEFINE "echo 7 > /sys/class/gpio/export"
|
||||
#define CMD_GPIO9_DEFINE "echo 9 > /sys/class/gpio/export"
|
||||
#define CMD_GPIO3_DEFINE "echo 3 > /sys/class/gpio/export"
|
||||
|
||||
// N config done
|
||||
#define CMD_GPIO7_EXIST "/sys/class/gpio/gpio7"
|
||||
// N Config
|
||||
#define CMD_GPIO9_EXIST "/sys/class/gpio/gpio9"
|
||||
// N CE (access to AS interface)
|
||||
#define CMD_GPIO3_EXIST "/sys/class/gpio/gpio3"
|
||||
|
||||
#define CMD_GPIO9_DEFINE_OUT "echo out > /sys/class/gpio/gpio9/direction"
|
||||
#define CMD_GPIO3_DEFINE_OUT "echo out > /sys/class/gpio/gpio3/direction"
|
||||
#define CMD_GPIO7_DEFINE_IN "echo in > /sys/class/gpio/gpio7/direction"
|
||||
#define CMD_GPIO9_DEFINE_IN "echo in > /sys/class/gpio/gpio9/direction"
|
||||
#define CMD_GPIO3_DEFINE_IN "echo in > /sys/class/gpio/gpio3/direction"
|
||||
|
||||
// nConfig
|
||||
#define CMD_GPIO9_DONT_TOUCH_FLASH "echo 0 > /sys/class/gpio/gpio9/value"
|
||||
// nCE
|
||||
#define CMD_GPIO3_DONT_TOUCH_FLASH "echo 1 > /sys/class/gpio/gpio3/value"
|
||||
// CD
|
||||
#define CMD_FPGA_PICKED_STATUS "cat /sys/class/gpio/gpio7/value"
|
||||
|
||||
#define CMD_GET_FPGA_FLASH_DRIVE "awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd"
|
||||
#define CMD_GET_KERNEL_FLASH_DRIVE "awk \'$4== \"\\\"linux\" {print $1}\' /proc/mtd"
|
||||
|
||||
|
||||
#define CMD_GET_AMD_FLASH "dmesg | grep Amd"
|
||||
|
||||
#define FLASH_BUFFER_MEMORY_SIZE (128 * 1024) // 500 KB
|
||||
// clang-format on
|
||||
|
||||
#define FLASH_DRIVE_NAME_SIZE 16
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char flashDriveName[FLASH_DRIVE_NAME_SIZE] = "/tmp/SLS_mtd3";
|
||||
#else
|
||||
char flashDriveName[FLASH_DRIVE_NAME_SIZE] = {0};
|
||||
#endif
|
||||
|
||||
char messageType[SHORT_STR_LENGTH] = {0};
|
||||
|
||||
extern int executeCommand(char *command, char *result, enum TLogLevel level);
|
||||
|
||||
int latestKernelVerified = -1;
|
||||
#define KERNEL_DATE_VRSN_3GPIO "Fri Oct 29 00:00:00 2021"
|
||||
|
||||
int defineGPIOpins(char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
// only latest kernel can use gpio3 pins
|
||||
if (latestKernelVerified == -1) {
|
||||
if (FAIL == validateKernelVersion(KERNEL_DATE_VRSN_3GPIO)) {
|
||||
latestKernelVerified = 0;
|
||||
LOG(logWARNING,
|
||||
("Kernel too old to use gpio3 (nCE). Update kernel to "
|
||||
"guarantee error-free fpga programming. \n\tNot the end "
|
||||
"of the world. Continuing with current kernel...\n"));
|
||||
} else {
|
||||
latestKernelVerified = 1;
|
||||
}
|
||||
}
|
||||
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
// define gpio7
|
||||
if (access(CMD_GPIO7_EXIST, F_OK) != 0) {
|
||||
if (executeCommand(CMD_GPIO7_DEFINE, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not define gpio7 (CD) for fpga (%s)\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio7 (CD): defined\n"));
|
||||
} else {
|
||||
LOG(logINFO, ("\tgpio7 (CD): already defined\n"));
|
||||
}
|
||||
|
||||
// define gpio7 direction
|
||||
if (executeCommand(CMD_GPIO7_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio7 (CD) as input for fpga (%s)\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio7 (CD): setting intput\n"));
|
||||
|
||||
// define gpio9
|
||||
if (access(CMD_GPIO9_EXIST, F_OK) != 0) {
|
||||
if (executeCommand(CMD_GPIO9_DEFINE, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not define gpio9 (nConfig) for fpga (%s)\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio9 (nConfig): defined\n"));
|
||||
} else {
|
||||
LOG(logINFO, ("\tgpio9 (nConfig): already defined\n"));
|
||||
}
|
||||
|
||||
// define gpio3 (not chip enable)
|
||||
if (latestKernelVerified == 1) {
|
||||
if (access(CMD_GPIO3_EXIST, F_OK) != 0) {
|
||||
if (executeCommand(CMD_GPIO3_DEFINE, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not define gpio3 (nCE) for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio3 (nCE): defined\n"));
|
||||
} else {
|
||||
LOG(logINFO, ("\tgpio3 (nCE): already defined\n"));
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
// define gpio9 as output
|
||||
if (executeCommand(CMD_GPIO9_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) as output for fpga (%s)\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio9 (nConfig): setting output\n"));
|
||||
|
||||
// define gpio3 as output
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) as output for fpga (%s)\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio3 (nCE): setting output\n"));
|
||||
}
|
||||
|
||||
// tell FPGA to not: gpio9
|
||||
if (executeCommand(CMD_GPIO9_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||
FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio9 (nConfig): fpga dont touch flash (Low)\n"));
|
||||
|
||||
// tell FPGA to not: gpio3
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||
FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio3 (nCE): fpga dont touch flash (High)\n"));
|
||||
}
|
||||
// usleep(100*1000);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int FPGATouchFlash(char *mess, int programming) {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
// tell FPGA to touch flash to program itself
|
||||
if (executeCommand(CMD_GPIO9_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) as input for fpga (%s)\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio9 (nConfig): setting input\n"));
|
||||
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) as input for fpga (%s)\n", retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tgpio3 (nCE): setting input\n"));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int resetFPGA(char *mess) {
|
||||
LOG(logINFOBLUE, ("Reseting FPGA\n"));
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
if (FPGAdontTouchFlash(mess, 0) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
if (FPGATouchFlash(mess, 0) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int emptyTempFolder(char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#else
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "rm -fr %s",
|
||||
TEMP_PROG_FOLDER_NAME_ALL_FILES) >= MAX_STR_LENGTH) {
|
||||
sprintf(mess,
|
||||
"Could not update %s. Command to empty %s folder is too long\n",
|
||||
messageType, TEMP_PROG_FOLDER_NAME);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not update %s. (could not empty %s folder: %s)\n",
|
||||
messageType, TEMP_PROG_FOLDER_NAME, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tEmptied temp folder(%s)\n", TEMP_PROG_FOLDER_NAME));
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
int preparetoCopyProgram(char *mess, char *functionType, FILE **fd,
|
||||
uint64_t fsize) {
|
||||
|
||||
if (emptyTempFolder(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// check available memory to copy program
|
||||
{
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
if (fsize >= info.freeram) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Not enough memory to copy "
|
||||
"program. [File size:%ldMB, free RAM: %ldMB]\n",
|
||||
functionType, (long int)(fsize / (1024 * 1024)),
|
||||
(long int)(info.freeram / (1024 * 1024)));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
// open file to copy program
|
||||
*fd = fopen(TEMP_PROG_FILE_NAME, "w");
|
||||
if (*fd == NULL) {
|
||||
sprintf(mess, "Could not %s. Unable to open %s in write mode\n",
|
||||
functionType, TEMP_PROG_FILE_NAME);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tGoing to copy program to %s\n", TEMP_PROG_FILE_NAME));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
char *functionType, char *clientChecksum,
|
||||
ssize_t fsize) {
|
||||
|
||||
memset(messageType, 0, sizeof(messageType));
|
||||
strcpy(messageType, functionType);
|
||||
|
||||
if (getDrive(mess, index) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE *flashfd = NULL;
|
||||
FILE *srcfd = NULL;
|
||||
if (openFileForFlash(mess, &flashfd, &srcfd) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (index == PROGRAM_FPGA) {
|
||||
if (FPGAdontTouchFlash(mess, 1) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (eraseFlash(mess) == FAIL) {
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (writeToFlash(mess, fsize, flashfd, srcfd) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (emptyTempFolder(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/* remove condition when flash fpga fixed */
|
||||
if (index == PROGRAM_KERNEL) {
|
||||
if (verifyChecksumFromFlash(mess, messageType, clientChecksum,
|
||||
flashDriveName, fsize) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == PROGRAM_FPGA) {
|
||||
if (waitForFPGAtoTouchFlash(mess) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
// kernel
|
||||
else {
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
if (executeCommand("sync", retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not update %s. (could not sync)\n", messageType);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logDEBUG1, ("Finding flash drive...\n"));
|
||||
// getting the drive
|
||||
// root:/> cat /proc/mtd
|
||||
// dev: size erasesize name
|
||||
// mtd0: 00040000 00020000 "bootloader(nor)"
|
||||
// mtd1: 00100000 00020000 "linux kernel(nor)"
|
||||
// mtd2: 002c0000 00020000 "file system(nor)"
|
||||
// mtd3: 01000000 00010000 "bitfile(spi)"
|
||||
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (index == PROGRAM_FPGA) {
|
||||
strcpy(cmd, CMD_GET_FPGA_FLASH_DRIVE);
|
||||
} else {
|
||||
strcpy(cmd, CMD_GET_KERNEL_FLASH_DRIVE);
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not %s. (could not get flash drive: %s)\n", messageType,
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (strlen(retvals) == 0) {
|
||||
LOG(logERROR, ("Could not %s. Could not get mtd drive, script returned "
|
||||
"empty string\n",
|
||||
messageType));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
char *pch = strtok(retvals, ":");
|
||||
if (pch == NULL) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Could not get mtd drive to flash (strtok "
|
||||
"fail).\n",
|
||||
messageType);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
memset(flashDriveName, 0, sizeof(flashDriveName));
|
||||
sprintf(flashDriveName, "/dev/%s", pch);
|
||||
LOG(logINFO, ("\tFlash drive found: %s\n", flashDriveName));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd) {
|
||||
// open src file
|
||||
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
|
||||
if (*srcfd == NULL) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to open temp program file %s in read "
|
||||
"mode\n",
|
||||
messageType, TEMP_PROG_FILE_NAME);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG1, ("Temp file ready for reading\n"));
|
||||
|
||||
// open flash drive for writing
|
||||
*flashfd = fopen(flashDriveName, "w");
|
||||
if (*flashfd == NULL) {
|
||||
fclose(*srcfd);
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to open flash drive %s in write "
|
||||
"mode\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tFlash ready for writing\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int eraseFlash(char *mess) {
|
||||
LOG(logINFO, ("\tErasing Flash...\n"));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "flash_eraseall %s", flashDriveName) >=
|
||||
MAX_STR_LENGTH) {
|
||||
sprintf(mess, "Could not %s. Command to erase flash is too long\n",
|
||||
messageType);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not update %s. (could not erase flash: %s)\n",
|
||||
messageType, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tFlash erased\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd) {
|
||||
LOG(logDEBUG1, ("writing to flash\n"));
|
||||
|
||||
char *buffer = malloc(FLASH_BUFFER_MEMORY_SIZE);
|
||||
if (buffer == NULL) {
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
sprintf(mess,
|
||||
"Could not %s. Memory allocation to write to "
|
||||
"flash failed.\n",
|
||||
messageType);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tWriting to Flash...\n"));
|
||||
|
||||
int oldProgress = 0;
|
||||
ssize_t totalBytes = 0;
|
||||
ssize_t bytes =
|
||||
fread((void *)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE, srcfd);
|
||||
|
||||
while (bytes > 0) {
|
||||
|
||||
ssize_t bytesWritten =
|
||||
fwrite((void *)buffer, sizeof(char), bytes, flashfd);
|
||||
totalBytes += bytesWritten;
|
||||
|
||||
if (bytesWritten != bytes) {
|
||||
free(buffer);
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
sprintf(mess,
|
||||
"Could not %s. Could not write to flash (bytes "
|
||||
"written:%ld, expected: "
|
||||
"%ld, total written:%ld)\n",
|
||||
messageType, (long int)bytesWritten, (long int)bytes,
|
||||
(long int)totalBytes);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// print progress
|
||||
if (fsize > 0) {
|
||||
int progress = (int)(((double)(totalBytes) / fsize) * 100);
|
||||
if (oldProgress != progress) {
|
||||
printf("%d%%\r", progress);
|
||||
fflush(stdout);
|
||||
oldProgress = progress;
|
||||
}
|
||||
} else
|
||||
printf(".");
|
||||
|
||||
bytes = fread((void *)buffer, sizeof(char), FLASH_BUFFER_MEMORY_SIZE,
|
||||
srcfd);
|
||||
}
|
||||
if (fsize <= 0) {
|
||||
printf("\n");
|
||||
}
|
||||
free(buffer);
|
||||
fclose(flashfd);
|
||||
fclose(srcfd);
|
||||
LOG(logINFO, ("\tWrote %ld bytes to flash\n", totalBytes));
|
||||
|
||||
if (totalBytes != fsize) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Incorrect bytes written to flash %lu "
|
||||
"[expected: %lu]\n",
|
||||
messageType, totalBytes, fsize);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int waitForFPGAtoTouchFlash(char *mess) {
|
||||
// touch and program
|
||||
if (FPGATouchFlash(mess, 1) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFO, ("\tWaiting for FPGA to program from flash... \n\t[gpio7 (CD) should be High when done]\n"));
|
||||
int timeSpent = 0;
|
||||
|
||||
int result = 0;
|
||||
while (result == 0) {
|
||||
// time taken for fpga to pick up from flash
|
||||
usleep(1000);
|
||||
timeSpent += 1000;
|
||||
if (timeSpent >= MAX_TIME_FPGA_TOUCH_FLASH_US) {
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not program fpga. (exceeded max time allowed: %ds)\n",
|
||||
MAX_TIME_FPGA_TOUCH_FLASH_US / (1000 * 1000));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// read gpio status
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
if (FAIL ==
|
||||
executeCommand(CMD_FPGA_PICKED_STATUS, retvals, logDEBUG1)) {
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not program fpga. (could not read gpio status: %s)\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// convert to int
|
||||
if (sscanf(retvals, "%d\n", &result) != 1) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not program fpga. (could not scan int for gpio "
|
||||
"status: [%s])\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG1, ("gpi07 (CD)returned %d\n", result));
|
||||
}
|
||||
LOG(logINFO, ("\tFPGA has picked up the program from flash. gpio7 (CD) is High\n"));
|
||||
return OK;
|
||||
}
|
@ -20,7 +20,6 @@ typedef struct Memory {
|
||||
pthread_mutex_t lockStatus;
|
||||
#ifdef EIGERD
|
||||
pthread_mutex_t lockLocalLink;
|
||||
pthread_mutex_t lockAcqFlag;
|
||||
#endif
|
||||
enum runStatus scanStatus; // idle, running or error
|
||||
int scanStop;
|
||||
@ -121,7 +120,6 @@ int sharedMemory_initialize() {
|
||||
#endif
|
||||
|
||||
#ifdef EIGERD
|
||||
// local link mutex
|
||||
pthread_mutexattr_t lockLocalLinkAttribute;
|
||||
if (pthread_mutexattr_init(&lockLocalLinkAttribute) != 0) {
|
||||
LOG(logERROR,
|
||||
@ -143,28 +141,6 @@ int sharedMemory_initialize() {
|
||||
"shared memory\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// acq flag mutex
|
||||
pthread_mutexattr_t lockAcqFlagAttribute;
|
||||
if (pthread_mutexattr_init(&lockAcqFlagAttribute) != 0) {
|
||||
LOG(logERROR,
|
||||
("Failed to initialize mutex attribute for lockAcqFlag for "
|
||||
"shared memory\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (pthread_mutexattr_setpshared(&lockAcqFlagAttribute,
|
||||
PTHREAD_PROCESS_SHARED) != 0) {
|
||||
LOG(logERROR, ("Failed to set attribute property to process shared for "
|
||||
"lockAcqFlag for shared memory\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&(shm->lockAcqFlag), &lockAcqFlagAttribute) !=
|
||||
0) {
|
||||
LOG(logERROR, ("Failed to initialize pthread_mutex_t lockAcqFlag for "
|
||||
"shared memory\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
shm->scanStatus = IDLE;
|
||||
shm->scanStop = 0;
|
||||
@ -290,10 +266,4 @@ void sharedMemory_lockLocalLink() { pthread_mutex_lock(&(shm->lockLocalLink)); }
|
||||
void sharedMemory_unlockLocalLink() {
|
||||
pthread_mutex_unlock(&(shm->lockLocalLink));
|
||||
}
|
||||
|
||||
void sharedMemory_lockAcqFlag() { pthread_mutex_lock(&(shm->lockAcqFlag)); }
|
||||
|
||||
void sharedMemory_unlockAcqFlag() {
|
||||
pthread_mutex_unlock(&(shm->lockAcqFlag));
|
||||
}
|
||||
#endif
|
@ -4,7 +4,6 @@
|
||||
The port number is passed as an argument */
|
||||
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "communication_funcs.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
@ -151,7 +150,7 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
LOG(logINFO, ("Detected update mode from command line\n"));
|
||||
LOG(logINFO, ("Detected update mode\n"));
|
||||
updateFlag = 1;
|
||||
break;
|
||||
|
||||
@ -186,24 +185,6 @@ int main(int argc, char *argv[]) {
|
||||
if (sharedMemory_create(portno) == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updateFlag == 0) {
|
||||
// update flag if update file exists (command line arg overwrites)
|
||||
const int fileNameSize = 128;
|
||||
char fname[fileNameSize];
|
||||
if (getAbsPath(fname, fileNameSize, UPDATE_FILE) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not get abs path to check if update file exists. "
|
||||
"Will try current folder instead.\n"));
|
||||
strcpy(fname, UPDATE_FILE);
|
||||
}
|
||||
if (access(fname, F_OK) == 0) {
|
||||
updateFlag = 1;
|
||||
LOG(logINFOBLUE, ("File Found: Update Mode enabled\n"));
|
||||
} else {
|
||||
LOG(logINFOBLUE, ("File not Found: Update Mode diabled\n"));
|
||||
}
|
||||
}
|
||||
#ifdef STOP_SERVER
|
||||
// start stop server process
|
||||
char cmd[MAX_STR_LENGTH];
|
||||
@ -212,7 +193,7 @@ int main(int argc, char *argv[]) {
|
||||
memset(portCmd, 0, 256);
|
||||
sprintf(portCmd, "-p%d", portno);
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
LOG(logDEBUG, ("i:%d argv[i]:%s\n", i, argv[i]));
|
||||
LOG(logINFOBLUE, ("i:%d argv[i]:%s\n", i, argv[i]));
|
||||
// remove port argument (--port) and [value]
|
||||
if (!strcasecmp(argv[i], "--port")) {
|
||||
++i;
|
||||
|
@ -77,42 +77,6 @@ char scanErrMessage[MAX_STR_LENGTH] = "";
|
||||
|
||||
/* initialization functions */
|
||||
|
||||
int updateModeAllowedFunction(int file_des) {
|
||||
unsigned int listsize = 19;
|
||||
enum detFuncs list[] = {F_EXEC_COMMAND,
|
||||
F_GET_DETECTOR_TYPE,
|
||||
F_GET_FIRMWARE_VERSION,
|
||||
F_GET_SERVER_VERSION,
|
||||
F_GET_SERIAL_NUMBER,
|
||||
F_WRITE_REGISTER,
|
||||
F_READ_REGISTER,
|
||||
F_LOCK_SERVER,
|
||||
F_GET_LAST_CLIENT_IP,
|
||||
F_PROGRAM_FPGA,
|
||||
F_RESET_FPGA,
|
||||
F_CHECK_VERSION,
|
||||
F_COPY_DET_SERVER,
|
||||
F_REBOOT_CONTROLLER,
|
||||
F_GET_KERNEL_VERSION,
|
||||
F_UPDATE_KERNEL,
|
||||
F_UPDATE_DETECTOR_SERVER,
|
||||
F_GET_UPDATE_MODE,
|
||||
F_SET_UPDATE_MODE};
|
||||
for (unsigned int i = 0; i < listsize; ++i) {
|
||||
if ((unsigned int)fnum == list[i]) {
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Funcion (%s) cannot be executed in update mode. Please disable "
|
||||
"update mode to continue.\n",
|
||||
getFunctionNameFromEnum((enum detFuncs)fnum));
|
||||
LOG(logERROR, (mess));
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int printSocketReadError() {
|
||||
LOG(logERROR, ("Error reading from socket. Possible socket crash.\n"));
|
||||
return FAIL;
|
||||
@ -128,13 +92,14 @@ void init_detector() {
|
||||
#ifdef EIGERD
|
||||
udpDetails[0].dstport2 = DEFAULT_UDP_DST_PORTNO + 1;
|
||||
#endif
|
||||
lockStatus = 0;
|
||||
|
||||
if (isControlServer) {
|
||||
basictests();
|
||||
initControlServer();
|
||||
} else {
|
||||
} else
|
||||
initStopServer();
|
||||
}
|
||||
strcpy(mess, "dummy message");
|
||||
lockStatus = 0;
|
||||
}
|
||||
|
||||
int decode_function(int file_des) {
|
||||
@ -153,13 +118,6 @@ int decode_function(int file_des) {
|
||||
LOG(logERROR, ("Unknown function enum %d\n", fnum));
|
||||
ret = (M_nofunc)(file_des);
|
||||
} else {
|
||||
|
||||
// udpate mode restricted functions, send error (without waitin for
|
||||
// arguments)
|
||||
if (updateFlag && updateModeAllowedFunction(file_des) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logDEBUG1, (" calling function fnum=%d, (%s)\n", fnum,
|
||||
getFunctionNameFromEnum((enum detFuncs)fnum)));
|
||||
ret = (*flist[fnum])(file_des);
|
||||
@ -456,12 +414,6 @@ void function_table() {
|
||||
flist[F_SET_UDP_FIRST_DEST] = &set_udp_first_dest;
|
||||
flist[F_GET_READOUT_SPEED] = &get_readout_speed;
|
||||
flist[F_SET_READOUT_SPEED] = &set_readout_speed;
|
||||
flist[F_GET_KERNEL_VERSION] = &get_kernel_version;
|
||||
flist[F_UPDATE_KERNEL] = &update_kernel;
|
||||
flist[F_UPDATE_DETECTOR_SERVER] = &update_detector_server;
|
||||
flist[F_GET_UPDATE_MODE] = &get_update_mode;
|
||||
flist[F_SET_UPDATE_MODE] = &set_update_mode;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
LOG(logERROR, ("The last detector function enum has reached its "
|
||||
@ -490,9 +442,6 @@ void modeNotImplemented(char *modename, int mode) {
|
||||
}
|
||||
|
||||
int executeCommand(char *command, char *result, enum TLogLevel level) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
const size_t tempsize = 256;
|
||||
char temp[tempsize];
|
||||
memset(temp, 0, tempsize);
|
||||
@ -517,26 +466,29 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
|
||||
memset(temp, 0, tempsize);
|
||||
}
|
||||
result[MAX_STR_LENGTH - 1] = '\0';
|
||||
if (strlen(result) == 0) {
|
||||
strcpy(result, "No result");
|
||||
}
|
||||
|
||||
int retval = OK;
|
||||
int success = pclose(sysFile);
|
||||
if (strlen(result)) {
|
||||
if (success) {
|
||||
retval = FAIL;
|
||||
LOG(logERROR, ("Executing cmd[%s]:%s\n", cmd, result));
|
||||
success = FAIL;
|
||||
LOG(logERROR, ("%s\n", result));
|
||||
} else {
|
||||
LOG(level, ("Result:\n[%s]\n", result));
|
||||
}
|
||||
|
||||
return retval;
|
||||
} else {
|
||||
LOG(level, ("No result\n"));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
int M_nofunc(int file_des) {
|
||||
ret = FAIL;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
// to receive any arguments
|
||||
int n = 1;
|
||||
while (n > 0)
|
||||
n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER);
|
||||
|
||||
sprintf(mess, "Unrecognized Function enum %d. Please do not proceed.\n",
|
||||
fnum);
|
||||
LOG(logERROR, (mess));
|
||||
@ -1499,7 +1451,7 @@ int write_register(int file_des) {
|
||||
} else {
|
||||
if (readRegister(addr, &retval) == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not read register 0x%x or inconsistent values. Try to read +0x100 for only left and +0x200 for only right.\n", addr);
|
||||
sprintf(mess, "Could not read register 0x%x.\n", addr);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
@ -1537,7 +1489,7 @@ int read_register(int file_des) {
|
||||
#elif EIGERD
|
||||
if (readRegister(addr, &retval) == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not read register 0x%x or inconsistent values. Try +0x100 for only left and +0x200 for only right..\n", addr);
|
||||
sprintf(mess, "Could not read register 0x%x.\n", addr);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
#else
|
||||
@ -1607,8 +1559,15 @@ int set_module(int file_des) {
|
||||
}
|
||||
}
|
||||
|
||||
// receive all arguments
|
||||
if (ret == FAIL) {
|
||||
int n = 1;
|
||||
while (n > 0)
|
||||
n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER);
|
||||
}
|
||||
|
||||
// only set
|
||||
if (ret == OK && Server_VerifyLock() == OK) {
|
||||
else if (Server_VerifyLock() == OK) {
|
||||
// check index
|
||||
|
||||
// setsettings
|
||||
@ -1909,6 +1868,9 @@ void *start_state_machine(void *arg) {
|
||||
}
|
||||
usleep(scanSettleTime_ns / 1000);
|
||||
}
|
||||
#ifdef EIGERD
|
||||
prepareAcquisition();
|
||||
#endif
|
||||
ret = startStateMachine();
|
||||
LOG(logDEBUG2, ("Starting Acquisition ret: %d\n", ret));
|
||||
if (ret == FAIL) {
|
||||
@ -2981,10 +2943,6 @@ int validateAndSetAllTrimbits(int arg) {
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
ret = setAllTrimbits(arg);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not set all trimbits\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
#ifdef EIGERD
|
||||
// changes settings to undefined
|
||||
if (getSettings() != UNDEFINED) {
|
||||
@ -3681,10 +3639,149 @@ int program_fpga(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
#if defined(EIGERD) || defined(GOTTHARDD)
|
||||
// to receive any arguments
|
||||
int n = 1;
|
||||
while (n > 0)
|
||||
n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER);
|
||||
functionNotImplemented();
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
#else
|
||||
receive_program(file_des, PROGRAM_FPGA);
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
|
||||
LOG(logINFOBLUE, ("Programming FPGA...\n"));
|
||||
|
||||
// filesize
|
||||
uint64_t filesize = 0;
|
||||
if (receiveData(file_des, &filesize, sizeof(filesize), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Program size is: %lld\n", (long long int)filesize));
|
||||
|
||||
// checksum
|
||||
char checksum[MAX_STR_LENGTH];
|
||||
memset(checksum, 0, MAX_STR_LENGTH);
|
||||
if (receiveData(file_des, checksum, MAX_STR_LENGTH, OTHER) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("checksum is: %s\n\n", checksum));
|
||||
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
if (filesize > NIOS_MAX_APP_IMAGE_SIZE) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not start programming FPGA. File size 0x%llx "
|
||||
"exceeds max size 0x%llx. Forgot Compression?\n",
|
||||
(long long unsigned int)filesize,
|
||||
(long long unsigned int)NIOS_MAX_APP_IMAGE_SIZE);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
|
||||
// receive program
|
||||
if (ret == OK) {
|
||||
char *fpgasrc = malloc(filesize);
|
||||
if (receiveData(file_des, fpgasrc, filesize, OTHER) < 0) {
|
||||
free(fpgasrc);
|
||||
return printSocketReadError();
|
||||
}
|
||||
ret = eraseAndWriteToFlash(mess, checksum, fpgasrc, filesize);
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
free(fpgasrc);
|
||||
}
|
||||
if (ret == FAIL) {
|
||||
LOG(logERROR, ("Program FPGA FAIL!\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#else // jungfrau, ctb, moench
|
||||
|
||||
// open file and allocate memory for part program
|
||||
FILE *fd = NULL;
|
||||
ret = preparetoCopyFPGAProgram(&fd, filesize, mess);
|
||||
char *src = NULL;
|
||||
if (ret == OK) {
|
||||
src = malloc(MAX_FPGAPROGRAMSIZE);
|
||||
if (src == NULL) {
|
||||
fclose(fd);
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
sprintf(mess,
|
||||
"Could not allocate memory to get fpga program. Free "
|
||||
"space: %d MB\n",
|
||||
(int)(info.freeram / (1024 * 1024)));
|
||||
LOG(logERROR, (mess));
|
||||
ret = FAIL;
|
||||
}
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
LOG(logERROR, ("Program FPGA FAIL1!\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// copying program part by part
|
||||
uint64_t totalsize = filesize;
|
||||
while (ret == OK && filesize) {
|
||||
uint64_t unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
||||
if (unitprogramsize > filesize) // less than 2mb
|
||||
unitprogramsize = filesize;
|
||||
LOG(logDEBUG1, ("unit size to receive is:%lld [filesize:%lld]\n",
|
||||
(long long unsigned int)unitprogramsize,
|
||||
(long long unsigned int)filesize));
|
||||
|
||||
// receive part of program
|
||||
if (receiveData(file_des, src, unitprogramsize, OTHER) < 0) {
|
||||
printSocketReadError();
|
||||
break;
|
||||
}
|
||||
|
||||
if (unitprogramsize - filesize == 0) {
|
||||
// src[unitprogramsize] = '\0';
|
||||
filesize -= unitprogramsize;
|
||||
// unitprogramsize++;
|
||||
} else
|
||||
filesize -= unitprogramsize;
|
||||
|
||||
// copy program
|
||||
if (fwrite((void *)src, sizeof(char), unitprogramsize, fd) !=
|
||||
unitprogramsize) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not copy program to /var/tmp (size:%ld)\n",
|
||||
(long int)unitprogramsize);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
break;
|
||||
}
|
||||
// print progress
|
||||
LOG(logINFO,
|
||||
("\t%d%%\r",
|
||||
(int)(((double)(totalsize - filesize) / totalsize) * 100)));
|
||||
fflush(stdout);
|
||||
}
|
||||
free(src);
|
||||
fclose(fd);
|
||||
|
||||
// checksum of copied program
|
||||
if (ret == OK) {
|
||||
ret = verifyChecksumFromFile(mess, checksum, TEMP_PROG_FILE_NAME);
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
LOG(logERROR, ("Program FPGA FAIL!\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// copy to flash
|
||||
ret = copyToFlash(totalsize, checksum, mess);
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
LOG(logERROR, ("Program FPGA FAIL!\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#endif // end of Blackfin programming
|
||||
LOG(logINFOGREEN, ("Programming FPGA completed successfully\n"));
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@ -3702,26 +3799,10 @@ int reset_fpga(int file_des) {
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (isControlServer) {
|
||||
basictests(); // mapping of control server at least
|
||||
char *message = NULL;
|
||||
if (getInitResult(&message) == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, message);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
initControlServer();
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
initStopServer(); // remapping of stop server
|
||||
}
|
||||
if (ret == OK) {
|
||||
char *message = NULL;
|
||||
if (getInitResult(&message) == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, message);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
@ -4145,8 +4226,9 @@ int copy_detector_server(int file_des) {
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
|
||||
// tftp server
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "tftp %s -r %s -g", hostname,
|
||||
sname) >= MAX_STR_LENGTH) {
|
||||
char *format = "tftp %s -r %s -g";
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, format, hostname, sname) >=
|
||||
MAX_STR_LENGTH) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not copy detector server. Command to copy "
|
||||
"server too long\n");
|
||||
@ -4154,15 +4236,101 @@ int copy_detector_server(int file_des) {
|
||||
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
ret = FAIL;
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (tftp). %s\n",
|
||||
retvals);
|
||||
"Could not copy detector server (tftp). %s\n", retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
} else {
|
||||
LOG(logINFO, ("\tServer copied\n"));
|
||||
}
|
||||
|
||||
// give permissions
|
||||
if (ret == OK) {
|
||||
ret = setupDetectorServer(mess, sname);
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "chmod 777 %s", sname) >=
|
||||
MAX_STR_LENGTH) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not copy detector server. Command to give "
|
||||
"permissions to server is too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
ret = FAIL;
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (permissions). %s\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
} else {
|
||||
LOG(logINFO, ("\tPermissions modified\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// symbolic link
|
||||
if (ret == OK) {
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "ln -sf %s %s", sname,
|
||||
LINKED_SERVER_NAME) >= MAX_STR_LENGTH) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not copy detector server. Command to "
|
||||
"create symbolic link too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
ret = FAIL;
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (symbolic link). %s\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
} else {
|
||||
LOG(logINFO, ("\tSymbolic link created\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// blackfin boards (respawn) (only kept for backwards compatibility)
|
||||
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
|
||||
defined(GOTTHARDD)
|
||||
// delete every line with DetectorServer in /etc/inittab
|
||||
if (ret == OK) {
|
||||
strcpy(cmd, "sed -i '/DetectorServer/d' /etc/inittab");
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
ret = FAIL;
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (del respawning). %s\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
} else {
|
||||
LOG(logINFO, ("\tinittab: DetectoServer line deleted\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// add new link name to /etc/inittab
|
||||
if (ret == OK) {
|
||||
format = "echo 'ttyS0::respawn:/./%s' >> /etc/inittab";
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, format, LINKED_SERVER_NAME) >=
|
||||
MAX_STR_LENGTH) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not copy detector server. Command "
|
||||
"to add new server for spawning is too long\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
ret = FAIL;
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (respawning). %s\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
} else {
|
||||
LOG(logINFO, ("\tinittab: updated for respawning\n"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// sync
|
||||
if (ret == OK) {
|
||||
strcpy(cmd, "sync");
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
ret = FAIL;
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not copy detector server (sync). %s\n",
|
||||
retvals);
|
||||
// LOG(logERROR, (mess)); already printed in executecommand
|
||||
} else {
|
||||
LOG(logINFO, ("\tsync\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -4657,13 +4825,6 @@ 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()) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set number of rows. Only available for "
|
||||
"Hardware Board version 2.0.\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@ -4699,10 +4860,11 @@ int get_read_n_rows(int file_des) {
|
||||
#if !defined(EIGERD) && !defined(JUNGFRAUD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getReadNRows();
|
||||
if (retval == -1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not get number of rows. \n");
|
||||
sprintf(mess, "Could not get numbr of rows. \n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("number of rows retval: %u\n", retval));
|
||||
@ -8675,16 +8837,8 @@ int get_flip_rows(int file_des) {
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
// only for HW 2.0 (version = 3)
|
||||
if (isHardwareVersion2()) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not get flip rows. Only available for "
|
||||
"Hardware Board version 2.0.\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
retval = getFlipRows();
|
||||
LOG(logDEBUG1, ("flip rows retval: %u\n", retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
@ -8743,16 +8897,8 @@ int get_num_filter_cells(int file_des) {
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
// only for chipv1.1
|
||||
if (getChipVersion() == 10) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not get number of filter cells. Only available for "
|
||||
"chip version 1.1\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
retval = getNumberOfFilterCells();
|
||||
LOG(logDEBUG1, ("num filter cells retval: %u\n", retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
@ -9266,369 +9412,3 @@ int set_readout_speed(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_kernel_version(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
char retvals[MAX_STR_LENGTH];
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
|
||||
LOG(logDEBUG1, ("Getting kernel version\n"));
|
||||
|
||||
// get only
|
||||
ret = getKernelVersion(retvals);
|
||||
if (ret == FAIL) {
|
||||
if (snprintf(mess, MAX_STR_LENGTH, "Could not get kernel version. %s\n",
|
||||
retvals) >= MAX_STR_LENGTH) {
|
||||
ret = FAIL;
|
||||
strcpy(mess,
|
||||
"Could not get kernel version. Reason too long to copy\n");
|
||||
}
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("kernel version: [%s]\n", retvals));
|
||||
}
|
||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||
}
|
||||
|
||||
int update_kernel(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
#ifdef EIGERD
|
||||
functionNotImplemented();
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
#else
|
||||
receive_program(file_des, PROGRAM_KERNEL);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int update_detector_server(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
return receive_program(file_des, PROGRAM_SERVER);
|
||||
}
|
||||
|
||||
int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
char functionType[SHORT_STR_LENGTH] = {0};
|
||||
switch (index) {
|
||||
case PROGRAM_FPGA:
|
||||
strcpy(functionType, "Update Firmware");
|
||||
break;
|
||||
case PROGRAM_KERNEL:
|
||||
strcpy(functionType, "Update Kernel");
|
||||
break;
|
||||
case PROGRAM_SERVER:
|
||||
strcpy(functionType, "Update Server");
|
||||
break;
|
||||
}
|
||||
LOG(logINFOBLUE, ("%s ...\n", functionType));
|
||||
|
||||
// filesize
|
||||
uint64_t filesize = 0;
|
||||
if (receiveData(file_des, &filesize, sizeof(filesize), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("\tProgram size: %lld\n", (long long int)filesize));
|
||||
|
||||
// client checksum
|
||||
char checksum[MAX_STR_LENGTH] = {0};
|
||||
if (receiveData(file_des, checksum, MAX_STR_LENGTH, OTHER) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("\tChecksum: %s\n", checksum));
|
||||
|
||||
// server name
|
||||
char serverName[MAX_STR_LENGTH] = {0};
|
||||
if (index == PROGRAM_SERVER) {
|
||||
if (receiveData(file_des, serverName, MAX_STR_LENGTH, OTHER) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("\tServer Name: %s\n", serverName));
|
||||
}
|
||||
|
||||
// in same folder as current process (will also work for virtual then
|
||||
// with write permissions)
|
||||
{
|
||||
const int fileNameSize = 128;
|
||||
char fname[fileNameSize];
|
||||
if (getAbsPath(fname, fileNameSize, serverName) == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not %s. Could not get abs path of current "
|
||||
"process\n",
|
||||
functionType);
|
||||
LOG(logERROR, (mess));
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
} else {
|
||||
strcpy(serverName, fname);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == OK) {
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD)
|
||||
receive_program_default(file_des, index, functionType, filesize,
|
||||
checksum, serverName);
|
||||
#else
|
||||
receive_program_via_blackfin(file_des, index, functionType,
|
||||
filesize, checksum, serverName);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ret == OK) {
|
||||
LOG(logINFOGREEN, ("%s completed successfully\n", functionType));
|
||||
} else {
|
||||
LOG(logERROR, ("%s FAIL!\n", functionType));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName) {
|
||||
|
||||
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
|
||||
!defined(GOTTHARDD)
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not %s. program via blackfin not implmented for this "
|
||||
"detector.\n",
|
||||
functionType);
|
||||
LOG(logERROR, (mess));
|
||||
#else
|
||||
// open file and allocate memory for part program
|
||||
FILE *fd = NULL;
|
||||
ret = preparetoCopyProgram(mess, functionType, &fd, filesize);
|
||||
char *src = NULL;
|
||||
if (ret == OK) {
|
||||
src = malloc(MAX_BLACKFIN_PROGRAM_SIZE);
|
||||
if (src == NULL) {
|
||||
fclose(fd);
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
sprintf(mess,
|
||||
"Could not %s. Memory allocation failure. Free "
|
||||
"space: %d MB\n",
|
||||
functionType, (int)(info.freeram / (1024 * 1024)));
|
||||
LOG(logERROR, (mess));
|
||||
ret = FAIL;
|
||||
}
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// copying program part by part
|
||||
uint64_t totalsize = filesize;
|
||||
while (ret == OK && filesize) {
|
||||
uint64_t unitprogramsize = MAX_BLACKFIN_PROGRAM_SIZE;
|
||||
if (unitprogramsize > filesize)
|
||||
unitprogramsize = filesize;
|
||||
LOG(logDEBUG1, ("unit size to receive is:%lld [filesize:%lld]\n",
|
||||
(long long unsigned int)unitprogramsize,
|
||||
(long long unsigned int)filesize));
|
||||
|
||||
// receive part of program
|
||||
if (receiveData(file_des, src, unitprogramsize, OTHER) < 0) {
|
||||
printSocketReadError();
|
||||
break;
|
||||
}
|
||||
filesize -= unitprogramsize;
|
||||
|
||||
// copy program
|
||||
if (fwrite((void *)src, sizeof(char), unitprogramsize, fd) !=
|
||||
unitprogramsize) {
|
||||
ret = FAIL;
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not %s. Could not copy program to /var/tmp (size:%ld)\n",
|
||||
functionType, (long int)unitprogramsize);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
break;
|
||||
}
|
||||
// print progress
|
||||
LOG(logINFO,
|
||||
("\t%d%%\r",
|
||||
(int)(((double)(totalsize - filesize) / totalsize) * 100)));
|
||||
fflush(stdout);
|
||||
}
|
||||
free(src);
|
||||
fclose(fd);
|
||||
|
||||
// checksum of copied program
|
||||
if (ret == OK) {
|
||||
ret = verifyChecksumFromFile(mess, functionType, checksum,
|
||||
TEMP_PROG_FILE_NAME);
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// appropriate functions
|
||||
switch (index) {
|
||||
case PROGRAM_FPGA:
|
||||
case PROGRAM_KERNEL:
|
||||
ret = eraseAndWriteToFlash(mess, index, functionType, checksum,
|
||||
totalsize);
|
||||
break;
|
||||
case PROGRAM_SERVER:
|
||||
ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME,
|
||||
"update detector server");
|
||||
if (ret == OK) {
|
||||
ret = setupDetectorServer(mess, serverName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Program index", (int)index);
|
||||
break;
|
||||
}
|
||||
|
||||
// erase and copy to flash
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void receive_program_default(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName) {
|
||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not %s. program via blackfin not implmented for this "
|
||||
"detector.\n",
|
||||
functionType);
|
||||
LOG(logERROR, (mess))
|
||||
#else
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||
// validate file size
|
||||
if (filesize > NIOS_MAX_APP_IMAGE_SIZE) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not %s. File size 0x%llx "
|
||||
"exceeds max size 0x%llx. Forgot Compression?\n",
|
||||
functionType, (long long unsigned int)filesize,
|
||||
(long long unsigned int)NIOS_MAX_APP_IMAGE_SIZE);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
#endif
|
||||
|
||||
// memory allocation
|
||||
char *src = NULL;
|
||||
if (ret == OK) {
|
||||
src = malloc(filesize);
|
||||
if (src == NULL) {
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
sprintf(mess,
|
||||
"Could not %s. Memory allocation failure. Free "
|
||||
"space: %d MB\n",
|
||||
functionType, (int)(info.freeram / (1024 * 1024)));
|
||||
LOG(logERROR, (mess));
|
||||
ret = FAIL;
|
||||
}
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// receive program
|
||||
if (receiveData(file_des, src, filesize, OTHER) < 0) {
|
||||
free(src);
|
||||
ret = printSocketReadError();
|
||||
return;
|
||||
}
|
||||
|
||||
// checksum of copied program
|
||||
if (ret == OK) {
|
||||
ret = verifyChecksumFromBuffer(mess, functionType, checksum, src,
|
||||
filesize);
|
||||
}
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
if (ret == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// appropriate functions
|
||||
switch (index) {
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||
case PROGRAM_FPGA:
|
||||
case PROGRAM_KERNEL:
|
||||
ret = eraseAndWriteToFlash(mess, index, functionType, checksum, src,
|
||||
filesize);
|
||||
break;
|
||||
#endif
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD)
|
||||
case PROGRAM_SERVER:
|
||||
ret = writeBinaryFile(mess, TEMP_PROG_FILE_NAME, src, filesize,
|
||||
"update detector server");
|
||||
// extra step to write to temp and move to real file as
|
||||
// fopen will give text busy if opening same name as process name
|
||||
if (ret == OK) {
|
||||
ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME,
|
||||
"update detector server");
|
||||
}
|
||||
if (ret == OK) {
|
||||
ret = verifyChecksumFromFile(mess, functionType, checksum,
|
||||
serverName);
|
||||
}
|
||||
if (ret == OK) {
|
||||
ret = setupDetectorServer(mess, serverName);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
modeNotImplemented("Program index", (int)index);
|
||||
break;
|
||||
}
|
||||
// send result
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
|
||||
// free resources
|
||||
free(src);
|
||||
#endif
|
||||
}
|
||||
|
||||
int get_update_mode(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
LOG(logDEBUG1, ("Getting update mode\n"));
|
||||
|
||||
retval = updateFlag;
|
||||
LOG(logDEBUG1, ("update mode retval: %d\n", retval));
|
||||
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_update_mode(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = -1;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting update mode to \n", arg));
|
||||
|
||||
switch (arg) {
|
||||
case 0:
|
||||
ret = deleteFile(mess, UPDATE_FILE, "unset update mode");
|
||||
break;
|
||||
case 1:
|
||||
ret = createEmptyFile(mess, UPDATE_FILE, "set update mode");
|
||||
break;
|
||||
default:
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set updatemode. Options: 0 or 1\n");
|
||||
LOG(logERROR, (mess));
|
||||
break;
|
||||
}
|
||||
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
@ -9,16 +9,16 @@ set(SOURCES
|
||||
src/Pattern.cpp
|
||||
)
|
||||
|
||||
add_library(slsDetectorObject OBJECT
|
||||
add_library(slsDetectorStatic STATIC
|
||||
${SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(slsDetectorObject PUBLIC
|
||||
target_include_directories(slsDetectorStatic PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
)
|
||||
|
||||
target_link_libraries(slsDetectorObject
|
||||
target_link_libraries(slsDetectorStatic
|
||||
PUBLIC
|
||||
slsProjectOptions
|
||||
slsSupportStatic
|
||||
@ -28,7 +28,7 @@ target_link_libraries(slsDetectorObject
|
||||
slsProjectWarnings
|
||||
)
|
||||
|
||||
set(DETECTOR_LIBRARY_TARGETS slsDetectorObject)
|
||||
set(DETECTOR_LIBRARY_TARGETS slsDetectorStatic)
|
||||
|
||||
|
||||
set(PUBLICHEADERS
|
||||
@ -39,29 +39,29 @@ set(PUBLICHEADERS
|
||||
)
|
||||
|
||||
#Shared library
|
||||
if(SLS_BUILD_SHARED_LIBRARIES)
|
||||
add_library(slsDetectorShared SHARED $<TARGET_OBJECTS:slsDetectorObject>)
|
||||
target_link_libraries(slsDetectorShared PUBLIC slsDetectorObject)
|
||||
set_target_properties(slsDetectorShared PROPERTIES
|
||||
VERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}
|
||||
SOVERSION ${PACKAGE_VERSION_MAJOR}
|
||||
LIBRARY_OUTPUT_NAME SlsDetector
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||
)
|
||||
list(APPEND DETECTOR_LIBRARY_TARGETS slsDetectorShared)
|
||||
endif(SLS_BUILD_SHARED_LIBRARIES)
|
||||
# if(SLS_BUILD_SHARED_LIBRARIES)
|
||||
# add_library(slsDetectorShared SHARED $<TARGET_OBJECTS:slsDetectorObject>)
|
||||
# target_link_libraries(slsDetectorShared PUBLIC slsDetectorObject)
|
||||
# set_target_properties(slsDetectorShared PROPERTIES
|
||||
# VERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}
|
||||
# SOVERSION ${PACKAGE_VERSION_MAJOR}
|
||||
# LIBRARY_OUTPUT_NAME SlsDetector
|
||||
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||
# )
|
||||
# list(APPEND DETECTOR_LIBRARY_TARGETS slsDetectorShared)
|
||||
# endif(SLS_BUILD_SHARED_LIBRARIES)
|
||||
|
||||
#Static library
|
||||
add_library(slsDetectorStatic STATIC $<TARGET_OBJECTS:slsDetectorObject>)
|
||||
target_link_libraries(slsDetectorStatic PUBLIC slsDetectorObject)
|
||||
# add_library(slsDetectorStatic STATIC $<TARGET_OBJECTS:slsDetectorObject>)
|
||||
# target_link_libraries(slsDetectorStatic PUBLIC slsDetectorObject)
|
||||
|
||||
set_target_properties(slsDetectorStatic PROPERTIES
|
||||
ARCHIVE_OUTPUT_NAME SlsDetectorStatic
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||
)
|
||||
list(APPEND DETECTOR_LIBRARY_TARGETS slsDetectorStatic)
|
||||
# list(APPEND DETECTOR_LIBRARY_TARGETS slsDetectorStatic)
|
||||
|
||||
|
||||
|
||||
@ -69,6 +69,9 @@ list(APPEND DETECTOR_LIBRARY_TARGETS slsDetectorStatic)
|
||||
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
set_property(TARGET ${DETECTOR_LIBRARY_TARGETS} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
# set_property(TARGET slsDetectorObject PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
# set_property(TARGET slsDetectorStatic PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
# set_property(TARGET slsDetectorShared PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
|
||||
@ -97,7 +100,7 @@ if(SLS_USE_TEXTCLIENT)
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
COMPILE_DEFINITIONS ${val2}=1
|
||||
)
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
if(SLS_LTO_AVAILABLE)
|
||||
set_property(TARGET ${val1} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -81,8 +81,6 @@ class Detector {
|
||||
|
||||
Result<int64_t> getDetectorServerVersion(Positions pos = {}) const;
|
||||
|
||||
Result<std::string> getKernelVersion(Positions pos = {}) const;
|
||||
|
||||
/* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */
|
||||
Result<int64_t> getSerialNumber(Positions pos = {}) const;
|
||||
|
||||
@ -1733,8 +1731,7 @@ class Detector {
|
||||
/** [Jungfrau][CTB][Moench] Advanced user Function! */
|
||||
void resetFPGA(Positions pos = {});
|
||||
|
||||
/** [[deprecated ("Replaced by updateDetectorServer, which does not require
|
||||
* tftp")]] [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2]
|
||||
/** [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2]
|
||||
* Advanced user Function! \n
|
||||
* Copy detector server fname from tftp folder of hostname to detector. Also
|
||||
* creates a symbolic link to a shorter name (without vx.x.x). Then the
|
||||
@ -1745,55 +1742,22 @@ class Detector {
|
||||
void copyDetectorServer(const std::string &fname,
|
||||
const std::string &hostname, Positions pos = {});
|
||||
|
||||
/** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector
|
||||
* server via TCP (without tftp).\nMakes a symbolic link with a shorter
|
||||
* name (without vx.x.x).\nThen, detector controller reboots (except
|
||||
* Eiger).\n[Jungfrau][Ctb][Moench]Also changes respawn server to the
|
||||
* link, which is effective after a reboot.
|
||||
*/
|
||||
void updateDetectorServer(const std::string &fname, Positions pos = {});
|
||||
|
||||
/** [Jungfrau][Ctb][Moench][Mythen3][Gotthard2] \n
|
||||
* Advanced Command!! You could damage the detector. Please use with
|
||||
* caution.\nUpdates the kernel image. Then, detector controller reboots
|
||||
* with new kernel
|
||||
*/
|
||||
void updateKernel(const std::string &fname, Positions pos = {});
|
||||
|
||||
/** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] Advanced user
|
||||
* Function! */
|
||||
void rebootController(Positions pos = {});
|
||||
|
||||
/** [[deprecated ("Replaced by overloaded updateDetectorServer, which does
|
||||
* not require tftp and has one less argument")]] Advanced user Function!\n
|
||||
* [Jungfrau][Gotthard][CTB][Moench] Updates the firmware, detector server,
|
||||
* make a soft link and then reboots detector controller. \n
|
||||
* [Mythen3][Gotthard2] Will require a script to start up the shorter named
|
||||
* server link at start up \n sname is name of detector server binary found
|
||||
* on tftp folder of host pc \n hostname is name of pc to tftp from \n fname
|
||||
* is programming file name with full path to it
|
||||
*/
|
||||
void updateFirmwareAndServer(const std::string &sname,
|
||||
const std::string &hostname,
|
||||
const std::string &fname, Positions pos = {});
|
||||
|
||||
/**
|
||||
* Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
|
||||
* firmware, detector server, make a soft link and then reboots detector
|
||||
* controller. \n [Mythen3][Gotthard2] Will require a script to start up the
|
||||
* shorter named server link at start up \n sname is full path name of
|
||||
* detector server \n fname is programming file name with full path to it
|
||||
* shorter named server link at start up \n sname is name of detector
|
||||
* server binary found on tftp folder of host pc \n hostname is name of pc
|
||||
* to tftp from \n fname is programming file name with full path to it
|
||||
*/
|
||||
void updateFirmwareAndServer(const std::string &sname,
|
||||
const std::string &hostname,
|
||||
const std::string &fname, Positions pos = {});
|
||||
|
||||
Result<bool> getUpdateMode(Positions pos = {}) const;
|
||||
|
||||
/** Restarts detector server in update mode. This is useful when
|
||||
* server-firmware compatibility is at its worst and server cannot start up
|
||||
* normally */
|
||||
void setUpdateMode(const bool updatemode, Positions pos = {});
|
||||
|
||||
/** Advanced user Function! \n
|
||||
* Goes to stop server. Hence, can be called while calling blocking
|
||||
* acquire(). \n [Eiger] Address is +0x100 for only left, +0x200 for only
|
||||
|
@ -275,7 +275,7 @@ std::string CmdProxy::Versions(int action) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getFirmwareVersion(std::vector<int>{det_id});
|
||||
auto t = det->getFirmwareVersion();
|
||||
os << "\nDetector Type: " << OutString(det->getDetectorType())
|
||||
<< "\nPackage Version: " << det->getPackageVersion() << std::hex
|
||||
<< "\nClient Version: 0x" << det->getClientVersion();
|
||||
@ -285,14 +285,10 @@ std::string CmdProxy::Versions(int action) {
|
||||
os << "\nFirmware Version: " << OutStringHex(t);
|
||||
}
|
||||
os << "\nDetector Server Version: "
|
||||
<< OutStringHex(
|
||||
det->getDetectorServerVersion(std::vector<int>{det_id}));
|
||||
os << "\nDetector Server Version: "
|
||||
<< OutString(det->getKernelVersion({std::vector<int>{det_id}}));
|
||||
<< OutStringHex(det->getDetectorServerVersion());
|
||||
if (det->getUseReceiverFlag().squash(true)) {
|
||||
os << "\nReceiver Version: "
|
||||
<< OutStringHex(
|
||||
det->getReceiverVersion(std::vector<int>{det_id}));
|
||||
<< OutStringHex(det->getReceiverVersion());
|
||||
}
|
||||
os << std::dec << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
@ -1434,9 +1430,8 @@ std::string CmdProxy::UDPDestinationList(int action) {
|
||||
throw sls::RuntimeError("udp_dstlist must be at module level.");
|
||||
}
|
||||
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
|
||||
throw sls::RuntimeError(std::string("Invalid receiver index ") +
|
||||
std::to_string(rx_id) +
|
||||
std::string(" to set round robin entry."));
|
||||
throw sls::RuntimeError(
|
||||
"Invalid receiver index to get round robin entry.");
|
||||
}
|
||||
auto t = det->getDestinationUDPList(rx_id, std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
@ -2853,14 +2848,11 @@ std::string CmdProxy::CopyDetectorServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
LOG(logWARNING) << "Deprecated! Replaced by updatedetectorserver that "
|
||||
"requires no tftp.\n";
|
||||
os << "[server_name (in tftp folder)] "
|
||||
"[pc_host_name]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3]["
|
||||
"Gotthard2] Copies detector server via TFTP from pc. Ensure that "
|
||||
"Gotthard2] Copies detector server via tftp from pc. Ensure that "
|
||||
"server is in the pc's tftp folder. Makes a symbolic link with a "
|
||||
"shorter name (without vx.x.x). Then, detector controller "
|
||||
"reboots (except "
|
||||
"shorter name (without vx.x.x). Then, detector reboots (except "
|
||||
"Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server "
|
||||
"to the link, which is effective after a reboot."
|
||||
<< '\n';
|
||||
@ -2878,98 +2870,30 @@ std::string CmdProxy::CopyDetectorServer(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::UpdateDetectorServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[server_name with full "
|
||||
"path]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3]["
|
||||
"Gotthard2] Copies detector server via TCP (without tftp). Makes "
|
||||
"a symbolic link with a shorter name (without vx.x.x). Then, "
|
||||
"detector controller reboots (except "
|
||||
"Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server "
|
||||
"to the link, which is effective after a reboot."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->updateDetectorServer(args[0], std::vector<int>{det_id});
|
||||
os << "successful\n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::UpdateKernel(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[kernel_name with full "
|
||||
"path]\n\t[Jungfrau][Ctb][Moench][Mythen3]["
|
||||
"Gotthard2] Advanced Command!! You could damage the detector. "
|
||||
"Please use"
|
||||
" with caution.\n\tUpdates the kernel image. Then, detector "
|
||||
"controller "
|
||||
"reboots with new kernel."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->updateKernel(args[0], std::vector<int>{det_id});
|
||||
os << "successful\n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tUsing tftp: Deprecated!! [server_name"
|
||||
" (in tftp folder)] [pc_host_name] [fname.pof (incl full path)]"
|
||||
"\n\tWithout tftp: Recommended [server_name (incl fullpath)] "
|
||||
"[fname.pof (incl full path)] "
|
||||
"This does not use tftp."
|
||||
"\n\t\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
|
||||
os << "[server_name (in tftp folder)] [pc_host_name] [fname.pof (incl "
|
||||
"full path)]\n\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
|
||||
"firmware, detector server, creates the symbolic link and then "
|
||||
"reboots detector controller. \n\t\t[Mythen3][Gotthard2] will "
|
||||
"reboots detector controller. \n\t[Mythen3][Gotthard2] will "
|
||||
"require a script to start up the shorter named server link at "
|
||||
"start up. \n\t\tsname is full path name of detector server "
|
||||
"binary"
|
||||
"\n\t\tfname is full path of programming file"
|
||||
"start up. \n\tsname is name of detector server binary found on "
|
||||
"tftp folder of host pc \n\thostname is name of pc to tftp from "
|
||||
"\n\tfname is programming file name"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 3 && args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
if (args.size() != 3) {
|
||||
WrongNumberOfParameters(3);
|
||||
}
|
||||
|
||||
int fpos = args.size() - 1;
|
||||
if (args[fpos].find(".pof") == std::string::npos &&
|
||||
args[fpos].find(".rbf") == std::string::npos) {
|
||||
throw sls::RuntimeError("Programming file must be a pof/rbf file.");
|
||||
if (args[2].find(".pof") == std::string::npos) {
|
||||
throw sls::RuntimeError("Programming file must be a pof file.");
|
||||
}
|
||||
|
||||
if (args.size() == 3) {
|
||||
LOG(logWARNING)
|
||||
<< "Deprecated! Recommend to use same command without tftp (no "
|
||||
"pc name) and using full path to the server binary";
|
||||
det->updateFirmwareAndServer(args[0], args[1], args[2],
|
||||
std::vector<int>{det_id});
|
||||
} else {
|
||||
det->updateFirmwareAndServer(args[0], args[1],
|
||||
std::vector<int>{det_id});
|
||||
}
|
||||
os << "successful\n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
|
@ -767,7 +767,6 @@ class CmdProxy {
|
||||
{"clientversion", &CmdProxy::ClientVersion},
|
||||
{"firmwareversion", &CmdProxy::FirmwareVersion},
|
||||
{"detectorserverversion", &CmdProxy::detectorserverversion},
|
||||
{"kernelversion", &CmdProxy::kernelversion},
|
||||
{"rx_version", &CmdProxy::rx_version},
|
||||
{"serialnumber", &CmdProxy::serialnumber},
|
||||
{"moduleid", &CmdProxy::moduleid},
|
||||
@ -1059,11 +1058,8 @@ class CmdProxy {
|
||||
{"programfpga", &CmdProxy::ProgramFpga},
|
||||
{"resetfpga", &CmdProxy::resetfpga},
|
||||
{"copydetectorserver", &CmdProxy::CopyDetectorServer},
|
||||
{"updatedetectorserver", &CmdProxy::UpdateDetectorServer},
|
||||
{"updatekernel", &CmdProxy::UpdateKernel},
|
||||
{"rebootcontroller", &CmdProxy::rebootcontroller},
|
||||
{"update", &CmdProxy::UpdateFirmwareAndDetectorServer},
|
||||
{"updatemode", &CmdProxy::updatemode},
|
||||
{"reg", &CmdProxy::Register},
|
||||
{"adcreg", &CmdProxy::AdcRegister},
|
||||
{"setbit", &CmdProxy::BitOperations},
|
||||
@ -1186,8 +1182,6 @@ class CmdProxy {
|
||||
/* Advanced */
|
||||
std::string ProgramFpga(int action);
|
||||
std::string CopyDetectorServer(int action);
|
||||
std::string UpdateDetectorServer(int action);
|
||||
std::string UpdateKernel(int action);
|
||||
std::string UpdateFirmwareAndDetectorServer(int action);
|
||||
std::string Register(int action);
|
||||
std::string AdcRegister(int action);
|
||||
@ -1212,10 +1206,6 @@ class CmdProxy {
|
||||
detectorserverversion, getDetectorServerVersion,
|
||||
"\n\tOn-board detector server software version in format [0xYYMMDD].");
|
||||
|
||||
GET_COMMAND(
|
||||
kernelversion, getKernelVersion,
|
||||
"\n\tGet kernel version on the detector including time and date.");
|
||||
|
||||
GET_COMMAND_HEX(rx_version, getReceiverVersion,
|
||||
"\n\tReceiver version in format [0xYYMMDD].");
|
||||
|
||||
@ -2185,12 +2175,6 @@ class CmdProxy {
|
||||
"\n\t[Jungfrau][Ctb][Moench][Gotthard][Mythen3]["
|
||||
"Gotthard2] Reboot controller of detector.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
updatemode, getUpdateMode, setUpdateMode, StringTo<int>,
|
||||
"[0|1]\n\tRestart the detector server in update mode or not. This is "
|
||||
"useful when server-firmware compatibility is at its worst and server "
|
||||
"cannot start up normally");
|
||||
|
||||
EXECUTE_SET_COMMAND(
|
||||
firmwaretest, executeFirmwareTest,
|
||||
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Firmware "
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "Module.h"
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
#include "sls/logger.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "sls/versionAPI.h"
|
||||
@ -88,7 +87,7 @@ void Detector::loadParameters(const std::vector<std::string> ¶meters) {
|
||||
for (const auto ¤t_line : parameters) {
|
||||
parser.Parse(current_line);
|
||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||
defs::PUT_ACTION, std::cout, parser.receiver_id());
|
||||
defs::PUT_ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,10 +117,6 @@ Result<int64_t> Detector::getDetectorServerVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDetectorServerVersion, pos);
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getKernelVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getKernelVersion, pos);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getSerialNumber(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getSerialNumber, pos);
|
||||
}
|
||||
@ -780,39 +775,7 @@ void Detector::startDetectorReadout() {
|
||||
}
|
||||
|
||||
void Detector::stopDetector(Positions pos) {
|
||||
|
||||
// stop and check status X times
|
||||
int retries{0};
|
||||
//avoid default construction of runStatus::IDLE on squash
|
||||
auto status = getDetectorStatus().squash(defs::runStatus::RUNNING);
|
||||
while(status != defs::runStatus::IDLE){
|
||||
pimpl->Parallel(&Module::stopAcquisition, pos);
|
||||
status = getDetectorStatus().squash(defs::runStatus::RUNNING);
|
||||
++retries;
|
||||
|
||||
if(retries == 10)
|
||||
throw RuntimeError("Could not stop detector");
|
||||
}
|
||||
|
||||
|
||||
// validate consistent frame numbers
|
||||
switch (getDetectorType().squash()) {
|
||||
case defs::EIGER:
|
||||
case defs::JUNGFRAU:
|
||||
case defs::MOENCH:
|
||||
case defs::CHIPTESTBOARD: {
|
||||
auto res = getNextFrameNumber(pos);
|
||||
if (!res.equal()) {
|
||||
uint64_t maxVal = 0;
|
||||
for (auto it : res) {
|
||||
maxVal = std::max(maxVal, it);
|
||||
}
|
||||
setNextFrameNumber(maxVal + 1);
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
|
||||
@ -2166,7 +2129,6 @@ void Detector::setAdditionalJsonParameter(const std::string &key,
|
||||
// Advanced
|
||||
|
||||
void Detector::programFPGA(const std::string &fname, Positions pos) {
|
||||
LOG(logINFO) << "Updating Firmware...";
|
||||
std::vector<char> buffer = pimpl->readProgrammingFile(fname);
|
||||
pimpl->Parallel(&Module::programFPGA, pos, buffer);
|
||||
rebootController(pos);
|
||||
@ -2178,30 +2140,12 @@ void Detector::resetFPGA(Positions pos) {
|
||||
|
||||
void Detector::copyDetectorServer(const std::string &fname,
|
||||
const std::string &hostname, Positions pos) {
|
||||
LOG(logINFO) << "Updating Detector Server (via tftp)...";
|
||||
pimpl->Parallel(&Module::copyDetectorServer, pos, fname, hostname);
|
||||
if (getDetectorType().squash() != defs::EIGER) {
|
||||
rebootController(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
||||
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
||||
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
|
||||
std::string filename = sls::getFileNameFromFilePath(fname);
|
||||
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
||||
if (getDetectorType().squash() != defs::EIGER) {
|
||||
rebootController(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void Detector::updateKernel(const std::string &fname, Positions pos) {
|
||||
LOG(logINFO) << "Updating Kernel...";
|
||||
std::vector<char> buffer = sls::readBinaryFile(fname, "Update Kernel");
|
||||
pimpl->Parallel(&Module::updateKernel, pos, buffer);
|
||||
rebootController(pos);
|
||||
}
|
||||
|
||||
void Detector::rebootController(Positions pos) {
|
||||
pimpl->Parallel(&Module::rebootController, pos);
|
||||
}
|
||||
@ -2210,34 +2154,10 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
const std::string &hostname,
|
||||
const std::string &fname,
|
||||
Positions pos) {
|
||||
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
|
||||
LOG(logINFO) << "Updating Detector Server (via tftp)...";
|
||||
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
|
||||
programFPGA(fname, pos);
|
||||
}
|
||||
|
||||
void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
const std::string &fname,
|
||||
Positions pos) {
|
||||
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
|
||||
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
||||
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
|
||||
std::string filename = sls::getFileNameFromFilePath(sname);
|
||||
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
||||
programFPGA(fname, pos);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getUpdateMode(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getUpdateMode, pos);
|
||||
}
|
||||
|
||||
void Detector::setUpdateMode(const bool updatemode, Positions pos) {
|
||||
pimpl->Parallel(&Module::setUpdateMode, pos, updatemode);
|
||||
if (getDetectorType().squash() != defs::EIGER) {
|
||||
rebootController(pos);
|
||||
}
|
||||
}
|
||||
|
||||
Result<uint32_t> Detector::readRegister(uint32_t addr, Positions pos) const {
|
||||
return pimpl->Parallel(&Module::readRegister, pos, addr);
|
||||
}
|
||||
@ -2316,7 +2236,7 @@ Result<sls::IpAddr> Detector::getLastClientIP(Positions pos) const {
|
||||
|
||||
Result<std::string> Detector::executeCommand(const std::string &value,
|
||||
Positions pos) {
|
||||
return pimpl->Parallel(&Module::executeCommand, pos, value);
|
||||
return pimpl->Parallel(&Module::execCommand, pos, value);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfFramesFromStart(Positions pos) const {
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
#include "sls/network_utils.h"
|
||||
#include "sls/string_utils.h"
|
||||
|
||||
@ -338,10 +337,8 @@ void DetectorImpl::updateDetectorSize() {
|
||||
<< shm()->numberOfChannels.y;
|
||||
|
||||
for (auto &module : modules) {
|
||||
if (module->getUpdateMode() == 0) {
|
||||
module->updateNumberOfModule(shm()->numberOfModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int DetectorImpl::size() const { return modules.size(); }
|
||||
@ -1264,7 +1261,8 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||
throw RuntimeError("programfpga not implemented for this detector");
|
||||
}
|
||||
|
||||
LOG(logINFO) << "This can take awhile. Please be patient.";
|
||||
LOG(logINFO)
|
||||
<< "Updating Firmware. This can take awhile. Please be patient...";
|
||||
LOG(logDEBUG1) << "Programming FPGA with file name:" << fname;
|
||||
|
||||
// check if it exists
|
||||
@ -1282,7 +1280,14 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||
}
|
||||
|
||||
// get srcSize to print progress
|
||||
ssize_t srcSize = sls::getFileSize(src, "Program FPGA");
|
||||
if (fseek(src, 0, SEEK_END) != 0) {
|
||||
throw RuntimeError("Program FPGA: Seek error in src file");
|
||||
}
|
||||
size_t srcSize = ftell(src);
|
||||
if (srcSize <= 0) {
|
||||
throw RuntimeError("Program FPGA: Could not get length of source file");
|
||||
}
|
||||
rewind(src);
|
||||
|
||||
// create temp destination file
|
||||
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
|
||||
@ -1354,12 +1359,36 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||
if (close(dst) != 0) {
|
||||
throw RuntimeError("Program FPGA: Could not close destination file");
|
||||
}
|
||||
LOG(logINFO) << "File has been converted to " << destfname;
|
||||
LOG(logINFOBLUE) << "File has been converted to " << destfname;
|
||||
|
||||
// load converted file to memory
|
||||
std::vector<char> buffer = readBinaryFile(destfname, "Program FPGA");
|
||||
// delete temporary
|
||||
unlink(destfname);
|
||||
// loading dst file to memory
|
||||
// FILE *fp = fopen("/tmp/SLS_DET_MCB.tzgmUT", "r");
|
||||
FILE *fp = fopen(destfname, "r");
|
||||
if (fp == nullptr) {
|
||||
throw RuntimeError("Program FPGA: Could not open rawbin file");
|
||||
}
|
||||
if (fseek(fp, 0, SEEK_END) != 0) {
|
||||
throw RuntimeError("Program FPGA: Seek error in rawbin file");
|
||||
}
|
||||
size_t filesize = ftell(fp);
|
||||
if (filesize <= 0) {
|
||||
throw RuntimeError("Program FPGA: Could not get length of rawbin file");
|
||||
}
|
||||
rewind(fp);
|
||||
|
||||
std::vector<char> buffer(filesize, 0);
|
||||
if (fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
|
||||
throw RuntimeError("Program FPGA: Could not read rawbin file");
|
||||
}
|
||||
|
||||
if (fclose(fp) != 0) {
|
||||
throw RuntimeError(
|
||||
"Program FPGA: Could not close destination file after converting");
|
||||
}
|
||||
|
||||
// unlink(destfname); // delete temporary file
|
||||
LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory";
|
||||
LOG(logDEBUG1) << "Read file into memory";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Convert raw file
|
||||
* [Jungfrau][Ctb][Moench] from pof file
|
||||
* [Jungfrau][Ctb] from pof file
|
||||
* [Mythen3][Gotthard2] from rbf file
|
||||
* @param fname name of pof/rbf file
|
||||
* @returns binary of the program
|
||||
|
@ -94,12 +94,6 @@ int64_t Module::getDetectorServerVersion() const {
|
||||
return sendToDetector<int64_t>(F_GET_SERVER_VERSION);
|
||||
}
|
||||
|
||||
std::string Module::getKernelVersion() const {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sendToDetector(F_GET_KERNEL_VERSION, nullptr, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t Module::getSerialNumber() const {
|
||||
return sendToDetector<int64_t>(F_GET_SERIAL_NUMBER);
|
||||
}
|
||||
@ -836,8 +830,7 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(F_GET_NUM_MISSING_PACKETS);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError(
|
||||
"Receiver " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto nports = client.Receive<int>();
|
||||
@ -1170,18 +1163,17 @@ std::string Module::getReceiverHostname() const {
|
||||
}
|
||||
|
||||
void Module::setReceiverHostname(const std::string &receiverIP) {
|
||||
LOG(logDEBUG1) << "Setting up Receiver hostname with " << receiverIP;
|
||||
|
||||
if (getRunStatus() == RUNNING) {
|
||||
throw RuntimeError("Cannot set receiver hostname. Acquisition already "
|
||||
"running. Stop it first.");
|
||||
}
|
||||
LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP;
|
||||
|
||||
if (receiverIP == "none") {
|
||||
memset(shm()->rxHostname, 0, MAX_STR_LENGTH);
|
||||
sls::strcpy_safe(shm()->rxHostname, "none");
|
||||
shm()->useReceiverFlag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (getRunStatus() == RUNNING) {
|
||||
LOG(logWARNING) << "Acquisition already running, Stopping it.";
|
||||
stopAcquisition();
|
||||
}
|
||||
|
||||
// start updating
|
||||
@ -1530,7 +1522,7 @@ void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
|
||||
receiver.Send(static_cast<int>(t.size()));
|
||||
receiver.Send(t);
|
||||
if (receiver.Receive<int>() == FAIL) {
|
||||
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + receiver.readErrorMessage());
|
||||
}
|
||||
}
|
||||
@ -1786,7 +1778,7 @@ void Module::sendVetoPhoton(const int chipIndex,
|
||||
client.Send(gainIndices);
|
||||
client.Send(values);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw DetectorError("Detector " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
@ -1798,13 +1790,13 @@ void Module::getVetoPhoton(const int chipIndex,
|
||||
client.Send(F_GET_VETO_PHOTON);
|
||||
client.Send(chipIndex);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw DetectorError("Detector " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
|
||||
auto nch = client.Receive<int>();
|
||||
if (nch != shm()->nChan.x) {
|
||||
throw DetectorError("Could not get veto photon. Expected " +
|
||||
throw RuntimeError("Could not get veto photon. Expected " +
|
||||
std::to_string(shm()->nChan.x) + " channels, got " +
|
||||
std::to_string(nch));
|
||||
}
|
||||
@ -2033,7 +2025,7 @@ void Module::getBadChannels(const std::string &fname) const {
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_GET_BAD_CHANNELS);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw DetectorError("Detector " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
// receive badchannels
|
||||
@ -2090,7 +2082,7 @@ void Module::setBadChannels(const std::string &fname) {
|
||||
client.Send(badchannels);
|
||||
}
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw DetectorError("Detector " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
@ -2404,7 +2396,7 @@ std::map<std::string, std::string> Module::getAdditionalJsonHeader() const {
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(F_GET_ADDITIONAL_JSON_HEADER);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto size = client.Receive<int>();
|
||||
@ -2453,7 +2445,7 @@ void Module::setAdditionalJsonHeader(
|
||||
client.Send(&buff[0], buff.size());
|
||||
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
@ -2487,15 +2479,14 @@ void Module::programFPGA(std::vector<char> buffer) {
|
||||
case JUNGFRAU:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware");
|
||||
programFPGAviaBlackfin(buffer);
|
||||
break;
|
||||
case MYTHEN3:
|
||||
case GOTTHARD2:
|
||||
sendProgram(false, buffer, F_PROGRAM_FPGA, "Update Firmware");
|
||||
programFPGAviaNios(buffer);
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Updating Firmware via the package is not "
|
||||
"implemented for this detector");
|
||||
throw RuntimeError("Program FPGA is not implemented for this detector");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2506,8 +2497,7 @@ void Module::copyDetectorServer(const std::string &fname,
|
||||
char args[2][MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(args[0], fname.c_str());
|
||||
sls::strcpy_safe(args[1], hostname.c_str());
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): Sending detector server " << args[0] << " from host "
|
||||
LOG(logINFO) << "Sending detector server " << args[0] << " from host "
|
||||
<< args[1];
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_COPY_DET_SERVER);
|
||||
@ -2517,65 +2507,15 @@ void Module::copyDetectorServer(const std::string &fname,
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): Detector server copied";
|
||||
}
|
||||
|
||||
void Module::updateDetectorServer(std::vector<char> buffer,
|
||||
const std::string &serverName) {
|
||||
switch (shm()->detType) {
|
||||
case JUNGFRAU:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
sendProgram(true, buffer, F_UPDATE_DETECTOR_SERVER,
|
||||
"Update Detector Server (no tftp)", serverName);
|
||||
break;
|
||||
case MYTHEN3:
|
||||
case GOTTHARD2:
|
||||
case EIGER:
|
||||
sendProgram(false, buffer, F_UPDATE_DETECTOR_SERVER,
|
||||
"Update Detector Server (no tftp)", serverName);
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError(
|
||||
"Updating DetectorServer via the package is not implemented "
|
||||
"for this detector");
|
||||
}
|
||||
}
|
||||
|
||||
void Module::updateKernel(std::vector<char> buffer) {
|
||||
switch (shm()->detType) {
|
||||
case JUNGFRAU:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
sendProgram(true, buffer, F_UPDATE_KERNEL, "Update Kernel");
|
||||
break;
|
||||
case MYTHEN3:
|
||||
case GOTTHARD2:
|
||||
sendProgram(false, buffer, F_UPDATE_KERNEL, "Update Kernel");
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Updating Kernel via the package is not implemented "
|
||||
"for this detector");
|
||||
}
|
||||
<< "): detector server copied";
|
||||
}
|
||||
|
||||
void Module::rebootController() {
|
||||
sendToDetector(F_REBOOT_CONTROLLER);
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): Controller rebooted successfully!";
|
||||
}
|
||||
|
||||
bool Module::getUpdateMode() const {
|
||||
return sendToDetector<int>(F_GET_UPDATE_MODE);
|
||||
}
|
||||
|
||||
void Module::setUpdateMode(const bool updatemode) {
|
||||
sendToDetector(F_SET_UPDATE_MODE, static_cast<int>(updatemode), nullptr);
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): Update Mode set to " << updatemode << "!";
|
||||
LOG(logINFO) << "Controller rebooted successfully!";
|
||||
}
|
||||
|
||||
uint32_t Module::readRegister(uint32_t addr) const {
|
||||
@ -2653,25 +2593,11 @@ sls::IpAddr Module::getLastClientIP() const {
|
||||
return sendToDetector<sls::IpAddr>(F_GET_LAST_CLIENT_IP);
|
||||
}
|
||||
|
||||
std::string Module::executeCommand(const std::string &cmd) {
|
||||
std::string Module::execCommand(const std::string &cmd) {
|
||||
char arg[MAX_STR_LENGTH]{};
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(arg, cmd.c_str());
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): Sending command " << cmd;
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_EXEC_COMMAND);
|
||||
client.Send(arg);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::cout << '\n';
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
}
|
||||
client.Receive(retval);
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): command executed";
|
||||
sendToDetector(F_EXEC_COMMAND, arg, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -3228,7 +3154,7 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
|
||||
client.Send(F_SET_MODULE);
|
||||
sendModule(&module, client);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw DetectorError("Module " + std::to_string(moduleIndex) +
|
||||
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
@ -3475,48 +3401,38 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
|
||||
return myMod;
|
||||
}
|
||||
|
||||
void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
||||
const int functionEnum,
|
||||
const std::string &functionType,
|
||||
const std::string serverName) {
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): Sending " << functionType;
|
||||
|
||||
// send fnum and filesize
|
||||
void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
// send program from memory to detector
|
||||
LOG(logINFO) << "Sending programming binary (from pof) to module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(functionEnum);
|
||||
client.Send(F_PROGRAM_FPGA);
|
||||
uint64_t filesize = buffer.size();
|
||||
client.Send(filesize);
|
||||
|
||||
// send checksum
|
||||
// checksum
|
||||
std::string checksum = sls::md5_calculate_checksum(buffer.data(), filesize);
|
||||
LOG(logDEBUG1) << "Checksum:" << checksum;
|
||||
char cChecksum[MAX_STR_LENGTH] = {0};
|
||||
char cChecksum[MAX_STR_LENGTH];
|
||||
memset(cChecksum, 0, MAX_STR_LENGTH);
|
||||
strcpy(cChecksum, checksum.c_str());
|
||||
client.Send(cChecksum);
|
||||
|
||||
// send server name
|
||||
if (functionEnum == F_UPDATE_DETECTOR_SERVER) {
|
||||
char sname[MAX_STR_LENGTH] = {0};
|
||||
strcpy(sname, serverName.c_str());
|
||||
client.Send(sname);
|
||||
}
|
||||
|
||||
// validate memory allocation etc in detector
|
||||
// opening file fail
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::cout << '\n';
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
|
||||
// send program
|
||||
if (blackfin) {
|
||||
// sending program in parts of 2mb each
|
||||
uint64_t unitprogramsize = 0;
|
||||
int currentPointer = 0;
|
||||
while (filesize > 0) {
|
||||
unitprogramsize = MAX_BLACKFIN_PROGRAM_SIZE;
|
||||
if (unitprogramsize > filesize) {
|
||||
unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
||||
if (unitprogramsize > filesize) { // less than 2mb
|
||||
unitprogramsize = filesize;
|
||||
}
|
||||
LOG(logDEBUG) << "unitprogramsize:" << unitprogramsize
|
||||
@ -3528,75 +3444,150 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
filesize -= unitprogramsize;
|
||||
currentPointer += unitprogramsize;
|
||||
}
|
||||
} else {
|
||||
client.Send(buffer);
|
||||
}
|
||||
|
||||
// tmp checksum verified in detector
|
||||
// checksum
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
LOG(logINFO) << "Checksum verified for module " << moduleIndex << " ("
|
||||
<< shm()->hostname << ")";
|
||||
|
||||
// simulating erasing and writing to
|
||||
if (blackfin) {
|
||||
if (functionEnum == F_PROGRAM_FPGA) {
|
||||
simulatingActivityinDetector("Erasing Flash",
|
||||
BLACKFIN_ERASE_FLASH_TIME);
|
||||
simulatingActivityinDetector("Writing to Flash",
|
||||
BLACKFIN_WRITE_TO_FLASH_TIME);
|
||||
}
|
||||
} else {
|
||||
if (functionEnum == F_PROGRAM_FPGA) {
|
||||
simulatingActivityinDetector("Erasing Flash",
|
||||
NIOS_ERASE_FLASH_TIME_FPGA);
|
||||
simulatingActivityinDetector("Writing to Flash",
|
||||
NIOS_WRITE_TO_FLASH_TIME_FPGA);
|
||||
} else if (functionEnum == F_UPDATE_KERNEL) {
|
||||
simulatingActivityinDetector("Erasing Flash",
|
||||
NIOS_ERASE_FLASH_TIME_KERNEL);
|
||||
simulatingActivityinDetector("Writing to Flash",
|
||||
NIOS_WRITE_TO_FLASH_TIME_KERNEL);
|
||||
}
|
||||
}
|
||||
|
||||
// update verified
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw DetectorError(os.str());
|
||||
}
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): " << functionType << " successful";
|
||||
}
|
||||
|
||||
void Module::simulatingActivityinDetector(const std::string &functionType,
|
||||
const int timeRequired) {
|
||||
LOG(logINFO) << "(Simulating) " << functionType << " for module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
// simulating erasing flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex
|
||||
<< " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
const int ERASE_TIME = timeRequired;
|
||||
// erasing takes 65 seconds, printing here (otherwise need threads
|
||||
// in server-unnecessary)
|
||||
const int ERASE_TIME = 65;
|
||||
int count = ERASE_TIME + 1;
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf(
|
||||
"%d%%\r",
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// simulating writing to flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Writing to Flash for module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// writing takes 30 seconds, printing here (otherwise need threads
|
||||
// in server-unnecessary)
|
||||
const int ERASE_TIME = 30;
|
||||
int count = ERASE_TIME + 1;
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
LOG(logINFO) << "FPGA programmed successfully";
|
||||
}
|
||||
|
||||
void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
LOG(logINFO) << "Sending programming binary (from rbf) to Module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_PROGRAM_FPGA);
|
||||
uint64_t filesize = buffer.size();
|
||||
client.Send(filesize);
|
||||
|
||||
// checksum
|
||||
std::string checksum = sls::md5_calculate_checksum(buffer.data(), filesize);
|
||||
LOG(logDEBUG1) << "Checksum:" << checksum;
|
||||
char cChecksum[MAX_STR_LENGTH];
|
||||
memset(cChecksum, 0, MAX_STR_LENGTH);
|
||||
strcpy(cChecksum, checksum.c_str());
|
||||
client.Send(cChecksum);
|
||||
|
||||
// validate file size before sending program
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
client.Send(buffer);
|
||||
|
||||
// simulating erasing flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex
|
||||
<< " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// erasing takes 10 seconds, printing here (otherwise need threads
|
||||
// in server-unnecessary)
|
||||
const int ERASE_TIME = 10;
|
||||
int count = ERASE_TIME + 1;
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// simulating writing to flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Writing to Flash for module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// writing takes 45 seconds, printing here (otherwise need threads
|
||||
// in server-unnecessary)
|
||||
const int ERASE_TIME = 45;
|
||||
int count = ERASE_TIME + 1;
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
LOG(logINFO) << "FPGA programmed successfully";
|
||||
}
|
||||
} // namespace sls
|
||||
|
@ -91,7 +91,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
int64_t getFirmwareVersion() const;
|
||||
int64_t getDetectorServerVersion() const;
|
||||
std::string getKernelVersion() const;
|
||||
int64_t getSerialNumber() const;
|
||||
int getModuleId() const;
|
||||
int64_t getReceiverSoftwareVersion() const;
|
||||
@ -541,12 +540,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
void resetFPGA();
|
||||
void copyDetectorServer(const std::string &fname,
|
||||
const std::string &hostname);
|
||||
void updateDetectorServer(std::vector<char> buffer,
|
||||
const std::string &serverName);
|
||||
void updateKernel(std::vector<char> buffer);
|
||||
void rebootController();
|
||||
bool getUpdateMode() const;
|
||||
void setUpdateMode(const bool updatemode);
|
||||
uint32_t readRegister(uint32_t addr) const;
|
||||
uint32_t writeRegister(uint32_t addr, uint32_t val);
|
||||
void setBit(uint32_t addr, int n);
|
||||
@ -570,7 +564,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
bool getLockDetector() const;
|
||||
void setLockDetector(bool lock);
|
||||
sls::IpAddr getLastClientIP() const;
|
||||
std::string executeCommand(const std::string &cmd);
|
||||
std::string execCommand(const std::string &cmd);
|
||||
int64_t getNumberOfFramesFromStart() const;
|
||||
int64_t getActualTime() const;
|
||||
int64_t getMeasurementTime() const;
|
||||
@ -751,20 +745,11 @@ class Module : public virtual slsDetectorDefs {
|
||||
std::string getTrimbitFilename(detectorSettings settings, int e_eV);
|
||||
sls_detector_module readSettingsFile(const std::string &fname,
|
||||
bool trimbits = true);
|
||||
void sendProgram(bool blackfin, std::vector<char> buffer,
|
||||
const int functionEnum, const std::string &functionType,
|
||||
const std::string serverName = "");
|
||||
void simulatingActivityinDetector(const std::string &functionType,
|
||||
const int timeRequired);
|
||||
void programFPGAviaBlackfin(std::vector<char> buffer);
|
||||
void programFPGAviaNios(std::vector<char> buffer);
|
||||
|
||||
const int moduleIndex;
|
||||
mutable sls::SharedMemory<sharedModule> shm{0, 0};
|
||||
static const int BLACKFIN_ERASE_FLASH_TIME = 65;
|
||||
static const int BLACKFIN_WRITE_TO_FLASH_TIME = 30;
|
||||
static const int NIOS_ERASE_FLASH_TIME_FPGA = 10;
|
||||
static const int NIOS_WRITE_TO_FLASH_TIME_FPGA = 45;
|
||||
static const int NIOS_ERASE_FLASH_TIME_KERNEL = 9;
|
||||
static const int NIOS_WRITE_TO_FLASH_TIME_KERNEL = 40;
|
||||
};
|
||||
|
||||
} // namespace sls
|
@ -103,13 +103,6 @@ TEST_CASE("detectorserverversion", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("detectorserverversion", {"0"}, -1, PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("kernelversion", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_NOTHROW(proxy.Call("kernelversion", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("kernelversion", {"0"}, -1, PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("serialnumber", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
@ -540,13 +533,7 @@ TEST_CASE("fliprows", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
bool jungfrauhw2 = false;
|
||||
if (det_type == defs::JUNGFRAU &&
|
||||
((det.getSerialNumber().tsquash("inconsistent serial number to test") &
|
||||
0x30000) == 0x30000)) {
|
||||
jungfrauhw2 = true;
|
||||
}
|
||||
if (det_type == defs::EIGER || jungfrauhw2) {
|
||||
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
|
||||
auto previous = det.getFlipRows();
|
||||
auto previous_numudp = det.getNumberofUDPInterfaces();
|
||||
if (det_type == defs::JUNGFRAU) {
|
||||
@ -1557,20 +1544,6 @@ TEST_CASE("readnrows", "[.cmd]") {
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
|
||||
bool jungfrauhw2 = false;
|
||||
if (det_type == defs::JUNGFRAU &&
|
||||
((det.getSerialNumber().tsquash(
|
||||
"inconsistent serial number to test") &
|
||||
0x30000) == 0x30000)) {
|
||||
jungfrauhw2 = true;
|
||||
}
|
||||
if (det_type == defs::JUNGFRAU && !jungfrauhw2) {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("readnrows", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "readnrows 512\n");
|
||||
}
|
||||
} else {
|
||||
auto prev_val = det.getReadNRows();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -1598,7 +1571,6 @@ TEST_CASE("readnrows", "[.cmd]") {
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setReadNRows(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("readnrows", {}, -1, GET));
|
||||
}
|
||||
@ -2026,6 +1998,8 @@ TEST_CASE("stop", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("stop", {}, -1, GET));
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
std::chrono::nanoseconds prev_val;
|
||||
bool virtualDet =
|
||||
det.isVirtualDetectorServer().tsquash("inconsistent virtual servers");
|
||||
if (det_type != defs::MYTHEN3) {
|
||||
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
||||
} else {
|
||||
@ -2056,8 +2030,11 @@ TEST_CASE("stop", "[.cmd]") {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("status", {}, -1, GET, oss);
|
||||
REQUIRE(((oss.str() == "status stopped\n") ||
|
||||
(oss.str() == "status idle\n")));
|
||||
if (!virtualDet && det_type == defs::JUNGFRAU) {
|
||||
REQUIRE(oss.str() == "status stopped\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() == "status idle\n");
|
||||
}
|
||||
}
|
||||
det.setExptime(-1, prev_val);
|
||||
det.setPeriod(prev_period);
|
||||
@ -2069,6 +2046,8 @@ TEST_CASE("status", "[.cmd]") {
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
std::chrono::nanoseconds prev_val;
|
||||
bool virtualDet =
|
||||
det.isVirtualDetectorServer().tsquash("inconsistent virtual servers");
|
||||
if (det_type != defs::MYTHEN3) {
|
||||
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
|
||||
} else {
|
||||
@ -2095,8 +2074,11 @@ TEST_CASE("status", "[.cmd]") {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("status", {}, -1, GET, oss);
|
||||
REQUIRE(((oss.str() == "status stopped\n") ||
|
||||
(oss.str() == "status idle\n")));
|
||||
if (!virtualDet && det_type == defs::JUNGFRAU) {
|
||||
REQUIRE(oss.str() == "status stopped\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() == "status idle\n");
|
||||
}
|
||||
}
|
||||
det.setExptime(-1, prev_val);
|
||||
det.setPeriod(prev_period);
|
||||
@ -2719,25 +2701,6 @@ TEST_CASE("copydetectorserver", "[.cmd]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("updatekernel", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
|
||||
det_type == defs::MOENCH || det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD2) {
|
||||
// TODO: send real server?
|
||||
// std::ostringstream oss;
|
||||
// proxy.Call("updatekernel",{"juImage_detector.lzma",
|
||||
// "pc13784"}, -1, PUT, oss);
|
||||
// REQUIRE(oss.str() == "updatekernel successful\n");
|
||||
REQUIRE_THROWS(proxy.Call("updatekernel", {}, -1, GET));
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("updatekernel", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("updatekernel", {}, -1, PUT));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rebootcontroller", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
@ -104,7 +104,7 @@ if (SLS_USE_RECEIVER_BINARIES)
|
||||
set_target_properties(slsReceiver PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
if(SLS_LTO_AVAILABLE)
|
||||
set_property(TARGET slsReceiver PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
@ -124,7 +124,7 @@ if (SLS_USE_RECEIVER_BINARIES)
|
||||
set_target_properties(slsMultiReceiver PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
if(SLS_LTO_AVAILABLE)
|
||||
set_property(TARGET slsMultiReceiver PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
|
@ -355,7 +355,7 @@ std::string Implementation::getFilePath() const { return filePath; }
|
||||
|
||||
void Implementation::setFilePath(const std::string &c) {
|
||||
if (!c.empty()) {
|
||||
sls::mkdir_p(c); // throws if it can't create
|
||||
mkdir_p(c); // throws if it can't create
|
||||
filePath = c;
|
||||
}
|
||||
LOG(logINFO) << "File path: " << filePath;
|
||||
|
@ -66,21 +66,21 @@ target_include_directories(md5sls
|
||||
|
||||
|
||||
# Create an object library to avoid building the library twice
|
||||
add_library(slsSupportObject OBJECT
|
||||
add_library(slsSupportStatic STATIC
|
||||
${SOURCES}
|
||||
${HEADERS}
|
||||
)
|
||||
|
||||
target_include_directories(slsSupportObject
|
||||
target_include_directories(slsSupportStatic
|
||||
PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
)
|
||||
|
||||
target_link_libraries(slsSupportObject
|
||||
target_link_libraries(slsSupportStatic
|
||||
PUBLIC
|
||||
slsProjectOptions
|
||||
libzmq
|
||||
# libzmq
|
||||
rapidjson
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
@ -92,33 +92,33 @@ if (SLS_USE_TESTS)
|
||||
endif(SLS_USE_TESTS)
|
||||
|
||||
#List of targets to support adding removing targets as config
|
||||
set(SUPPORT_LIBRARY_TARGETS slsSupportObject)
|
||||
set(SUPPORT_LIBRARY_TARGETS slsSupportStatic)
|
||||
|
||||
# Add shared library version of the support lib
|
||||
if(SLS_BUILD_SHARED_LIBRARIES)
|
||||
add_library(slsSupportShared SHARED $<TARGET_OBJECTS:slsSupportObject>)
|
||||
target_link_libraries(slsSupportShared PUBLIC slsSupportObject)
|
||||
# if(SLS_BUILD_SHARED_LIBRARIES)
|
||||
# add_library(slsSupportShared SHARED $<TARGET_OBJECTS:slsSupportObject>)
|
||||
# target_link_libraries(slsSupportShared PUBLIC slsSupportObject)
|
||||
|
||||
set_target_properties(slsSupportShared PROPERTIES
|
||||
VERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}
|
||||
SOVERSION ${PACKAGE_VERSION_MAJOR}
|
||||
LIBRARY_OUTPUT_NAME SlsSupport
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||
)
|
||||
list(APPEND SUPPORT_LIBRARY_TARGETS slsSupportShared)
|
||||
endif(SLS_BUILD_SHARED_LIBRARIES)
|
||||
# set_target_properties(slsSupportShared PROPERTIES
|
||||
# VERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}
|
||||
# SOVERSION ${PACKAGE_VERSION_MAJOR}
|
||||
# LIBRARY_OUTPUT_NAME SlsSupport
|
||||
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||
# )
|
||||
# list(APPEND SUPPORT_LIBRARY_TARGETS slsSupportShared)
|
||||
# endif(SLS_BUILD_SHARED_LIBRARIES)
|
||||
|
||||
# Add static version of the support lib
|
||||
add_library(slsSupportStatic STATIC $<TARGET_OBJECTS:slsSupportObject>)
|
||||
target_link_libraries(slsSupportStatic PUBLIC slsSupportObject)
|
||||
# add_library(slsSupportStatic STATIC $<TARGET_OBJECTS:slsSupportObject>)
|
||||
# target_link_libraries(slsSupportStatic PUBLIC slsSupportObject)
|
||||
|
||||
set_target_properties(slsSupportStatic PROPERTIES
|
||||
ARCHIVE_OUTPUT_NAME SlsSupportStatic
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||
)
|
||||
list(APPEND SUPPORT_LIBRARY_TARGETS slsSupportStatic)
|
||||
# list(APPEND SUPPORT_LIBRARY_TARGETS slsSupportStatic)
|
||||
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
set_property(TARGET ${SUPPORT_LIBRARY_TARGETS} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user