Commit 0e74a71e authored by Adam Wujek's avatar Adam Wujek Committed by Adam Wujek

sw: create petalinux project

With the command:
petalinux-create -t project -n petalinux --template zynqMP
Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent df02c6b7
*/*/config.old
*/*/rootfs_config.old
build/
images/linux/
pre-built/linux/
.petalinux/*
!.petalinux/metadata
*.o
*.jou
*.log
project-spec/meta-plnx-generated/
project-spec/hw-description
/components/plnx_workspace
#
# Automatically generated file; DO NOT EDIT.
# PetaLinux SDK Project Configuration
#
CONFIG_PROJECT_ADDITIONAL_COMPONENTS_SEARCH_PATH=""
#
# Subsystems of the project
#
CONFIG_PROJECT_SUBSYSTEM_LINUX_INSTANCE_LINUX=y
CONFIG_PROJECT_SUBSYSTEMS=y
#Virtual Providers
#defconfigs
UBOOT_DEFAULT_DEFCONFIG="xilinx_zynqmp_zcu102_revB_defconfig"
#
# Automatically generated file; DO NOT EDIT.
# linux System Configuration
#
CONFIG_SUBSYSTEM_TYPE_LINUX=y
CONFIG_SYSTEM_ZYNQMP=y
#
# linux Components Selection
#
CONFIG_SUBSYSTEM_COMPONENT_DEVICE__TREE_NAME_DEVICE__TREE__GENERATOR=y
CONFIG_SUBSYSTEM_COMPONENT_BOOTLOADER_AUTO_FSBL=y
CONFIG_SUBSYSTEM_COMPONENT_BOOTLOADER_AUTO_PS_INIT=y
CONFIG_SUBSYSTEM_COMPONENT_BOOTLOADER_NAME_ZYNQMP_FSBL=y
CONFIG_SUBSYSTEM_COMPONENT_U__BOOT_NAME_U__BOOT__PLNX=y
# CONFIG_SUBSYSTEM_COMPONENT_U__BOOT_NAME_REMOTE is not set
# CONFIG_SUBSYSTEM_COMPONENT_U__BOOT_NAME_NONE is not set
CONFIG_SUBSYSTEM_COMPONENT_ARM__TRUSTED__FIRMWARE_NAME_ATF=y
# CONFIG_SUBSYSTEM_COMPONENT_ARM__TRUSTED__FIRMWARE_NAME_REMOTE is not set
# CONFIG_SUBSYSTEM_COMPONENT_ARM__TRUSTED__FIRMWARE_NAME_NONE is not set
CONFIG_SUBSYSTEM_COMPONENT_LINUX__KERNEL_INSTANCE_KERNEL_NAME_XLNX__4___4=y
# CONFIG_SUBSYSTEM_COMPONENT_LINUX__KERNEL_INSTANCE_KERNEL_NAME_REMOTE is not set
CONFIG_SUBSYSTEM_COMPONENT_ROOTFS_NAME_PETALINUX__ROOTFS=y
#
# Generic Components
#
#
# Auto Config Settings
#
CONFIG_SUBSYSTEM_AUTOCONFIG_DEVICE__TREE=y
# CONFIG_SUBSYSTEM_DEVICE_TREE_MANUAL_INCLUDE is not set
CONFIG_SUBSYSTEM_DEVICE_TREE_INCLUDE_DIR="${STAGING_KERNEL_DIR}/include"
CONFIG_SUBSYSTEM_AUTOCONFIG_KERNEL=y
CONFIG_SUBSYSTEM_AUTOCONFIG_ROOTFS=y
CONFIG_SUBSYSTEM_AUTOCONFIG_U__BOOT=y
CONFIG_SUBSYSTEM_HARDWARE_AUTO=y
CONFIG_SUBSYSTEM_PROCESSOR_PSU_CORTEXA53_0_SELECT=y
CONFIG_SUBSYSTEM_ARCH_AARCH64=y
#
# Memory Settings
#
CONFIG_SUBSYSTEM_MEMORY_PSU_DDR_0_BANKLESS_SELECT=y
# CONFIG_SUBSYSTEM_MEMORY_SIMPLE_SELECT is not set
# CONFIG_SUBSYSTEM_MEMORY_MANUAL_SELECT is not set
CONFIG_SUBSYSTEM_MEMORY_PSU_DDR_0_BANKLESS_BASEADDR=0x0
CONFIG_SUBSYSTEM_MEMORY_PSU_DDR_0_BANKLESS_SIZE=0x100000000
CONFIG_SUBSYSTEM_MEMORY_PSU_DDR_0_BANKLESS_U__BOOT_TEXTBASE_OFFSET=0x100000
#
# Serial Settings
#
# CONFIG_SUBSYSTEM_SERIAL_PSU_UART_1_SELECT is not set
CONFIG_SUBSYSTEM_SERIAL_PSU_UART_0_SELECT=y
# CONFIG_SUBSYSTEM_SERIAL_MANUAL_SELECT is not set
# CONFIG_SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_9600 is not set
# CONFIG_SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_19200 is not set
# CONFIG_SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_38400 is not set
# CONFIG_SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_57600 is not set
CONFIG_SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_115200=y
# CONFIG_SUBSYSTEM_SERIAL_PSU_UART_0_BAUDRATE_230400 is not set
#
# Ethernet Settings
#
CONFIG_SUBSYSTEM_ETHERNET_PSU_ETHERNET_3_SELECT=y
# CONFIG_SUBSYSTEM_ETHERNET_MANUAL_SELECT is not set
# CONFIG_SUBSYSTEM_ETHERNET_PSU_ETHERNET_3_MAC_AUTO is not set
CONFIG_SUBSYSTEM_ETHERNET_PSU_ETHERNET_3_MAC="00:0a:35:00:22:01"
CONFIG_SUBSYSTEM_ETHERNET_PSU_ETHERNET_3_USE_DHCP=y
#
# Flash Settings
#
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_SELECT=y
# CONFIG_SUBSYSTEM_FLASH_MANUAL_SELECT is not set
# CONFIG_SUBSYSTEM_FLASH__ADVANCED_AUTOCONFIG is not set
#
# partition 0
#
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_PART0_NAME="boot"
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_PART0_SIZE=0x100000
#
# partition 1
#
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_PART1_NAME="bootenv"
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_PART1_SIZE=0x40000
#
# partition 2
#
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_PART2_NAME="kernel"
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_PART2_SIZE=0x1600000
#
# partition 3
#
CONFIG_SUBSYSTEM_FLASH_PSU_QSPI_0_BANKLESS_PART3_NAME=""
#
# SD/SDIO Settings
#
CONFIG_SUBSYSTEM_PRIMARY_SD_PSU_SD_0_SELECT=y
# CONFIG_SUBSYSTEM_SD_MANUAL_SELECT is not set
#
# RTC Settings
#
CONFIG_SUBSYSTEM_RTC_PSU_RTC_SELECT=y
# CONFIG_SUBSYSTEM_RTC_MANUAL_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG=y
#
# boot image settings
#
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_BOOT_MEDIA_FLASH_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_BOOT_MEDIA_SD_SELECT=y
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_BOOT_MEDIA_MANUAL_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_BOOT_IMAGE_NAME="BOOT.BIN"
#
# u-boot env partition settings
#
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_BOOTENV_MEDIA_FLASH_SELECT=y
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_BOOTENV_MEDIA_MANUAL_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_BOOTENV_PART_NAME="bootenv"
#
# kernel image settings
#
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_KERNEL_MEDIA_FLASH_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_KERNEL_MEDIA_SD_SELECT=y
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_KERNEL_MEDIA_ETHERNET_SELECT is not set
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_KERNEL_MEDIA_MANUAL_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_KERNEL_IMAGE_NAME="image.ub"
#
# jffs2 rootfs image settings
#
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_MEDIA_FLASH_SELECT=y
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_MEDIA_MANUAL_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_PART_NAME="jffs2"
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_IMAGE_NAME="rootfs.jffs2"
#
# dtb image settings
#
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_DTB_MEDIA_BOOTIMAGE_SELECT=y
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_DTB_MEDIA_FLASH_SELECT is not set
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_DTB_MEDIA_SD_SELECT is not set
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_DTB_MEDIA_ETHERNET_SELECT is not set
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_DTB_MEDIA_MANUAL_SELECT is not set
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_DTB_IMAGE_NAME="system.dtb"
CONFIG_SUBSYSTEM_ENDIAN_LITTLE=y
CONFIG_SUBSYSTEM_BOOTARGS_GENERATED="earlycon clk_ignore_unused"
#
# ARM Trusted Firmware Compilation Configuration
#
CONFIG_SUBSYSTEM_ATF_COMPILE_EXTRA_SETTINGS=""
#
# u-boot Configuration
#
CONFIG_SUBSYSTEM_UBOOT_CONFIG_PETALINUX=y
CONFIG_SUBSYSTEM_UBOOT_CONFIG_TARGET="xilinx_zynqmp_zcu102_rev1_0_defconfig"
CONFIG_SUBSYSTEM_NETBOOT_OFFSET=0x10000000
CONFIG_SUBSYSTEM_U__BOOT_TFTPSERVER_IP="AUTO"
#
# Image Packaging Configuration
#
CONFIG_SUBSYSTEM_ROOTFS_INITRAMFS=y
# CONFIG_SUBSYSTEM_ROOTFS_INITRD is not set
# CONFIG_SUBSYSTEM_ROOTFS_JFFS2 is not set
# CONFIG_SUBSYSTEM_ROOTFS_NFS is not set
# CONFIG_SUBSYSTEM_ROOTFS_EXT is not set
# CONFIG_SUBSYSTEM_ROOTFS_OTHER is not set
CONFIG_SUBSYSTEM_UIMAGE_NAME="image.ub"
# CONFIG_SUBSYSTEM_UIMAGE_HASH_NONE is not set
CONFIG_SUBSYSTEM_UIMAGE_HASH_CRC32=y
# CONFIG_SUBSYSTEM_UIMAGE_HASH_SHA1 is not set
# CONFIG_SUBSYSTEM_UIMAGE_HASH_BOTH is not set
CONFIG_SUBSYSTEM_COMPRESS_IMAGE=y
CONFIG_SUBSYSTEM_DTB_PADDING_SIZE=0x1000
CONFIG_SUBSYSTEM_COPY_TO_TFTPBOOT=y
CONFIG_SUBSYSTEM_TFTPBOOT_DIR="/tftpboot"
#
# Firmware Version Configuration
#
CONFIG_SUBSYSTEM_HOSTNAME="diot"
CONFIG_SUBSYSTEM_PRODUCT="diot"
CONFIG_SUBSYSTEM_FW_VERSION="1.00"
CONFIG_SUBSYSTEM_MACHINE_NAME="template"
#
# Yocto Settings
#
CONFIG_TMP_DIR_LOCATION="${PROOT}/build/tmp"
CONFIG_PRE_MIRROR_URL="http://petalinux.xilinx.com/sswreleases/rel-v${PETALINUX_VER%%.*}/downloads"
CONFIG_YOCTO_NETWORK_SSTATE_FEEDS_URL="http://petalinux.xilinx.com/sswreleases/rel-v${PETALINUX_VER%%.*}/aarch64/sstate-cache"
CONFIG_mtd-utils=y
CONFIG_canutils=y
CONFIG_openssh-sftp-server=y
CONFIG_pciutils=y
CONFIG_run-postinsts=y
CONFIG_haveged=y
CONFIG_packagegroup-core-boot=y
CONFIG_packagegroup-core-ssh-dropbear=y
CONFIG_tcf-agent=y
CONFIG_bridge-utils=y
CONFIG_hellopm=y
CONFIG_udev-extraconf=y
CONFIG_imagefeature-ssh-server-dropbear=y
CONFIG_imagefeature-hwcodecs=y
CONFIG_ROOTFS_ROOT_PASSWD="root"
CONFIG_watchdog-init=y
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"
LAYERSERIES_COMPAT_meta-user = "thud"
#User Configuration
#OE_TERMINAL = "tmux"
# Add EXTRA_IMAGEDEPENDS default components
EXTRA_IMAGEDEPENDS_append = " virtual/fsbl virtual/pmu-firmware arm-trusted-firmware qemu-devicetrees"
# prevent U-Boot from deploying the boot.bin
SPL_BINARY = ""
#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"
#Note: Mention Each package in individual line
#These packages will get added into rootfs menu entry
CONFIG_gpio-demo
CONFIG_peekpoke
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.
*
* 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}
}
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.
*
* 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.
*
* 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}
}
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://system-user.dtsi"
#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
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://platform-top.h"
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