Commit 2856e2ea authored by Lucas Russo's avatar Lucas Russo

Merge branch 'devel'

parents 5fc880a0 8f0fd4b7
[submodule "foreign/libbsmp"]
path = foreign/libbsmp
url = https://github.com/lerwys/libbsmp.git
url = https://github.com/lnls-dig/libbsmp.git
[submodule "foreign/pcie-driver"]
path = foreign/pcie-driver
url = https://github.com/lerwys/fpga_pcie_driver.git
[submodule "foreign/libmdp"]
path = foreign/libmdp
url = https://github.com/lerwys/majordomo.git
url = https://github.com/lnls-dig/fpga_pcie_driver.git
# Travis CI script
language: c
compiler:
- clang
- gcc
env:
- BOARD=ml605 WITH_EXAMPLES=with_examples
- BOARD=afcv3 WITH_EXAMPLES=with_examples
before_install:
- git submodule update --init --recursive
# Build-check-install all subprojects
before_script:
- sudo apt-get install uuid-dev
# libsodium
- git clone git://github.com/jedisct1/libsodium.git
- ( cd libsodium; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# libzmq
- git clone git://github.com/zeromq/libzmq.git
- ( cd libzmq; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# CZMQ
- git clone git://github.com/zeromq/czmq.git
- ( cd czmq; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# Zyre
- git clone git://github.com/zeromq/zyre.git
- ( cd zyre; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# Malamute
- git clone git://github.com/zeromq/malamute.git
- ( cd malamute; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# Build and check this project
script:
- ./ci_build.sh
This diff is collapsed.
[![Build Status](https://travis-ci.org/lnls-dig/bpm-sw.svg)](https://travis-ci.org/lnls-dig/bpm-sw)
# Beam Position Monitor Software
Software for controlling the AFC BPM boards
## Prerequisites:
Make sure you have the following libraries installed:
Make sure you have the following libraries installed, either by download
the binaries or executing the instructions below:
* zeromq-4.2.0 (http://zeromq.org/area:download)
* czmq-3.0.1 (http://czmq.zeromq.org/page:get-the-software)
* mlm-0.1.0 (https://github.com/zeromq/malamute.git)
* zeromq-4.0.4 (http://zeromq.org/area:download)
* czmq-2.2.0 (http://czmq.zeromq.org/page:get-the-software)
## Optional libraries:
Cloning this repository
* uuid (distribution available):
git clone --recursive https://github.com/lerwys/bpm-software.git
sudo apt-get install uuid
Install the Majordomo application from this repository (autotools-based)
### Prerequisites Installation Instructions
cd majordomo/libmdp
git clone git://github.com/zeromq/libzmq.git && \
git clone git://github.com/zeromq/czmq.git && \
git clone git://github.com/zeromq/malamute.git &&
for project in libsodium libzmq czmq malamute; do
cd $project
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig
cd ..
done
Execute the traditional sequence of autotools commands:
## Cloning this repository
./autogen.sh && make && sudo make install
git clone --recursive https://github.com/lerwys/bpm-sw.git
## PCIe Installation Instructions
......@@ -47,28 +63,28 @@ Load the Driver module
sudo insmod /lib/modules/$(uname -r)/extra/PciDriver.ko
After this the kernel should have found the FPGA board
After this the kernel should have found the FPGA board
and initialized it. Run the following command and check its output
dmesg | tail
You should see something like the excerpt below:
[267002.495109] pciDriver - pcidriver_init :
[267002.495109] pciDriver - pcidriver_init :
Major 250 allocated to nodename 'fpga'
[267002.495130] pciDriver - pcidriver_probe :
[267002.495130] pciDriver - pcidriver_probe :
Found ML605 board at 0000:01:00.0
[267002.495224] pciDriver - pcidriver_probe :
[267002.495224] pciDriver - pcidriver_probe :
Device /dev/fpga0 added
[267002.495434] pciDriver - pcidriver_probe_irq :
[267002.495434] pciDriver - pcidriver_probe_irq :
Registered Interrupt Handler at pin 1, line 11, IRQ 16
[267002.495450] pciDriver - pcidriver_init :
[267002.495450] pciDriver - pcidriver_init :
Module loaded
## Running the PCIe self-test
After the installation of the PCIe driver (see above)
it is possible to run a self test to check if
After the installation of the PCIe driver (see above)
it is possible to run a self test to check if
everything is setup properly. For this run the following:
Change to the "compiled tests folder"
......@@ -85,11 +101,11 @@ You should get an output like the following, if everythig is ok:
Testing PCIDRIVER_IOC_MMAP_MODE... PASSED!
Testing PCIDRIVER_IOC_MMAP_AREA... PASSED!
Testing PCIDRIVER_IOC_PCI_INFO... PASSED!
Testing PCI CONFIG...
Testing PCI CONFIG...
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!
Testing PCI mmap...
Testing PCI mmap...
Reading PCI info... PASSED!
Setting mmap mode... PASSED!
Setting mmap area... PASSED!
......@@ -118,7 +134,7 @@ You should get an output like the following, if everythig is ok:
Setting KMEM SYNC to read mode... PASSED!
Setting KMEM SYNC to read/write mode... PASSED!
Testing PCIDRIVER_IOC_KMEM_FREE... PASSED!
Testing Kernel Buffer mmap...
Testing Kernel Buffer mmap...
Setting MMAP mode to KMEM... PASSED!
Allocing size 1024 : PASSED!
MMAPing size 1024 : PASSED!
......@@ -185,66 +201,52 @@ allocate more memory than the kernel has available.
### Server
Compile everything with debug info. The superuser access
is necessary because it checks (and installs if needed)
the PCIe kernel driver.
Compile everything with debug info. The superuser access
is necessary because it checks (and installs if needed)
the PCIe kernel driver.
If the PCIe driver is already installed, you could
run it without superuser.
make DBE_DBG=y
./compile.sh <board type = [ml605|afcv3]>
### Client
Change to the Client API folder
cd libclient
cd src/libs/libbpmclient
Compile the library
Compile the library, with debug info
make
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)”’
Install the library
sudo make install
## Running the example
## Running the examples
Change to the examples folder
cd examples
Compile the examples
make examples
make
Run the server components with the helper script, like shown below:
Run an example application, for instance, the leds example
./init.sh <tranport type = [ipc|tcp]> <broker_endpoint>
./leds -v -b <broker_endpoint> -board <board_number> -bpm <bpm_number>
Typically, one should choose the IPC transport method
for its faster than TCP. For instance:
./init.sh ipc /tmp/bpm
If one would like to use TCP, it should call, for instance:
./init.sh tcp 127.0.0.1:8888
Now we should be good to start making transactions.
Change to the example applications folder
cd examples
Run the Example application with verbose flag (-v)
and specifying a broker endpoint (-b)
./client -v -b <broker_endpoint>
Typically, one should choose the the IPC transport method
for its faster than TCP. For instance:
./client -v -b ipc:///tmp/bpm
./leds -v -b ipc:///tmp/bpm -board <board_number> -bpm <bpm_number>
If one would like to use TCP, it should call, for instance:
./client -v -b tcp://127.0.0.1:8888
./leds -v -b tcp://127.0.0.1:8888 -board <board_number> -bpm <bpm_number>
Leds should be blinking in the FMC ADC board
......@@ -3,18 +3,24 @@ CROSS_COMPILE ?=
CMDSEP = ;
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
MAKE = make
CC ?= $(CROSS_COMPILE)gcc
AR ?= $(CROSS_COMPILE)ar
LD ?= $(CROSS_COMPILE)ld
OBJDUMP ?= $(CROSS_COMPILE)objdump
OBJCOPY ?= $(CROSS_COMPILE)objcopy
SIZE ?= $(CROSS_COMPILE)size
MAKE ?= make
CFG_DIR ?= /etc/bpm_sw
PREFIX ?= /usr/local
CFG_DIR ?= ${PREFIX}/etc/bpm_sw
# Get all .cfg files
CFG_FILES ?= $(wildcard *.cfg)
# Config file must have the following name
CFG_FILENAME = bpm_sw.cfg
# This could be set to a different config folder
CFG ?= crude_defconfig
# Get crude defconfig .cfg file
CFG_FILES = $(CFG)/$(CFG_FILENAME)
.PHONY: all clean mrproper install uninstall
......@@ -22,7 +28,7 @@ CFG_FILES ?= $(wildcard *.cfg)
all:
install:
@mkdir -p $(CFG_DIR)
@mkdir -m 755 -p $(CFG_DIR)
$(foreach cfg,$(CFG_FILES),install -m 755 $(cfg) $(CFG_DIR)/ $(CMDSEP))
uninstall:
......
......@@ -3,9 +3,9 @@
# Device manager configurations
dev_mngr
broker
bind = tcp://10.0.18.35:8888
bind = tcp://127.0.0.1:9999
log
dir = /export/remote_logs
dir = /media/remote_logs
filename = dev_mngr.log
verbose = 1 # Ask for a trace
daemonize = no # Ask for daemonize process (options are: yes or no)
......@@ -16,7 +16,7 @@ dev_io
bpm0
dbe
afe
bind = tcp://10.0.18.59:6791
bind =
bpm1
dbe
afe
......
# BPM-SW configuration file
# Device manager configurations
dev_mngr
broker
bind = tcp://127.0.0.1:9999
log
dir = /media/remote_logs
filename = dev_mngr.log
verbose = 1 # Ask for a trace
daemonize = no # Ask for daemonize process (options are: yes or no)
# Device I/O configurations
dev_io
board0
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
board1
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
board2
bpm0
dbe
afe
bind = tcp://10.2.117.210:6791
bpm1
dbe
afe
bind = tcp://10.2.117.211:6791
board3
bpm0
dbe
afe
bind = tcp://10.2.117.208:6791
bpm1
dbe
afe
bind = tcp://10.2.117.209:6791
board4
bpm0
dbe
afe
bind = tcp://10.2.117.206:6791
bpm1
dbe
afe
bind = tcp://10.2.117.207:6791
board5
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
board6
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
board7
bpm0
dbe
afe
bind = tcp://10.2.117.204:6791
bpm1
dbe
afe
bind = tcp://10.2.117.205:6791
board8
bpm0
dbe
afe
bind = tcp://10.2.117.202:6791
bpm1
dbe
afe
bind = tcp://10.2.117.203:6791
board9
bpm0
dbe
afe
bind = tcp://10.2.117.200:6791
bpm1
dbe
afe
bind = tcp://10.2.117.201:6791
board10
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
board11
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
#!/usr/bin/env bash
./compile.sh $BOARD $WITH_EXAMPLES
#!/bin/bash
#!/usr/bin/env bash
VALID_BOARDS_STR="Valid values are: \"ml605\" and \"afcv3\"."
VALID_WITH_EXAMPLES_STR="Valid values are: \"with_examples\" or \"without_examples\"."
#######################################
# All of our Makefile options
#######################################
# Select board in which we will work. Options are: ml605 or afcv3
BOARD=afcv3
BOARD=$1
if [ -z "$BOARD" ]; then
echo "\"BOARD\" variable unset. "$VALID_BOARDS_STR
exit 1
fi
if [ "$BOARD" != "afcv3" ] && [ "$BOARD" != "ml605" ]; then
echo "Unsupported board. "$VALID_BOARDS_STR
exit 1
fi
WITH_EXAMPLES=$2
if [ -n "$WITH_EXAMPLES" ] && [ "$WITH_EXAMPLES" != "with_examples" ] && [ "$WITH_EXAMPLES" != "without_examples" ]; then
echo "Wrong variable value. "$VALID_WITH_EXAMPLES_STR
exit 1
fi
# Select if we want to have the AFCv3 DDR memory shrink to 2^28 or the full size 2^32. Options are: (y)es ot (n)o.
# This is a TEMPORARY fix until the AFCv3 FPGA firmware is fixed. If unsure, select (y)es.
SHRINK_AFCV3_DDR_SIZE=y
#Select if we want to compile code with all messages outputs. Options are: y(es) or n(o)
LOCAL_MSG_DBG=n
#Select if we want to compile with debug mode on. Options are: y(es) or n(o)
DBE_DBG=y
ERRHAND_DBG=y
# Select the minimum debug verbosity. See liberrhand file errhand_opts.h for more info.
ERRHAND_MIN_LEVEL=DBG_LVL_TRACE
# Select the subsytems which will have the debug on. See liberrhand file errhand_opts.h for more info.
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)"'
# Select the FMC ADC board type. Options are: passive or active
FMC130M_4CH_TYPE=passive
# Select if we should program FMC EEPROM with some code or not. Option are:
......@@ -17,10 +47,18 @@ FMC130M_4CH_EEPROM_PROGRAM=
WITH_DEV_MNGR=y
# Selects the AFE RFFE version. Options are: 2
AFE_RFFE_TYPE=2
# Selects if we want to compile DEVIO Config. Options are: y(es) or n(o).
# If selected, the FPGA firmware must have the AFC diagnostics module
# synthesized.
WITH_DEVIO_CFG=y
# Selects the install location of the config file
CFG_FILENAME=/etc/bpm_sw/bpm_sw.cfg
# Selects the install location of the config file
CFG_DIR=/etc/bpm_sw
PREFIX=/usr/local
CFG_DIR=${PREFIX}/etc/bpm_sw
# Selects which config file to install. Options are: crude_defconfig or lnls_defconfig
CFG=lnls_defconfig
export CFG
COMMAND_DEPS="\
make deps && \
......@@ -28,25 +66,39 @@ COMMAND_DEPS="\
COMMAND_HAL="\
make BOARD=${BOARD} \
SHRINK_AFCV3_DDR_SIZE=${SHRINK_AFCV3_DDR_SIZE} \
ERRHAND_DBG=${ERRHAND_DBG} \
ERRHAND_MIN_LEVEL=${ERRHAND_MIN_LEVEL} \
ERRHAND_SUBSYS_ON='"${ERRHAND_SUBSYS_ON}"' \
LOCAL_MSG_DBG=${LOCAL_MSG_DBG} \
DBE_DBG=${DBE_DBG} \
FMC130M_4CH_TYPE=${FMC130M_4CH_TYPE} \
FMC130M_4CH_EEPROM_PROGRAM=${FMC130M_4CH_EEPROM_PROGRAM} \
WITH_DEV_MNGR=${WITH_DEV_MNGR} \
AFE_RFFE_TYPE=${AFE_RFFE_TYPE} \
WITH_DEVIO_CFG=${WITH_DEVIO_CFG} \
CFG_DIR=${CFG_DIR} && \
sudo make install"
sudo make CFG=${CFG} install"
COMMAND_LIBCLIENT="\
COMMAND_LIBBPMCLIENT="\
make BOARD=${BOARD} \
LOCAL_MSG_DBG=${LOCAL_MSG_DBG} \
DBE_DBG=${DBE_DBG} libclient && \
sudo make libclient_install"
ERRHAND_DBG=${ERRHAND_DBG} \
ERRHAND_MIN_LEVEL=${ERRHAND_MIN_LEVEL} \
ERRHAND_SUBSYS_ON='"${ERRHAND_SUBSYS_ON}"' \
LOCAL_MSG_DBG=${LOCAL_MSG_DBG} && \
sudo make libbpmclient_install"
if [ "$WITH_EXAMPLES" = "with_examples" ]; then
COMMAND_EXAMPLES="\
make examples"
else
COMMAND_EXAMPLES=""
fi
COMMAND_ARRAY=(
"${COMMAND_DEPS}"
"${COMMAND_HAL}"
"${COMMAND_LIBCLIENT}"
"${COMMAND_LIBBPMCLIENT}"
"${COMMAND_EXAMPLES}"
)
for i in "${COMMAND_ARRAY[@]}"
......
......@@ -3,13 +3,13 @@ CROSS_COMPILE ?=
CMDSEP = ;
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
MAKE = make
CC ?= $(CROSS_COMPILE)gcc
AR ?= $(CROSS_COMPILE)ar
LD ?= $(CROSS_COMPILE)ld
OBJDUMP ?= $(CROSS_COMPILE)objdump
OBJCOPY ?= $(CROSS_COMPILE)objcopy
SIZE ?= $(CROSS_COMPILE)size
MAKE ?= make
# General C flags
CFLAGS = -std=gnu99 -O2
......@@ -30,11 +30,13 @@ endif
CFLAGS_DEBUG += -g
# Specific platform Flags
CFLAGS_PLATFORM = -Wall -Wextra -Werror
CFLAGS_PLATFORM = -Wall -Wextra -Werror \
-Wno-missing-field-initializers \
-Wno-missing-braces
LDFLAGS_PLATFORM =
# Libraries
LIBS = -lbpmclient -lmdp -lczmq -lzmq
LIBS = -lbpmclient -lerrhand -lhutils -lmlm -lczmq -lzmq
# General library flags -L<libdir>
LFLAGS =
......
Project Dependencies:
liberrhand
libhutils
libbpmclient
Foreign Dependencies:
libmlm
libczmq
libzmq
......@@ -3,7 +3,6 @@
* * a client and the FPGA device
* */
#include <mdp.h>
#include <czmq.h>
#include <inttypes.h>
#include <stdio.h>
......@@ -19,7 +18,6 @@
#define MAX_BPM_NUMBER 1
#define DFLT_BOARD_NUMBER 0
#define MAX_BOARD_NUMBER 5
/* Arbitrary hard limits */
#define MAX_NUM_SAMPLES (1 << 28)
......@@ -28,7 +26,7 @@
void print_data (uint32_t chan, uint32_t *data, uint32_t size)
{
/* FIXME: Make it more generic */
if (chan == 0 || chan == 9) {
if (chan == 0 || chan == 1 /* Only ADC and ADC SWAP */ ) {
int16_t *raw_data16 = (int16_t *) data;