Commit b3989149 authored by Evangelia Gousiou's avatar Evangelia Gousiou

folders restructure

parent a20a6565
Production Test Suite, automatized tests for OHWR boards.
Copyright (C) 2011 CERN
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This is Production Test Suite project.
Supporting automated hardware testing at BE/CO/HT
since 2011 or even less
License: GPL v2 or later
......@@ -6,14 +6,15 @@
# Website: http://www.ohwr.org
sudo rmmod cp210x
cd ~/fmc-tdc-1ns-5cha-tst
cd ~/fmc-tdc-1ns-5cha-tst/pts
sudo insmod ./cp210x-driver/cp210x.ko
cd usbdriver
sudo ./usbtmc_load
cd ..
cd ~/fmc-tdc-1ns-5cha-tst/pts
LOGDIR=./log_fmctdc1ns5cha_calib
LOGDIR=../logs/log_fmctdc1ns5cha_calib
mkdir -p $LOGDIR
sudo rm -fr $LOGDIR/fmc-tdc-1ns-5cha-tst*
......@@ -55,7 +56,7 @@ do
echo "Test series run $nb_test out of $nb_test_limit"
echo " "
sudo ./pts.py -b FmcTdc1ns5cha -s $serial -e $extra_serial -t./test/fmctdc1ns5cha/calibration/python -l $LOGDIR 02 03
sudo ./pts.py -b FmcTdc1ns5cha -s $serial -e $extra_serial -t ../test/fmctdc1ns5cha/calibration/python -l $LOGDIR 00 01 02 03
if [ "$nb_test" != "$nb_test_limit" ]
then
......
CFLAGS = -Wall -ggdb -I../kernel
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
ALL = rrcmd flip loadfile
all: $(ALL)
loadfile: load-main.o loader-ll.o
$(CC) $^ $(LDFLAGS) -o $@
loader-ll.o: ../kernel/loader-ll.c
$(CC) $(CFLAGS) $^ -c -o $@
clean:
rm -f $(ALL) *.o *~
/* Trivial.... */
#include <stdio.h>
int main(int argc, char **argv)
{
unsigned int c;
while ( (c = getchar()) != EOF)
putchar( 0
| ((c & 0x80) >> 7)
| ((c & 0x40) >> 5)
| ((c & 0x20) >> 3)
| ((c & 0x10) >> 1)
| ((c & 0x08) << 1)
| ((c & 0x04) << 3)
| ((c & 0x02) << 5)
| ((c & 0x01) << 7));
return 0;
}
/* Trivial frontend for the gennum loader (../kernel/loader-ll.c) */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include "rawrabbit.h"
#include "loader-ll.h"
#define DEVNAME "/dev/rawrabbit"
static char buf[64*1024*1024]; /* 64 MB binary? */
int main(int argc, char **argv)
{
int fd;
FILE *f;
int nbytes, rval;
if (argc != 2) {
fprintf(stderr, "%s: Use \"%s <firmware-file>\n",
argv[0], argv[0]);
exit(1);
}
f = fopen(argv[1], "r");
if (!f) {
fprintf(stderr, "%s: %s: %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
fd = open(DEVNAME, O_RDWR);
if (fd < 0) {
fprintf(stderr, "%s: %s: %s\n",
argv[0], DEVNAME, strerror(errno));
exit(1);
}
nbytes = fread(buf, 1, sizeof(buf), f);
fclose(f);
if (nbytes < 0) {
fprintf(stderr, "%s: %s: %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
printf("Programming %i bytes of binary gateware\n", nbytes);
rval = loader_low_level(fd, NULL, buf, nbytes);
if (rval < 0) {
fprintf(stderr, "%s: load_firmware: %s\n",
argv[0], strerror(-rval));
exit(1);
}
/* We must now wait for the "done" interrupt bit */
{
unsigned long t = time(NULL) + 3;
int i, done = 0;
struct rr_iocmd iocmd = {
.datasize = 4,
.address = FCL_IRQ | __RR_SET_BAR(4),
};
if (ioctl(fd, RR_READ, &iocmd) < 0) perror("ioctl");
while (time(NULL) < t) {
if (ioctl(fd, RR_READ, &iocmd) < 0) perror("ioctl");
i = iocmd.data32;
if (i & 0x8) {
done = 1;
break;
}
if (i & 0x4) {
fprintf(stderr,"Error after %i words\n", rval);
exit(1);
}
usleep(100*1000);
}
}
return 0;
}
/*
* User space frontend (command line) for the raw I/O interface
*
* Copyright (C) 2010 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*
* This work is part of the White Rabbit project, a research effort led
* by CERN, the European Institute for Nuclear Research.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include "rawrabbit.h"
#define DEVNAME "/dev/rawrabbit"
char *prgname;
void help(void)
{
fprintf(stderr, "%s: use like this (all numbers are hex):\n"
" %s [<vendor:device>[/<subvendor>:<subdev>]"
"[@<bus>:<devfn>]] <cmd>\n", prgname, prgname);
fprintf(stderr, " <cmd> = info\n");
fprintf(stderr, " <cmd> = irqwait\n");
fprintf(stderr, " <cmd> = irqena\n");
fprintf(stderr, " <cmd> = getdmasize\n");
fprintf(stderr, " <cmd> = getplist\n");
fprintf(stderr, " <cmd> = r[<sz>] <bar>:<addr>\n");
fprintf(stderr, " <cmd> = w[<sz>] <bar>:<addr> <val>\n");
fprintf(stderr, " <sz> = 1, 2, 4, 8 (default = 4)\n");
fprintf(stderr, " <bar> = 0, 2, 4, c (c == dma buffer)\n");
exit(1);
}
int parse_devsel(int fd, char *arg)
{
struct rr_devsel devsel;
int n;
devsel.subvendor = RR_DEVSEL_UNUSED;
devsel.bus = RR_DEVSEL_UNUSED;
if (strlen(arg) > 32) /* to prevent overflow with strtol */
return -EINVAL;
n = sscanf(arg, "%hx:%hx/%hx:%hx@%hx:%hx",
&devsel.vendor, &devsel.device,
&devsel.subvendor, &devsel.subdevice,
&devsel.bus, &devsel.devfn);
switch(n) {
case 6: /* all info */
case 4: /* id/subid but no busdev */
break;
case 2:
/* check if bus/dev is there */
n = sscanf(arg, "%hx:%hx@%hx:%hx",
&devsel.vendor, &devsel.device,
&devsel.bus, &devsel.devfn);
if (n == 4 || n == 2)
break;
/* fall through */
default:
printf("%s: can't parse \"%s\"\n", prgname, arg);
return -EINVAL;
}
/* Now try to do the change */
if (ioctl(fd, RR_DEVSEL, &devsel) < 0) {
fprintf(stderr, "%s: %s: ioctl(DEVSEL): %s\n", prgname, DEVNAME,
strerror(errno));
return -EIO;
}
return 0;
}
int do_iocmd(int fd, char *cmdname, char *addr, char *datum)
{
char rest[32];
struct rr_iocmd iocmd;
int i, ret;
unsigned bar;
__u64 d;
char cmd;
if (strlen(cmdname) >= sizeof(rest))
return -EINVAL;
if (strlen(addr) >= sizeof(rest))
return -EINVAL;
if (datum && strlen(addr) >= sizeof(rest))
return -EINVAL;
/* parse command and size */
i = sscanf(cmdname, "%c%i%s\n", &cmd, &iocmd.datasize, rest);
if (cmd != 'r' && cmd != 'w')
return -EINVAL;
if (i == 3)
return -EINVAL;
if (i == 1)
iocmd.datasize = 4;
/* parse address */
i = sscanf(addr, "%x:%x%s", &bar, &iocmd.address, rest);
if (i != 2)
return -EINVAL;
iocmd.address |= __RR_SET_BAR(bar);
if (!rr_is_valid_bar(iocmd.address))
return -EINVAL;
/* parse datum */
if (datum) {
i = sscanf(datum, "%llx%s", &d, rest);
if (i == 2)
return -EINVAL;
switch(iocmd.datasize) {
case 1:
iocmd.data8 = d;
break;
case 2:
iocmd.data16 = d;
break;
case 4:
iocmd.data32 = d;
break;
case 8:
iocmd.data64 = d;
break;
default:
return -EINVAL;
}
}
if (datum)
ret = ioctl(fd, RR_WRITE, &iocmd);
else
ret = ioctl(fd, RR_READ, &iocmd);
if (ret < 0)
return -errno;
if (!datum && !ret) {
switch(iocmd.datasize) {
case 1:
printf("0x%02x\n", (unsigned int)iocmd.data8);
break;
case 2:
printf("0x%04x\n", (unsigned int)iocmd.data16);
break;
case 4:
printf("0x%08lx\n", (unsigned long)iocmd.data32);
break;
case 8:
printf("0x%016llx\n", (unsigned long long)iocmd.data64);
break;
default:
return -EINVAL;
}
}
return ret;
}
int do_getplist(int fd)
{
uintptr_t plist[RR_PLIST_LEN];
int i, size;
size = ioctl(fd, RR_GETDMASIZE);
if (size < 0)
return -errno;
i = ioctl(fd, RR_GETPLIST, plist);
if (i < 0)
return -errno;
for (i = 0; i < size/RR_PLIST_SIZE; i++)
printf("buf 0x%08x: pfn 0x%08x, addr 0x%012llx\n",
i * RR_PLIST_SIZE, plist[i],
(unsigned long long)plist[i] << 12);
return 0;
}
int main(int argc, char **argv)
{
struct rr_devsel devsel;
int fd, ret = -EINVAL;
prgname = argv[0];
fd = open(DEVNAME, O_RDWR);
if (fd < 0) {
fprintf(stderr, "%s: %s: %s\n", prgname, DEVNAME,
strerror(errno));
exit(1);
}
/* parse argv[1] for devsel */
if (argc > 1 && strchr(argv[1], ':')) {
ret = parse_devsel(fd, argv[1]);
if (!ret) {
argc--, argv++;
}
}
if (argc > 1 && !strcmp(argv[1], "info")) {
if (ioctl(fd, RR_DEVGET, &devsel) < 0) {
if (errno == ENODEV) {
printf("%s: not bound\n", DEVNAME);
exit(0);
}
fprintf(stderr, "%s: %s: ioctl(DEVGET): %s\n", prgname,
DEVNAME, strerror(errno));
exit(1);
}
printf("%s: bound to %04x:%04x/%04x:%04x@%04x:%04x\n", DEVNAME,
devsel.vendor, devsel.device,
devsel.subvendor, devsel.subdevice,
devsel.bus, devsel.devfn);
ret = 0;
} else if (argc > 1 && !strcmp(argv[1], "irqwait")) {
ret = ioctl(fd, RR_IRQWAIT);
if (ret < 0)
fprintf(stderr, "%s: ioctl(IRQWAIT): %s\n", argv[0],
strerror(errno));
} else if (argc > 1 && !strcmp(argv[1], "irqena")) {
ret = ioctl(fd, RR_IRQENA);
if (ret < 0) {
fprintf(stderr, "%s: ioctl(IRQENA): %s\n", argv[0],
strerror(errno));
} else {
printf("delay: %i ns\n", ret);
ret = 0;
}
} else if (argc > 1 && !strcmp(argv[1], "getdmasize")) {
ret = ioctl(fd, RR_GETDMASIZE);
printf("dmasize: %i (0x%x -- %g MB)\n", ret, ret,
ret / (double)(1024*1024));
ret = 0;
} else if (argc > 1 && !strcmp(argv[1], "getplist")) {
ret = do_getplist(fd);
} else if (argc == 3 || argc == 4) {
ret = do_iocmd(fd, argv[1], argv[2], argv[3] /* may be NULL */);
} else if (argc > 4) {
ret = -EINVAL;
}
/* subroutines return "invalid argument" to ask for help */
if (ret == -EINVAL)
help();
if (ret) {
fprintf(stderr, "%s: command returned \"%s\"\n", prgname,
strerror(errno));
exit(1);
}
return 0;
}
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
MODULE_INFO(vermagic, VERMAGIC_STRING);
struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
static const struct modversion_info ____versions[]
__used
__attribute__((section("__versions"))) = {
{ 0x35ec255d, "module_layout" },
{ 0x985f683d, "usb_deregister" },
{ 0x7485e15e, "unregister_chrdev_region" },
{ 0x4f99f09f, "usb_register_driver" },
{ 0x29537c9e, "alloc_chrdev_region" },
{ 0x95aaa356, "usb_reset_configuration" },
{ 0xd0d8621b, "strlen" },
{ 0x91715312, "sprintf" },
{ 0x2f287f0d, "copy_to_user" },
{ 0x362ef408, "_copy_from_user" },
{ 0x89b5c527, "usb_bulk_msg" },
{ 0x64d0da33, "usb_control_msg" },
{ 0x93d085b2, "dev_set_drvdata" },
{ 0xebd5feb1, "cdev_add" },
{ 0xb2c831b6, "cdev_init" },
{ 0x50eedeb8, "printk" },
{ 0x41ad0272, "kmem_cache_alloc_trace" },
{ 0xcea0a119, "kmalloc_caches" },
{ 0x15ff4409, "usb_get_dev" },
{ 0x2f35ab80, "cdev_del" },
{ 0xddffa24, "dev_get_drvdata" },
{ 0x37a0cba, "kfree" },
{ 0xb4390f9a, "mcount" },
};
static const char __module_depends[]
__used
__attribute__((section(".modinfo"))) =
"depends=";
MODULE_INFO(srcversion, "F441DD0E780FE4FB5D2A150");
#!/bin/bash
module="usbtmc"
# Remove module from kernel (just in case it is still running)
/sbin/rmmod $module 2> /dev/null
# Install module
#/sbin/insmod /home/user/pts_fmcfd/pts/usbdriver/$module.ko
/sbin/insmod /home/user/fmc-tdc-1ns-5cha-tst/pts/usbdriver/$module.ko 2> /dev/null
# Find major number used
major=$(cat /proc/devices | grep USBTMCCHR | awk '{print $1}')
#echo Using major number $major
# Remove old device files
rm -f /dev/${module}[0-9]
# Ceate new device files
mknod /dev/${module}0 c $major 0
mknod /dev/${module}1 c $major 1
mknod /dev/${module}2 c $major 2
mknod /dev/${module}3 c $major 3
mknod /dev/${module}4 c $major 4
mknod /dev/${module}5 c $major 5
mknod /dev/${module}6 c $major 6
mknod /dev/${module}7 c $major 7
mknod /dev/${module}8 c $major 8
mknod /dev/${module}9 c $major 9
# Change access mode
chmod 666 /dev/${module}0
chmod 666 /dev/${module}1
chmod 666 /dev/${module}2
chmod 666 /dev/${module}3
chmod 666 /dev/${module}4
chmod 666 /dev/${module}5
chmod 666 /dev/${module}6
chmod 666 /dev/${module}7
chmod 666 /dev/${module}8
chmod 666 /dev/${module}9
......@@ -83,11 +83,11 @@ import math
from datetime import datetime
# Add common modules location tp path
sys.path.append('../../../../')
sys.path.append('../../../../gnurabbit/python/')
sys.path.append('../../../../common/')
sys.path.append('../../../../common/usb_box')
sys.path.append('../../../../common/cp210x')
sys.path.append('../../../../pts/')
sys.path.append('../../../../pts/gnurabbit/python/')
sys.path.append('../../../../pts/common/')
sys.path.append('../../../../pts/common/usb_box')
sys.path.append('../../../../pts/common/cp210x')
# Import common modules
......@@ -161,7 +161,7 @@ def main (default_directory='.'):
# Constants declaration
FMC_TDC_ADDR = '1a39:0004/1a39:0004@000B:0000'
FMC_TDC_BITSTREAM_PATH = '../firmwares/tdc.bin'
FPGA_LOADER_PATH = '../../../../gnurabbit/user/fpga_loader'
FPGA_LOADER_PATH = '../../../../pts/gnurabbit/user/fpga_loader'
DAC_CALIBR_FILENAME = "DAC_calib_data.txt"
......
......@@ -59,11 +59,11 @@ from ctypes import *
from datetime import datetime
# Add common modules location tp path
sys.path.append('../../../../')
sys.path.append('../../../../gnurabbit/python/')
sys.path.append('../../../../common/')
sys.path.append('../../../../common/usb_box')
sys.path.append('../../../../common/cp210x')
sys.path.append('../../../../pts/')
sys.path.append('../../../../pts/gnurabbit/python/')
sys.path.append('../../../../pts/common/')
sys.path.append('../../../../pts/common/usb_box')
sys.path.append('../../../../pts/common/cp210x')
# Import common modules
......@@ -107,7 +107,7 @@ def main (default_directory='.'):
# Constants declaration
FMC_TDC_ADDR = '1a39:0004/1a39:0004@000B:0000'
FMC_TDC_BITSTREAM_PATH = '../firmwares/tdc.bin'
FPGA_LOADER_PATH = '../../../../gnurabbit/user/fpga_loader'
FPGA_LOADER_PATH = '../../../../pts/gnurabbit/user/fpga_loader'
CH_CALIBR_FILENAME = "ch_calib_data.txt"
CH_CALIBR_FILENAME = os.path.join(default_directory, CH_CALIBR_FILENAME)
......
......@@ -55,11 +55,11 @@ from ctypes import *
from datetime import datetime
# Add common modules location tp path
sys.path.append('../../../../')
sys.path.append('../../../../gnurabbit/python/')
sys.path.append('../../../../common/')
sys.path.append('../../../../common/usb_box')
sys.path.append('../../../../common/cp210x')
sys.path.append('../../../../pts/')
sys.path.append('../../../../pts/gnurabbit/python/')
sys.path.append('../../../../pts/common/')
sys.path.append('../../../../pts/common/usb_box')
sys.path.append('../../../../pts/common/cp210x')
......@@ -118,7 +118,7 @@ def main (default_directory='.'):
# Constants declaration
FMC_TDC_ADDR = '1a39:0004/1a39:0004@000B:0000'
FMC_TDC_BITSTREAM_PATH = '../firmwares/tdc.bin'
FPGA_LOADER_PATH = '../../../../gnurabbit/user/fpga_loader'
FPGA_LOADER_PATH = '../../../../pts/gnurabbit/user/fpga_loader'
CALIBR_BIN_FILENAME = "calib_data.bin"
CALIBR_BIN_FILENAME = os.path.join(default_directory, CALIBR_BIN_FILENAME)
......
......@@ -47,10 +47,10 @@ import os
import numpy as np
# Add common modules and libraries location to path
sys.path.append('../../../../')
sys.path.append('../../../../gnurabbit/python/')
sys.path.append('../../../../common/')
sys.path.append('../../../../common/fmceeprom/python')
sys.path.append('../../../../pts/')
sys.path.append('../../../../pts/gnurabbit/python/')
sys.path.append('../../../../pts/common/')
sys.path.append('../../../../pts/common/fmceeprom/python')
# Import common modules
from ptsexcept import *
......@@ -68,7 +68,7 @@ def main (default_directory='.'):
PRODUCT_NAME = "FmcTdc1ns5cha"
PART_NUMBER = "EDA-02290-V3-0"
NAME = 'tdc_1ns_5cha'
SERIAL_FILENAME = "../../../../serial.txt"
SERIAL_FILENAME = "../../../../pts/serial.txt"
SERIAL_FILENAME = os.path.join(default_directory, SERIAL_FILENAME)
CH_CALIBR_FILENAME = "ch_calib_data.txt"
CH_CALIBR_FILENAME = os.path.join(default_directory, CH_CALIBR_FILENAME)
......@@ -89,7 +89,7 @@ def main (default_directory='.'):
# Constants declaration
FMC_TDC_ADDR = '1a39:0004/1a39:0004@000B:0000'
FMC_TDC_BITSTREAM_PATH = '../firmwares/tdc.bin'
FPGA_LOADER_PATH = '../../../../gnurabbit/user/fpga_loader'
FPGA_LOADER_PATH = '../../../../pts/gnurabbit/user/fpga_loader'
# SPEC object declaration
spec = rr.Gennum()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment