Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B2b ps dietrich 2024 aug 28 #378

Merged
merged 13 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/b2b/app/buildApp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# './buildApp.sh $HOME/consoleApps/b2b b2b-pro-transfer-mon b2b-mon'

SW=../x86
USRPATH=/common/usr/timing/b2b/centos7
USRPATH=/common/usr/timing/b2b/rocky9
APPBUILD=$1/$2/current
NAME=$2
BIN=$3
Expand Down
2 changes: 1 addition & 1 deletion modules/b2b/app/start-app-b2b-int-sys-mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ BASEDIR=$(cd "${SCRIPTDIR}/.." >/dev/null; pwd)
# script for starting the b2b system viewer on INT
export DIM_DNS_NODE=asl105
export LD_LIBRARY_PATH=${BASEDIR}/lib
xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys -s int
xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys int
3 changes: 1 addition & 2 deletions modules/b2b/app/start-app-b2b-pro-sys-mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ BASEDIR=$(cd "${SCRIPTDIR}/.." >/dev/null; pwd)
# script for starting the b2b system viewer on INT
export DIM_DNS_NODE=asl105
export LD_LIBRARY_PATH=${BASEDIR}/lib
xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys\
-s pro
xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys pro
2 changes: 1 addition & 1 deletion modules/b2b/fw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RAM_SIZE := $(shell cat $(PLATFMAKEFILE) | grep -m1 RAM_SIZE | cut -d'=

SHARED_SIZE ?= 8K
USRCPUCLK ?= 125000
VERSION = 00.07.02
VERSION = 00.08.00

.DEFAULT_GOAL := fwbin

Expand Down
311 changes: 201 additions & 110 deletions modules/b2b/fw/b2b-cbu.c

Large diffs are not rendered by default.

67 changes: 41 additions & 26 deletions modules/b2b/fw/b2b-kd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* created : 2020
* author : Dietrich Beck, GSI-Darmstadt
* version : 22-Dec-2022
* version : 16-Aug-2024
*
* firmware required for kicker and related diagnostics
*
Expand Down Expand Up @@ -34,7 +34,7 @@
* For all questions and ideas contact: [email protected]
* Last update: 19-November-2020
********************************************************************************************/
#define B2BPM_FW_VERSION 0x000702 // make this consistent with makefile
#define B2BPM_FW_VERSION 0x000800 // make this consistent with makefile

// standard includes
#include <stdio.h>
Expand Down Expand Up @@ -72,13 +72,17 @@ volatile uint32_t *pSharedGettKickDMon; // pointer to a "user defined" u32 re
volatile uint32_t *pSharedGettKickDProbe; // pointer to a "user defined" u32 register; here: delay of probe signal
volatile uint32_t *pSharedGetKickSid; // pointer to a "user defined" u32 register; here: SID of last kicker event
volatile uint32_t *pSharedGetKickGid; // pointer to a "user defined" u32 register; here: GID of last kicker event
volatile int32_t *pSharedGetComLatency; // pointer to a "user defined" u32 register; here: latency for messages received via ECA

uint32_t *cpuRamExternal; // external address (seen from host bridge) of this CPU's RAM

uint64_t statusArray; // all status infos are ORed bit-wise into statusArray, statusArray is then published
uint32_t nTransfer; // # of transfers
uint32_t transStat; // status of transfer, here: meanDelta of 'poor mans fit'
int32_t comLatency; // latency for messages received via ECA [ns]
int32_t offsDone; // offset deadline WR message to time when we are done [ns]
int32_t maxComLatency;
uint32_t maxOffsDone;
uint32_t nLate; // # of late messages


// typical init for lm32
Expand Down Expand Up @@ -110,7 +114,6 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize)
pSharedGettKickDProbe = (uint32_t *)(pShared + (B2B_SHARED_GET_DKPROBE >> 2));
pSharedGetKickSid = (uint32_t *)(pShared + (B2B_SHARED_GET_SID >> 2));
pSharedGetKickGid = (uint32_t *)(pShared + (B2B_SHARED_GET_GID >> 2));
pSharedGetComLatency = (int32_t *)(pShared + (B2B_SHARED_GET_COMLATENCY >> 2));

// find address of CPU from external perspective
idx = 0;
Expand Down Expand Up @@ -153,9 +156,15 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize)
// clear project specific diagnostics
void extern_clearDiag()
{
statusArray = 0x0;
nTransfer = 0;
transStat = 0;
statusArray = 0x0;
nTransfer = 0;
transStat = 0;
nLate = 0x0;
comLatency = 0x0;
maxComLatency = 0x0;
offsDone = 0x0;
maxOffsDone = 0x0;

} // extern_clearDiag


