Commit 7a8e4912 authored by Lucas Russo's avatar Lucas Russo

Merge branch 'devel'

Version v0.2
parents 2856e2ea 3804d6a4
......@@ -5,37 +5,20 @@ compiler:
- clang
- gcc
sudo: false
env:
- BOARD=ml605 WITH_EXAMPLES=with_examples
- BOARD=afcv3 WITH_EXAMPLES=with_examples
- BOARD=ml605 EXAMPLES=with_examples LIBS_LINK=without_libs_link
- BOARD=afcv3 EXAMPLES=with_examples LIBS_LINK=without_libs_link
addons:
apt:
packages:
- uuid-dev
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.
This diff is collapsed.
......@@ -9,9 +9,9 @@ Software for controlling the AFC BPM boards
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.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)
* mlm-0.1.2 (https://github.com/lnls-dig/malamute/tree/v0.1.2)
## Optional libraries:
......
......@@ -9,60 +9,140 @@ dev_mngr
filename = dev_mngr.log
verbose = 1 # Ask for a trace
daemonize = no # Ask for daemonize process (options are: yes or no)
workdir = . # Working directory for daemon
spawn_broker = no # Ask to spawn broker (options are: yes or no)
# Device I/O configurations
dev_io
board0
board1
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board1
board2
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board2
board3
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board3
board4
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board4
board5
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board5
board6
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board7
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board8
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board9
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board10
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board11
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board12
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
......@@ -9,114 +9,140 @@ dev_mngr
filename = dev_mngr.log
verbose = 1 # Ask for a trace
daemonize = no # Ask for daemonize process (options are: yes or no)
workdir = . # Working directory for daemon
spawn_broker = no # Ask to spawn broker (options are: yes or no)
# Device I/O configurations
dev_io
board0
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
board1
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board2
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.210:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.211:6791
board3
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.208:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.209:6791
board4
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.206:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.207:6791
board5
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board6
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board7
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.204:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.205:6791
board8
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.202:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.203:6791
board9
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.200:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.201:6791
board10
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board11
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board12
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
#!/usr/bin/env bash
./compile.sh $BOARD $WITH_EXAMPLES
# help debug
set -x
# Build and local install repositories
mkdir tmp
BUILD_PREFIX=$PWD/tmp
LIBSODIUM_VER=1.0.3
LIBZMQ_VER=v4.2.0-pre
LIBCZMQ_VER=v3.0.2
MALAMUTE_VER=v0.1.1
ZYRE_VER=v1.1.0
CONFIG_FLAGS=()
CONFIG_FLAGS+=("CFLAGS=-I${BUILD_PREFIX}/include")
CONFIG_FLAGS+=("CPPFLAGS=-I${BUILD_PREFIX}/include")
CONFIG_FLAGS+=("CXXFLAGS=-I${BUILD_PREFIX}/include")
CONFIG_FLAGS+=("LDFLAGS=-L${BUILD_PREFIX}/lib")
KERNEL_FLAGS=()
KERNEL_FLAGS+=("INSTALLDIR=${BUILD_PREFIX}/lib/modules/$(shell uname -r)/extra")
KERNEL_FLAGS+=("INSTALLHDRDIR=${BUILD_PREFIX}/include/pciDriver/driver")
BPM_OPTS=()
BPM_OPTS+=(${CONFIG_FLAGS[@]})
BPM_OPTS+=(${KERNEL_FLAGS[@]})
BPM_OPTS+=("PREFIX=${BUILD_PREFIX}")
CONFIG_OPTS=()
CONFIG_OPTS+=(${CONFIG_FLAGS[@]})
CONFIG_OPTS+=("PKG_CONFIG_PATH=${BUILD_PREFIX}/lib/pkgconfig")
CONFIG_OPTS+=("--prefix=${BUILD_PREFIX}")
# libsodium
git clone --branch=${LIBSODIUM_VER} git://github.com/jedisct1/libsodium.git &&
( cd libsodium; ./autogen.sh && ./configure --prefix=$BUILD_PREFIX &&
make check && make install ) || exit 1
# libzmq
git clone --branch=${LIBZMQ_VER} git://github.com/lnls-dig/libzmq.git &&
( cd libzmq; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
# CZMQ
git clone --branch=${LIBCZMQ_VER} git://github.com/zeromq/czmq.git &&
( cd czmq; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
# Zyre
git clone --branch=${ZYRE_VER} git://github.com/zeromq/zyre.git &&
( cd zyre; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
# Malamute
git clone --branch=${MALAMUTE_VER} git://github.com/lnls-dig/malamute.git &&
( cd malamute; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
./compile.sh $BOARD $EXAMPLES $LIBS_LINK "${BPM_OPTS[@]}"
......@@ -2,6 +2,7 @@
VALID_BOARDS_STR="Valid values are: \"ml605\" and \"afcv3\"."
VALID_WITH_EXAMPLES_STR="Valid values are: \"with_examples\" or \"without_examples\"."
VALID_WITH_LIBS_LINK_STR="Valid values are: \"with_libs_link\" or \"without_libs_link\"."
#######################################
# All of our Makefile options
......@@ -27,6 +28,20 @@ if [ -n "$WITH_EXAMPLES" ] && [ "$WITH_EXAMPLES" != "with_examples" ] && [ "$WIT
exit 1
fi
WITH_LIBS_LINK=$3
if [ -n "$WITH_LIBS_LINK" ] && [ "$WITH_LIBS_LINK" != "with_libs_link" ] && [ "$WITH_LIBS_LINK" != "without_libs_link" ]; then
echo "Wrong variable value. "$VALID_WITH_LIBS_LINK_STR
exit 1
fi
EXTRA_FLAGS=()
# Get all other arguments
for item in "${@:4}"
do
EXTRA_FLAGS+=("${item}")
done
# 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
......@@ -61,11 +76,23 @@ CFG=lnls_defconfig
export CFG
COMMAND_DEPS="\
make deps && \
sudo make deps_install"
make ${EXTRA_FLAGS[@]} deps && \
make ${EXTRA_FLAGS[@]} deps_install"
COMMAND_LIBS="\
make \
${EXTRA_FLAGS[@]} \
BOARD=${BOARD} \
ERRHAND_DBG=${ERRHAND_DBG} \
ERRHAND_MIN_LEVEL=${ERRHAND_MIN_LEVEL} \
ERRHAND_SUBSYS_ON='"${ERRHAND_SUBSYS_ON}"' \
LOCAL_MSG_DBG=${LOCAL_MSG_DBG} \
libs_compile_install"
COMMAND_HAL="\
make BOARD=${BOARD} \
make \
${EXTRA_FLAGS[@]} \
BOARD=${BOARD} \
SHRINK_AFCV3_DDR_SIZE=${SHRINK_AFCV3_DDR_SIZE} \
ERRHAND_DBG=${ERRHAND_DBG} \
ERRHAND_MIN_LEVEL=${ERRHAND_MIN_LEVEL} \
......@@ -77,28 +104,27 @@ COMMAND_HAL="\
AFE_RFFE_TYPE=${AFE_RFFE_TYPE} \
WITH_DEVIO_CFG=${WITH_DEVIO_CFG} \
CFG_DIR=${CFG_DIR} && \
sudo make CFG=${CFG} install"
COMMAND_LIBBPMCLIENT="\
make BOARD=${BOARD} \
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"
make CFG=${CFG} ${EXTRA_FLAGS[@]} install"
if [ "$WITH_EXAMPLES" = "with_examples" ]; then
COMMAND_EXAMPLES="\
make examples"
make ${EXTRA_FLAGS[@]} examples"
else
COMMAND_EXAMPLES=""
fi
if [ "$WITH_LIBS_LINK" == "with_libs_link" ] || [ "$WITH_LIBS_LINK" == "" ]; then
COMMAND_LIBS_LINK="ldconfig"
else
COMMAND_LIBS_LINK=""
fi
COMMAND_ARRAY=(
"${COMMAND_DEPS}"
"${COMMAND_LIBS}"
"${COMMAND_HAL}"
"${COMMAND_LIBBPMCLIENT}"
"${COMMAND_EXAMPLES}"
"${COMMAND_LIBS_LINK}"
)
for i in "${COMMAND_ARRAY[@]}"
......
......@@ -11,8 +11,12 @@ OBJCOPY ?= $(CROSS_COMPILE)objcopy
SIZE ?= $(CROSS_COMPILE)size
MAKE ?= make
# General C flags
CFLAGS = -std=gnu99 -O2
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
LOCAL_MSG_DBG ?= n
DBE_DBG ?= n
......@@ -33,6 +37,15 @@ CFLAGS_DEBUG += -g
CFLAGS_PLATFORM = -Wall -Wextra -Werror \
-Wno-missing-field-initializers \
-Wno-missing-braces
ifeq ($(notdir $(CC)),$(filter $(notdir $(CC)),gcc cc))
CFLAGS_PLATFORM += -Wno-cpp
endif
ifeq ($(notdir $(CC)),clang)
CFLAGS_PLATFORM += -Wno-error=\#warnings
endif
LDFLAGS_PLATFORM =
# Libraries
......@@ -43,12 +56,10 @@ LFLAGS =
# Include directories
INCLUDE_DIRS = -I. -I/usr/local/lib
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
#-Os
LDFLAGS = $(LDFLAGS_PLATFORM)
#-ffunction-sections -fdata-sections -Wl,--gc-sections
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Every .c file will must be a separate example
examples_SRC = $(wildcard *.c)
......@@ -57,7 +68,7 @@ OUT = $(basename $(examples_SRC))
all: $(OUT)
%: %.c
$(CC) $(LFLAGS) $(CFLAGS) $(INCLUDE_DIRS) $^ -o $@ $(LIBS)
$(CC) $(LDFLAGS) $(CFLAGS) $(INCLUDE_DIRS) $^ -o $@ $(LIBS)
#BAD
clean:
......
......@@ -19,6 +19,7 @@
#define DFLT_BOARD_NUMBER 0
#define MIN_NUM_SAMPLES 4
/* Arbitrary hard limits */
#define MAX_NUM_SAMPLES (1 << 28)
#define MAX_NUM_CHANS (1 << 8)
......@@ -135,7 +136,12 @@ int main (int argc, char *argv [])
else {
num_samples = strtoul (num_samples_str, NULL, 10);
if (num_samples > MAX_NUM_SAMPLES) {
if (num_samples < MIN_NUM_SAMPLES) {
fprintf (stderr, "[client:acq]: Number of samples too small! Defaulting to: %u\n",
MIN_NUM_SAMPLES);
num_samples = MIN_NUM_SAMPLES;
}
else if (num_samples > MAX_NUM_SAMPLES) {
fprintf (stderr, "[client:acq]: Number of samples too big! Defaulting to: %u\n",
MAX_NUM_SAMPLES);
num_samples = MAX_NUM_SAMPLES;
......@@ -197,11 +203,21 @@ int main (int argc, char *argv [])
goto err_bpm_client_new;
}
/* Set trigger to skip */
uint32_t acq_trig = 0;
bpm_client_err_e err = bpm_set_acq_trig (bpm_client, service, acq_trig);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_acq_set_trig failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t data_size = num_samples*acq_chan[chan].sample_size;
uint32_t *data = (uint32_t *) zmalloc (data_size*sizeof (uint8_t));
bool new_acq = true;
acq_trans_t acq_trans = {.req = {
.num_samples = num_samples,
.num_samples_pre = num_samples,
.num_samples_post = 0,
.num_shots = 1,
.chan = chan,
},
.block = {
......@@ -209,7 +225,7 @@ int main (int argc, char *argv [])
.data_size = data_size,
}
};
bpm_client_err_e err = bpm_get_curve (bpm_client, service, &acq_trans,
err = bpm_get_curve (bpm_client, service, &acq_trans,
50000, new_acq);