diff options
author | Michel Zou | 2018-04-18 10:27:47 +0200 |
---|---|---|
committer | Michel Zou | 2018-04-18 10:27:47 +0200 |
commit | 4df1f58323c3527fcae11034bf51fd54c5c401b0 (patch) | |
tree | 842b10939a6b18bd3305b52ec7d777257a4302e3 | |
parent | 98ab274305167f46b253fe2bf828f15e9d6f8860 (diff) | |
download | aur-4df1f58323c3527fcae11034bf51fd54c5c401b0.tar.gz |
#149, #150 patches
-rw-r--r-- | .SRCINFO | 10 | ||||
-rw-r--r-- | PKGBUILD | 20 | ||||
-rw-r--r-- | cpuinfo-from-devicetree.patch | 84 | ||||
-rw-r--r-- | read-pin-base.patch | 138 |
4 files changed, 246 insertions, 6 deletions
@@ -1,9 +1,9 @@ # Generated by mksrcinfo v8 -# Wed Dec 27 15:51:01 UTC 2017 +# Wed Apr 18 08:27:46 UTC 2018 pkgbase = python-rpi.gpio pkgdesc = A module to control Raspberry Pi GPIO channels pkgver = 0.6.3 - pkgrel = 1 + pkgrel = 2 url = http://sourceforge.net/projects/raspberry-gpio-python/ arch = i686 arch = x86_64 @@ -15,7 +15,11 @@ pkgbase = python-rpi.gpio makedepends = python-setuptools makedepends = python2-setuptools source = https://pypi.python.org/packages/e2/58/6e1b775606da6439fa3fd1550e7f714ac62aa75e162eed29dbec684ecb3e/RPi.GPIO-0.6.3.tar.gz - md5sums = e4abe1cfb5eacebe53078032256eb837 + source = read-pin-base.patch + source = cpuinfo-from-devicetree.patch + sha256sums = a5fc0eb5e401963b6c0a03650da6b42c4005f02d962b81241d96c98d0a578516 + sha256sums = 72539b6246f8f6b1c792052c5d7078e3d171f0a7a3a01d81b59431fed7058fda + sha256sums = 436825c6601e9ba873092d0be3d76693570e610479523abd3e9b821ff42ea83c pkgname = python-rpi.gpio depends = python @@ -1,14 +1,28 @@ pkgbase=python-rpi.gpio pkgname=('python-rpi.gpio' 'python2-rpi.gpio') pkgver=0.6.3 -pkgrel=1 +pkgrel=2 pkgdesc="A module to control Raspberry Pi GPIO channels" url="http://sourceforge.net/projects/raspberry-gpio-python/" arch=('i686' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64') license=('MIT') makedepends=('python-setuptools' 'python2-setuptools') -source=("https://pypi.python.org/packages/e2/58/6e1b775606da6439fa3fd1550e7f714ac62aa75e162eed29dbec684ecb3e/RPi.GPIO-0.6.3.tar.gz") -md5sums=('e4abe1cfb5eacebe53078032256eb837') +source=("https://pypi.python.org/packages/e2/58/6e1b775606da6439fa3fd1550e7f714ac62aa75e162eed29dbec684ecb3e/RPi.GPIO-0.6.3.tar.gz" + read-pin-base.patch + cpuinfo-from-devicetree.patch) +sha256sums=('a5fc0eb5e401963b6c0a03650da6b42c4005f02d962b81241d96c98d0a578516' + '72539b6246f8f6b1c792052c5d7078e3d171f0a7a3a01d81b59431fed7058fda' + '436825c6601e9ba873092d0be3d76693570e610479523abd3e9b821ff42ea83c') + +prepare () { + cd "${srcdir}"/RPi.GPIO-$pkgver + + # https://sourceforge.net/p/raspberry-gpio-python/tickets/149/ + patch -p1 -i "${srcdir}"/cpuinfo-from-devicetree.patch + + # https://sourceforge.net/p/raspberry-gpio-python/tickets/150/ + patch -p1 -i "${srcdir}"/read-pin-base.patch +} build() { cp -r "${srcdir}"/RPi.GPIO-$pkgver "${srcdir}"/RPi.GPIO-$pkgver-py2 diff --git a/cpuinfo-from-devicetree.patch b/cpuinfo-from-devicetree.patch new file mode 100644 index 000000000000..0aeaaa8b3e2e --- /dev/null +++ b/cpuinfo-from-devicetree.patch @@ -0,0 +1,84 @@ +diff -r c53985209d09 source/cpuinfo.c +--- a/source/cpuinfo.c Sun Oct 30 22:41:09 2016 +0000 ++++ b/source/cpuinfo.c Wed Feb 22 17:15:44 2017 +0100 +@@ -34,6 +34,8 @@ + char *rev; + int found = 0; + int len; ++ char *line; ++ size_t linelen = 128; + + if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) + return -1; +@@ -51,8 +53,70 @@ + } + fclose(fp); + +- if (!found) ++ if (!found) { ++ // We may have data from the device-tree ++ if ((fp = fopen("/proc/device-tree/compatible", "r")) != NULL) { ++ line = calloc(linelen, sizeof(char)); ++ ++ while (getdelim(&line, &linelen, '\0', fp) != -1) { ++ // Look for the board model ++ if (strstr(line, "raspberrypi,model-a")) { ++ info->type = "Model A"; ++ info->p1_revision = 2; ++ info->ram = "256M"; ++ } else if (strstr(line, "raspberrypi,model-b")) { ++ info->type = "Model B"; ++ info->p1_revision = 2; ++ info->ram = "256M"; ++ } else if (strstr(line, "raspberrypi,model-a-plus")) { ++ info->type = "Model A+"; ++ info->p1_revision = 3; ++ info->ram = "Unknown"; ++ } else if (strstr(line, "raspberrypi,model-b-plus")) { ++ info->type = "Model B+"; ++ info->p1_revision = 3; ++ info->ram = "512M"; ++ } else if (strstr(line, "raspberrypi,2-model-b")) { ++ info->type = "Pi 2 Model B"; ++ info->p1_revision = 3; ++ info->ram = "1G"; ++ } else if (strstr(line, "raspberrypi,compute-module")) { ++ info->type = "Compute"; ++ info->p1_revision = 0; ++ info->ram = "512M"; ++ } else if (strstr(line, "raspberrypi,3-model-b")) { ++ info->type = "Pi 3 Model B"; ++ info->p1_revision = 3; ++ info->ram = "1G"; ++ } else if (strstr(line, "raspberrypi,model-zero")) { ++ info->type = "Zero"; ++ info->p1_revision = 3; ++ info->ram = "512M"; ++ } else if (strstr(line, "raspberrypi,model-b-rev2")) { ++ info->type = "Model B"; ++ info->p1_revision = 2; ++ info->ram = "Unknown"; ++ } ++ ++ // Look for CPU part ++ if (strstr(line, "brcm,bcm2835")) { ++ info->processor = "BCM2835"; ++ } else if (strstr(line, "brcm,bcm2836")) { ++ info->processor = "BCM2836"; ++ } else if (strstr(line, "brcm,bcm2837")) { ++ info->processor = "BCM2837"; ++ } ++ } ++ free(line); ++ ++ info->manufacturer = "Unknown"; ++ fclose(fp); ++ ++ return 0; ++ } ++ + return -1; ++ } + + if ((len = strlen(revision)) == 0) + return -1; diff --git a/read-pin-base.patch b/read-pin-base.patch new file mode 100644 index 000000000000..0e527c97336a --- /dev/null +++ b/read-pin-base.patch @@ -0,0 +1,138 @@ +diff -r c53985209d09 source/event_gpio.c +--- a/source/event_gpio.c Sun Oct 30 22:41:09 2016 +0000 ++++ b/source/event_gpio.c Thu Feb 23 18:22:28 2017 +0100 +@@ -24,6 +24,7 @@ + #include <sys/epoll.h> + #include <stdio.h> + #include <stdlib.h> ++#include <dirent.h> + #include <errno.h> + #include <fcntl.h> + #include <unistd.h> +@@ -62,17 +63,64 @@ + int thread_running = 0; + int epfd_thread = -1; + int epfd_blocking = -1; ++int pin_base = -1; + + /************* /sys/class/gpio functions ************/ ++void gpio_find_chip_base() ++{ ++ DIR *gpio_dir; ++ struct dirent *child; ++ char label_path[128]; ++ char label[128]; ++ int fd; ++ ++ /* No need to search for it twice */ ++ if (pin_base >= 0) ++ return; ++ ++ if ((gpio_dir = opendir("/sys/class/gpio")) == NULL) { ++ pin_base = 0; ++ return; ++ } ++ ++ while ((child = readdir(gpio_dir)) != NULL) { ++ if (!strstr(child->d_name, "gpiochip")) ++ continue; ++ ++ if (snprintf(label_path, sizeof(label_path), ++ "/sys/class/gpio/%s/label", child->d_name) < 0) { ++ pin_base = 0; ++ return; ++ } ++ ++ if ((fd = open(label_path, O_RDONLY)) < 0) { ++ pin_base = 0; ++ return; ++ } ++ ++ if (read(fd, label, sizeof(label)) > 0 && ++ strstr(label, "pinctrl-bcm2835")) { ++ pin_base = atoi(child->d_name + 8); ++ break; ++ } ++ close(fd); ++ } ++ ++ if (pin_base < 0) ++ pin_base = 0; ++} ++ + int gpio_export(unsigned int gpio) + { + int fd, len; +- char str_gpio[3]; ++ char str_gpio[64]; + + if ((fd = open("/sys/class/gpio/export", O_WRONLY)) < 0) + return -1; + +- len = snprintf(str_gpio, sizeof(str_gpio), "%d", gpio); ++ gpio_find_chip_base(); ++ ++ len = snprintf(str_gpio, sizeof(str_gpio), "%d", pin_base + gpio); + write(fd, str_gpio, len); + close(fd); + +@@ -82,12 +130,14 @@ + int gpio_unexport(unsigned int gpio) + { + int fd, len; +- char str_gpio[3]; ++ char str_gpio[64]; + + if ((fd = open("/sys/class/gpio/unexport", O_WRONLY)) < 0) + return -1; + +- len = snprintf(str_gpio, sizeof(str_gpio), "%d", gpio); ++ gpio_find_chip_base(); ++ ++ len = snprintf(str_gpio, sizeof(str_gpio), "%d", pin_base + gpio); + write(fd, str_gpio, len); + close(fd); + +@@ -99,9 +149,11 @@ + int retry; + struct timespec delay; + int fd; +- char filename[33]; ++ char filename[64]; + +- snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/direction", gpio); ++ gpio_find_chip_base(); ++ ++ snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/direction", pin_base + gpio); + + // retry waiting for udev to set correct file permissions + delay.tv_sec = 0; +@@ -126,9 +178,11 @@ + int gpio_set_edge(unsigned int gpio, unsigned int edge) + { + int fd; +- char filename[28]; ++ char filename[64]; + +- snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/edge", gpio); ++ gpio_find_chip_base(); ++ ++ snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/edge", pin_base + gpio); + + if ((fd = open(filename, O_WRONLY)) < 0) + return -1; +@@ -141,10 +195,12 @@ + int open_value_file(unsigned int gpio) + { + int fd; +- char filename[29]; ++ char filename[64]; ++ ++ gpio_find_chip_base(); + + // create file descriptor of value file +- snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/value", gpio); ++ snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/value", pin_base + gpio); + if ((fd = open(filename, O_RDONLY | O_NONBLOCK)) < 0) + return -1; + return fd; |