Commit 98981d1d authored by Pieter Van Trappen's avatar Pieter Van Trappen

updated readme; added petalinux-oe meta-user layer for reference

parent b8f72b89
# FASEC prototype project
This Vivado 2016.2 project incorperates several cores (see te-abt-ec/cores
This Vivado 2018.1 project incorperates several cores (see te-abt-ec/cores
repo) and its aim is to fully test the FASEC card
[http://www.ohwr.org/projects/fasec/wiki](http://www.ohwr.org/projects/fasec/wiki). The
design is modular and by using AXI4-Lite slaves the XADC, FMC-slots, etc. will
......@@ -10,14 +10,20 @@ The following has been tested so far:
* DDR3 full range
* FMCs I2C bus
* PL output LEDs
...
* White Rabbit PTP Core [https://www.ohwr.org/project/wr-cores/wikis/wrpc-core]
* (much more, lost track of updating this document)
The project itself is not uploaded, to recreate it after cloning the repo:
$ git submodule init
$ git submodule update --recursive
$ git submodule update --init --recursive
$ vivado -mode batch -source syn/fasec_prototype_project-generation.tcl
Now the project can be openend with Vivado. There's a hacky script to update
some fasec_hwtest AXI4-Lite registers to include build time and commit
number. To use, run bitstream generation as follows from the Tcl Console:
> cd [get_property DIRECTORY [current_project]]; source FASEC_prototype.srcs/tcl/set_registers.tcl
## Petalinux
Petalinux 2018.1 (OE/Yocto based) is used for the software-side of the project. To facilitate integration
in your project, the so-called `meta-user` layer is inluded here in the petalinux-oe folder. It contains some
applications and drivers you might not need, but it has the important device-tree files and PHY kernel patch.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
This README file contains information on the contents of the
meta-user layer.
Please see the corresponding sections below for details.
Dependencies
============
This layer depends on:
URI: git://git.openembedded.org/bitbake
branch: master
URI: git://git.openembedded.org/openembedded-core
layers: meta
branch: master
URI: git://git.yoctoproject.org/xxxx
layers: xxxx
branch: master
Patches
=======
Please submit any patches against the meta-user layer to the
xxxx mailing list (xxxx@zzzz.org) and cc: the maintainer:
Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
Table of Contents
=================
I. Adding the meta-user layer to your build
II. Misc
I. Adding the meta-user layer to your build
=================================================
--- replace with specific instructions for the meta-user layer ---
In order to use this layer, you need to make the build system aware of
it.
Assuming the meta-user layer exists at the top-level of your
yocto build tree, you can add it to the build system by adding the
location of the meta-user layer to bblayers.conf, along with any
other layers needed. e.g.:
BBLAYERS ?= " \
/path/to/yocto/meta \
/path/to/yocto/meta-poky \
/path/to/yocto/meta-yocto-bsp \
/path/to/yocto/meta-meta-user \
"
II. Misc
========
--- replace with specific information about the meta-user layer ---
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "meta-user"
BBFILE_PATTERN_meta-user = "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-user = "6"
#User Configuration
#OE_TERMINAL = "tmux"
# Add EXTRA_IMAGEDEPENDS default components
EXTRA_IMAGEDEPENDS_append_zynqmp = " virtual/fsbl virtual/pmu-firmware arm-trusted-firmware"
EXTRA_IMAGEDEPENDS_append_zynq = " virtual/fsbl"
EXTRA_IMAGEDEPENDS_append_microblaze = " virtual/fsboot virtual/elfrealloc"
#Remove all qemu contents
IMAGE_CLASSES_remove = "image-types-xilinx-qemu qemuboot-xilinx"
IMAGE_FSTYPES_remove = "wic.qemu-sd"
EXTRA_IMAGEDEPENDS_remove = "qemu-helper-native virtual/boot-bin"
#get rid of some warnings
DISTRO_FEATURES_append = " virtualization"
SIGGEN_UNLOCKED_RECIPES += "glib-2.0"
# Load the PetaLinux SDK main gdbinit script
source plnx_gdbinit
PetaLinux User Application Template
===================================
This directory contains a PetaLinux user application created from a template.
You can easily import any already built application or script by copying
it into this directory, and editing the automatically generated Makefile
as described below.
Modify the "install:" target in Makefile to use $(TARGETINST) to install your
prebuilt application or script to the host copy of the target file system
referring to the comments of the "install:" target.
Before building the application, you will need to enable the application
from PetaLinux menuconfig by running:
"petalinux-config -c rootfs"
You will see your application in the "Applications --->" submenu.
To install your prebuilt application or script to the target file system
copy on the host, simply run the
"petalinux-build -c rootfs/copy-rootfs-bootscript"
command.
You will also need to rebuild PetaLinux bootable images so that the images
is updated with the updated target filesystem copy, run this command:
"petalinux-build -x package"
You can also run one PetaLinux command to install the application to the
target filesystem host copy and update the bootable images as follows:
"petalinux-build"
#
# This file is the copy-rootfs-bootscript recipe.
#
SUMMARY = "Simple copy-rootfs-bootscript application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://watchdog_ps.sh \
file://bootscript.sh \
file://fmcs_termination.sh \
"
S = "${WORKDIR}"
homedir = "${D}/home/root"
#inherit update-rc.d
#
#INITSCRIPT_NAME = "bootscript"
#INITSCRIPT_PARAMS = "start 99 S."
do_install() {
install -d ${D}${sysconfdir}/rc5.d
install -d ${D}${sysconfdir}/init.d
install -d ${D}/home/root/
install -m 0755 ${S}/watchdog_ps.sh ${homedir}
install -m 0755 ${S}/fmcs_termination.sh ${homedir}
install -m 0755 bootscript.sh ${D}${sysconfdir}/init.d/bootscript
rm -f /etc/init.d/bootscript /etc/rc5.d/S99bootscript
ln -sf ../init.d/bootscript ${D}${sysconfdir}/rc5.d/S99bootscript
}
# Ship files
FILES_${PN} += "/home/root/watchdog_ps.sh \
/home/root/bootscript.sh \
/home/root/fmcs_termination.sh \
"
#dependencies gpio_leds.sh contained in package copy-rootfs-bootscript requires /bin/bash
RDEPENDS_${PN} = "bash"
#!/bin/bash
# configure FMCs 50 Ohm termination
/home/root/fmcs_termination.sh
# eth link is always up, outgoing packets seem to help to restore connection
ping -c 2 -w 20 -q cern.ch
# start the FIS Silecs server with loggin to /dev/null
/usr/bin/silecsserv > /dev/null 2>&1 &
#!/bin/bash
# turn on/off a certain amount of IO from the FASEC FMC gpiochips
# TODO: check for gpiochip i2c address!
readonly FMC1CHIP=890 # addr 74
readonly FMC2CHIP=874 # addr 75
# for gpiochip addr, see https://wikis.cern.ch/display/TEABT/FIDS+integration
# if part of FMCnARR array, 50 Ohm termination will be enabled for that input
declare -a FMCnARR=()
declare -a FMCnLEDS=(885 886 901 902)
declare -a FMCnHighImp=(874 875 876 877 878 879 880 881 882 883 890 891 894 895 896 899 892 893 897 898)
if [ ! -d "/sys/class/gpio/gpiochip"$FMC1CHIP ]; then
echo "WARNING: not found FMC1 gpiochip"$FMC1CHIP
fi
if [ ! -d "/sys/class/gpio/gpiochip"$FMC2CHIP ]; then
echo "WARNING: not found FMC2 gpiochip"$FMC2CHIP
fi
for i in "${FMCnHighImp[@]}"
do
gpio="$i"
# exporting first cause possible new IC (not configured) connected
if [ -d "/sys/class/gpio/gpio"$gpio ]; then
echo $gpio > /sys/class/gpio/unexport
fi
echo $gpio > /sys/class/gpio/export
echo out > "/sys/class/gpio/gpio"$gpio"/direction"
echo 0 > "/sys/class/gpio/gpio"$gpio"/value"
done
for i in "${FMCnARR[@]}"
do
gpio="$i"
# exporting first cause possible new IC (not configured) connected
if [ -d "/sys/class/gpio/gpio"$gpio ]; then
echo $gpio > /sys/class/gpio/unexport
fi
echo $gpio > /sys/class/gpio/export
echo out > "/sys/class/gpio/gpio"$gpio"/direction"
echo 1 > "/sys/class/gpio/gpio"$gpio"/value"
done
# switch on FMC LEDs to indicate proper configuration
for i in "${FMCnLEDS[@]}"
do
gpio="$i"
# exporting first cause possible new IC (not configured) connected
if [ -d "/sys/class/gpio/gpio"$gpio ]; then
echo $gpio > /sys/class/gpio/unexport
fi
echo $gpio > /sys/class/gpio/export
echo out > "/sys/class/gpio/gpio"$gpio"/direction"
echo 0 > "/sys/class/gpio/gpio"$gpio"/value"
done
#!/bin/bash
# period in us
readonly PERIOD=1
echo configuring GPIO pin
if [ ! -d /sys/class/gpio/gpiochip906 ]; then
echo "gpiochip not found!"
fi
if [ ! -d /sys/class/gpio/gpio957 ]; then
echo 957 > /sys/class/gpio/export
fi
echo out > /sys/class/gpio/gpio957/direction
echo starting loop
while [ 1 ]
do
echo 1 > /sys/class/gpio/gpio957/value
# usleep 1 #$((PERIOD/2))
echo 0 > /sys/class/gpio/gpio957/value
# usleep 1 #$((PERIOD/2))
done
APP = gpio-demo
# Add any other object files to this list below
APP_OBJS = gpio-demo.o
all: $(APP)
$(APP): $(APP_OBJS)
$(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)
clean:
-rm -f $(APP) *.elf *.gdb *.o
/*
*
* gpio-demo app
*
* Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or (b) that interact
* with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in this
* Software without prior written authorization from Xilinx.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#define GPIO_ROOT "/sys/class/gpio"
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
static enum {NONE, IN, OUT, CYLON, KIT} gpio_opt = NONE;
static const unsigned long cylon[] = {
0x00000080, 0x00000040, 0x00000020, 0x00000010,
0x00000008, 0x00000004, 0x00000002, 0x00000001,
0x00000002, 0x00000004, 0x00000008,
0x00000010, 0x00000020, 0x00000040, 0x00000080,
};
static const unsigned long kit[] = {
0x000000e0, 0x00000070, 0x00000038, 0x0000001c,
0x0000000e, 0x00000007, 0x00000003, 0x00000001,
0x00000003, 0x00000007, 0x0000000e,
0x0000001c, 0x00000038, 0x00000070, 0x000000e0,
};
static int gl_gpio_base = 0;
static void usage (char *argv0)
{
char *basename = strrchr(argv0, '/');
if (!basename)
basename = argv0;
fprintf(stderr,
"Usage: %s [-g GPIO_BASE] COMMAND\n"
"\twhere COMMAND is one of:\n"
"\t\t-i\t\tInput value from GPIO and print it\n"
"\t\t-o\tVALUE\tOutput value to GPIO\n"
"\t\t-c\t\tCylon test pattern\n"
"\t\t-k\t\t KIT test pattern\n"
"\tGPIO_BASE indicates which GPIO chip to talk to (The number can be \n"
"\tfound at /sys/class/gpio/gpiochipN).\n"
"\tThe highest gpiochipN is the first gpio listed in the dts file, \n"
"\tand the lowest gpiochipN is the last gpio listed in the dts file.\n"
"\tE.g.If the gpiochip240 is the LED_8bit gpio, and I want to output '1' \n"
"\tto the LED_8bit gpio, the command should be:\n"
"\t\tgpio-demo -g 240 -o 1\n"
"\n"
"\tgpio-demo written by Xilinx Inc.\n"
"\n"
, basename);
exit(-2);
}
static int open_gpio_channel(int gpio_base)
{
char gpio_nchan_file[128];
int gpio_nchan_fd;
int gpio_max;
int nchannel;
char nchannel_str[5];
char *cptr;
int c;
char channel_str[5];
char *gpio_export_file = "/sys/class/gpio/export";
int export_fd=0;
/* Check how many channels the GPIO chip has */
sprintf(gpio_nchan_file, "%s/gpiochip%d/ngpio", GPIO_ROOT, gpio_base);
gpio_nchan_fd = open(gpio_nchan_file, O_RDONLY);
if (gpio_nchan_fd < 0) {
fprintf(stderr, "Failed to open %s: %s\n", gpio_nchan_file, strerror(errno));
return -1;
}
read(gpio_nchan_fd, nchannel_str, sizeof(nchannel_str));
close(gpio_nchan_fd);
nchannel=(int)strtoul(nchannel_str, &cptr, 0);
if (cptr == nchannel_str) {
fprintf(stderr, "Failed to change %s into GPIO channel number\n", nchannel_str);
exit(1);
}
/* Open files for each GPIO channel */
export_fd=open(gpio_export_file, O_WRONLY);
if (export_fd < 0) {
fprintf(stderr, "Cannot open GPIO to export %d\n", gpio_base);
return -1;
}
gpio_max = gpio_base + nchannel;
for(c = gpio_base; c < gpio_max; c++) {
sprintf(channel_str, "%d", c);
write(export_fd, channel_str, (strlen(channel_str)+1));
}
close(export_fd);
return nchannel;
}
static int close_gpio_channel(int gpio_base)
{
char gpio_nchan_file[128];
int gpio_nchan_fd;
int gpio_max;
int nchannel;
char nchannel_str[5];
char *cptr;
int c;
char channel_str[5];
char *gpio_unexport_file = "/sys/class/gpio/unexport";
int unexport_fd=0;
/* Check how many channels the GPIO chip has */
sprintf(gpio_nchan_file, "%s/gpiochip%d/ngpio", GPIO_ROOT, gpio_base);
gpio_nchan_fd = open(gpio_nchan_file, O_RDONLY);
if (gpio_nchan_fd < 0) {
fprintf(stderr, "Failed to open %s: %s\n", gpio_nchan_file, strerror(errno));
return -1;
}
read(gpio_nchan_fd, nchannel_str, sizeof(nchannel_str));
close(gpio_nchan_fd);
nchannel=(int)strtoul(nchannel_str, &cptr, 0);
if (cptr == nchannel_str) {
fprintf(stderr, "Failed to change %s into GPIO channel number\n", nchannel_str);
exit(1);
}
/* Close opened files for each GPIO channel */
unexport_fd=open(gpio_unexport_file, O_WRONLY);
if (unexport_fd < 0) {
fprintf(stderr, "Cannot close GPIO by writing unexport %d\n", gpio_base);
return -1;
}
gpio_max = gpio_base + nchannel;
for(c = gpio_base; c < gpio_max; c++) {
sprintf(channel_str, "%d", c);
write(unexport_fd, channel_str, (strlen(channel_str)+1));
}
close(unexport_fd);
return 0;
}
static int set_gpio_direction(int gpio_base, int nchannel, char *direction)
{
char gpio_dir_file[128];
int direction_fd=0;
int gpio_max;
int c;
gpio_max = gpio_base + nchannel;
for(c = gpio_base; c < gpio_max; c++) {
sprintf(gpio_dir_file, "/sys/class/gpio/gpio%d/direction",c);
direction_fd=open(gpio_dir_file, O_RDWR);
if (direction_fd < 0) {
fprintf(stderr, "Cannot open the direction file for GPIO %d\n", c);
return 1;
}
write(direction_fd, direction, (strlen(direction)+1));
close(direction_fd);
}
return 0;
}
static int set_gpio_value(int gpio_base, int nchannel, int value)
{
char gpio_val_file[128];
int val_fd=0;
int gpio_max;
char val_str[2];
int c;
gpio_max = gpio_base + nchannel;
for(c = gpio_base; c < gpio_max; c++) {
sprintf(gpio_val_file, "/sys/class/gpio/gpio%d/value",c);
val_fd=open(gpio_val_file, O_RDWR);
if (val_fd < 0) {
fprintf(stderr, "Cannot open the value file of GPIO %d\n", c);
return -1;
}
sprintf(val_str,"%d", (value & 1));
write(val_fd, val_str, sizeof(val_str));
close(val_fd);
value >>= 1;
}
return 0;
}
static int get_gpio_value(int gpio_base, int nchannel)
{
char gpio_val_file[128];
int val_fd=0;
int gpio_max;
char val_str[2];
char *cptr;
int value = 0;
int c;
gpio_max = gpio_base + nchannel;
for(c = gpio_max-1; c >= gpio_base; c--) {
sprintf(gpio_val_file, "/sys/class/gpio/gpio%d/value",c);
val_fd=open(gpio_val_file, O_RDWR);
if (val_fd < 0) {
fprintf(stderr, "Cannot open GPIO to export %d\n", c);
return -1;
}
read(val_fd, val_str, sizeof(val_str));
value <<= 1;
value += (int)strtoul(val_str, &cptr, 0);
if (cptr == optarg) {
fprintf(stderr, "Failed to change %s into integer", val_str);
}
close(val_fd);
}
return value;
}
void signal_handler(int sig)
{
switch (sig) {
case SIGTERM:
case SIGHUP:
case SIGQUIT:
case SIGINT:
close_gpio_channel(gl_gpio_base);
exit(0) ;
default:
break;
}
}
int main(int argc, char *argv[])
{
extern char *optarg;
char *cptr;
int gpio_value = 0;
int nchannel = 0;
int c;
int i;
opterr = 0;
while ((c = getopt(argc, argv, "g:io:ck")) != -1) {
switch (c) {
case 'g':
gl_gpio_base = (int)strtoul(optarg, &cptr, 0);
if (cptr == optarg)
usage(argv[0]);
break;
case 'i':
gpio_opt = IN;
break;
case 'o':
gpio_opt = OUT;
gpio_value = (int)strtoul(optarg, &cptr, 0);
if (cptr == optarg)
usage(argv[0]);
break;
case 'c':
gpio_opt = CYLON;
break;
case 'k':
gpio_opt = KIT;
break;
case '?':
usage(argv[0]);
default:
usage(argv[0]);
}
}
if (gl_gpio_base == 0) {
usage(argv[0]);
}
nchannel = open_gpio_channel(gl_gpio_base);
signal(SIGTERM, signal_handler); /* catch kill signal */
signal(SIGHUP, signal_handler); /* catch hang up signal */
signal(SIGQUIT, signal_handler); /* catch quit signal */
signal(SIGINT, signal_handler); /* catch a CTRL-c signal */
switch (gpio_opt) {
case IN:
set_gpio_direction(gl_gpio_base, nchannel, "in");
gpio_value=get_gpio_value(gl_gpio_base, nchannel);
fprintf(stdout,"0x%08X\n", gpio_value);
break;
case OUT:
set_gpio_direction(gl_gpio_base, nchannel, "out");
set_gpio_value(gl_gpio_base, nchannel, gpio_value);
break;
case CYLON:
#define CYLON_DELAY_USECS (10000)
set_gpio_direction(gl_gpio_base, nchannel, "out");
for (;;) {
for(i=0; i < ARRAY_SIZE(cylon); i++) {
gpio_value=(int)cylon[i];
set_gpio_value(gl_gpio_base, nchannel, gpio_value);
}
usleep(CYLON_DELAY_USECS);
}
case KIT:
#define KIT_DELAY_USECS (10000)
set_gpio_direction(gl_gpio_base, nchannel, "out");
for (;;) {
for (i=0; i<ARRAY_SIZE(kit); i++) {
gpio_value=(int)kit[i];
set_gpio_value(gl_gpio_base, nchannel, gpio_value);
}
usleep(KIT_DELAY_USECS);
}
default:
break;
}
close_gpio_channel(gl_gpio_base);
return 0;
}
#
# This is the GPIO-DEMO apllication recipe
#
#
SUMMARY = "gpio-demo application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://gpio-demo.c \
file://Makefile \
"
S = "${WORKDIR}"
CFLAGS_prepend = "-I ${S}/include"
do_compile() {
oe_runmake
}
do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/gpio-demo ${D}${bindir}
}
# Load the PetaLinux SDK main gdbinit script
source plnx_gdbinit
PetaLinux User Application Template
===================================
This directory contains a PetaLinux user application created from a template.
If you are developing your application from scratch, simply start editing the
file libsnap7.c.
You can easily import any existing application code by copying it into this
directory, and editing the automatically generated Makefile.
Before building the application, you will need to enable the application
from PetaLinux menuconfig by running:
"petalinux-config -c rootfs"
You will see your application in the "Applications --->" submenu.
Before building the application, you will need to enable the application
from PetaLinux menuconfig by running:
"petalinux-config -c rootfs"
You will see your application in the "Applications --->" submenu.
To build your application, simply run "petalinux-build -c libsnap7".
This command will build your application and will install your application
into the target file system host copy.
You will also need to rebuild PetaLinux bootable images so that the images
is updated with the updated target filesystem copy, run this command:
"petalinux-build -x package"
You can also run one PetaLinux command to install the application to the
target filesystem host copy and update the bootable images as follows:
"petalinux-build"
To add extra source code files (for example, to split a large application into
multiple source files), add the relevant .o files to the list in the local
Makefile where indicated.
To have other files (for example application configuration files or scripts)
copied into the root file system, add addition lines under the "install:"
target in the Makefile. For example:
$(TARGETINST) myfile.conf /etc
Copy the file myfile.conf from this directory into the /etc directory
on the Embedded Linux filesystem).
Another example:
(TARGETINST) -a "some text here" /etc/system.conf
Add the line "some text here" to the /etc/system.conf file.
See ${PETALINUX}/components/rootfs/targetroot-inst.sh for details and more options.
--- /dev/null 2018-06-22 10:23:33.533000000 +0200
+++ git/Makefile 2018-07-26 16:20:25.816518936 +0200
@@ -0,0 +1,26 @@
+APP = libsnap7.so
+
+CPU ?= ARM7
+SNAP7DIR = "snap7/1.4.2/build/"
+
+all: build
+
+build: $(APP)
+
+$(APP): $(wildcard snap7/1.4.2/src/**/*)
+ifeq ($(CPU), ARM7)
+ cd $(SNAP7DIR)unix/ && $(MAKE) -e -f arm_v7_linux.mk CXXFLAGS+='-O3 -g -fPIC -mword-relocations -pedantic'
+ cp ./$(SNAP7DIR)bin/arm_v7-linux/libsnap7.so ./
+else
+ cd $(SNAP7DIR)unix/ && $(MAKE) -e -f x86_64_linux.mk CXXFLAGS+='-O3 -fPIC -pedantic'
+ cp ./$(SNAP7DIR)bin/x86_64-linux/libsnap7.so ./
+endif
+
+clean:
+ -rm -f $(APP)
+ifeq ($(CPU), ARM7)
+ cd $(SNAP7DIR)unix/ && $(MAKE) -e -f arm_v7_linux.mk clean
+else
+ cd $(SNAP7DIR)unix/ && $(MAKE) -e -f x86_64_linux.mk clean
+endif
+
#
# This file is the libsnap7 recipe.
#
SUMMARY = "Simple libsnap7 application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "git://git@gitlab.cern.ch:7999/silecs/silecs-3rdparty.git;protocol=ssh;branch=master \
file://snap7.patch \
"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"
TARGET_CC_ARCH += "${LDFLAGS}"
do_compile() {
oe_runmake
}
do_install() {
install -d ${D}${libdir}
install -m 0655 ${S}/libsnap7.so ${D}${libdir}
}
FILES_${PN} += "${libdir}"
FILES_SOLIBSDEV = ""
PEEK = peek
POKE = poke
# Add any other object files to this list below
PEEK_OBJS = peek.o
POKE_OBJS = poke.o
all: $(PEEK) $(POKE)
$(POKE): $(POKE_OBJS)
$(CC) $(LDFLAGS) -o $@ $(POKE_OBJS) $(LDLIBS)
$(PEEK): $(PEEK_OBJS)
$(CC) $(LDFLAGS) -o $@ $(PEEK_OBJS) $(LDLIBS)
clean:
-rm -f $(POKE) $(PEEK) *.elf *.gdb *.o
/*
* peek utility - for those who remember the good old days!
*
*
* Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or (b) that interact
* with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in this
* Software without prior written authorization from Xilinx.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
void usage(char *prog)
{
printf("usage: %s ADDR\n",prog);
printf("\n");
printf("ADDR may be specified as hex values\n");
}
int main(int argc, char *argv[])
{
int fd;
void *ptr;
unsigned addr, page_addr, page_offset;
unsigned page_size=sysconf(_SC_PAGESIZE);
if(argc!=2) {
usage(argv[0]);
exit(-1);
}
fd=open("/dev/mem",O_RDONLY);
if(fd<1) {
perror(argv[0]);
exit(-1);
}
addr=strtoul(argv[1],NULL,0);
page_addr=(addr & ~(page_size-1));
page_offset=addr-page_addr;
ptr=mmap(NULL,page_size,PROT_READ,MAP_SHARED,fd,(addr & ~(page_size-1)));
if((int)ptr==-1) {
perror(argv[0]);
exit(-1);
}
printf("0x%08x\n",*((unsigned *)(ptr+page_offset)));
return 0;
}
/*
* poke utility - for those who remember the good old days!
*
* Copyright (C) 2013 - 2016 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or (b) that interact
* with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in this
* Software without prior written authorization from Xilinx.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
void usage(char *prog)
{
printf("usage: %s ADDR VAL\n",prog);
printf("\n");
printf("ADDR and VAL may be specified as hex values\n");
}
int main(int argc, char *argv[])
{
int fd;
void *ptr;
unsigned val;
unsigned addr, page_addr, page_offset;
unsigned page_size=sysconf(_SC_PAGESIZE);
fd=open("/dev/mem",O_RDWR);
if(fd<1) {
perror(argv[0]);
exit(-1);
}
if(argc!=3) {
usage(argv[0]);
exit(-1);
}
addr=strtoul(argv[1],NULL,0);
val=strtoul(argv[2],NULL,0);
page_addr=(addr & ~(page_size-1));
page_offset=addr-page_addr;
ptr=mmap(NULL,page_size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,(addr & ~(page_size-1)));
if((int)ptr==-1) {
perror(argv[0]);
exit(-1);
}
*((unsigned *)(ptr+page_offset))=val;
return 0;
}
#
# This is the peekpoke apllication recipe
#
#
SUMMARY = "peekpoke application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://peek.c \
file://poke.c \
file://Makefile \
"
S = "${WORKDIR}"
CFLAGS_prepend = "-I ${S}/include"
do_compile() {
oe_runmake
}
do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/peek ${D}${bindir}
install -m 0755 ${S}/poke ${D}${bindir}
}
# Load the PetaLinux SDK main gdbinit script
source plnx_gdbinit
PetaLinux User Application Template
===================================
This directory contains a PetaLinux user application created from a template.
If you are developing your application from scratch, simply start editing the
file silecsserv.c.
You can easily import any existing application code by copying it into this
directory, and editing the automatically generated Makefile.
Before building the application, you will need to enable the application
from PetaLinux menuconfig by running:
"petalinux-config -c rootfs"
You will see your application in the "Applications --->" submenu.
Before building the application, you will need to enable the application
from PetaLinux menuconfig by running:
"petalinux-config -c rootfs"
You will see your application in the "Applications --->" submenu.
To build your application, simply run "petalinux-build -c silecsserv".
This command will build your application and will install your application
into the target file system host copy.
You will also need to rebuild PetaLinux bootable images so that the images
is updated with the updated target filesystem copy, run this command:
"petalinux-build -x package"
You can also run one PetaLinux command to install the application to the
target filesystem host copy and update the bootable images as follows:
"petalinux-build"
To add extra source code files (for example, to split a large application into
multiple source files), add the relevant .o files to the list in the local
Makefile where indicated.
To have other files (for example application configuration files or scripts)
copied into the root file system, add addition lines under the "install:"
target in the Makefile. For example:
$(TARGETINST) myfile.conf /etc
Copy the file myfile.conf from this directory into the /etc directory
on the Embedded Linux filesystem).
Another example:
(TARGETINST) -a "some text here" /etc/system.conf
Add the line "some text here" to the /etc/system.conf file.
See ${PETALINUX}/components/rootfs/targetroot-inst.sh for details and more options.
#
# This file is the silecsserv recipe.
#
SUMMARY = "Silecsserv application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "gitsm://git@gitlab.cern.ch:7999/te-abt-ec/silecsserv.git;protocol=ssh;branch=sbds-mkdv"
SRCREV = "${AUTOREV}"
EXTRA_OEMAKE = "CPU=ARM7 "
DEPENDS = "libsnap7"
RDEPENDS_silecsserv = "libsnap7"
S = "${WORKDIR}/git"
do_compile() {
oe_runmake
}
do_install() {
install -d ${D}${bindir}
install -m 0755 silecsserv ${D}${bindir}
}
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://system-user.dtsi"
/include/ "system-conf.dtsi"
/ {
chosen{
bootargs = "console=ttyPS0,115200 earlyprintk
uio_pdrv_genirq.of_id=generic-uio";
};
};
&amba {
gpio-leds {
compatible = "gpio-leds";
en_ps_n {
label = "en_ps_n";
gpios = <&gpio0 32 1>;
default-state = "on";
linux,default-trigger = "default-on";
};
line_ps {
/* Off green, on red */
label = "line_ps";
gpios = <&gpio0 33 0>;
default-state = "off";
linux,default-trigger = "default-off";
};
ps1 {
label = "led-ps1";
gpios = <&gpio0 34 0>;
default-state = "on";
linux,default-trigger = "heartbeat";
};
ps2 {
label = "led-ps2";
gpios = <&gpio0 35 0>;
default-state = "on";
linux,default-trigger = "heartbeat";
};
ps3 {
label = "led-ps3";
gpios = <&gpio0 36 0>;
default-state = "on";
linux,default-trigger = "heartbeat";
};
ps4 {
label = "led-ps4";
gpios = <&gpio0 37 0>;
default-state = "on";
linux,default-trigger = "heartbeat";
};
};
/*
fasc_watchdog {
compatible = "linux,wdt-gpio";
gpios = <&gpio0 51 1>;
hw_algo = "toggle";
};
*/
};
&gem0 {
compatible = "cdns,gem";
phy-mode = "moca";
/* below will be changed by uboot before passing to kernel */
local-mac-address = [08 00 30 00 38 00];
fixed-link {
speed = <1000>;
full-duplex;
reg = <0x4>;
};
mdio {
#address-cells = <1>;
#size-cells = <0>;
phy0: phy@1 {
reg = <0x1>;
};
phy1: phy@2 {
reg = <0x2>;
};
switch0: switch0@0 {
compatible = "marvell,mv88e6085";
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@1 {
reg = <1>;
label = "eth1";
phy-handle = <&phy0>;
};
port@2 {
reg = <2>;
label = "eth2";
phy-handle = <&phy1>;
};
port@4 {
reg = <4>;
label = "cpu";
ethernet = <&gem0>;
fixed-link {
speed = <1000>;
full-duplex;
};
};
};
};
};
};
&axi_wb_i2c_master_2{
#address-cells = <1>;
#size-cells = <0>;
compatible = "opencores,i2c-ocores";
status = "okay";
reg = <0x43c00000 0x8>;
interrupt-parent = <&intc>;
interrupts = <0 30 4>;
opencores,ip-clock-frequency = <100000000>;
clock-frequency = <400000>;
/* shift & width to accomodate AXI4 addressing */
reg-shift = <2>;
reg-io-width = <4>;
/* below devices only there when FMC card is plugged in!
* moreover addresses depend on FMC-slot - done for both
*/
eeprom_fmc1@50{
compatible = "microchip,24c64";
reg = <0x50>;
pagesize = <32>;
};
gpio_fmc1@74{
compatible = "ti,tca9539";
reg = <0x74>;
};
eeprom_fmc2@52{
compatible = "microchip,24c64";
reg = <0x52>;
pagesize = <32>;
};
gpio_fmc2@75{
compatible = "ti,tca9539";
reg = <0x75>;
};
};
&FID_top_0{
compatible = "cern,fasec_hwtest";
interrupt-parent = <&intc>;
interrupts = <0 32 1>; /* intr_led_o */
};
/* MIO pins 38, 39 - PMBus power controller */
&i2c0{
compatible = "cdns,i2c-r1p10"; /* r1p14 for Zynq Ultrascale MP */
status = "okay";
clock-frequency = <100000>;
ucd90120@5B {
compatible = "ti,ucd90120";
reg = <0x5B>;
};
};
/* MIO pins 28, 29 - external patch panel */
&i2c1{
compatible = "cdns,i2c-r1p10"; /* r1p14 for Zynq Ultrascale MP */
status = "okay";
clock-frequency = <100000>;
/* commented out, fasec_hwtest driver creates i2c_client structs now
gpio_patch_ic3@74{
compatible = "ti,tca9539";
reg = <0x74>;
};
gpio_patch_ic2@75{
compatible = "ti,tca9539";
reg = <0x75>;
};
gpio_patch_ic1@77{
compatible = "ti,tca9539";
reg = <0x77>;
};
*/
};
/* disable adc driver from zynq-7000.dtsi */
&adc{
status = "disabled";
};
&xadc_wiz_0{
compatible = "xlnx,axi-xadc-1.00.a";
clocks = <&clkc 15>;
xlnx,channels{
#address-cells = <1>;
#size-cells = <0>;
/* from bindings info: 1 is vauxp/n[0]! */
channel@1 {
reg = <1>;
xlnx,bipolar;
};
channel@2 {
reg = <2>;
xlnx,bipolar;
};
channel@3 {
reg = <3>;
xlnx,bipolar;
};
channel@9 {
reg = <9>;
xlnx,bipolar;
};
channel@10 {
reg = <10>;
xlnx,bipolar;
};
channel@11 {
reg = <11>;
xlnx,bipolar;
};
};
};
&flash0 {
compatible = "s25fl128s1";
};
#include <configs/platform-auto.h>
#define CONFIG_SYS_BOOTM_LEN 0xF000000
#define DFU_ALT_INFO_RAM \
"dfu_ram_info=" \
"setenv dfu_alt_info " \
"image.ub ram $netstart 0x1e00000\0" \
"dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
"thor_ram=run dfu_ram_info && thordown 0 ram 0\0"
#define DFU_ALT_INFO_MMC \
"dfu_mmc_info=" \
"set dfu_alt_info " \
"${kernel_image} fat 0 1\\\\;" \
"dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0\0" \
"thor_mmc=run dfu_mmc_info && thordown 0 mmc 0\0"
/*Required for uartless designs */
#ifndef CONFIG_BAUDRATE
#define CONFIG_BAUDRATE 115200
#ifdef CONFIG_DEBUG_UART
#undef CONFIG_DEBUG_UART
#endif
#endif
/*Define CONFIG_ZYNQ_EEPROM here and its necessaries in u-boot menuconfig if you had EEPROM memory. */
#ifdef CONFIG_ZYNQ_EEPROM
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x54
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
#define CONFIG_SYS_EEPROM_SIZE 1024 /* Bytes */
#define CONFIG_SYS_I2C_MUX_ADDR 0x74
#define CONFIG_SYS_I2C_MUX_EEPROM_SEL 0x4
#endif
# CONFIG_PHY_NATSEMI is not set
# CONFIG_PHY_REALTEK is not set
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://platform-top.h \
file://user_2018-06-24-22-56-00.cfg \
"
#Note: Mention Each package in individual line
# cascaded representation with line breaks are not valid in this file.
IMAGE_INSTALL_append = " peekpoke"
IMAGE_INSTALL_append = " gpio-demo"
IMAGE_INSTALL_append = " silecsserv"
IMAGE_INSTALL_append = " libsnap7"
IMAGE_INSTALL_append = " fasec-driver"
IMAGE_INSTALL_append = " copy-rootfs-bootscript"
CONFIG_PCIEPORTBUS=y
CONFIG_PCIEAER=y
# CONFIG_PCIE_ECRC is not set
# CONFIG_PCIEAER_INJECT is not set
CONFIG_PCIEASPM=y
# CONFIG_PCIEASPM_DEBUG is not set
CONFIG_PCIEASPM_DEFAULT=y
# CONFIG_PCIEASPM_POWERSAVE is not set
# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set
# CONFIG_PCIEASPM_PERFORMANCE is not set
CONFIG_PCIE_PME=y
# CONFIG_PCIE_DPC is not set
# CONFIG_PCIE_PTM is not set
# CONFIG_EXT2_FS is not set
CONFIG_EXT4_USE_FOR_EXT2=y
# CONFIG_PCI is not set
# CONFIG_PCI_DOMAINS_GENERIC is not set
# CONFIG_PCI_SYSCALL is not set
# CONFIG_PCIEASPM_DEFAULT is not set
CONFIG_NET_DSA=y
CONFIG_NET_DSA_TAG_DSA=y
CONFIG_NET_DSA_TAG_EDSA=y
CONFIG_NET_DSA_TAG_KSZ=y
CONFIG_NET_SWITCHDEV=y
# CONFIG_WIRELESS is not set
# CONFIG_B53 is not set
# CONFIG_NET_DSA_BCM_SF2 is not set
# CONFIG_NET_DSA_LOOP is not set
# CONFIG_NET_DSA_MT7530 is not set
# CONFIG_NET_DSA_MV88E6060 is not set
CONFIG_MICROCHIP_KSZ=y
# CONFIG_MICROCHIP_KSZ_SPI_DRIVER is not set
CONFIG_NET_DSA_MV88E6XXX=y
CONFIG_NET_DSA_MV88E6XXX_GLOBAL2=y
# CONFIG_NET_DSA_QCA8K is not set
# CONFIG_NET_DSA_SMSC_LAN9303_I2C is not set
# CONFIG_NET_DSA_SMSC_LAN9303_MDIO is not set
# CONFIG_NET_VENDOR_HISILICON is not set
CONFIG_NET_VENDOR_MICREL=y
# CONFIG_KS8842 is not set
# CONFIG_KS8851 is not set
# CONFIG_KS8851_MLL is not set
CONFIG_NET_VENDOR_MICROCHIP=y
# CONFIG_ENC28J60 is not set
# CONFIG_ENCX24J600 is not set
# CONFIG_NET_VENDOR_QUALCOMM is not set
# CONFIG_NET_VENDOR_SAMSUNG is not set
# CONFIG_NET_VENDOR_SYNOPSYS is not set
# CONFIG_MARVELL_PHY is not set
CONFIG_MICREL_PHY=m
CONFIG_MICROCHIP_PHY=m
#
# Host-side USB support is needed for USB Network Adapter support
#
# CONFIG_WLAN is not set
CONFIG_I2C_OCORES=y
# CONFIG_MEDIA_SUPPORT is not set
# CONFIG_DRM is not set
# CONFIG_FB_CFB_FILLRECT is not set
# CONFIG_FB_CFB_COPYAREA is not set
# CONFIG_FB_CFB_IMAGEBLIT is not set
# CONFIG_FB_SYS_FILLRECT is not set
# CONFIG_FB_SYS_COPYAREA is not set
# CONFIG_FB_SYS_IMAGEBLIT is not set
# CONFIG_FB_SYS_FOPS is not set
# CONFIG_SOUND is not set
# CONFIG_USB_SUPPORT is not set
# CONFIG_USB_ZERO is not set
CONFIG_FMC=y
# CONFIG_FMC_FAKEDEV is not set
# CONFIG_FMC_TRIVIAL is not set
CONFIG_FMC_WRITE_EEPROM=y
# CONFIG_FMC_CHARDEV is not set
# CONFIG_RAS is not set
CONFIG_GPIO_PCA953X=y
# CONFIG_GPIO_PCA953X_IRQ is not set
SRC_URI += "file://user_2018-06-23-14-31-00.cfg \
file://user_2018-06-24-22-29-00.cfg \
file://user_2018-06-25-09-25-00.cfg \
file://user_2018-08-08-17-10-00.cfg \
"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SUMMARY = "Recipe for build an external fasec-driver Linux kernel module"
SECTION = "PETALINUX/modules"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"
inherit module
SRC_URI = "git://git@gitlab.cern.ch:7999/te-abt-ec/FIDS/fasec-driver.git;protocol=ssh;branch=master"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"
# The inherit of module.bbclass will automatically name module packages with
# "kernel-module-" prefix as required by the oe-core build environment.
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