Expand Down Expand Up @@ -212,7 +221,12 @@ uint32_t extern_entryActionOperation()
*pSharedGettKickDProbe = 0x0;
*pSharedGetKickSid = 0x0;
*pSharedGetKickGid = 0x0;
*pSharedGetComLatency = 0x0;

nLate = 0x0;
comLatency = 0x0;
maxComLatency = 0x0;
offsDone = 0x0;
maxOffsDone = 0x0;

return COMMON_STATUS_OK;
} // extern_entryActionOperation
Expand All @@ -236,7 +250,7 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time
uint32_t flagIsDelayed; // flag 'delayed'
uint32_t ecaAction; // action triggered by event received from ECA
uint64_t recDeadline; // deadline received
uint64_t reqDeadline; // deadline requested by sender
static uint64_t reqDeadline; // deadline requested by sender
uint64_t recEvtId; // evt ID received
uint64_t recParam; // param received
uint32_t recTEF; // TEF received
Expand All @@ -261,7 +275,8 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time
static uint32_t flagSendMessage; // flag: a message shall be sent

int64_t dKickMon; // delay of kicker monitor signal with respect to kicker trigger signal
int64_t dKickProbe; // delay of kicker probe signal with respect to kicker trigger signal
int64_t dKickProbe; // delay of kicker probe signal with respect to kicker trigger signal
uint64_t sysTime; // helper variable

status = actStatus;
transStat = 0x0;
Expand All @@ -275,6 +290,8 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time
// this is ugly, but ...
if (ecaAction == B2B_ECADO_B2B_TRIGGEREXT) flagIsExt = 1;
else flagIsExt = 0;

comLatency = (int32_t)(getSysTime() - recDeadline);

reqDeadline = recDeadline + (uint64_t)B2B_PRETRIGGERTR;// ECA is configured to pre-trigger ahead of time!!!

Expand All @@ -291,18 +308,11 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time
*pSharedGetKickSid = recSid;
*pSharedGettKickTrigHi = (uint32_t)((tKickTrig >> 32) & 0xffffffff);
*pSharedGettKickTrigLo = (uint32_t)( tKickTrig & 0xffffffff);
*pSharedGetComLatency = (int32_t)(getSysTime() - recDeadline);


// we must do this here, as doing this os B2B_ECADO_TLUINPUT2 would be too late
// hence, we receive probe signals only if the kicker fires after it has been triggered
//fwlib_ioCtrlSetGate(1, 0); chk // enable input gate probe signal extraction
//fwlib_ioCtrlSetGate(1, 3); chk // enable input gate probe signal injection

break; // B2B_ECADO_B2B_TRIGGERINJ

case B2B_ECADO_TLUINPUT2 : // received monitor signal from kicker electronics

comLatency = (int32_t)(getSysTime() - recDeadline);
tKickMon = recDeadline;
flagRecMon = 1;

Expand Down Expand Up @@ -369,16 +379,15 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time
sendDeadline = tKickTrig + (uint64_t)(2 * COMMON_AHEADT); // data shall become true 1ms after trigger event

// if we are too late, reschedule message; this will happen in case there is no monitor signal from the electronics
if (getSysTime() > (sendDeadline - COMMON_AHEADT)) {
sendDeadline = getSysTime() + COMMON_AHEADT;
sysTime = getSysTime();
if (sysTime > (sendDeadline - COMMON_AHEADT)) {
sendDeadline = sysTime + COMMON_AHEADT;
status = B2B_STATUS_NOKICK; // ohps, too late!
} // if getSysTime

fwlib_ebmWriteTM(sendDeadline, sendEvtId, sendParam, 0, 0);

//fwlib_ioCtrlSetGate(0, 0); chk // disable input gates
//fwlib_ioCtrlSetGate(0, 3); chk

offsDone = sysTime - reqDeadline;
*pSharedGettKickDMon = dKickMon;
*pSharedGettKickDProbe = dKickProbe;
transStat = flagsError;
Expand All @@ -387,8 +396,12 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time
} // if flagSendMessage

// check for late event
if ((status == COMMON_STATUS_OK) && flagIsLate) status = B2B_STATUS_LATEMESSAGE;

// check for late event
if ((status == COMMON_STATUS_OK) && flagIsLate) {
status = B2B_STATUS_LATEMESSAGE;
nLate++;
} // if status

