[Armadeus-commitlog] armadeus branch, buildroot-update, updated. armadeus-6.0-160-ge816e6a
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2016-11-10 18:41:28
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, buildroot-update has been updated
via e816e6a6f0239485908a8377ca4076ee909f70ca (commit)
via ffc813ebed48e76dc86c7d7000ff7d5fa3610811 (commit)
via 414e9ae58097ae030555d76275fa3169addf7eae (commit)
via 0a5db3288fa58cab9faf043a39720de546145bf4 (commit)
via d9a6e99824a4495309691520601f433fff7d4114 (commit)
via f9dacd9ebc7b00c1d6a2f4e25f770c0252dd369a (commit)
via 70dd67a19575a792940d67ac3e08782601c1e81c (commit)
via 05d303d961ba13eabe98657333dd1da6c7b8f8fe (commit)
via 6a025547a6fe3b520e6d3afbc4ee07c705370548 (commit)
from b1a6f2157c4e62867ef6b30fe1235110a4dc3972 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e816e6a6f0239485908a8377ca4076ee909f70ca
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 19:35:02 2016 +0100
[AS_DEVICES]: wiringPi: add userspace irq handling (with pthreads)
commit ffc813ebed48e76dc86c7d7000ff7d5fa3610811
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 19:33:29 2016 +0100
[AS_DEVICES]: as_gpio: add internal helper as_gpio_set_pin_irq_mode() to allow pin irq mode selection directly with its gpio number
commit 414e9ae58097ae030555d76275fa3169addf7eae
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 19:30:28 2016 +0100
[AS_DEVICES]: as_gpio: don't open/close /sys/class/gpio/gpioxx/value file each time as_gpio_set_pin_value() is called, but instead remember which gpio was requested and associated value file descriptor.
commit 0a5db3288fa58cab9faf043a39720de546145bf4
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 19:26:20 2016 +0100
[AS_DEVICES]: as_gpio: rename as_gpio_open() to as_gpio_request() to better match what is done in Linux kernel
commit d9a6e99824a4495309691520601f433fff7d4114
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 19:09:44 2016 +0100
[AS_DEVICES] wiringPi: don't quit program when wiringPiSetupSys() is called several time. Just signal it.
commit f9dacd9ebc7b00c1d6a2f4e25f770c0252dd369a
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 19:08:01 2016 +0100
[AS_DEVICES] wiringPi: add some comments
commit 70dd67a19575a792940d67ac3e08782601c1e81c
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 19:05:53 2016 +0100
[AS_DEVICES] wiringPi: add some more supported pins to GPIO mapping
commit 05d303d961ba13eabe98657333dd1da6c7b8f8fe
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Nov 10 18:57:42 2016 +0100
[TOOLS] opos6ul_recovery: improve comment for BOOT jumpers
commit 6a025547a6fe3b520e6d3afbc4ee07c705370548
Author: Julien BOIBESSOT <jul...@ar...>
Date: Mon Nov 7 16:18:43 2016 +0100
typos
-----------------------------------------------------------------------
Summary of changes:
patches/u-boot/2015.01/403-apf51-nand-spl-NG.patch | 4 +-
software/uboot_recover/opos6ul_recovery.py | 2 +-
target/packages/as_devices/c/Makefile | 2 +-
target/packages/as_devices/c/as_gpio.c | 122 +++++++++++++-----
target/packages/as_devices/c/as_gpio.h | 19 +++-
target/packages/as_devices/c/wiringPi/wiringPi.c | 134 +++++++++++++++++++-
target/packages/as_devices/c/wiringPi/wiringPi.h | 4 +-
7 files changed, 241 insertions(+), 46 deletions(-)
diff --git a/patches/u-boot/2015.01/403-apf51-nand-spl-NG.patch b/patches/u-boot/2015.01/403-apf51-nand-spl-NG.patch
index 63201b7..203ca20 100644
--- a/patches/u-boot/2015.01/403-apf51-nand-spl-NG.patch
+++ b/patches/u-boot/2015.01/403-apf51-nand-spl-NG.patch
@@ -4,8 +4,8 @@ Add APF51 new NAND SPL:
- run SPL from IRAM
- intialize SDRAM from SPL instead of DCD: cf imx51 chip errata
- use regular U-Boot mxc_nand driver
-- add nand loch/unlock feature
-- final binary may be launch from NAND, IRAM or SDRAM
+- add nand lock/unlock feature
+- final binary may be launched from NAND, IRAM or SDRAM
- use make u-boot-with-nand-spl.imx to build U-Boot with NAND SPL
Signed-off-by: Eric Jarrige <eri...@ar...>
diff --git a/software/uboot_recover/opos6ul_recovery.py b/software/uboot_recover/opos6ul_recovery.py
index 4d70284..ada6b56 100644
--- a/software/uboot_recover/opos6ul_recovery.py
+++ b/software/uboot_recover/opos6ul_recovery.py
@@ -95,7 +95,7 @@ if __name__ == "__main__":
print " * have \"sb\" tool installed on your PC (on Ubuntu: sudo apt-get install lrzsz),"
print " * have launched this script as root (sudo)."
print "2] Power off your board, close all serial terminal sessions, remove all USB cables"
- print "3] Take jumper off BOOT1 pins and put it on BOOT0 pins."
+ print "3] Take jumper off BOOT1 pins (if any) and put a jumper on BOOT0 pins."
print "4] Power on your board"
print "5] Connect a USB cable from your PC to the OPOS6ULDev OTG miniUSB connector"
print "6] Connect a USB cable from your PC to the OPOS6ULDev console/debug miniUSB connector"
diff --git a/target/packages/as_devices/c/Makefile b/target/packages/as_devices/c/Makefile
index ebaa128..cb78c32 100644
--- a/target/packages/as_devices/c/Makefile
+++ b/target/packages/as_devices/c/Makefile
@@ -43,7 +43,7 @@ ARCHIVE_OPTS = -cvq
$(LIBNAME): $(OBJ)
@echo " LNK $@"
- @$(CC) -shared -Wl,-soname,$(SONAME) -o $(SONAME) $(OBJ)
+ @$(CC) -shared -Wl,-soname,$(SONAME) -o $(SONAME) $(OBJ) -lpthread
@ln -sf $(SONAME) $(LIBNAME)
$(STAT_LIB): $(OBJ)
diff --git a/target/packages/as_devices/c/as_gpio.c b/target/packages/as_devices/c/as_gpio.c
index 11eddcd..c5e9a70 100644
--- a/target/packages/as_devices/c/as_gpio.c
+++ b/target/packages/as_devices/c/as_gpio.c
@@ -37,38 +37,69 @@
#undef ERROR
#define ERROR(fmt, ...) printf(fmt, ##__VA_ARGS__)
+static int gpio_fds [256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+};
+
/*------------------------------------------------------------------------------*/
-struct as_gpio_device *as_gpio_open(int aGpioNum)
+/* For Compat: */
+struct as_gpio_device *as_gpio_open(int gpio_num)
+{
+ return as_gpio_request(gpio_num);
+}
+
+struct as_gpio_device *as_gpio_request(int gpio_num)
{
struct as_gpio_device *dev;
- int pin_file;
- int export_file;
+ int value_fd;
+ int export_fd;
int retval;
char buf[BUFF_SIZE];
- export_file = open("/sys/class/gpio/export", O_WRONLY);
- if (export_file < 0) {
- ERROR
- ("Can't open /sys/class/gpio/export\nBe sure that gpiolib is under your kernel\n");
+ if (gpio_num >= 256) {
+ ERROR("GPIO number (%d) is to high !\n", gpio_num);
+ return NULL;
+ }
+
+ export_fd = open("/sys/class/gpio/export", O_WRONLY);
+ if (export_fd < 0) {
+ ERROR("Can't open /sys/class/gpio/export\nBe sure that gpiolib"
+ " interface is supported by your kernel !\n");
return NULL;
}
- retval = as_write_buffer(export_file, aGpioNum);
+ retval = as_write_buffer(export_fd, gpio_num);
if (retval < 0) {
ERROR("/sys/class/gpio/export can't be written\n");
- close(export_file);
+ close(export_fd);
return NULL;
}
- close(export_file);
+ close(export_fd);
- snprintf(buf, BUFF_SIZE, "/sys/class/gpio/gpio%d/value", aGpioNum);
- pin_file = open(buf, O_RDWR);
- if (pin_file < 0) {
- ERROR("Can't export gpio number %d\n", aGpioNum);
+ snprintf(buf, BUFF_SIZE, "/sys/class/gpio/gpio%d/value", gpio_num);
+ value_fd = open(buf, O_RDWR);
+ if (value_fd < 0) {
+ ERROR("Can't export gpio number %d\n", gpio_num);
return NULL;
+ } else {
+ gpio_fds[gpio_num] = value_fd;
}
- close(pin_file);
dev = malloc(sizeof(struct as_gpio_device));
if (dev == NULL) {
@@ -76,7 +107,7 @@ struct as_gpio_device *as_gpio_open(int aGpioNum)
return NULL;
}
- dev->port_num = aGpioNum;
+ dev->port_num = gpio_num;
return dev;
}
@@ -143,36 +174,48 @@ const char *as_gpio_get_pin_direction(struct as_gpio_device *aDev)
return direction;
}
+static int CHECK(struct as_gpio_device * dev)
+{
+ if (dev == NULL) {
+ ERROR("device is NULL\n");
+ return -1;
+ }
+
+ if (dev->port_num > 256) {
+ ERROR("gpio pin number (%d) is not supported !\n", dev->port_num);
+ return -1;
+ }
+
+ return 0;
+}
+
/*------------------------------------------------------------------------------*/
-int32_t as_gpio_set_pin_value(struct as_gpio_device * aDev, int aValue)
+int32_t as_gpio_set_pin_value(struct as_gpio_device * dev, int value)
{
char buf[BUFF_SIZE];
- int pin_file;
int retval;
+ int value_fd;
- if (aDev == NULL) {
- ERROR("device is NULL\n");
- return -1;
- }
+ retval = CHECK(dev);
+ if(retval != 0)
+ return retval;
- snprintf(buf, BUFF_SIZE, "/sys/class/gpio/gpio%d/value",
- aDev->port_num);
- pin_file = open(buf, O_WRONLY);
- if (pin_file < 0) {
- ERROR("Can't open gpio%d direction\n", aDev->port_num);
+ value_fd = gpio_fds[dev->port_num];
+ if (value_fd < 0) {
+ ERROR("gpio%d not initialized\n", dev->port_num);
return -1;
}
+ snprintf(buf, BUFF_SIZE, "/sys/class/gpio/gpio%d/value",
+ dev->port_num);
- retval = as_write_buffer(pin_file, aValue);
+ retval = as_write_buffer(value_fd, value);
if (retval < 0) {
- ERROR("Can't write value\n");
- close(pin_file);
+ ERROR("Can't set gpio %d value\n", dev->port_num);
return -1;
}
- close(pin_file);
- return aValue;
+ return value;
}
/*------------------------------------------------------------------------------*/
@@ -315,6 +358,21 @@ int32_t as_gpio_set_irq_mode(struct as_gpio_device * aDev, char *mode)
}
/*------------------------------------------------------------------------------*/
+/* FOR AS_DEVICES INTERNAL USE ONLY !! */
+
+int32_t as_gpio_set_pin_irq_mode(int pin, char *mode)
+{
+ struct as_gpio_device dev;
+ int ret;
+
+ dev.port_num = pin;
+
+ ret = as_gpio_set_irq_mode(&dev, mode);
+ return ret;
+}
+
+/*------------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------------*/
int32_t as_gpio_get_pin_num(struct as_gpio_device * aDev)
{
diff --git a/target/packages/as_devices/c/as_gpio.h b/target/packages/as_devices/c/as_gpio.h
index 594fb2b..9b02bd8 100644
--- a/target/packages/as_devices/c/as_gpio.h
+++ b/target/packages/as_devices/c/as_gpio.h
@@ -53,13 +53,21 @@ struct as_gpio_device {
int irq_mode;
};
-/** @brief Initialize port access
+/** @brief Initialize port access (deprecated, use as_gpio_request() instead)
*
- * @param aGpioNum int pin number
+ * @param gpio_num int pin number
*
- * @return error if negative value
+ * @return error if negative value otherwise pointer to as_gpio_device structure
+ */
+struct as_gpio_device *as_gpio_open(int gpio_num);
+
+/** @brief Request GPIO access
+ *
+ * @param gpio_num int pin number
+ *
+ * @return error if negative value otherwise pointer to as_gpio_device structure
*/
-struct as_gpio_device *as_gpio_open(int aGpioNum);
+struct as_gpio_device *as_gpio_request(int gpio_num);
/** @brief Set pin direction
*
@@ -117,6 +125,9 @@ int32_t as_gpio_wait_event(struct as_gpio_device *aDev, int aDelay_ms);
int32_t as_gpio_set_irq_mode(struct as_gpio_device *gpio_dev,
char *mode);
+/* FOR AS_DEVICES INTERNAL USE ONLY !! */
+int32_t as_gpio_set_pin_irq_mode(int pin, char *mode);
+
/** @brief Get pin irq mode value
*
* @param gpio_dev as_gpio_device pointer structure
diff --git a/target/packages/as_devices/c/wiringPi/wiringPi.c b/target/packages/as_devices/c/wiringPi/wiringPi.c
index a24baaf..8a728da 100644
--- a/target/packages/as_devices/c/wiringPi/wiringPi.c
+++ b/target/packages/as_devices/c/wiringPi/wiringPi.c
@@ -38,8 +38,12 @@
#include <sys/time.h> /* gettimeofday() */
#include <time.h> /* nanosleep() */
#include <fcntl.h> /* open() */
+#include <errno.h> /* errno */
+#include <sys/ioctl.h> /* ioctl() / FIONREAD */
+#include <pthread.h> /* pthread_xx() */
#include "wiringPi.h"
+#include "../as_gpio.h"
// Environment Variables
@@ -48,9 +52,16 @@
#define ENV_GPIOMEM "WIRINGPI_GPIOMEM"
+// Time for easy calculations
+
static uint64_t epochMilli, epochMicro ;
+// Misc
+
static int wiringPiMode = WPI_MODE_UNINITIALISED ;
+static volatile int pinPass = -1 ;
+static pthread_mutex_t pinMutex ;
+
// Debugging & Return codes
int wiringPiDebug = FALSE ;
@@ -70,9 +81,20 @@ static int sysFds [GPIO_NUMBER] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
} ;
+// ISR Data
+
+static void (*isrFunctions [64])(void) ;
+
+// Doing it the Arduino way with lookup tables...
+// Yes, it's probably more inefficient than all the bit-twidling, but it
+// does tend to make it all a bit clearer. At least to me!
+
+// pinToGpio:
+// Take a Wiring pin (0 through X) and re-map it to the MX6UL pin
+
static int pinToGpio [] =
{
- 24, -1, -1, -1, -1, -1, 97, 10,
+ 24, -1, 25, -1, 18, 19, 97, 9,
-1, -1, -1, -1, -1, -1, -1, -1,
// Padding:
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 31
@@ -126,7 +148,7 @@ int wpiPinToGpio (int wpiPin)
void pinMode (int pin, int mode)
{
fprintf(stderr, "wiringPi emulation in as_devices: your software is calling pinMode(%d, %d) which is not implemented. \n"
- "I hope you did the corresponding echo %d > /sys/class/gpio/export + echo in/out > /sys/class/gpio/gpio%d/direction !\n",
+ "I hope you did the corresponding echo %d > /sys/class/gpio/export + echo in/out > /sys/class/gpio/gpio%d/direction !\n\n",
pin, mode, wpiPinToGpio(pin), wpiPinToGpio(pin));
}
@@ -225,6 +247,106 @@ int waitForInterrupt (int pin, int mS)
/*
+ * interruptHandler:
+ * This is a thread and gets started to wait for the interrupt we're
+ * hoping to catch. It will call the user-function when the interrupt
+ * fires.
+ *********************************************************************************
+ */
+
+static void *interruptHandler (void *arg)
+{
+ int myPin ;
+
+// (void)piHiPri (55) ; // Only effective if we run as root
+
+ myPin = pinPass ;
+ pinPass = -1 ;
+
+ for (;;)
+ if (waitForInterrupt(myPin, -1) > 0)
+ isrFunctions [myPin] () ;
+
+ return NULL ;
+}
+
+
+/*
+ * wiringPiISR:
+ * Pi Specific.
+ * Take the details and create an interrupt handler that will do a call-
+ * back to the user supplied function.
+ *********************************************************************************
+ */
+
+int wiringPiISR (int pin, int mode, void (*function)(void))
+{
+ pthread_t threadId ;
+ char *modeS ;
+ char fName [64] ;
+ char pinS [8] ;
+ int count, i ;
+ char c ;
+ int bcmGpioPin ;
+
+ if ((pin < 0) || (pin > 63))
+ return wiringPiFailure (WPI_FATAL, "wiringPiISR: pin must be 0-63 (%d)\n", pin) ;
+
+ /**/ if (wiringPiMode == WPI_MODE_UNINITIALISED)
+ return wiringPiFailure (WPI_FATAL, "wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ;
+ else if (wiringPiMode == WPI_MODE_PINS)
+ bcmGpioPin = pinToGpio [pin] ;
+ else
+ bcmGpioPin = pin ;
+
+// Now export the pin and set the right edge
+// Contrary to what is done on original wiringPi, we don't use
+// an external executable (gpio) to do the job.
+
+ if (mode != INT_EDGE_SETUP)
+ {
+ /**/ if (mode == INT_EDGE_FALLING)
+ modeS = "falling" ;
+ else if (mode == INT_EDGE_RISING)
+ modeS = "rising" ;
+ else
+ modeS = "both" ;
+
+ sprintf (pinS, "%d", bcmGpioPin) ;
+
+ printf("%s: setting irq mode on gpio %d\n", __func__, bcmGpioPin);
+ as_gpio_set_pin_irq_mode(bcmGpioPin, modeS);
+ }
+
+// Now pre-open the /sys/class node - but it may already be open if
+// we are in Sys mode...
+
+ if (sysFds [bcmGpioPin] == -1) {
+ sprintf (fName, "/sys/class/gpio/gpio%d/value", bcmGpioPin) ;
+ if ((sysFds [bcmGpioPin] = open (fName, O_RDWR)) < 0)
+ return wiringPiFailure (WPI_FATAL, "wiringPiISR: unable to open %s: %s\n", fName, strerror (errno)) ;
+ }
+
+// Clear any initial pending interrupt
+
+ ioctl (sysFds [bcmGpioPin], FIONREAD, &count) ;
+ for (i = 0 ; i < count ; ++i)
+ read (sysFds [bcmGpioPin], &c, 1) ;
+
+ isrFunctions [pin] = function ;
+
+ pthread_mutex_lock (&pinMutex) ;
+ pinPass = pin ;
+ pthread_create (&threadId, NULL, interruptHandler, NULL) ;
+ while (pinPass != -1)
+ delay (1) ;
+ pthread_mutex_unlock (&pinMutex) ;
+
+ return 0 ;
+}
+
+
+/*
* initialiseEpoch:
* Initialise our start-of-time variable to be the current unix
* time in milliseconds and microseconds.
@@ -363,8 +485,12 @@ int wiringPiSetupSys (void)
// This is here to trap the unwary - those who's program appears to work then fails some
// time later with a weird error message because you run out of file-handles.
- if (alreadyCalled)
- (void)wiringPiFailure (WPI_FATAL, "wiringPiSetupSys: You must only call this once per program run. This is a fatal error. Please fix your code.\n") ;
+ if (alreadyCalled) {
+ //(void)wiringPiFailure (WPI_FATAL,
+ printf(
+ "wiringPiSetupSys: You must only call this once per program run. This is a fatal error. Please fix your code.\n") ;
+ return 0;
+ }
alreadyCalled = TRUE ;
diff --git a/target/packages/as_devices/c/wiringPi/wiringPi.h b/target/packages/as_devices/c/wiringPi/wiringPi.h
index e51e397..4222fe9 100644
--- a/target/packages/as_devices/c/wiringPi/wiringPi.h
+++ b/target/packages/as_devices/c/wiringPi/wiringPi.h
@@ -67,7 +67,7 @@
#define PWM_MODE_MS 0
#define PWM_MODE_BAL 1
-
+*/
// Interrupt levels
#define INT_EDGE_SETUP 0
@@ -77,7 +77,7 @@
// Pi model types and version numbers
// Intended for the GPIO program Use at your own risk.
-
+/*
#define PI_MODEL_A 0
#define PI_MODEL_B 1
#define PI_MODEL_AP 2
hooks/post-receive
--
armadeus
|