Browse Source

Add HEB scripts and re-organize the structure

Suren A. Chilingaryan 10 years ago
parent
commit
ef4f563559

+ 2 - 0
apps/CMakeLists.txt

@@ -11,3 +11,5 @@ add_executable(pio_test pio_test.c)
 target_link_libraries(pio_test pcilib rt)
 
 add_executable(compare_to_value compare_to_value.c)
+
+add_executable(heb_strip_bad_values heb_strip_bad_values.c)

+ 98 - 0
apps/heb_strip_bad_values.c

@@ -0,0 +1,98 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int main(int argc, char *argv[]) {
+    long i, num;
+    size_t count = 0, total = 0, size;
+    int offset = 3, toread = 1, toskip = 3;
+    uint32_t value;
+    uint32_t *buf;
+    uint32_t expected = 0;
+    uint32_t blocks = 0, status_good = 0;
+    
+    char fixed[4096];
+    struct stat st_buf;
+    
+    if ((argc != 2)&&(argc != 5)) {
+	printf("Usage: %s <file> [offset_dwords read_dwords skip_dwords] \n", argv[0]);
+	exit(0);
+    }
+    
+    FILE *f = fopen(argv[1], "r");
+    if (!f) {
+	printf("Can't open %s\n", argv[1]);
+	exit(1);
+    }
+
+    stat(argv[1], &st_buf);
+    size = st_buf.st_size / sizeof(uint32_t);
+
+
+    buf = malloc(size * sizeof(uint32_t));
+    if (!buf) {
+	printf("Can't allocate %lu bytes of memory\n", size * sizeof(uint32_t));
+	exit(1);
+    }
+    
+    if (argc == 5) {
+	offset = atoi(argv[2]);
+	toread = atoi(argv[3]);
+	toskip = atoi(argv[4]);
+    }
+    
+
+    num = fread(buf, 4, size, f);
+    if (num != size) {
+	printf("Failed to read %lu dwords, only %lu read\n", size, num);
+	exit(1);
+    }
+    fclose(f);
+    
+    sprintf(fixed, "%s.fixed", argv[1]);
+    f = fopen(fixed, "w");
+    if (!f) {
+	printf("Failed to open %s for output\n", fixed);
+	exit(1);
+    }
+    
+    expected = (buf[offset]>>24) + 2;
+    for (i = 1; i < size; i += (toread + toskip)) {
+	total++;
+	    
+	value = buf[i + offset] >> 24;
+//	printf("0x%lx: value (%lx) = expected (%lx)\n", i + offset, value, expected);
+	if (value == expected) {
+	    if (!status_good) {
+		status_good = 1;
+		blocks++;
+	    }
+	    fwrite(&buf[i], 4, toread + toskip, f);
+	    expected += 2;
+	    if (expected == 0xb8) 
+		expected = 0;
+	} else if ((!status_good)&&(value == 0)&&((i + toread + toskip)< size)) {
+	    value = buf[i + offset + toread + toskip] >> 24;
+	    if (value == 2) {
+		status_good = 1;
+		blocks++;
+		fwrite(&buf[i], 4, toread + toskip, f);
+		expected = 2;
+	    } else {
+		count++;
+	    }
+	} else {
+	    printf("0x%lx: value (%x) = expected (%x)\n", (i + offset)*sizeof(uint32_t), value, expected);
+	    status_good = 0;
+	    count++;
+	}
+    }
+    fclose(f);
+    free(buf);
+    
+    printf("%lu of %lu is wrong\n", count, total);
+    return 0;
+}

+ 19 - 0
tests/dma/debug/test-iommu.sh

@@ -0,0 +1,19 @@
+#! /bin/bash
+
+i=1
+while [ 1 ]; do
+    pci --start-dma dma1r
+    for name in /sys/class/fpga/fpga0/kbuf*; do
+	bus_addr=0x`cat $name | grep "bus addr" | cut -d ':' -f 2 | sed -e 's/\s\+//g'`
+	if [ $((bus_addr % 4096)) -ne 0 ]; then
+	    
+	    echo "Failed at iteration $i, $name"
+	    echo "----------------------"
+	    cat $name
+	    exit
+	fi
+
+    done
+    pci  --stop-dma dma1r
+    i=$((i + 1))
+done

+ 0 - 0
tests/bench_nwl.sh → tests/dma/nwl/bench.sh


+ 0 - 0
tests/cleanup.sh → tests/dma/nwl/cleanup.sh


+ 0 - 0
tests/xilinx_dma.sh → tests/dma/xilinx/xilinx_dma.sh


+ 0 - 37
tests/frame2.sh

