mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-30 01:40:04 +02:00
changed fifo_data address, made fifo related stuff volatile, changed makefile to incorporate compiling image and program simultaneously
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@138 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
7c07ae5a5a
commit
c2846e72e7
@ -5,16 +5,10 @@
|
|||||||
|
|
||||||
CROSS = bfin-uclinux-
|
CROSS = bfin-uclinux-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
|
|
||||||
CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE -DVERYVERBOSE #-DVIRTUAL
|
CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE -DVERYVERBOSE #-DVIRTUAL
|
||||||
|
|
||||||
#INCLUDES= /usr/src/kernels/2.6.18-238.12.1.el5-i686/include
|
|
||||||
#/home/l_maliakal_d/bfin/blackfin-linux-dist/linux-2.6.x/include
|
|
||||||
#/usr/include/asm/page.h
|
|
||||||
|
|
||||||
|
|
||||||
PROGS= gotthardDetectorServer
|
PROGS= gotthardDetectorServer
|
||||||
|
|
||||||
INSTDIR= /tftpboot
|
INSTDIR= /tftpboot
|
||||||
INSTMODE= 0777
|
INSTMODE= 0777
|
||||||
|
|
||||||
@ -25,9 +19,6 @@ SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.
|
|||||||
OBJS = $(SRCS:%.c=%.o)
|
OBJS = $(SRCS:%.c=%.o)
|
||||||
|
|
||||||
|
|
||||||
#LDLIBS+= -lm
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: clean $(PROGS)
|
all: clean $(PROGS)
|
||||||
|
|
||||||
@ -35,7 +26,7 @@ boot: $(OBJS)
|
|||||||
|
|
||||||
$(PROGS): $(OBJS)
|
$(PROGS): $(OBJS)
|
||||||
echo $(OBJS)
|
echo $(OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||||
|
|
||||||
|
|
||||||
install: $(PROGS)
|
install: $(PROGS)
|
||||||
@ -43,14 +34,11 @@ install: $(PROGS)
|
|||||||
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
|
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
|
||||||
|
|
||||||
|
|
||||||
#CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS
|
romfs:
|
||||||
#-DVERBOSE
|
$(ROMFSINST) /bin/$(PROGS)
|
||||||
#-DVERYVERBOSE
|
|
||||||
#-Werror
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(PROGS) *.o
|
rm -rf $(PROGS) *.o *.gdb
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "communication_funcs.h"
|
#include "communication_funcs.h"
|
||||||
//#include <sys/socket.h>
|
//#include <sys/socket.h>
|
||||||
#include <netinet/tcp.h> /* for TCP_NODELAY */
|
#include <netinet/tcp.h> /* for TCP_NODELAY */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -209,7 +209,7 @@ void exitServer(int socketDescriptor) {
|
|||||||
int sendDataOnly(int file_des, void* buf,int length) {
|
int sendDataOnly(int file_des, void* buf,int length) {
|
||||||
|
|
||||||
|
|
||||||
return write(file_des, buf, length);
|
return write(file_des, buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include </opt/uClinux/bfin-linux-uclibc/bfin-linux-uclibc/runtime/usr/include/bfin_sram.h>
|
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <sched.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ FILE *debugfp, *datafp;
|
|||||||
int fr;
|
int fr;
|
||||||
int wait_time;
|
int wait_time;
|
||||||
int *fifocntrl;
|
int *fifocntrl;
|
||||||
int *values;
|
volatile const u_int16_t *values;
|
||||||
//int *statusreg; commented out by dhanya
|
//int *statusreg; commented out by dhanya
|
||||||
const int nModY=1;
|
const int nModY=1;
|
||||||
int nModBoard;
|
int nModBoard;
|
||||||
@ -36,8 +37,8 @@ int nModX=NMAXMOD;
|
|||||||
int dynamicRange=16;//32;
|
int dynamicRange=16;//32;
|
||||||
int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
||||||
int storeInRAM=0;
|
int storeInRAM=0;
|
||||||
int *ram_values=NULL;
|
volatile u_int32_t *ram_values=NULL;
|
||||||
char *now_ptr=NULL;
|
volatile char *now_ptr=NULL;
|
||||||
int ram_size=0;
|
int ram_size=0;
|
||||||
|
|
||||||
int64_t totalTime=1;
|
int64_t totalTime=1;
|
||||||
@ -190,13 +191,13 @@ int mapCSP0(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u_int16_t bus_r16(u_int32_t offset){
|
u_int16_t bus_r16(u_int32_t offset){
|
||||||
u_int16_t *ptr1;
|
volatile u_int16_t *ptr1;
|
||||||
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
||||||
return *ptr1;
|
return *ptr1;
|
||||||
}
|
}
|
||||||
//aldos function volatile (not needed)
|
//aldos function volatile (not needed)
|
||||||
u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
||||||
u_int16_t *ptr1;
|
volatile u_int16_t *ptr1;
|
||||||
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
||||||
// printf("writing at 0x%x data 0x%x %d%d%d\n",CSP0BASE+offset*2,data, (data>>2)&0x1,(data>>1)&0x1 ,(data>>0)&0x1);
|
// printf("writing at 0x%x data 0x%x %d%d%d\n",CSP0BASE+offset*2,data, (data>>2)&0x1,(data>>1)&0x1 ,(data>>0)&0x1);
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
|||||||
|
|
||||||
|
|
||||||
u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
|
u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
|
||||||
u_int32_t *ptr1;
|
volatile u_int32_t *ptr1;
|
||||||
|
|
||||||
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
||||||
*ptr1=data;
|
*ptr1=data;
|
||||||
@ -216,7 +217,7 @@ u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
|
|||||||
|
|
||||||
|
|
||||||
u_int32_t bus_r(u_int32_t offset) {
|
u_int32_t bus_r(u_int32_t offset) {
|
||||||
u_int32_t *ptr1;
|
volatile u_int32_t *ptr1;
|
||||||
|
|
||||||
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
||||||
return *ptr1;
|
return *ptr1;
|
||||||
@ -525,7 +526,7 @@ u_int32_t getMcsVersion() {
|
|||||||
// for fpga test
|
// for fpga test
|
||||||
u_int32_t testFpga(void) {
|
u_int32_t testFpga(void) {
|
||||||
printf("Test FPGA:\n");
|
printf("Test FPGA:\n");
|
||||||
u_int32_t val,addr;
|
volatile u_int32_t val,addr,val2;
|
||||||
int result=OK,i;
|
int result=OK,i;
|
||||||
//fixed pattern
|
//fixed pattern
|
||||||
val=bus_r(FIX_PATT_REG);
|
val=bus_r(FIX_PATT_REG);
|
||||||
@ -543,9 +544,12 @@ u_int32_t testFpga(void) {
|
|||||||
printf("FPGA version too old! %06x\n",val);
|
printf("FPGA version too old! %06x\n",val);
|
||||||
result= FAIL;
|
result= FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//dummy register
|
//dummy register
|
||||||
addr = DUMMY_REG;
|
addr = DUMMY_REG;
|
||||||
for(i=0;i<100;i++)
|
for(i=0;i<1000000;i++)
|
||||||
{
|
{
|
||||||
val=0x5A5A5A5A-i;
|
val=0x5A5A5A5A-i;
|
||||||
bus_w(addr, val);
|
bus_w(addr, val);
|
||||||
@ -554,6 +558,13 @@ u_int32_t testFpga(void) {
|
|||||||
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of %x \n",i,val,0x5A5A5A5A-i);
|
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of %x \n",i,val,0x5A5A5A5A-i);
|
||||||
result=FAIL;
|
result=FAIL;
|
||||||
}
|
}
|
||||||
|
val=(i+(i<<10)+(i<<20));
|
||||||
|
bus_w(addr, val);
|
||||||
|
val2=bus_r(addr);
|
||||||
|
if (val2!=val) {
|
||||||
|
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! read %x instead of %x.\n",i,val2,val);
|
||||||
|
result=FAIL;
|
||||||
|
}
|
||||||
val=0x0F0F0F0F;
|
val=0x0F0F0F0F;
|
||||||
bus_w(addr, val);
|
bus_w(addr, val);
|
||||||
val=bus_r(addr);
|
val=bus_r(addr);
|
||||||
@ -562,8 +573,8 @@ u_int32_t testFpga(void) {
|
|||||||
result=FAIL;
|
result=FAIL;
|
||||||
}
|
}
|
||||||
val=0xF0F0F0F0;
|
val=0xF0F0F0F0;
|
||||||
bus_w(DUMMY_REG, val);
|
bus_w(addr, val);
|
||||||
val=bus_r(DUMMY_REG);
|
val=bus_r(addr);
|
||||||
if (val!=0xF0F0F0F0) {
|
if (val!=0xF0F0F0F0) {
|
||||||
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of 0xF0F0F0F0 \n\n",i,val);
|
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of 0xF0F0F0F0 \n\n",i,val);
|
||||||
result=FAIL;
|
result=FAIL;
|
||||||
@ -572,7 +583,7 @@ u_int32_t testFpga(void) {
|
|||||||
if(result==OK)
|
if(result==OK)
|
||||||
{
|
{
|
||||||
printf("----------------------------------------------------------------------------------------------");
|
printf("----------------------------------------------------------------------------------------------");
|
||||||
printf("\nATTEMPT 100: FPGA DUMMY REGISTER OK!!\n");
|
printf("\nATTEMPT 1000000: FPGA DUMMY REGISTER OK!!!\n");
|
||||||
printf("----------------------------------------------------------------------------------------------\n");
|
printf("----------------------------------------------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -1451,12 +1462,31 @@ u_int32_t* fifo_read_event()
|
|||||||
#endif
|
#endif
|
||||||
dma_memcpy(now_ptr,values ,dataBytes);
|
dma_memcpy(now_ptr,values ,dataBytes);
|
||||||
|
|
||||||
|
//memcpy(now_ptr,values ,dataBytes);
|
||||||
|
/* struct timeval t1,t2;
|
||||||
|
long long t;
|
||||||
|
gettimeofday(&t1,NULL);
|
||||||
|
if(geteuid()==0){
|
||||||
|
struct sched_param sp;
|
||||||
|
memset(&sp,0,sizeof(sp));
|
||||||
|
sp.sched_priority= sched_get_priority_max(SCHED_FIFO);
|
||||||
|
sched_setscheduler(0,SCHED_FIFO,&sp);
|
||||||
|
mlockall(MCL_CURRENT | MCL_FUTURE);
|
||||||
|
}
|
||||||
|
gettimeofday(&t2,NULL);
|
||||||
|
memmove(now_ptr,values ,dataBytes);
|
||||||
|
t = ((t2.tv_sec * 1000000) + t2.tv_usec) - ((t1.tv_sec * 1000000) + t1.tv_usec);
|
||||||
|
printf("\n*********Call took %lld us*******\n", t);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
printf("\n x%08x\n",now_ptr);
|
|
||||||
int a;
|
int a;
|
||||||
for (a=0;a<10; a=a+2)
|
for (a=0;a<8; a=a+2)
|
||||||
printf("\n%d: x%04x",a,now_ptr[a]);
|
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
||||||
printf("\n");
|
for (a=2554;a<2560; a=a+2)
|
||||||
|
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
||||||
|
printf("********\n");
|
||||||
//memcpy(now_ptr, values, dataBytes);
|
//memcpy(now_ptr, values, dataBytes);
|
||||||
#endif
|
#endif
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
//FIFO
|
//FIFO
|
||||||
#define LOOK_AT_ME_REG 0x28<<11
|
#define LOOK_AT_ME_REG 0x28<<11
|
||||||
|
|
||||||
#define FIFO_DATA_REG_OFF 0x80<<11 ///////
|
#define FIFO_DATA_REG_OFF 0x50<<11 ///////
|
||||||
|
|
||||||
|
|
||||||
//to read back dac registers
|
//to read back dac registers
|
||||||
|
@ -10,12 +10,13 @@
|
|||||||
#include "trimming_funcs.h"
|
#include "trimming_funcs.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
|
|
||||||
int (*flist[256])(int);
|
int (*flist[256])(int);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
#endif
|
#endif
|
||||||
@ -34,7 +35,7 @@ extern char thisClientIP[INET_ADDRSTRLEN];
|
|||||||
extern int differentClients;
|
extern int differentClients;
|
||||||
|
|
||||||
/* global variables for optimized readout */
|
/* global variables for optimized readout */
|
||||||
extern int *ram_values;
|
extern unsigned int *ram_values;
|
||||||
char *dataretval=NULL;
|
char *dataretval=NULL;
|
||||||
int nframes, iframes, dataret;
|
int nframes, iframes, dataret;
|
||||||
char mess[1000];
|
char mess[1000];
|
||||||
@ -68,7 +69,7 @@ int init_detector( int b) {
|
|||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
if (b) {
|
if (b) {
|
||||||
initDetector();
|
initDetector();
|
||||||
printf("\ninitdetector done! \n");
|
printf("\n----initdetector done! new serverRdRR\n\n");
|
||||||
testFpga();
|
testFpga();
|
||||||
testRAM();
|
testRAM();
|
||||||
|
|
||||||
@ -846,7 +847,7 @@ int read_register(int file_des) {
|
|||||||
|
|
||||||
if(ret!=FAIL){
|
if(ret!=FAIL){
|
||||||
address=(addr<<11);
|
address=(addr<<11);
|
||||||
if(addr==0x80)
|
if(addr==0x50)
|
||||||
retval=bus_r16(address);
|
retval=bus_r16(address);
|
||||||
else
|
else
|
||||||
retval=bus_r(address);
|
retval=bus_r(address);
|
||||||
@ -1931,7 +1932,7 @@ int read_frame(int file_des) {
|
|||||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||||
sendDataOnly(file_des,dataretval,dataBytes);
|
sendDataOnly(file_des,dataretval,dataBytes);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("sent %d bytes\n",dataBytes);
|
printf("sent %d bytes \n",dataBytes);
|
||||||
#endif
|
#endif
|
||||||
printf("dataret OK\n");
|
printf("dataret OK\n");
|
||||||
return OK;
|
return OK;
|
||||||
@ -2007,15 +2008,13 @@ int read_frame(int file_des) {
|
|||||||
|
|
||||||
int read_all(int file_des) {
|
int read_all(int file_des) {
|
||||||
|
|
||||||
|
while(read_frame(file_des)==OK) {
|
||||||
while(read_frame(file_des)==OK) {
|
|
||||||
//usleep(0);
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("frame read\n");
|
printf("frame read\n");
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Frames finished\n");
|
printf("Frames finished\n");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user