[Pkg-raspi-maintainers] Bug#941669: python3-rpi.gpio fails to work on aarch64 (upgrade needed)
Peter Green
plugwash-urgent at p10link.net
Thu Jan 16 19:25:15 GMT 2020
On 07/01/2020 13:55, andred wrote:
> On Tue, Jan 7, 2020 at 9:22 AM Peter Green <plugwash-urgent at p10link.net> wrote:
>> have either of you tested 0.7.0 on a Pi running Debian arm64
> Yes, v0.7.0 (from pypi.org) works fine here on Debian arm64.
Thanks.
I have just prepared a package of 0.7.0, I would appreciate people testing it, both on systems where it worked before and on systems where it is currently broken.
This package also drops python 2 support in-line with the general effort to remove python 2. I'm not sure why sandro's script hasn't bumped the python 2 removal bug on this package to serious, despite their being no reverse-dependencies. Maybe it's been confused by the fact that this package is not currently in testing or the limited architecture list.
I also discovered a missing build-dependency on dh-python, so I added that.
I have attached a debdiff to this mail, I have also posted source and binary packages (for armhf and arm64) at https://plugwash.raspbian.org/rpi.gpio/
If I get positive feedback from users or get around to setting up a test environment to test this myself then I will NMU this.
-------------- next part --------------
diff -Nru rpi.gpio-0.6.5/CHANGELOG.txt rpi.gpio-0.7.0/CHANGELOG.txt
--- rpi.gpio-0.6.5/CHANGELOG.txt 2018-11-16 10:05:26.000000000 +0000
+++ rpi.gpio-0.7.0/CHANGELOG.txt 2019-07-21 13:42:56.000000000 +0000
@@ -1,6 +1,15 @@
Change Log
==========
+0.7.0
+-------
+- Updated RPI_INFO to include RPi 4B
+- Fixed pull up/down for Pi4 (issue 168)
+- Fix spelling mistake in docstrings
+- Tested and working on Raspbian Buster + Python 3.8.0b2
+- Fix board detection for aarch64 (Issues 161 / 165)
+- Fix checking mmap return value in c_gpio.c (issue 166)
+
0.6.5
-----
- Fix exception on re-export of /sys/class/gpio/gpioNN
diff -Nru rpi.gpio-0.6.5/debian/changelog rpi.gpio-0.7.0/debian/changelog
--- rpi.gpio-0.6.5/debian/changelog 2019-01-13 13:50:43.000000000 +0000
+++ rpi.gpio-0.7.0/debian/changelog 2020-01-16 16:20:40.000000000 +0000
@@ -1,3 +1,14 @@
+rpi.gpio (0.7.0-0.1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * New upstream release
+ - Fixes pi detection on arm64 (Closes: 941669)
+ - Adds Raspberry pi 4 support.
+ * Drop python 2 support (Closes: 938409)
+ * Drop spelling.patch (fixed upstream)
+
+ -- Peter Michael Green <plugwash at debian.org> Thu, 16 Jan 2020 16:20:40 +0000
+
rpi.gpio (0.6.5-1) unstable; urgency=medium
* New upstream version.
diff -Nru rpi.gpio-0.6.5/debian/control rpi.gpio-0.7.0/debian/control
--- rpi.gpio-0.6.5/debian/control 2019-01-13 13:50:43.000000000 +0000
+++ rpi.gpio-0.7.0/debian/control 2020-01-16 16:20:40.000000000 +0000
@@ -6,13 +6,10 @@
Priority: optional
Build-Depends:
debhelper (>= 11~),
- dh-python,
- python-all (>= 2.6.6-3),
- python-all-dev,
- python-setuptools (>= 0.6b3),
python3-all,
python3-all-dev,
python3-setuptools,
+ dh-python,
Standards-Version: 4.3.1
Homepage: http://sourceforge.net/projects/raspberry-gpio-python/
Vcs-Git: https://salsa.debian.org/raspi-team/rpi.gpio.git
@@ -32,21 +29,6 @@
.
This package contains common files, for example udev rules.
-Package: python-rpi.gpio
-Architecture: arm64 armel armhf
-Depends:
- ${misc:Depends},
- ${python:Depends},
- ${shlibs:Depends},
-Description: Module to control Raspberry Pi GPIO channels (Python 2)
- RPi.GPIO allows controlling Raspberry Pi GPIO channels in Python.
- .
- It provides all the basic functionality, but is unsuitable for
- real-time or timing critical applications. RPi.GPIO also does not
- support SPI, I²C or hardware PWM yet.
- .
- This package contains the Python 2 module.
-
Package: python3-rpi.gpio
Architecture: arm64 armel armhf
Depends:
diff -Nru rpi.gpio-0.6.5/debian/patches/series rpi.gpio-0.7.0/debian/patches/series
--- rpi.gpio-0.6.5/debian/patches/series 2018-10-26 17:45:22.000000000 +0000
+++ rpi.gpio-0.7.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000
@@ -1 +0,0 @@
-spelling.patch
diff -Nru rpi.gpio-0.6.5/debian/patches/spelling.patch rpi.gpio-0.7.0/debian/patches/spelling.patch
--- rpi.gpio-0.6.5/debian/patches/spelling.patch 2018-06-12 12:22:46.000000000 +0000
+++ rpi.gpio-0.7.0/debian/patches/spelling.patch 1970-01-01 00:00:00.000000000 +0000
@@ -1,13 +0,0 @@
-From: Dominik George <nik at naturalnet.de>
-Subject: Fix spelling in upstream source
---- a/source/py_gpio.c
-+++ b/source/py_gpio.c
-@@ -962,7 +962,7 @@ PyMethodDef rpi_gpio_methods[] = {
- {"getmode", py_getmode, METH_VARARGS, "Get numbering mode used for channel numbers.\nReturns BOARD, BCM or None"},
- {"add_event_detect", (PyCFunction)py_add_event_detect, METH_VARARGS | METH_KEYWORDS, "Enable edge detection events for a particular GPIO channel.\nchannel - either board pin number or BCM number depending on which mode is set.\nedge - RISING, FALLING or BOTH\n[callback] - A callback function for the event (optional)\n[bouncetime] - Switch bounce timeout in ms for callback"},
- {"remove_event_detect", py_remove_event_detect, METH_VARARGS, "Remove edge detection for a particular GPIO channel\nchannel - either board pin number or BCM number depending on which mode is set."},
-- {"event_detected", py_event_detected, METH_VARARGS, "Returns True if an edge has occured on a given GPIO. You need to enable edge detection using add_event_detect() first.\nchannel - either board pin number or BCM number depending on which mode is set."},
-+ {"event_detected", py_event_detected, METH_VARARGS, "Returns True if an edge has occurred on a given GPIO. You need to enable edge detection using add_event_detect() first.\nchannel - either board pin number or BCM number depending on which mode is set."},
- {"add_event_callback", (PyCFunction)py_add_event_callback, METH_VARARGS | METH_KEYWORDS, "Add a callback for an event already defined using add_event_detect()\nchannel - either board pin number or BCM number depending on which mode is set.\ncallback - a callback function"},
- {"wait_for_edge", (PyCFunction)py_wait_for_edge, METH_VARARGS | METH_KEYWORDS, "Wait for an edge. Returns the channel number or None on timeout.\nchannel - either board pin number or BCM number depending on which mode is set.\nedge - RISING, FALLING or BOTH\n[bouncetime] - time allowed between calls to allow for switchbounce\n[timeout] - timeout in ms"},
- {"gpio_function", py_gpio_function, METH_VARARGS, "Return the current GPIO function (IN, OUT, PWM, SERIAL, I2C, SPI)\nchannel - either board pin number or BCM number depending on which mode is set."},
diff -Nru rpi.gpio-0.6.5/debian/rules rpi.gpio-0.7.0/debian/rules
--- rpi.gpio-0.6.5/debian/rules 2018-06-12 12:22:46.000000000 +0000
+++ rpi.gpio-0.7.0/debian/rules 2020-01-16 16:20:40.000000000 +0000
@@ -15,7 +15,7 @@
include /usr/share/dpkg/default.mk
%:
- dh $@ --with python2,python3 --buildsystem=pybuild
+ dh $@ --with python3 --buildsystem=pybuild
override_dh_installdocs:
dh_installdocs --link-doc=rpi.gpio-common
diff -Nru rpi.gpio-0.6.5/PKG-INFO rpi.gpio-0.7.0/PKG-INFO
--- rpi.gpio-0.6.5/PKG-INFO 2018-11-16 10:14:50.000000000 +0000
+++ rpi.gpio-0.7.0/PKG-INFO 2019-07-21 13:45:06.000000000 +0000
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: RPi.GPIO
-Version: 0.6.5
+Version: 0.7.0
Summary: A module to control Raspberry Pi GPIO channels
Home-page: http://sourceforge.net/projects/raspberry-gpio-python/
Author: Ben Croston
@@ -24,6 +24,15 @@
Change Log
==========
+ 0.7.0
+ -------
+ - Updated RPI_INFO to include RPi 4B
+ - Fixed pull up/down for Pi4 (issue 168)
+ - Fix spelling mistake in docstrings
+ - Tested and working on Raspbian Buster + Python 3.8.0b2
+ - Fix board detection for aarch64 (Issues 161 / 165)
+ - Fix checking mmap return value in c_gpio.c (issue 166)
+
0.6.5
-----
- Fix exception on re-export of /sys/class/gpio/gpioNN
diff -Nru rpi.gpio-0.6.5/RPi/GPIO/__init__.py rpi.gpio-0.7.0/RPi/GPIO/__init__.py
--- rpi.gpio-0.6.5/RPi/GPIO/__init__.py 2018-11-16 10:06:38.000000000 +0000
+++ rpi.gpio-0.7.0/RPi/GPIO/__init__.py 2019-07-21 12:49:10.000000000 +0000
@@ -1,5 +1,5 @@
"""
-Copyright (c) 2012-2018 Ben Croston
+Copyright (c) 2012-2019 Ben Croston
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
@@ -22,4 +22,4 @@
from RPi._GPIO import *
-VERSION = '0.6.5'
+VERSION = '0.7.0'
diff -Nru rpi.gpio-0.6.5/setup.py rpi.gpio-0.7.0/setup.py
--- rpi.gpio-0.6.5/setup.py 2018-11-16 10:06:48.000000000 +0000
+++ rpi.gpio-0.7.0/setup.py 2019-07-21 12:49:21.000000000 +0000
@@ -1,5 +1,5 @@
"""
-Copyright (c) 2012-2018 Ben Croston
+Copyright (c) 2012-2019 Ben Croston
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
@@ -33,7 +33,7 @@
'Topic :: System :: Hardware']
setup(name = 'RPi.GPIO',
- version = '0.6.5',
+ version = '0.7.0',
author = 'Ben Croston',
author_email = 'ben at croston.org',
description = 'A module to control Raspberry Pi GPIO channels',
diff -Nru rpi.gpio-0.6.5/source/c_gpio.c rpi.gpio-0.7.0/source/c_gpio.c
--- rpi.gpio-0.6.5/source/c_gpio.c 2018-11-16 10:04:06.000000000 +0000
+++ rpi.gpio-0.7.0/source/c_gpio.c 2019-07-21 12:41:22.000000000 +0000
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2012-2015 Ben Croston
+Copyright (c) 2012-2019 Ben Croston
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
@@ -43,6 +43,11 @@
#define PULLUPDN_OFFSET 37 // 0x0094 / 4
#define PULLUPDNCLK_OFFSET 38 // 0x0098 / 4
+#define PULLUPDN_OFFSET_2711_0 57
+#define PULLUPDN_OFFSET_2711_1 58
+#define PULLUPDN_OFFSET_2711_2 59
+#define PULLUPDN_OFFSET_2711_3 60
+
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
@@ -72,8 +77,7 @@
// try /dev/gpiomem first - this does not require root privs
if ((mem_fd = open("/dev/gpiomem", O_RDWR|O_SYNC)) > 0)
{
- gpio_map = (uint32_t *)mmap(NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0);
- if ((uint32_t)gpio_map < 0) {
+ if ((gpio_map = (uint32_t *)mmap(NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0)) == MAP_FAILED) {
return SETUP_MMAP_FAIL;
} else {
return SETUP_OK;
@@ -126,9 +130,7 @@
if ((uint32_t)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);
- gpio_map = (uint32_t *)mmap( (void *)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, gpio_base);
-
- if ((uint32_t)gpio_map < 0)
+ if ((gpio_map = (uint32_t *)mmap( (void *)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, gpio_base)) == MAP_FAILED)
return SETUP_MMAP_FAIL;
return SETUP_OK;
@@ -208,21 +210,42 @@
void set_pullupdn(int gpio, int pud)
{
- int clk_offset = PULLUPDNCLK_OFFSET + (gpio/32);
- int shift = (gpio%32);
-
- if (pud == PUD_DOWN)
- *(gpio_map+PULLUPDN_OFFSET) = (*(gpio_map+PULLUPDN_OFFSET) & ~3) | PUD_DOWN;
- else if (pud == PUD_UP)
- *(gpio_map+PULLUPDN_OFFSET) = (*(gpio_map+PULLUPDN_OFFSET) & ~3) | PUD_UP;
- else // pud == PUD_OFF
+ // Check GPIO register
+ int is2711 = *(gpio_map+PULLUPDN_OFFSET_2711_3) != 0x6770696f;
+ if (is2711) {
+ // Pi 4 Pull-up/down method
+ int pullreg = PULLUPDN_OFFSET_2711_0 + (gpio >> 4);
+ int pullshift = (gpio & 0xf) << 1;
+ unsigned int pullbits;
+ unsigned int pull = 0;
+ switch (pud) {
+ case PUD_OFF: pull = 0; break;
+ case PUD_UP: pull = 1; break;
+ case PUD_DOWN: pull = 2; break;
+ default: pull = 0; // switch PUD to OFF for other values
+ }
+ pullbits = *(gpio_map + pullreg);
+ pullbits &= ~(3 << pullshift);
+ pullbits |= (pull << pullshift);
+ *(gpio_map + pullreg) = pullbits;
+ } else {
+ // Legacy Pull-up/down method
+ int clk_offset = PULLUPDNCLK_OFFSET + (gpio/32);
+ int shift = (gpio%32);
+
+ if (pud == PUD_DOWN) {
+ *(gpio_map+PULLUPDN_OFFSET) = (*(gpio_map+PULLUPDN_OFFSET) & ~3) | PUD_DOWN;
+ } else if (pud == PUD_UP) {
+ *(gpio_map+PULLUPDN_OFFSET) = (*(gpio_map+PULLUPDN_OFFSET) & ~3) | PUD_UP;
+ } else { // pud == PUD_OFF
+ *(gpio_map+PULLUPDN_OFFSET) &= ~3;
+ }
+ short_wait();
+ *(gpio_map+clk_offset) = 1 << shift;
+ short_wait();
*(gpio_map+PULLUPDN_OFFSET) &= ~3;
-
- short_wait();
- *(gpio_map+clk_offset) = 1 << shift;
- short_wait();
- *(gpio_map+PULLUPDN_OFFSET) &= ~3;
- *(gpio_map+clk_offset) = 0;
+ *(gpio_map+clk_offset) = 0;
+ }
}
void setup_gpio(int gpio, int direction, int pud)
diff -Nru rpi.gpio-0.6.5/source/cpuinfo.c rpi.gpio-0.7.0/source/cpuinfo.c
--- rpi.gpio-0.6.5/source/cpuinfo.c 2018-11-16 10:04:06.000000000 +0000
+++ rpi.gpio-0.7.0/source/cpuinfo.c 2019-07-21 12:41:22.000000000 +0000
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2012-2016 Ben Croston
+Copyright (c) 2012-2019 Ben Croston
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
@@ -20,9 +20,15 @@
SOFTWARE.
*/
+/* See the following for up to date information:
+ * https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+ */
+
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <arpa/inet.h>
#include "cpuinfo.h"
int get_rpi_info(rpi_info *info)
@@ -31,23 +37,33 @@
char buffer[1024];
char hardware[1024];
char revision[1024];
- char *rev;
int found = 0;
int len;
- if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
- return -1;
- while(!feof(fp) && fgets(buffer, sizeof(buffer), fp)) {
- sscanf(buffer, "Hardware : %s", hardware);
- if (strcmp(hardware, "BCM2708") == 0 ||
- strcmp(hardware, "BCM2709") == 0 ||
- strcmp(hardware, "BCM2835") == 0 ||
- strcmp(hardware, "BCM2836") == 0 ||
- strcmp(hardware, "BCM2837") == 0 ) {
- found = 1;
+ if ((fp = fopen("/proc/device-tree/system/linux,revision", "r"))) {
+ uint32_t n;
+ if (fread(&n, sizeof(n), 1, fp) != 1) {
+ fclose(fp);
+ return -1;
}
- sscanf(buffer, "Revision : %s", revision);
+ sprintf(revision, "%x", ntohl(n));
+ found = 1;
}
+ else if ((fp = fopen("/proc/cpuinfo", "r"))) {
+ while(!feof(fp) && fgets(buffer, sizeof(buffer), fp)) {
+ sscanf(buffer, "Hardware : %s", hardware);
+ if (strcmp(hardware, "BCM2708") == 0 ||
+ strcmp(hardware, "BCM2709") == 0 ||
+ strcmp(hardware, "BCM2835") == 0 ||
+ strcmp(hardware, "BCM2836") == 0 ||
+ strcmp(hardware, "BCM2837") == 0 ) {
+ found = 1;
+ }
+ sscanf(buffer, "Revision : %s", revision);
+ }
+ }
+ else
+ return -1;
fclose(fp);
if (!found)
@@ -60,36 +76,56 @@
// new scheme
//info->rev = revision[len-1]-'0';
strcpy(info->revision, revision);
- switch (revision[len-2]) {
- case '0': info->type = "Model A"; info->p1_revision = 2; break;
- case '1': info->type = "Model B"; info->p1_revision = 2; break;
- case '2': info->type = "Model A+"; info->p1_revision = 3; break;
- case '3': info->type = "Model B+"; info->p1_revision = 3; break;
- case '4': info->type = "Pi 2 Model B"; info->p1_revision = 3; break;
- case '5': info->type = "Alpha"; info->p1_revision = 3; break;
- case '6': info->type = "Compute"; info->p1_revision = 0; break;
- case '8': info->type = "Pi 3 Model B"; info->p1_revision = 3; break;
- case '9': info->type = "Zero"; info->p1_revision = 3; break;
- default : info->type = "Unknown"; info->p1_revision = 3; break;
- }
- switch (revision[len-4]) {
- case '0': info->processor = "BCM2835"; break;
- case '1': info->processor = "BCM2836"; break;
- case '2': info->processor = "BCM2837"; break;
- default : info->processor = "Unknown"; break;
- }
- switch (revision[len-5]) {
- case '0': info->manufacturer = "Sony"; break;
- case '1': info->manufacturer = "Egoman"; break;
- case '2': info->manufacturer = "Embest"; break;
- case '4': info->manufacturer = "Embest"; break;
- default : info->manufacturer = "Unknown"; break;
- }
- switch (strtol((char[]){revision[len-6],0}, NULL, 16) & 7) {
- case 0: info->ram = "256M"; break;
- case 1: info->ram = "512M"; break;
- case 2: info->ram = "1024M"; break;
- default: info->ram = "Unknown"; break;
+ switch (revision[len-3]) {
+ case '0' :
+ switch (revision[len-2]) {
+ case '0': info->type = "Model A"; info->p1_revision = 2; break;
+ case '1': info->type = "Model B"; info->p1_revision = 2; break;
+ case '2': info->type = "Model A+"; info->p1_revision = 3; break;
+ case '3': info->type = "Model B+"; info->p1_revision = 3; break;
+ case '4': info->type = "Pi 2 Model B"; info->p1_revision = 3; break;
+ case '5': info->type = "Alpha"; info->p1_revision = 3; break;
+ case '6': info->type = "Compute Module 1"; info->p1_revision = 0; break;
+ case '8': info->type = "Pi 3 Model B"; info->p1_revision = 3; break;
+ case '9': info->type = "Zero"; info->p1_revision = 3; break;
+ case 'a': info->type = "Compute Module 3"; info->p1_revision = 0; break;
+ case 'c': info->type = "Zero W"; info->p1_revision = 3; break;
+ case 'd': info->type = "Pi 3 Model B+"; info->p1_revision = 3; break;
+ case 'e': info->type = "Pi 3 Model A+"; info->p1_revision = 3; break;
+ default : info->type = "Unknown"; info->p1_revision = 3; break;
+ } break;
+ case '1':
+ switch (revision[len-2]) {
+ case '0': info->type = "Compute Module 3+"; info->p1_revision = 0; break;
+ case '1': info->type = "Pi 4 Model B"; info->p1_revision = 3; break;
+ default : info->type = "Unknown"; info->p1_revision = 3; break;
+ } break;
+ default: info->type = "Unknown"; info->p1_revision = 3; break;
+ }
+
+ switch (revision[len-4]) {
+ case '0': info->processor = "BCM2835"; break;
+ case '1': info->processor = "BCM2836"; break;
+ case '2': info->processor = "BCM2837"; break;
+ case '3': info->processor = "BCM2711"; break;
+ default : info->processor = "Unknown"; break;
+ }
+ switch (revision[len-5]) {
+ case '0': info->manufacturer = "Sony"; break;
+ case '1': info->manufacturer = "Egoman"; break;
+ case '2': info->manufacturer = "Embest"; break;
+ case '3': info->manufacturer = "Sony Japan"; break;
+ case '4': info->manufacturer = "Embest"; break;
+ case '5': info->manufacturer = "Stadium"; break;
+ default : info->manufacturer = "Unknown"; break;
+ }
+ switch (strtol((char[]){revision[len-6],0}, NULL, 16) & 7) {
+ case 0: info->ram = "256M"; break;
+ case 1: info->ram = "512M"; break;
+ case 2: info->ram = "1G"; break;
+ case 3: info->ram = "2G"; break;
+ case 4: info->ram = "4G"; break;
+ default: info->ram = "Unknown"; break;
}
} else {
// old scheme
@@ -99,88 +135,105 @@
info->type = "Unknown";
strcpy(info->revision, revision);
- // get last four characters (ignore preceeding 1000 for overvolt)
- if (len > 4)
- rev = (char *)&revision+len-4;
- else
- rev = revision;
+ uint64_t rev;
+ sscanf(revision, "%llx", &rev);
+ rev = rev & 0xefffffff; // ignore preceeding 1000 for overvolt
- if ((strcmp(rev, "0002") == 0) ||
- (strcmp(rev, "0003") == 0)) {
+ if (rev == 0x0002 || rev == 0x0003) {
info->type = "Model B";
info->p1_revision = 1;
info->ram = "256M";
+ info->manufacturer = "Egoman";
info->processor = "BCM2835";
- } else if (strcmp(rev, "0004") == 0) {
+ } else if (rev == 0x0004) {
info->type = "Model B";
info->p1_revision = 2;
info->ram = "256M";
- info->manufacturer = "Sony";
+ info->manufacturer = "Sony UK";
info->processor = "BCM2835";
- } else if (strcmp(rev, "0005") == 0) {
+ } else if (rev == 0x0005) {
info->type = "Model B";
info->p1_revision = 2;
info->ram = "256M";
info->manufacturer = "Qisda";
info->processor = "BCM2835";
- } else if (strcmp(rev, "0006") == 0) {
+ } else if (rev == 0x0006) {
info->type = "Model B";
info->p1_revision = 2;
info->ram = "256M";
info->manufacturer = "Egoman";
info->processor = "BCM2835";
- } else if (strcmp(rev, "0007") == 0) {
+ } else if (rev == 0x0007) {
info->type = "Model A";
info->p1_revision = 2;
info->ram = "256M";
info->manufacturer = "Egoman";
info->processor = "BCM2835";
- } else if (strcmp(rev, "0008") == 0) {
+ } else if (rev == 0x0008) {
info->type = "Model A";
info->p1_revision = 2;
info->ram = "256M";
- info->manufacturer = "Sony";
+ info->manufacturer = "Sony UK";
info->processor = "BCM2835";
- } else if (strcmp(rev, "0009") == 0) {
+ } else if (rev == 0x0009) {
info->type = "Model A";
info->p1_revision = 2;
info->ram = "256M";
info->manufacturer = "Qisda";
info->processor = "BCM2835";
- } else if (strcmp(rev, "000d") == 0) {
+ } else if (rev == 0x000d) {
info->type = "Model B";
info->p1_revision = 2;
info->ram = "512M";
info->manufacturer = "Egoman";
info->processor = "BCM2835";
- } else if (strcmp(rev, "000e") == 0) {
+ } else if (rev == 0x000e) {
info->type = "Model B";
info->p1_revision = 2;
info->ram = "512M";
- info->manufacturer = "Sony";
+ info->manufacturer = "Sony UK";
info->processor = "BCM2835";
- } else if (strcmp(rev, "000f") == 0) {
+ } else if (rev == 0x000f) {
info->type = "Model B";
info->p1_revision = 2;
info->ram = "512M";
info->manufacturer = "Qisda";
info->processor = "BCM2835";
- } else if ((strcmp(rev, "0011") == 0) ||
- (strcmp(rev, "0014") == 0)) {
- info->type = "Compute Module";
+ } else if (rev == 0x0010) {
+ info->type = "Model B+";
+ info->p1_revision = 3;
+ info->ram = "512M";
+ info->manufacturer = "Sony UK";
+ info->processor = "BCM2835";
+ } else if (rev == 0x0011) {
+ info->type = "Compute Module 1";
info->p1_revision = 0;
info->ram = "512M";
+ info->manufacturer = "Sony UK";
info->processor = "BCM2835";
- } else if (strcmp(rev, "0012") == 0) {
+ } else if (rev == 0x0012) {
info->type = "Model A+";
info->p1_revision = 3;
info->ram = "256M";
+ info->manufacturer = "Sony UK";
info->processor = "BCM2835";
- } else if ((strcmp(rev, "0010") == 0) ||
- (strcmp(rev, "0013") == 0)) {
+ } else if (rev == 0x0013) {
info->type = "Model B+";
info->p1_revision = 3;
info->ram = "512M";
+ info->manufacturer = "Embest";
+ info->processor = "BCM2835";
+ } else if (rev == 0x0014) {
+ info->type = "Compute Module 1";
+ info->p1_revision = 0;
+ info->ram = "512M";
+ info->manufacturer = "Embest";
+ info->processor = "BCM2835";
+ } else if (rev == 0x0015) {
+ info->type = "Model A+";
+ info->p1_revision = 3;
+ info->ram = "Unknown";
+ info->manufacturer = "Embest";
info->processor = "BCM2835";
} else { // don't know - assume revision 3 p1 connector
info->p1_revision = 3;
diff -Nru rpi.gpio-0.6.5/source/py_gpio.c rpi.gpio-0.7.0/source/py_gpio.c
--- rpi.gpio-0.6.5/source/py_gpio.c 2018-11-16 10:04:06.000000000 +0000
+++ rpi.gpio-0.7.0/source/py_gpio.c 2019-07-21 12:41:22.000000000 +0000
@@ -962,7 +962,7 @@
{"getmode", py_getmode, METH_VARARGS, "Get numbering mode used for channel numbers.\nReturns BOARD, BCM or None"},
{"add_event_detect", (PyCFunction)py_add_event_detect, METH_VARARGS | METH_KEYWORDS, "Enable edge detection events for a particular GPIO channel.\nchannel - either board pin number or BCM number depending on which mode is set.\nedge - RISING, FALLING or BOTH\n[callback] - A callback function for the event (optional)\n[bouncetime] - Switch bounce timeout in ms for callback"},
{"remove_event_detect", py_remove_event_detect, METH_VARARGS, "Remove edge detection for a particular GPIO channel\nchannel - either board pin number or BCM number depending on which mode is set."},
- {"event_detected", py_event_detected, METH_VARARGS, "Returns True if an edge has occured on a given GPIO. You need to enable edge detection using add_event_detect() first.\nchannel - either board pin number or BCM number depending on which mode is set."},
+ {"event_detected", py_event_detected, METH_VARARGS, "Returns True if an edge has occurred on a given GPIO. You need to enable edge detection using add_event_detect() first.\nchannel - either board pin number or BCM number depending on which mode is set."},
{"add_event_callback", (PyCFunction)py_add_event_callback, METH_VARARGS | METH_KEYWORDS, "Add a callback for an event already defined using add_event_detect()\nchannel - either board pin number or BCM number depending on which mode is set.\ncallback - a callback function"},
{"wait_for_edge", (PyCFunction)py_wait_for_edge, METH_VARARGS | METH_KEYWORDS, "Wait for an edge. Returns the channel number or None on timeout.\nchannel - either board pin number or BCM number depending on which mode is set.\nedge - RISING, FALLING or BOTH\n[bouncetime] - time allowed between calls to allow for switchbounce\n[timeout] - timeout in ms"},
{"gpio_function", py_gpio_function, METH_VARARGS, "Return the current GPIO function (IN, OUT, PWM, SERIAL, I2C, SPI)\nchannel - either board pin number or BCM number depending on which mode is set."},
@@ -1020,7 +1020,7 @@
"MANUFACTURER",rpiinfo.manufacturer,
"PROCESSOR",rpiinfo.processor,
"RAM",rpiinfo.ram);
- PyModule_AddObject(module, "RPI_INFO", board_info);
+ PyModule_AddObject(module, "RPI_INFO", board_info);
if (rpiinfo.p1_revision == 1) {
pin_to_gpio = &pin_to_gpio_rev1;
diff -Nru rpi.gpio-0.6.5/test/test.py rpi.gpio-0.7.0/test/test.py
--- rpi.gpio-0.6.5/test/test.py 2018-11-16 10:04:06.000000000 +0000
+++ rpi.gpio-0.7.0/test/test.py 2019-07-21 12:41:22.000000000 +0000
@@ -30,6 +30,7 @@
SWITCH_PIN = 18 (with 0.1 uF capacitor around switch) to 0v
LOOP_IN = 16 connected with 1K resistor to LOOP_OUT
LOOP_OUT = 22
+NC_PIN = 24 not connected to anything
"""
import os
@@ -52,6 +53,7 @@
LOOP_IN = 16
LOOP_IN_BCM = 23
LOOP_OUT = 22
+NC_PIN = 24
non_interactive = False
for i,val in enumerate(sys.argv):
@@ -131,6 +133,17 @@
self.assertEqual(GPIO.input(LED_PIN), GPIO.LOW)
GPIO.cleanup()
+ # test pull up/down works
+ GPIO.setmode(GPIO.BOARD)
+ for i in range(1000):
+ GPIO.setup(NC_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
+ time.sleep(0.001)
+ self.assertEqual(GPIO.input(NC_PIN), GPIO.LOW)
+ GPIO.setup(NC_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
+ time.sleep(0.001)
+ self.assertEqual(GPIO.input(NC_PIN), GPIO.HIGH)
+ GPIO.cleanup()
+
# test setup of a list of channels
GPIO.setmode(GPIO.BOARD)
GPIO.setup( [LED_PIN, LOOP_OUT], GPIO.OUT)
More information about the Pkg-raspi-maintainers
mailing list