@@ -1,37 +0,0 @@
-#!/bin/bash
-
-function pci {
-    PCILIB_PATH="/root/pcitool"
-    LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
-}
-
-pci --stop-dma dma1
-#pci --reset
-
-echo "Set packet size 1024 .. "
-pci -w cmosis_number_lines 1088
-#pci -w xrawdata_packet_length 4096
-pci --start-dma dma1
-usleep 1000
-
-echo "Send frame request ... "
-pci -w control 1e9
-usleep 1000
-pci -w control 1e1
-usleep 300000
-pci -w control 1e9
-usleep 1000
-pci -w control 1e1
-usleep 3000
-
-echo "Enable Readout ... "
-pci -w control 3e1
-
-usleep 100000
-
-pci -r dma1 -o bench.out --multipacket --timeout 1000000
-
-pci -w control 1e1
-
-pci --stop-dma dma1
-

+ 96 - 0
tests/heb/DataTaking.sh

@@ -0,0 +1,96 @@
+#!/bin/bash
+
+#Channel 1 --> 05
+#Channel 2 --> 0B
+#Channel 1&2 --> 0F
+#Channel 3 --> 13
+#Channel 4 --> 23
+#Channel 3&4 --> 33
+#ALL --> 3F
+
+#rm *.out
+pci -r dma1 --multipacket -o /dev/null
+
+echo "Start DMA ..... "
+#pci --start-dma dma1
+sleep 0.2
+
+echo "Data Reset ... "
+pci -w 0x9040 000003f1 
+sleep 0.1
+pci -w 0x9040 000003f0 
+
+sleep 0.1
+#echo "Pilot bunch emulator ..... "
+#pci -w 0x9040 400003f0 
+sleep 0.2
+pci -w 0x9040 03f0 
+#pci -r 0x9000 -s 40
+#sleep 0.2
+echo "Start data pci. ..... "
+pci -w 0x9040 00bf0 
+
+sleep 2
+
+echo "Stop data acquis...... "
+pci -w 0x9040 003f0 
+pci -r 0x9000 -s 40
+sleep 0.1
+echo "Enable data transfer.... "
+pci -w 0x9040 007f0 
+exit
+sleep 2
+pci -r dma1 -o run_num_$1.out --multipacket
+sleep 2
+
+pci -w 0x9040 003f0 
+#echo "Status ... "
+
+
+
+pci -r 0x9000 -s 40
+
+   status=`pci -r 0x9050 -s 1 | awk '{print $2$3$4}'`
+    if [ "$status" != "85000021" ]; then
+       echo "--------------------------------->>>> ERROR! ... "
+       error=1
+       exit
+    else 
+       echo " Status 1 -> OK "	
+    fi	
+	
+   status=`pci -r 0x9000 -s 1 | awk '{print $2$3$4}'`
+    if [ "$status" != "01000021" ]; then
+       echo "--------------------------------->>>> ERROR! ... "
+       error=1
+        exit
+    else 
+       echo " Status 1 Readout -> OK "	
+   fi
+    
+status=`pci -r 0x9008 -s 1 | awk '{print $2$3$4}'`
+    if [ "$status" != "01000021" ]; then
+       echo "--------------------------------->>>> ERROR! ... "
+       error=1
+        exit
+    else 
+       echo " Status 2 Readout -> OK "	
+   fi
+
+status=`pci -r 0x9010 -s 1 | awk '{print $2$3$4}'`
+    if [ "$status" != "01000021" ]; then
+       echo "--------------------------------->>>> ERROR! ... "
+       error=1
+        exit
+    else 
+       echo " Status 3 Readout -> OK "	
+   fi
+
+status=`pci -r 0x9018 -s 1 | awk '{print $2$3$4}'`
+    if [ "$status" != "01000021" ]; then
+       echo "--------------------------------->>>> ERROR! ... "
+       error=1
+        exit
+    else 
+       echo " Status 4 Readout -> OK "	
+   fi

+ 11 - 0
tests/heb/cfg/BoardOFF.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+
+echo " ************************************************************** "
+echo " 			Board OFF"
+echo " ************************************************************** "
+
+pci -w 0x9040 0x01
+sleep 0.5
+
+pci --stop-dma dma1

+ 57 - 0
tests/heb/cfg/BoardOn.sh

