aboutsummaryrefslogtreecommitdiffstats
path: root/meta-steppeeagle/recipes-applications
diff options
context:
space:
mode:
Diffstat (limited to 'meta-steppeeagle/recipes-applications')
-rw-r--r--meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.c575
-rw-r--r--meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.h17
-rw-r--r--meta-steppeeagle/recipes-applications/gpio-test/gpio-test_1.0.bb22
-rw-r--r--meta-steppeeagle/recipes-applications/spi-test/files/spirom-test.c798
-rw-r--r--meta-steppeeagle/recipes-applications/spi-test/files/spirom.h53
-rw-r--r--meta-steppeeagle/recipes-applications/spi-test/spi-test_1.0.bb22
6 files changed, 0 insertions, 1487 deletions
diff --git a/meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.c b/meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.c
deleted file mode 100644
index 9fc646b1..00000000
--- a/meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.c
+++ /dev/null
@@ -1,575 +0,0 @@
-/*****************************************************************************
-*
-* Copyright (c) 2014, Advanced Micro Devices, Inc.
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of Advanced Micro Devices, Inc. nor the names of
-* its contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*
-***************************************************************************/
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-
-#include <readline/readline.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-
-#include "gpio-test.h"
-
-#define GPIO_APP_VERSION "0.1"
-#define AMD_GPIO_NUM_PINS 184
-static int gpio_in_use[AMD_GPIO_NUM_PINS];
-
-char *show_prompt(void)
-{
- return "$ ";
-}
-
-void sighandler(int sig)
-{
- printf("\n%s", show_prompt());
-}
-
-void show_license(void)
-{
- printf("/*****************************************************************************\n"
- "*\n"
- "* Copyright (c) 2014, Advanced Micro Devices, Inc.\n"
- "* All rights reserved.\n"
- "*\n"
- "* Redistribution and use in source and binary forms, with or without\n"
- "* modification, are permitted provided that the following conditions are met:\n"
- "* * Redistributions of source code must retain the above copyright\n"
- "* notice, this list of conditions and the following disclaimer.\n"
- "* * Redistributions in binary form must reproduce the above copyright\n"
- "* notice, this list of conditions and the following disclaimer in the\n"
- "* documentation and/or other materials provided with the distribution.\n"
- "* * Neither the name of Advanced Micro Devices, Inc. nor the names of\n"
- "* its contributors may be used to endorse or promote products derived\n"
- "* from this software without specific prior written permission.\n"
- "*\n"
- "* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n"
- "* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"
- "* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n"
- "* DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY\n"
- "* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n"
- "* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n"
- "* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n"
- "* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
- "* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n"
- "* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
- "*\n"
- "*\n"
- "***************************************************************************/\n");
-}
-
-void print_usage()
-{
- printf("\nCommands Supported ->\n");
- printf(" getgpiomode <gpio> : Gets the mode of GPIO pin\n");
- printf(" setgpiomode <gpio> <in/out/high/low> : Sets the mode of GPIO pin to input or output(high/low)\n");
- printf(" getgpiovalue <gpio> : Gets the value of GPIO pin\n");
- printf(" setgpiovalue <gpio> <high/low> : Sets the value of GPO pin to high or low\n");
- printf(" getnumgpio : Gets the number of GPIO pins supported\n");
- printf(" getgpiobase : Gets the number of first GPIO pin\n");
- printf(" getgpioname : Gets the name of GPIO driver currently in use\n");
- printf(" dmesg : Displays the kernel log messages related to GPIO\n");
- printf(" license : Displays the terms of LICENSE for this application\n");
- printf(" help : Displays help text\n");
- printf(" exit : Exits the application\n\n");
-}
-
-void parse_cmd(const char *cmdline)
-{
- int fd;
-
- if ((cmdline == NULL) || (strncmp(cmdline, "exit", 4) == 0)) {
- int i;
- int ret;
- char gpio[3 + 1];
-
- printf("\nExiting...\n");
-
- /* We need to unexport all the GPIO pins exported earlier */
- for (i = 0; i < AMD_GPIO_NUM_PINS; i++) {
- if (gpio_in_use[i]) {
- int fd;
-
- fd = open("/sys/class/gpio/unexport", O_WRONLY);
- if (fd < 0) {
- printf("\nPlease make sure AMD GPIO driver is loaded\n");
- exit(EXIT_FAILURE);
- }
- memset(gpio, '\0', (3 + 1));
- snprintf(gpio, 4, "%d", i);
-
- ret = write(fd, gpio, strlen(gpio));
- if (ret < 0)
- perror("Error writing to /sys/class/gpio/unexport");
- }
- }
-
- exit(EXIT_SUCCESS);
- } else if (strncmp(cmdline, "help", 4) == 0)
- print_usage();
- else if (strncmp(cmdline, "getnumgpio", 10) == 0) {
- int fd;
- char ngpio[3 + 1];
-
- memset(ngpio, '\0', (3 + 1));
- fd = open("/sys/class/gpio/gpiochip0/ngpio", O_RDONLY);
- if (fd < 0) {
- printf("\nPlease make sure AMD GPIO driver is loaded\n");
- exit(EXIT_FAILURE);
- }
-
- /* Value read from the file is ASCII text */
- if(read(fd, ngpio, 3) < 0)
- perror("Cannot read number of GPIO pins");
-
- printf("\nThe maximum number of GPIO pins supported is %d\n", atoi(ngpio));
- close(fd);
- } else if (strncmp(cmdline, "getgpiobase", 11) == 0) {
- int fd;
- char gpiobase[3 + 1];
-
- memset(gpiobase, '\0', (3 + 1));
- fd = open("/sys/class/gpio/gpiochip0/base", O_RDONLY);
- if (fd < 0) {
- printf("\nPlease make sure AMD GPIO driver is loaded\n");
- exit(EXIT_FAILURE);
- }
-
- if(read(fd, gpiobase, 3) < 0)
- perror("Cannot read GPIO base");
-
- printf("\nGPIO pin numbering starts from %d\n", atoi(gpiobase));
- close(fd);
- } else if (strncmp(cmdline, "getgpioname", 11) == 0) {
- int fd;
- char gpioname[10 + 1]; /* Max 10 characters + NULL character */
-
- /* Zero initialize gpioname array */
- memset(gpioname, '\0', sizeof(gpioname));
-
- fd = open("/sys/class/gpio/gpiochip0/label", O_RDONLY);
- if (fd < 0) {
- printf("\nPlease make sure AMD GPIO driver is loaded\n");
- exit(EXIT_FAILURE);
- }
-
- if(read(fd, gpioname, 10) < 0)
- perror("Cannot read GPIO driver name");
-
- printf("\nGPIO driver loaded is %s\n", gpioname);
- close(fd);
- } else if (strncmp(cmdline, "getgpiovalue", 12) == 0) {
- int fd;
- int gpio;
- const char *charp = cmdline;
- char pathname[80];
- int ret = 0;
-
- /* Lets point to the end of first token */
- charp += strlen("getgpiovalue");
- /* Skip blank characters */
- while (*charp == ' ' || *charp == '\t' || *charp == '\n')
- charp++;
-
- /* Now we should be pointing to the first 'digit' character */
- gpio = atoi(charp);
-
- fd = open("/sys/class/gpio/export", O_WRONLY);
- if (fd < 0) {
- if (errno == EACCES)
- printf("\nYou do not have correct permission, please run as root\n");
- else
- perror("Eror opening /sys/class/gpio/export");
-
- exit(EXIT_FAILURE);
- }
-
- ret = write(fd, charp, strlen(charp));
- /*
- * There can be two situations ->
- * 1) The GPIO is being exported for the first time.
- * 2) The GPIO is being exported again.
- * In the first case, the write to file descriptor should
- * succeed, and we should still fall into the if clause.
- *
- * In the second case, write will fail and errno will be
- * set to EBUSY, since the GPIO pin is already exported.
- * Rest all is error.
- */
- if((ret >= 0) || ((ret < 0) && (errno == EBUSY))) {
- /* Close the last file descriptor */
- close(fd);
-
- memset(pathname, '\0', sizeof(pathname));
- sprintf(pathname, "/sys/class/gpio/gpio%d/value", gpio);
-
- fd = open(pathname, O_RDONLY);
- if (fd < 0)
- perror("GPIO read error");
- else {
- char value[1 + 1];
-
- memset(value, '\0', 2);
- ret = read(fd, value, 1);
- if (ret < 0)
- perror("Cannot read GPIO pin");
-
- printf("\nGPIO pin %s is at \"%s\"\n", charp,
- (strncmp(value, "1", 1) == 0) ? "high" : "low");
-
- close(fd);
-
- /*
- * Mark the GPIO as already exported, so that we can use
- * unexport them during exit.
- */
- gpio_in_use[gpio] = 1;
- }
- } else {
- if (errno == EINVAL)
- printf("\nInvalid GPIO number\n");
- else
- perror("Error exporting GPIO number");
-
- close(fd);
- }
- } else if (strncmp(cmdline, "getgpiomode", 11) == 0) {
- int fd;
- int gpio;
- const char *charp = cmdline;
- char pathname[80];
- int ret = 0;
-
- /* Lets point to the end of first token */
- charp += strlen("getgpiomode");
- /* Skip blank characters */
- while (*charp == ' ' || *charp == '\t' || *charp == '\n')
- charp++;
-
- /* Now we should be pointing to the first 'digit' character */
- gpio = atoi(charp);
-
- fd = open("/sys/class/gpio/export", O_WRONLY);
- if (fd < 0) {
- if (errno == EACCES)
- printf("\nYou do not have correct permission, please run as root\n");
- else
- perror("Eror opening /sys/class/gpio/export");
-
- exit(EXIT_FAILURE);
- }
-
- ret = write(fd, charp, strlen(charp));
- /*
- * There can be two situations ->
- * 1) The GPIO is being exported for the first time.
- * 2) The GPIO is being exported again.
- * In the first case, the write to file descriptor should
- * succeed, and we should still fall into the if clause.
- *
- * In the second case, write will fail and errno will be
- * set to EBUSY, since the GPIO pin is already exported.
- * Rest all is error.
- */
- if((ret >= 0) || ((ret < 0) && (errno == EBUSY))) {
- FILE *fp;
-
- /* Close the last file descriptor */
- close(fd);
-
- memset(pathname, '\0', sizeof(pathname));
- sprintf(pathname, "/sys/class/gpio/gpio%d/direction", gpio);
-
- fp = fopen(pathname, "r");
- if (fp == NULL)
- perror("GPIO read error");
- else {
- char mode[3 + 1];
- int c, i = 0;
-
- memset(mode, '\0', (3 + 1));
- /*
- * Since we do not exactly know whether the
- * direction will be 'in' or 'out', we need to
- * use fgetc() so that we read the input till
- * we find terminating '\n', at which point
- * we stop reading any further.
- */
- while ((c = fgetc(fp)) != '\n')
- mode[i++] = c;
-
- printf("\nGPIO pin %s is in \"%s\" mode\n", charp,
- (strncmp(mode, "in", 2) == 0) ? "input" : "output");
-
- fclose(fp);
-
- /*
- * Mark the GPIO as already exported, so that we can use
- * unexport them during exit.
- */
- gpio_in_use[gpio] = 1;
- }
- } else {
- if (errno == EINVAL)
- printf("\nInvalid GPIO number\n");
- else
- perror("Error exporting GPIO number");
-
- close(fd);
- }
- } else if (strncmp(cmdline, "setgpiomode", 11) == 0) {
- int fd;
- const char *charp = cmdline;
- int i = 0;
- char gpio[3 + 1];
- int ngpio;
- int ret;
-
- charp += strlen("setgpiomode");
- while (*charp == ' ' || *charp == '\t' || *charp == '\n')
- charp++;
-
- memset(gpio, '\0', (3 + 1));
- /*
- * We are at the start of string which contains the GPIO
- * number. We look for the end of this string, copying
- * byte by byte into array. We also make sure that we
- * do not store more than 3 bytes into the array, since
- * a GPIO can have a maximum value of 183, that is, not
- * exceeding 3 characters.
- */
- while (*charp != ' ' && *charp != '\t' && (i < 3)) {
- gpio[i++] = *charp;
- charp++;
- }
-
- ngpio = atoi(gpio);
-
- fd = open("/sys/class/gpio/export", O_WRONLY);
- if (fd < 0) {
- if (errno == EACCES)
- printf("\nYou do not have correct permission, please run as root\n");
- else
- perror("Eror opening /sys/class/gpio/export");
-
- exit(EXIT_FAILURE);
- }
-
- ret = write(fd, gpio, strlen(gpio));
- if((ret >= 0) || ((ret < 0) && (errno == EBUSY))) {
- char pathname[80];
-
- /* Close the last file descriptor */
- close(fd);
-
- memset(pathname, '\0', sizeof(pathname));
- sprintf(pathname, "/sys/class/gpio/gpio%d/direction", ngpio);
-
- fd = open(pathname, O_WRONLY);
- if (fd < 0)
- perror("GPIO read error");
- else {
- char mode[4 + 1];
-
- memset(mode, '\0', (4 + 1));
-
- /* Lets skip the blanks till we find a character */
- while (*charp == ' ' || *charp == '\t')
- charp++;
-
- i = 0;
- /*
- * Mode can be 'in', 'out', 'high' or 'low',
- * again a maximum of 4 characters.
- */
- while (*charp != ' ' && *charp != '\t' && (i < 4)) {
- mode[i++] = *charp;
- charp++;
- }
-
- /* Sanity check */
- if ((strncmp(mode, "in", 2) == 0) ||
- (strncmp(mode, "out", 3) == 0) ||
- (strncmp(mode, "high", 4) == 0) ||
- (strncmp(mode, "low", 3) == 0)) {
- /* Write mode into /sys/.../direction file */
- ret = write(fd, mode, strlen(mode));
- if (ret < 0)
- perror("Error writing GPIO mode");
- } else
- printf("\nInvalid GPIO mode, please try again\n");
-
- close(fd);
-
- /*
- * Mark the GPIO as exported, so that we can use
- * unexport them during exit.
- */
- gpio_in_use[ngpio] = 1;
- }
- } else {
- if (errno == EINVAL)
- printf("\nInvalid GPIO number\n");
- else
- perror("Error exporting GPIO number");
-
- close(fd);
- }
- } else if (strncmp(cmdline, "setgpiovalue", 12) == 0) {
- int fd;
- const char *charp = cmdline;
- int i = 0;
- char gpio[3 + 1];
- int ngpio;
- int ret;
-
- charp += strlen("setgpiovalue");
- while (*charp == ' ' || *charp == '\t' || *charp == '\n')
- charp++;
-
- memset(gpio, '\0', (3 + 1));
- /*
- * We are at the start of string which contains the GPIO
- * number. We look for the end of this string, copying
- * byte by byte into array. We also make sure that we
- * do not store more than 3 bytes into the array, since
- * a GPIO can have a maximum value of 183, that is, not
- * exceeding 3 characters.
- */
- while (*charp != ' ' && *charp != '\t' && (i < 3)) {
- gpio[i++] = *charp;
- charp++;
- }
-
- ngpio = atoi(gpio);
-
- fd = open("/sys/class/gpio/export", O_WRONLY);
- if (fd < 0) {
- if (errno == EACCES)
- printf("\nYou do not have correct permission, please run as root\n");
- else
- perror("Eror opening /sys/class/gpio/export");
-
- exit(EXIT_FAILURE);
- }
-
- ret = write(fd, gpio, strlen(gpio));
- if((ret >= 0) || ((ret < 0) && (errno == EBUSY))) {
- char pathname[80];
-
- /* Close the last file descriptor */
- close(fd);
-
- memset(pathname, '\0', sizeof(pathname));
- sprintf(pathname, "/sys/class/gpio/gpio%d/value", ngpio);
-
- fd = open(pathname, O_WRONLY);
- if (fd < 0)
- perror("GPIO read error");
- else {
- char value[1 + 1];
-
- memset(value, '\0', (1 + 1));
-
- /* Lets skip the blanks till we find a character */
- while (*charp == ' ' || *charp == '\t')
- charp++;
-
- i = 0;
-
- if (strncmp(charp, "high", 4) == 0)
- value[0] = '1';
- else if (strncmp(charp, "low", 3) == 0)
- value[0] = '0';
- else {
- printf("\nInvalid input, please try again...\n");
- goto out;
- }
-
- /* Write mode into /sys/.../direction file */
- ret = write(fd, value, 1);
- if (ret < 0)
- perror("Error writing GPIO mode");
-
-out:
- close(fd);
-
- /*
- * Mark the GPIO as exported, so that we can use
- * unexport them during exit.
- */
- gpio_in_use[ngpio] = 1;
- }
- } else {
- if (errno == EINVAL)
- printf("\nInvalid GPIO number\n");
- else
- perror("Error exporting GPIO number");
-
- close(fd);
- }
- } else if (strncmp(cmdline, "dmesg", 5) == 0) {
- if (system("dmesg | grep GPIO") < 0)
- perror("Error executing \'dmesg | grep GPIO\'");
- } else if (strncmp(cmdline, "license", 7) == 0) {
- show_license();
- } else {
- printf("\nUnknown command\n");
- print_usage();
- }
-}
-
-int main(void)
-{
- char *cmdline= NULL;
-
- printf("GPIO sample application version: %s\n", GPIO_APP_VERSION);
- printf("Copyright (c) 2014, Advanced Micro Devices, Inc.\n"
- "This sample application comes with ABSOLUTELY NO WARRANTY;\n"
- "This is free software, and you are welcome to redistribute it\n"
- "under certain conditions; type `license' for details.\n\n");
-
- /* Handler for Ctrl+C */
- signal(SIGINT, sighandler);
-
- while (1) {
- cmdline = readline(show_prompt());
- parse_cmd(cmdline);
- /* Free the memory malloc'ed by readline */
- free(cmdline);
- }
-
- /* Should never reach here */
- return 0;
-}
diff --git a/meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.h b/meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.h
deleted file mode 100644
index af9c3b68..00000000
--- a/meta-steppeeagle/recipes-applications/gpio-test/files/gpio-test.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _GPIO_TEST_H_
-#define _GPIO_TEST_H_
-
-
-
-/* IOCTL numbers */
-
-typedef struct {
- int offset;
- int value;
-}debug_data;
-
-#define GPIO_TEST_IOC_MAGIC 'k'
-#define GPIO_IOC_SWCTRLIN _IOW(GPIO_TEST_IOC_MAGIC, 1, debug_data)
-#define GPIO_IOC_SWCTRLEN _IOW(GPIO_TEST_IOC_MAGIC, 2, debug_data)
-
-#endif /* _GPIO_TEST_H_ */
diff --git a/meta-steppeeagle/recipes-applications/gpio-test/gpio-test_1.0.bb b/meta-steppeeagle/recipes-applications/gpio-test/gpio-test_1.0.bb
deleted file mode 100644
index be664e17..00000000
--- a/meta-steppeeagle/recipes-applications/gpio-test/gpio-test_1.0.bb
+++ /dev/null
@@ -1,22 +0,0 @@
-DESCRIPTION = "Sample application for AMD GPIO driver"
-SECTION = "applications"
-LICENSE = "BSD"
-DEPENDS = "readline"
-LIC_FILES_CHKSUM = "file://gpio-test.c;endline=29;md5=8e7a9706367d146e5073510a6e176dc2"
-
-SRC_URI = "file://gpio-test.c \
- file://gpio-test.h \
- "
-
-TARGET_CC_ARCH += "${LDFLAGS}"
-
-S = "${WORKDIR}"
-
-do_compile() {
- ${CC} gpio-test.c -o gpio-test -lreadline
-}
-
-do_install() {
- install -d ${D}${bindir}
- install -m 0755 gpio-test ${D}${bindir}
-}
diff --git a/meta-steppeeagle/recipes-applications/spi-test/files/spirom-test.c b/meta-steppeeagle/recipes-applications/spi-test/files/spirom-test.c
deleted file mode 100644
index 091ced1a..00000000
--- a/meta-steppeeagle/recipes-applications/spi-test/files/spirom-test.c
+++ /dev/null
@@ -1,798 +0,0 @@
-/*****************************************************************************
-*
-* Copyright (c) 2014, Advanced Micro Devices, Inc.
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of Advanced Micro Devices, Inc. nor the names of
-* its contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*
-***************************************************************************/
-#include <stdint.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string.h>
-#include <dirent.h>
-#include <signal.h>
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-
-#include <readline/readline.h>
-
-#include "spirom.h"
-
-#define SPI_APP_VERSION "1.0"
-
-static int device_opened = 0;
-static char filename[20];
-static int fd = -1;
-
-char *show_prompt(void)
-{
- return "$ ";
-}
-
-void sighandler(int sig)
-{
- /* Do nothing. That is the idea. */
-}
-
-void show_license(void)
-{
- printf("/*****************************************************************************\n"
- "*\n"
- "* Copyright (c) 2014, Advanced Micro Devices, Inc.\n"
- "* All rights reserved.\n"
- "*\n"
- "* Redistribution and use in source and binary forms, with or without\n"
- "* modification, are permitted provided that the following conditions are met:\n"
- "* * Redistributions of source code must retain the above copyright\n"
- "* notice, this list of conditions and the following disclaimer.\n"
- "* * Redistributions in binary form must reproduce the above copyright\n"
- "* notice, this list of conditions and the following disclaimer in the\n"
- "* documentation and/or other materials provided with the distribution.\n"
- "* * Neither the name of Advanced Micro Devices, Inc. nor the names of\n"
- "* its contributors may be used to endorse or promote products derived\n"
- "* from this software without specific prior written permission.\n"
- "*\n"
- "* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n"
- "* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"
- "* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n"
- "* DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY\n"
- "* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n"
- "* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n"
- "* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n"
- "* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
- "* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n"
- "* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
- "*\n"
- "*\n"
- "***************************************************************************/\n");
-}
-
-void print_usage(void)
-{
- printf("\nCommands Supported ->\n");
- printf(" enumerate : List all SPI device nodes available\n");
- printf(" setdevice <dev_id> : Set the SPI device number to access\n");
- printf(" wren : Enable Write operation on SPI device\n");
- printf(" wrdi : Disable Write operation on SPI device\n");
- printf(" chiperase : Erase entire ROM chip\n");
- printf(" rdsr : Read status register of ROM device\n");
- printf(" rdid : Read device identification string\n");
- printf(" sectorerase <addr> <num_sectors> : Erase a fixed number of sectors starting at the address\n"
- " specified\n");
- printf(" blockerase <addr> <num_blocks> : Erase a fixed number of blocks starting at the address\n"
- " specified\n");
- printf(" read <addr> <num_bytes> <filename> : Read a fixed number of bytes starting at address\n"
- " specified, and output the contents into file\n");
- printf(" write <addr> <num_bytes> <filename> : Read a fixed number of bytes from file and output\n"
- " the contents to the device starting at the address\n"
- " specified\n");
- printf(" license : Displays the terms of LICENSE for this application\n");
- printf(" help : Displays help text\n");
- printf(" exit : Exits the application\n\n");
-}
-
-void parse_cmd(const char *cmdline)
-{
- struct spi_ioc_transfer tr;
- unsigned int bytes_chunks;
- unsigned int remaining_bytes;
- int addr;
- int ret;
-
- if ((cmdline == NULL) || (strncmp(cmdline, "exit", 4) == 0)) {
- printf("\nExiting...\n");
- close(fd);
- exit(EXIT_SUCCESS);
- } else if (strncmp(cmdline, "enumerate", 9) == 0) {
- DIR *dir;
- struct dirent *dir_entry;
- int device_found = 0;
-
- /* Get the directory handle */
- if ((dir = opendir("/dev")) == NULL) {
- printf("\n\nFailed to open directory /dev. Probably you "
- "do not have right privilege!\n\n");
- exit(EXIT_FAILURE);
- }
-
- /* Iterate over all the directory entries */
- while ((dir_entry = readdir(dir)) != NULL) {
- /*
- * If the file is a character device, and its signature
- * matches spirom, then we print the corresponding file.
- */
- if ((dir_entry->d_type == DT_CHR) &&
- (strncmp(dir_entry->d_name, "spirom", 6) == 0)) {
- printf("/dev/%s\n", dir_entry->d_name);
- device_found = 1;
- }
- }
-
- printf("\n");
-
- /*
- * In case we did not find even a single entry, we print a
- * message and exit.
- */
- if (!device_found) {
- printf("\n\nNo spirom device nodes found, load spirom "
- "kernel module and try again\n\n");
- exit(EXIT_FAILURE);
- }
- } else if (strncmp(cmdline, "setdevice", 9) == 0) {
- char input[2 + 1];
- int file_desc;
-
- cmdline += 10;
- memset(input, 0, 3);
- if (sscanf(cmdline, "%s", input) < 1) {
- printf("\nInvalid inputs, please try again\n\n");
- return;
- }
-
- memset(filename, 0, 20);
- snprintf(filename, 19, "/dev/spirom%s", input);
- file_desc = open(filename, O_RDWR);
- if (file_desc < 0) {
- printf("\nError opening file %s\n\n", filename);
- return;
- }
-
- /* Once we have validated inputs, we store them into the global
- * variables used at other places in the program.
- */
- fd = file_desc;
- device_opened = 1;
- printf("\nSPI device set to /dev/spirom%s\n\n", input);
- } else if (strncmp(cmdline, "wren", 4) == 0) {
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- /* command without data */
- tr.buf[0] = ROM_WREN;
- tr.direction = 0;
- tr.len = 0;
- tr.addr_present = 0;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1)
- printf("\nError executing WREN command\n\n");
- else
- printf("\n...WREN completed successfully\n\n");
- } else if (strncmp(cmdline, "wrdi", 4) == 0) {
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- /* command without data */
- tr.buf[0] = ROM_WRDI;
- tr.direction = 0;
- tr.len = 0;
- tr.addr_present = 0;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1)
- printf("\nError executing WRDI command\n\n");
- else
- printf("\n...WRDI completed successfully\n\n");
- } else if (strncmp(cmdline, "chiperase", 9) == 0) {
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");;
- return;
- } else if ((tr.buf[1] & 0x02) == 0x00) {
- printf("\nCannot execute RDSR command, write is disabled\n\n");
- return;
- }
-
- /* Command without data */
- tr.buf[0] = ROM_CHIP_ERASE;
- tr.direction = 0;
- tr.len = 0;
- tr.addr_present = 0;
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing CHIPERASE command\n\n");
- return;
- }
-
- printf("\n\nCHIPERASE operation in progress, please do not "
- " stop in between.\n\n");
-
- /* Make sure WIP has been reset */
- while (1) {
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- }
-
- if ((tr.buf[1] & 0x01) == 0x00)
- break;
- }
-
- printf("\n\n...CHIPERASE completed successfully\n\n");
- /* Restore signal handler to default */
- } else if (strncmp(cmdline, "rdsr", 4) == 0) {
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- /* Command with response */
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- }
-
- /*
- * The 1-byte response will be stored in tr.buf,
- * so print it out
- */
- printf("\nRDSR command returned: 0x%.2x\n\n", tr.buf[1]);
- } else if (strncmp(cmdline, "rdid", 4) == 0) {
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- /* Command with response */
- tr.buf[0] = ROM_RDID;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 3;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDID command\n\n");
- return;
- }
-
- /*
- * The 3-bytes response will be stored in tr.buf,
- * so print it out
- */
- printf("\nRDID command returned: 0x%.2x%.2x%.2x\n", tr.buf[1],
- tr.buf[2], tr.buf[3]);
- } else if (strncmp(cmdline, "sectorerase", 11) == 0) {
- int nsectors;
- int i;
-
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- cmdline += 12;
- if (sscanf(cmdline, "0x%x 0x%x", &addr, &nsectors) < 2) {
- printf("\nInvalid inputs, please try again\n\n");
- return;
- }
-
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- } else if ((tr.buf[1] & 0x02) == 0x00) {
- printf("\nCannot execute SECTORERASE command, write is disabled\n\n");
- return;
- }
-
- printf("\n\nSECTORERASE operation in progress, please do not "
- " stop in between.\n\n");
-
- for (i = 0; i < nsectors; i++) {
- /* Write Enable before Sector Erase */
- tr.buf[0] = ROM_WREN;
- tr.direction = 0;
- tr.len = 0;
- tr.addr_present = 0;
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing WREN command\n\n");
- return;
- }
-
- /* Command with address but no data */
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_SECTOR_ERASE;
- tr.buf[3] = addr & 0xff;
- tr.buf[2] = (addr >> 8) & 0xff;
- tr.buf[1] = (addr >> 16) & 0xff;
- tr.addr_present = 1;
- tr.direction = 0;
- tr.len = 0;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing SECTORERASE command\n\n");
- return;
- }
-
- /* point to the next 4k sector */
- addr += 4 * 1024;
-
- /*
- * Before the next loop, we need to make sure that WIP
- * bit in the output of RDSR has been reset.
- */
- while (1) {
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- }
-
- if ((tr.buf[1] & 0x01) == 0x00)
- break;
- }
- }
-
- printf("\n\n...SECTORERASE completed successfully\n\n");
- } else if (strncmp(cmdline, "blockerase", 10) == 0) {
- int nblocks;
- int i;
-
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- cmdline += 11;
- if (sscanf(cmdline, "0x%x 0x%x", &addr, &nblocks) < 2) {
- printf("\nInvalid inputs, please try again\n\n");
- return;
- }
-
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- } else if ((tr.buf[1] & 0x02) == 0x00) {
- printf("\nError executing BLOCKERASE command, write is disabled\n\n");
- return;
- }
-
- printf("\n\nBLOCKERASE operation in progress, please do not "
- " stop in between.\n\n");
-
- for (i = 0; i < nblocks; i++) {
- /* Write Enable before Block Erase */
- tr.buf[0] = ROM_WREN;
- tr.direction = 0;
- tr.len = 0;
- tr.addr_present = 0;
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing WREN command\n\n");
- return;
- }
-
- /* Command with address but no data */
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_BLOCK_ERASE;
- tr.buf[3] = addr & 0xff;
- tr.buf[2] = (addr >> 8) & 0xff;
- tr.buf[1] = (addr >> 16) & 0xff;
- tr.addr_present = 1;
- tr.direction = 0;
- tr.len = 0;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing BLOCKERASE command\n\n");
- return;
- }
-
- /* point to the next 64k block */
- addr += 64 * 1024;
-
- /*
- * Before the next loop, we need to make sure that WIP
- * bit in the output of RDSR has been reset.
- */
- while (1) {
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- }
-
- if ((tr.buf[1] & 0x01) == 0x00)
- break;
- }
- }
-
- printf("\n\n...BLOCKERASE completed successfully\n\n");
- } else if (strncmp(cmdline, "read", 4) == 0) {
- int nbytes;
- int outfile_fd;
- int i;
-
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- cmdline += 5;
- memset(filename, 0, 20);
- if (sscanf(cmdline, "0x%x 0x%x %s", &addr, &nbytes, filename) < 3) {
- printf("\nInvalid inputs, please try again\n\n");
- return;
- }
-
- /*
- * Open the output file for writing. Create a new file if not
- * there, and empty the file before writing if file already
- * exists.
- */
- outfile_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (outfile_fd < 0) {
- printf("\nError opening file %s for writing\n\n", filename);
- return;
- }
-
- /*
- * We will break down the bytes to be received in chunks of
- * of 4-bytes. Data might not be a even multiple of 4. So
- * in that case, we will have some remaining bytes <4. We
- * handle that separately.
- */
- bytes_chunks = nbytes / 4;
- remaining_bytes = nbytes % 4;
-
- printf("\n\nREAD operation in progress.\n\n");
-
- for (i = 0; i < bytes_chunks; i++) {
- /* Command with address and data */
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_READ;
- tr.direction = RECEIVE;
- /*
- * We will store the address into the buffer in little
- * endian order.
- */
- tr.buf[3] = addr & 0xff;
- tr.buf[2] = (addr >> 8) & 0xff;
- tr.buf[1] = (addr >> 16) & 0xff;
- tr.len = 4;
- tr.addr_present = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing READ command\n\n");
- return;
- }
-
- /* Write the data read to output file */
- if (write(outfile_fd, &tr.buf[4], tr.len) < 0) {
- printf("\nError writing to file %s\n\n", filename);
- return;
- }
- addr += 4;
- }
-
- if (remaining_bytes) {
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_READ;
- tr.direction = RECEIVE;
- tr.buf[3] = addr & 0xff;
- tr.buf[2] = (addr >> 8) & 0xff;
- tr.buf[1] = (addr >> 16) & 0xff;
- tr.len = remaining_bytes;
- tr.addr_present = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing READ command\n\n");
- return;
- }
-
- if (write(outfile_fd, &tr.buf[4], tr.len) < 0) {
- printf("\nError writing to file %s\n\n", filename);
- return;
- }
- }
-
- printf("\n\n...READ completed successfully\n\n");
- close(outfile_fd);
- } else if (strncmp(cmdline, "write", 5) == 0) {
- int nbytes;
- int infile_fd;
- int i;
-
- if (!device_opened) {
- printf("\nSPI device needs to be set before you can "
- "perform this operation\n\n");
- return;
- }
-
- cmdline += 6;
- memset(filename, 0, 20);
- if (sscanf(cmdline, "0x%x 0x%x %s", &addr, &nbytes, filename) < 3) {
- printf("\nInvalid inputs, please try again\n\n");
- return;
- }
-
- /* Open the input file for reading*/
- infile_fd = open(filename, O_RDONLY);
- if (infile_fd < 0) {
- printf("\nError opening file %s for reading\n\n", filename);
- return;
- }
-
- /*
- * We will break down the bytes to be transmitted in chunks of
- * of 4-bytes. Like for read, we might not have data in an
- * even multiple of 4 bytes. So we will handle the remaining
- * bytes in the end.
- */
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- } else if ((tr.buf[1] & 0x02) == 0x00) {
- printf("\nCannot execute WRITE command, write is disabled\n\n");
- return;
- }
-
- bytes_chunks = nbytes / 4;
- remaining_bytes = nbytes % 4;
-
- printf("\n\nWRITE operation in progress, please do not "
- " stop in between.\n\n");
-
- for (i = 0; i < bytes_chunks; i++) {
- tr.buf[0] = ROM_WREN;
- tr.direction = 0;
- tr.len = 0;
- tr.addr_present = 0;
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing WREN command\n\n");
- return;
- }
-
- /* Command with data and address */
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_WRITE;
- tr.direction = TRANSMIT;
- /*
- * We will store the address into the buffer in little
- * endian order.
- */
- tr.buf[3] = addr & 0xff;
- tr.buf[2] = (addr >> 8) & 0xff;
- tr.buf[1] = (addr >> 16) & 0xff;
- tr.len = 4;
- tr.addr_present = 1;
-
- /* Read 4 bytes from input file to buffer */
- if (read(infile_fd, &tr.buf[4], tr.len) < 0) {
- printf("\nError reading from file %s\n\n", filename);
- return;
- }
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing WRITE command\n\n");
- return;
- }
-
- addr += 4;
-
- /*
- * Before the next loop, we need to make sure that WIP
- * bit in the output of RDSR has been reset.
- */
- while (1) {
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- }
-
- if ((tr.buf[1] & 0x01) == 0x00)
- break;
- }
- }
-
- if (remaining_bytes) {
- tr.buf[0] = ROM_WREN;
- tr.direction = 0;
- tr.len = 0;
- tr.addr_present = 0;
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing WREN command\n\n");
- return;
- }
-
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_WRITE;
- tr.direction = TRANSMIT;
- tr.buf[3] = addr & 0xff;
- tr.buf[2] = (addr >> 8) & 0xff;
- tr.buf[1] = (addr >> 16) & 0xff;
- tr.len = remaining_bytes;
- tr.addr_present = 1;
-
- if (read(infile_fd, &tr.buf[4], tr.len) < 0) {
- printf("\nError reading from file %s\n\n", filename);
- return;
- }
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing WRITE command\n\n");
- return;
- }
-
- while (1) {
- memset(&tr, 0, sizeof(struct spi_ioc_transfer));
- tr.buf[0] = ROM_RDSR;
- tr.direction = RECEIVE;
- tr.addr_present = 0;
- tr.len = 1;
-
- ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
- if (ret < 1) {
- printf("\nError executing RDSR command\n\n");
- return;
- }
-
- if ((tr.buf[1] & 0x01) == 0x00)
- break;
- }
- }
-
- printf("\n\n...WRITE completed successfully\n\n");
- close(infile_fd);
- } else if (strncmp(cmdline, "license", 7) == 0) {
- show_license();
- } else if (strncmp(cmdline, "help", 4) == 0) {
- print_usage();
- } else {
- printf("\nUnknown command\n");
- print_usage();
- }
-}
-
-int main(void)
-{
- char *cmdline= NULL;
-
- printf("SPI sample application version: %s\n", SPI_APP_VERSION);
- printf("Copyright (c) 2014, Advanced Micro Devices, Inc.\n"
- "This sample application comes with ABSOLUTELY NO WARRANTY;\n"
- "This is free software, and you are welcome to redistribute it\n"
- "under certain conditions; type `license` for details.\n\n");
-
- /* Set the signal handler */
- signal(SIGINT, sighandler);
-
- while (1) {
- cmdline = readline(show_prompt());
- parse_cmd(cmdline);
- /* Free the memory malloc'ed by readline */
- free(cmdline);
- }
-
- /* Restore the default signal handler */
- signal(SIGINT, SIG_DFL);
-
- /* Should never reach here */
- return 0;
-}
diff --git a/meta-steppeeagle/recipes-applications/spi-test/files/spirom.h b/meta-steppeeagle/recipes-applications/spi-test/files/spirom.h
deleted file mode 100644
index 941b357a..00000000
--- a/meta-steppeeagle/recipes-applications/spi-test/files/spirom.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef SPIROM_H
-#define SPIROM_H
-
-#include <linux/types.h>
-
-/*---------------------------------------------------------------------------*/
-
-/* IOCTL commands */
-
-#define SPI_IOC_MAGIC 'k'
-
-#define TRANSMIT 1
-#define RECEIVE 2
-
-/*
- * struct spi_ioc_transfer - interface structure between application and ioctl
- *
- * @buf: Buffer to hold 1-byte command, 3-bytes address, and 64-byte data for
- * transmit or receive. The internal FIFO of our controller can hold a
- * maximum of 70 bytes, including the address. But here we assume the
- * maximum data excluding address to be 64-bytes long.
- *
- * @direction: Direction of data transfer, either TRANSMIT or RECEIVE.
- *
- * @len: Length of data excluding command and address.
- *
- * @addr_present: Flag to indicate whether 'buf' above contains an address.
- */
-struct spi_ioc_transfer {
- __u8 buf[64 + 1 + 3];
- __u8 direction;
- __u8 len;
- __u8 addr_present;
-};
-
-/* not all platforms use <asm-generic/ioctl.h> or _IOC_TYPECHECK() ... */
-#define SPI_MSGSIZE(N) \
- ((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \
- ? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
-#define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])
-
-/* SPI ROM command codes */
-#define ROM_WREN 0x06
-#define ROM_WRDI 0x04
-#define ROM_RDSR 0x05
-#define ROM_RDID 0x9F
-#define ROM_CHIP_ERASE 0x60
-#define ROM_SECTOR_ERASE 0x20
-#define ROM_BLOCK_ERASE 0xD8
-#define ROM_READ 0x03
-#define ROM_WRITE 0x02
-
-#endif /* SPIROM_H */
diff --git a/meta-steppeeagle/recipes-applications/spi-test/spi-test_1.0.bb b/meta-steppeeagle/recipes-applications/spi-test/spi-test_1.0.bb
deleted file mode 100644
index 764f112a..00000000
--- a/meta-steppeeagle/recipes-applications/spi-test/spi-test_1.0.bb
+++ /dev/null
@@ -1,22 +0,0 @@
-DESCRIPTION = "Sample application for AMD SPI driver"
-SECTION = "applications"
-LICENSE = "BSD"
-DEPENDS = "readline"
-LIC_FILES_CHKSUM = "file://spirom-test.c;endline=29;md5=8e7a9706367d146e5073510a6e176dc2"
-
-SRC_URI = "file://spirom-test.c \
- file://spirom.h \
- "
-
-S = "${WORKDIR}"
-
-TARGET_CC_ARCH += "${LDFLAGS}"
-
-do_compile() {
- ${CC} spirom-test.c -o spirom-test -lreadline
-}
-
-do_install() {
- install -d ${D}${bindir}
- install -m 0755 spirom-test ${D}${bindir}
-}