README.md 8.38 KB
Newer Older
1
# Beam Position Monitor Software
Lucas Russo's avatar
Lucas Russo committed
2

3 4 5 6 7
[![Build Status](https://travis-ci.org/lnls-dig/bpm-sw.svg)](https://travis-ci.org/lnls-dig/bpm-sw)
![Latest tag](https://img.shields.io/github/tag/lnls-dig/bpm-sw.svg?style=flat)
[![Latest release](https://img.shields.io/github/release/lnls-dig/bpm-sw.svg?style=flat)](https://github.com/lnls-dig/bpm-sw/releases)
[![GPL License 3.0](https://img.shields.io/github/license/lnls-dig/bpm-sw.svg?style=flat)](COPYING)

8
Software for controlling the AFC BPM boards
Lucas Russo's avatar
Lucas Russo committed
9

10
## Prerequisites:
Lucas Russo's avatar
Lucas Russo committed
11

12 13
Make sure you have the following libraries installed, either by download
the binaries or executing the instructions below:
Lucas Russo's avatar
Lucas Russo committed
14

15
* libsodium-1.0.8 (https://github.com/jedisct1/libsodium/tree/1.0.8)
16 17
* zeromq-4.2.0 (https://github.com/lnls-dig/libzmq/tree/v4.2.0-pre)
* czmq-3.0.2 (https://github.com/zeromq/czmq/tree/v3.0.2)
18
* mlm-1.0 (https://github.com/lnls-dig/malamute/tree/v1.0)
Lucas Russo's avatar
Lucas Russo committed
19

20
## Optional libraries:
Lucas Russo's avatar
Lucas Russo committed
21

22 23 24
* uuid (distribution available):

	sudo apt-get install uuid
Lucas Russo's avatar
Lucas Russo committed
25

26
### Prerequisites Installation Instructions
27 28

	git clone --branch=1.0.8 https://github.com/jedisct1/libsodium.git && \
29 30 31
	git clone --branch=v4.2.0-pre https://github.com/lnls-dig/libzmq.git && \
	git clone --branch=v3.0.2 https://github.com/zeromq/czmq.git && \
	git clone --branch=v1.0 https://github.com/lnls-dig/malamute.git &&
32 33 34 35 36 37 38 39
	for project in libsodium libzmq czmq malamute; do
	    cd $project
	    ./autogen.sh
	    ./configure && make check
	    sudo make install
	    sudo ldconfig
	    cd ..
	done
40

41
## Cloning this repository
42

43
	git clone --recursive https://github.com/lerwys/bpm-sw.git
44

45
## PCIe Installation Instructions
46

47
Install linux header files
Lucas Russo's avatar
Lucas Russo committed
48

49
	sudo apt-get install linux-headers-generic
Lucas Russo's avatar
Lucas Russo committed
50

51
Install the GIT package
Lucas Russo's avatar
Lucas Russo committed
52

53
	sudo apt-get install binutils gcc
Lucas Russo's avatar
Lucas Russo committed
54

55
Change folder to the pcie driver location
Lucas Russo's avatar
Lucas Russo committed
56

57
	cd kernel
Lucas Russo's avatar
Lucas Russo committed
58

59
Compile the PCIe driver and its tests
Lucas Russo's avatar
Lucas Russo committed
60

61
	make
Lucas Russo's avatar
Lucas Russo committed
62

63
Install the PCIe drivers and libraries
Lucas Russo's avatar
Lucas Russo committed
64

65
	sudo make install
Lucas Russo's avatar
Lucas Russo committed
66

67
Load the Driver module
Lucas Russo's avatar
Lucas Russo committed
68

69
	sudo insmod /lib/modules/$(uname -r)/extra/PciDriver.ko
Lucas Russo's avatar
Lucas Russo committed
70

71
After this the kernel should have found the FPGA board
72
and initialized it. Run the following command and check its output
Lucas Russo's avatar
Lucas Russo committed
73

74
	dmesg | tail
Lucas Russo's avatar
Lucas Russo committed
75

76
You should see something like the excerpt below:
Lucas Russo's avatar
Lucas Russo committed
77

78
	[267002.495109] pciDriver - pcidriver_init :
79
		Major 250 allocated to nodename 'fpga'
80
	[267002.495130] pciDriver - pcidriver_probe :
81
		Found ML605 board at 0000:01:00.0
82
	[267002.495224] pciDriver - pcidriver_probe :
83
		Device /dev/fpga0 added
84
	[267002.495434] pciDriver - pcidriver_probe_irq :
85
		Registered Interrupt Handler at pin 1, line 11, IRQ 16
86
	[267002.495450] pciDriver - pcidriver_init :
87
		Module loaded
Lucas Russo's avatar
Lucas Russo committed
88

89
## Running the PCIe self-test
Lucas Russo's avatar
Lucas Russo committed
90

91 92
After the installation of the PCIe driver (see above)
it is possible to run a self test to check if
93
everything is setup properly. For this run the following:
Lucas Russo's avatar
Lucas Russo committed
94

95
Change to the "compiled tests folder"
Lucas Russo's avatar
Lucas Russo committed
96

97
	cd tests/pcie/bin
Lucas Russo's avatar
Lucas Russo committed
98

99
Run the test entitled "testPciDriverMod"
Lucas Russo's avatar
Lucas Russo committed
100

101
	sudo ./testPciDriverMod
Lucas Russo's avatar
Lucas Russo committed
102

103
You should get an output like the following, if everythig is ok:
Lucas Russo's avatar
Lucas Russo committed
104 105 106 107 108

        Testing OPEN DEVICE... PASSED!
         Testing PCIDRIVER_IOC_MMAP_MODE... PASSED!
         Testing PCIDRIVER_IOC_MMAP_AREA... PASSED!
         Testing PCIDRIVER_IOC_PCI_INFO...  PASSED!
109
         Testing PCI CONFIG...
Lucas Russo's avatar
Lucas Russo committed
110 111 112
           Reading PCI config area in byte mode ... PASSED!
           Reading PCI config area in word mode ... PASSED!
           Reading PCI config area in double-word mode ... PASSED!
113
         Testing PCI mmap...
Lucas Russo's avatar
Lucas Russo committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
           Reading PCI info... PASSED!
           Setting mmap mode... PASSED!
           Setting mmap area... PASSED!
           MMAP'ing BAR0... PASSED!
           Setting mmap area... PASSED!
           MMAP'ing BAR2... PASSED!
           Setting mmap area... PASSED!
           MMAP'ing BAR4... PASSED!
         Testing PCIDRIVER_IOC_KMEM_ALLOC...
           alloc size    1024 :  PASSED!
           alloc size    2048 :  PASSED!
           alloc size    4096 :  PASSED!
           alloc size    8192 :  PASSED!
           alloc size   16384 :  PASSED!
           alloc size   32768 :  PASSED!
           alloc size   65536 :  PASSED!
           alloc size  131072 :  PASSED!
           alloc size  262144 :  PASSED!
           alloc size  524288 :  PASSED!
           alloc size 1048576 :  PASSED!
           alloc size 2097152 :  PASSED!
           alloc size 4194304 :  PASSED!
           alloc size 8388608 :  FAILED (maybe size is just too big)!
         Testing PCIDRIVER_IOC_KMEM_SYNC...
           Setting KMEM SYNC to write mode... PASSED!
           Setting KMEM SYNC to read mode... PASSED!
           Setting KMEM SYNC to read/write mode... PASSED!
         Testing PCIDRIVER_IOC_KMEM_FREE... PASSED!
142
         Testing Kernel Buffer mmap...
Lucas Russo's avatar
Lucas Russo committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
           Setting MMAP mode to KMEM... PASSED!
             Allocing size    1024 : PASSED!
             MMAPing size     1024 : PASSED!
             Allocing size    2048 : PASSED!
             MMAPing size     2048 : PASSED!
             Allocing size    4096 : PASSED!
             MMAPing size     4096 : PASSED!
             Allocing size    8192 : PASSED!
             MMAPing size     8192 : PASSED!
             Allocing size   16384 : PASSED!
             MMAPing size    16384 : PASSED!
             Allocing size   32768 : PASSED!
             MMAPing size    32768 : PASSED!
             Allocing size   65536 : PASSED!
             MMAPing size    65536 : PASSED!
             Allocing size  131072 : PASSED!
             MMAPing size   131072 : PASSED!
             Allocing size  262144 : PASSED!
             MMAPing size   262144 : PASSED!
             Allocing size  524288 : PASSED!
             MMAPing size   524288 : PASSED!
             Allocing size 1048576 : PASSED!
             MMAPing size  1048576 : PASSED!
             Allocing size 2097152 : PASSED!
             MMAPing size  2097152 : PASSED!
             Allocing size 4194304 : PASSED!
             MMAPing size  4194304 : PASSED!
             Allocing size 8388608 : FAILED (maybe size is just too big)!
           Freeing Kernel buffers...
              Buffer index 0... PASSED!
              Buffer index 1... PASSED!
              Buffer index 2... PASSED!
              Buffer index 3... PASSED!
              Buffer index 4... PASSED!
              Buffer index 5... PASSED!
              Buffer index 6... PASSED!
              Buffer index 7... PASSED!
              Buffer index 8... PASSED!
              Buffer index 9... PASSED!
              Buffer index 10... PASSED!
              Buffer index 11... PASSED!
              Buffer index 12... PASSED!
         Testing PCIDRIVER_IOC_UMEM_SGMAP ... PASSED!
         Testing PCIDRIVER_IOC_UMEM_SGGET ... PASSED!
         Testing PCIDRIVER_IOC_UMEM_SYNC ...
           Setting UMEM SYNC to write mode... PASSED!
           Setting UMEM SYNC to read mode... PASSED!
           Setting UMEM SYNC to read/write mode... PASSED!
         Testing PCIDRIVER_IOC_UMEM_SGUNMAP ... PASSED!

		-------------------------------------
		|        All tests PASSED!          |
		-------------------------------------

197 198 199 200 201 202 203 204 205
Notice that some tests that try to evaluate the limits of a current
Linux Kernel may fail in some cases. In the example above,
two tests , due to an attempt to allocate a large buffer in kernel
space.

This is not actually an error or a failure, it is just trying to
allocate more memory than the kernel has available.

## Installation Instructions
Lucas Russo's avatar
Lucas Russo committed
206

207
### Server
Lucas Russo's avatar
Lucas Russo committed
208

209 210 211
Compile everything with debug info. The superuser access
is necessary because it checks (and installs if needed)
the PCIe kernel driver.
212 213 214 215

If the PCIe driver is already installed, you could
run it without superuser.

216
	./compile.sh <board type = [ml605|afcv3]>
217 218 219 220 221

### Client

Change to the Client API folder

222
	cd src/libs/libbpmclient
223

224
Compile the library, with debug info
225

226 227 228
	make ERRHAND_DBG=y ERRHAND_MIN_LEVEL=DBG_MIN_TRACE \
        ERRHAND_SUBSYS_ON=’”(DBG_DEV_MNGR | DBG_DEV_IO | DBG_SM_IO | \
        DBG_LIB_CLIENT  | DBG_SM_PR | DBG_SM_CH | DBG_LL_IO | DBG_HAL_UTILS)”’
229 230

Install the library
231

232 233
	sudo make install

234 235 236 237 238
## Running the examples

Change to the examples folder

    cd examples
Lucas Russo's avatar
Lucas Russo committed
239

240
Compile the examples
Lucas Russo's avatar
Lucas Russo committed
241

242
	make
Lucas Russo's avatar
Lucas Russo committed
243

244
Run an example application, for instance, the leds example
Lucas Russo's avatar
Lucas Russo committed
245

246
	./leds -v -b <broker_endpoint> -board <board_number> -bpm <bpm_number>
Lucas Russo's avatar
Lucas Russo committed
247

248 249
Typically, one should choose the IPC transport method
for its faster than TCP. For instance:
Lucas Russo's avatar
Lucas Russo committed
250

251
	./leds -v -b ipc:///tmp/bpm -board <board_number> -bpm <bpm_number>
252 253 254

If one would like to use TCP, it should call, for instance:

255
	./leds -v -b tcp://127.0.0.1:8888 -board <board_number> -bpm <bpm_number>
Lucas Russo's avatar
Lucas Russo committed
256

257
Leds should be blinking in the FMC ADC board