@@ -0,0 +1,57 @@
+#!/bin/bash
+
+echo " ************************************************************** "
+echo "				Start DMA"
+echo " ************************************************************** "
+
+pci --start-dma dma1
+sleep 0.5
+pci  --list-dma-engines
+
+
+echo " ************************************************************** "
+echo " 			Board ON procedure"
+echo " ************************************************************** "
+
+pci -w 0x9040 0x01
+sleep 1
+
+echo "switch ON the power supply  --> FIRST <--"
+echo "Press a key to continue ...."
+read -n 1 -s
+
+echo "Switch ON T/Hs"
+pci -w 0x9040 0x3C1
+pci -r 0x9040 -s1
+
+echo "switch ON the power supply  --> SECOND <--"
+echo "Press a key to continue ...."
+read -n 1 -s
+
+echo "Switch ON ADCs"
+pci -w 0x9040 0x3F1
+pci -r 0x9040 -s1
+sleep 0.1
+
+
+pci -w 0x9040 0x3F0 
+pci -r 0x9040 -s1
+sleep 1
+
+echo " Status ................... "
+pci -r 0x9000 -s 40
+
+
+
+./PLL_conf_calib_3001.sh
+
+echo " Status ................... "
+pci -r 0x9000 -s 40
+
+
+echo " ************************************************************** "
+echo "				Board Ready"
+echo " ************************************************************** "
+
+
+echo " --> remember to run: ./Set_Default.sh"

+ 11 - 0
tests/heb/cfg/README

@@ -0,0 +1,11 @@
+ - Initializing
+    ./BoardOn.sh
+    ./Set_Default.sh
+
+ - Configuring the size
+    pci -w 9020 0x20 (linear scale)
+
+    * Number of samples are determined by 0x9020 / 0x9028 (0x0e by default)
+    * For each sample is descibed by (184 / 2) * 128 bits
+    * Where most-significant bytes of 4 dwords (128 bit) are iterating 
+    from 0x00 to 0xb8 with step 0x02

+ 10 - 0
tests/heb/cfg/Set_ADC_1_Delay.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set CH_4 clock ADC 1 delay... "
+
+upfix=000501
+fixed=4
+
+    hex_val=$(printf "%01x\n" $1)
+    echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+    pci -w 0x9060 $upfix$hex_val$fixed

+ 10 - 0
tests/heb/cfg/Set_ADC_2_Delay.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set CH_5 clock ADC 2 delay... "
+
+upfix=000501
+fixed=5
+
+    hex_val=$(printf "%01x\n" $1)
+    echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+    pci -w 0x9060 $upfix$hex_val$fixed

+ 10 - 0
tests/heb/cfg/Set_ADC_3_Delay.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set CH_6 clock ADC 3 delay... "
+
+upfix=000501
+fixed=6
+
+    hex_val=$(printf "%01x\n" $1)
+    echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+    pci -w 0x9060 $upfix$hex_val$fixed

+ 11 - 0
tests/heb/cfg/Set_ADC_4_Delay.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+echo "Set CH_7 clock ADC 4 delay... "
+
+upfix=000501
+fixed=7
+
+    hex_val=$(printf "%01x\n" $1)
+    echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+    pci -w 0x9060 $upfix$hex_val$fixed
+

+ 30 - 0
tests/heb/cfg/Set_Default.sh

@@ -0,0 +1,30 @@
+#!/bin/bash
+
+echo "Set Defaults delay value in the board... "
+
+./Set_FPGA_clock_delay.sh 0
+sleep 0.1
+
+ ./Set_Delay_chip.sh 16 16 16 16
+sleep 0.1
+
+./Set_TH_Delay.sh 12
+sleep 0.1
+
+./Set_ADC_1_Delay.sh 5
+sleep 0.1
+
+./Set_ADC_2_Delay.sh 5
+sleep 0.1
+
+./Set_ADC_3_Delay.sh 5
+sleep 0.1
+
+./Set_ADC_4_Delay.sh 5
+
+#pci -w 0x9020 200b20
+pci -w 0x9020 20
+pci -w 0x9028 e
+
+echo " DONE ................ "
+

+ 11 - 0
tests/heb/cfg/Set_Delay_chip.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+    zero=0
+    hex_val1=$(printf "%02x\n" $1)
+    hex_val2=$(printf "%02x\n" $2)
+    hex_val3=$(printf "%02x\n" $3)
+    hex_val4=$(printf "%02x\n" $4)
+
+    pci -w 0x9080 $zero$hex_val4$hex_val3$hex_val2$hex_val1
+    pci -r 0x9080 -s 1
+    sleep 0.5			    

+ 10 - 0
tests/heb/cfg/Set_FPGA_clock_delay.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set delay on T/Hs signals... "
+
+upfix=000501
+fixed=0
+
+    hex_val=$(printf "%01x\n" $1)
+    echo "Set $hex_val --> Time picosecond = `expr $1 "*" 150`."
+    pci -w 0x9060 $upfix$hex_val$fixed

+ 10 - 0
tests/heb/cfg/Set_TH_Delay.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set delay on T/Hs signals... "
+
+upfix=000501
+fixed=3
+
+    hex_val=$(printf "%01x\n" $1)
+    echo "Set $hex_val --> Time picosecond = `expr $1 "*" 150`."
+    pci -w 0x9060 $upfix$hex_val$fixed

