From 7cf1fddb800dec178db65b2a71a15b7d9d663f6e Mon Sep 17 00:00:00 2001 From: Dave Crawford Date: Fri, 29 Jan 2016 14:05:49 -0500 Subject: [PATCH 1/3] Modify CPU check Handles the difference in string values in /proc/cpuinfo across various kernel versions by locating the "sun7i" anywhere in the hardware string. Examples: -- Linux lemaker 3.4.103 #1 SMP PREEMPT Thu Dec 18 13:07:12 CST 2014 armv7l GNU/Linux Hardware : sun7i -- Linux bananapi 4.2.3-sunxi #2 SMP Sun Oct 11 14:12:18 CEST 2015 armv7l GNU/Linux Hardware : Allwinner sun7i (A20) Family --- source/cpuinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/cpuinfo.c b/source/cpuinfo.c index 4d77919..d89b6c5 100644 --- a/source/cpuinfo.c +++ b/source/cpuinfo.c @@ -38,8 +38,8 @@ char *get_cpuinfo_revision(char *revision) while(!feof(fp)) { fgets(buffer, sizeof(buffer) , fp); - sscanf(buffer, "Hardware : %s", hardware); - if (strcmp(hardware, "sun7i") == 0) { + sscanf(buffer, "Hardware : %[^\n]", hardware); + if (strcmp(hardware, "sun7i") >= 0 ) { f_a20=1; rpi_found = 1; //printf("BAPI: Banana Pi!!\n"); From 87377593c9e63c677ed7d9c52eb828508540ec60 Mon Sep 17 00:00:00 2001 From: Dave Crawford Date: Fri, 29 Jan 2016 14:44:58 -0500 Subject: [PATCH 2/3] Update cpuinfo.c --- source/cpuinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/cpuinfo.c b/source/cpuinfo.c index d89b6c5..7603950 100644 --- a/source/cpuinfo.c +++ b/source/cpuinfo.c @@ -39,7 +39,7 @@ char *get_cpuinfo_revision(char *revision) while(!feof(fp)) { fgets(buffer, sizeof(buffer) , fp); sscanf(buffer, "Hardware : %[^\n]", hardware); - if (strcmp(hardware, "sun7i") >= 0 ) { + if (strcmp(hardware, "sun7i") <= 0 ) { f_a20=1; rpi_found = 1; //printf("BAPI: Banana Pi!!\n"); From f9c0597cfb40e75c095de68b77ddc6835778a7bf Mon Sep 17 00:00:00 2001 From: Dave Crawford Date: Tue, 9 Feb 2016 12:51:24 -0500 Subject: [PATCH 3/3] Remove printf of 'revision' --- source/py_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/py_gpio.c b/source/py_gpio.c index 2c1583b..e426dc6 100644 --- a/source/py_gpio.c +++ b/source/py_gpio.c @@ -658,7 +658,7 @@ PyMODINIT_FUNC initGPIO(void) // detect board revision and set up accordingly revision = get_rpi_revision(); -D printf("BAPI: revision(%d)\n",revision); +//D printf("BAPI: revision(%d)\n",revision); if (revision == -1) { PyErr_SetString(PyExc_RuntimeError, "This module can only be run on a Raspberry Pi!");