// check WR sync state
if (fwlib_wrCheckSyncState() == COMMON_STATUS_WRBADSYNC) return COMMON_STATUS_WRBADSYNC;
else return status;
Expand Down Expand Up @@ -453,7 +466,9 @@ int main(void) {
fwlib_publishStatusArray(statusArray);
pubState = actState;
fwlib_publishState(pubState);
fwlib_publishTransferStatus(nTransfer, 0x0, transStat);
if (comLatency > maxComLatency) maxComLatency = comLatency;
if (offsDone > maxOffsDone) maxOffsDone = offsDone;
fwlib_publishTransferStatus(nTransfer, 0x0, transStat, nLate, maxOffsDone, maxComLatency);
} // while

return(1); // this should never happen ...
Expand Down
14 changes: 5 additions & 9 deletions modules/b2b/fw/b2b-pm-stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* created : 2021
* author : Dietrich Beck, GSI-Darmstadt
* version : 23-Nov-2023
* version : 16-Aug-2024
*
* firmware required for measuring the h=1 phase for ring machine
*
Expand Down Expand Up @@ -38,7 +38,7 @@
* For all questions and ideas contact: [email protected]
* Last update: 15-April-2019
********************************************************************************************/
#define B2BPMSTUB_FW_VERSION 0x000703 // make this consistent with makefile
#define B2BPMSTUB_FW_VERSION 0x000800 // make this consistent with makefile

//standard includes
#include <stdio.h>
Expand Down Expand Up @@ -75,7 +75,6 @@ volatile uint32_t *pSharedGetSid; // pointer to a "user defined" u32 regis
volatile uint32_t *pSharedGetTH1Hi; // pointer to a "user defined" u32 register; here: period of h=1, high bits
volatile uint32_t *pSharedGetTH1Lo; // pointer to a "user defined" u32 register; here: period of h=1, low bits
volatile uint32_t *pSharedGetNH; // pointer to a "user defined" u32 register; here: harmonic number
volatile int32_t *pSharedGetComLatency;// pointer to a "user defined" u32 register; here: latency for messages received via ECA

uint32_t *cpuRamExternal; // external address (seen from host bridge) of this CPU's RAM

Expand Down Expand Up @@ -115,7 +114,6 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize)
pSharedGetTH1Hi = (uint32_t *)(pShared + (B2B_SHARED_GET_TH1EXTHI >> 2)); // for simplicity: use 'EXT' for data
pSharedGetTH1Lo = (uint32_t *)(pShared + (B2B_SHARED_GET_TH1EXTLO >> 2));
pSharedGetNH = (uint32_t *)(pShared + (B2B_SHARED_GET_NHEXT >> 2));
pSharedGetComLatency = (int32_t *)(pShared + (B2B_SHARED_GET_COMLATENCY >> 2));

// find address of CPU from external perspective
idx = 0;
Expand Down Expand Up @@ -209,7 +207,6 @@ uint32_t extern_entryActionOperation()
*pSharedGetNH = 0x0;
*pSharedGetGid = 0x0;
*pSharedGetSid = 0x0;
*pSharedGetComLatency = 0x0;

return COMMON_STATUS_OK;
} // extern_entryActionOperation
Expand Down Expand Up @@ -343,15 +340,15 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time

ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT * 1000, &recDeadline, &recEvtId, &recParam, &recTEF, &flagIsLate, &flagEarly, &flagConflict, &flagDelayed);

if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline);

switch (ecaAction) {
// the following two cases handle H=1 group DDS phase measurement
case B2B_ECADO_B2B_PMEXT : // this is an OR, no 'break' on purpose
sendEvtNo = B2B_ECADO_B2B_PREXT;
case B2B_ECADO_B2B_PMINJ :
if (!sendEvtNo) sendEvtNo = B2B_ECADO_B2B_PRINJ;

comLatency = (int32_t)(getSysTime() - recDeadline);

*pSharedGetTH1Hi = (uint32_t)((recParam >> 32) & 0x00ffffff); // lower 56 bit used as period
*pSharedGetTH1Lo = (uint32_t)( recParam & 0xffffffff);
*pSharedGetNH = (uint32_t)((recParam>> 56) & 0xff ); // upper 8 bit used as harmonic number
Expand Down Expand Up @@ -557,8 +554,7 @@ int main(void) {
fwlib_publishStatusArray(statusArray);
pubState = actState;
fwlib_publishState(pubState);
fwlib_publishTransferStatus(nTransfer, 0x0, transStat);
*pSharedGetComLatency = comLatency;
fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /* chk: set values of nLate and offsDone */
} // while

return(1); // this should never happen ...
Expand Down
Loading
Loading