+ 45 - 0
tests/heb/debug/debug.sh

@@ -0,0 +1,45 @@
+#! /bin/bash
+
+SCRIPT_PATH="`dirname \"$0\"`" 
+SCRIPT_PATH="`( cd \"$TESTS_PATH\" && pwd )`"
+PCILIB_PATH=${SCRIPT_PATH%/tests/*}
+
+function pci {
+    LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
+}
+
+function strip_bad_values {
+    LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/apps/heb_strip_bad_values $*
+}
+
+function request_data {
+    $PCILIB_PATH/tests/heb/debug/request_data.sh $*
+}
+
+while [ 1 ]; do
+    from=`pci --list-dma-engines | grep C2S | sed -s 's/\s\+/ /g' | cut -d ' ' -f 6`
+    to=`pci --list-dma-engines | grep C2S | sed -s 's/\s\+/ /g' | cut -d ' ' -f 8`
+
+    if [ $from -gt $to ]; then
+	buffers="`seq $from 255` `seq 0 $to`"
+    else
+	buffers=`seq $from $to`
+    fi
+
+    echo $buffers
+
+    rm data.out
+    for i in $buffers; do
+	pci --read-dma-buffer dma1r:$i -o data.out
+    done
+
+
+    error=`strip_bad_values data.out | head -n 1 | cut -f 1 -d ':'`
+    if [ $error != "0x1140" ]; then
+	echo "Problems found"
+	exit
+    else
+	echo "Fine"
+	request_data
+    fi
+done

+ 27 - 0
tests/heb/debug/request_data.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+
+pci -r dma1 --multipacket -o /dev/null
+
+#echo "Data Reset ... "
+pci -w 0x9040 000003f1 
+sleep 0.1
+pci -w 0x9040 000003f0 
+
+sleep 0.1
+#echo "Pilot bunch emulator ..... "
+#pci -w 0x9040 400003f0 
+sleep 0.2
+pci -w 0x9040 03f0 
+#pci -r 0x9000 -s 40
+#sleep 0.2
+#echo "Start data pci. ..... "
+pci -w 0x9040 00bf0 
+
+sleep 2
+
+#echo "Stop data acquis...... "
+pci -w 0x9040 003f0 
+pci -r 0x9000 -s 40
+sleep 0.1
+#echo "Enable data transfer.... "
+pci -w 0x9040 007f0 

+ 0 - 0
tests/bench_ipecamera.sh → tests/ipecamera/bench.sh


+ 0 - 0
tests/ipecamera/Reset_Init_all_reg_10bit.sh → tests/ipecamera/cfg/Reset_Init_all_reg_10bit.sh


+ 0 - 0
tests/ipecamera/Reset_Init_all_reg_10bit_4Mp.sh → tests/ipecamera/cfg/Reset_Init_all_reg_10bit_4Mp.sh


+ 0 - 0
tests/ipecamera/Reset_Init_all_reg_11bit.sh → tests/ipecamera/cfg/Reset_Init_all_reg_11bit.sh


+ 0 - 0
tests/ipecamera/Reset_Init_all_reg_12bit.sh → tests/ipecamera/cfg/Reset_Init_all_reg_12bit.sh


+ 0 - 0
tests/incomplete.sh → tests/ipecamera/debug/incomplete.sh


+ 0 - 0
tests/frame.sh → tests/ipecamera/frame.sh


+ 0 - 0
tests/frame_req.sh → tests/ipecamera/frame_req.sh


+ 0 - 0
tests/grabhw.sh → tests/ipecamera/grab-hwtrigger.sh


+ 0 - 0
tests/stimuli.sh → tests/ipecamera/stimuli.sh


+ 1 - 1
tests/loopback-test.sh → tests/ipecamera/tests/loopback-test.sh

@@ -18,7 +18,7 @@ size=`expr 1024 "*" 1`
 multiplier=2
 wait=0
 
-/root/pcitool/tests/frame.sh &> /dev/null
+/root/pcitool/tests/ipecamera/frame.sh &> /dev/null
 rm -f bench.out
 
 pci --stop-dma dma1

+ 2 - 2
tests/run-and-decode-test.sh → tests/ipecamera/tests/run-and-decode-test.sh

@@ -24,8 +24,8 @@ function reset {
 }
 
 
-$TESTS_PATH/ipecamera/Reset_Init_all_reg_10bit.sh &> /dev/null
-/root/pcitool/tests/frame.sh &> /dev/null
+$TESTS_PATH/ipecamera/cfg/Reset_Init_all_reg_10bit.sh &> /dev/null
+$TESTS_PATH/ipecamera/frame.sh &> /dev/null
 rm -f bench.out
 
 pci --stop-dma