and it worked fine on my Raspberry Pi 2 with Raspbian 2015-02-16.
diff -ruN WebIOPi-0.7.1.orig/python/native/cpuinfo.c WebIOPi-0.7.1/python/native/cpuinfo.c
--- WebIOPi-0.7.1.orig/python/native/cpuinfo.c 2012-10-29 06:26:10.000000000 +0900
+++ WebIOPi-0.7.1/python/native/cpuinfo.c 2015-03-18 16:50:19.479997210 +0900
@@ -37,7 +37,10 @@
while(!feof(fp)) {
fgets(buffer, sizeof(buffer) , fp);
sscanf(buffer, "Hardware : %s", hardware);
- if (strcmp(hardware, "BCM2708") == 0)
+ if (strcmp(hardware, "BCM2708") == 0 ||
+ strcmp(hardware, "BCM2709") == 0 ||
+ strcmp(hardware, "BCM2835") == 0 ||
+ strcmp(hardware, "BCM2836") == 0)
rpi_found = 1;
sscanf(buffer, "Revision : %s", revision);
}
diff -ruN WebIOPi-0.7.1.orig/python/native/gpio.c WebIOPi-0.7.1/python/native/gpio.c
--- WebIOPi-0.7.1.orig/python/native/gpio.c 2013-02-04 07:04:18.000000000 +0900
+++ WebIOPi-0.7.1/python/native/gpio.c 2015-03-18 16:48:52.769997243 +0900
@@ -20,6 +20,7 @@
SOFTWARE.
*/
+#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -29,8 +30,8 @@
#include <pthread.h>
#include "gpio.h"
-#define BCM2708_PERI_BASE 0x20000000
-#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000)
+#define BCM2708_PERI_BASE_DEFAULT 0x20000000
+#define GPIO_BASE_OFFSET 0x200000
#define FSEL_OFFSET 0 // 0x0000
#define SET_OFFSET 7 // 0x001c / 4
#define CLR_OFFSET 10 // 0x0028 / 4
@@ -71,6 +72,22 @@
{
int mem_fd;
uint8_t *gpio_mem;
+ uint32_t peri_base = BCM2708_PERI_BASE_DEFAULT;
+ uint32_t gpio_base;
+ unsigned char buf[4];
+ FILE *fp;
+
+ // get peri base from device tree
+ if ((fp = fopen("/proc/device-tree/soc/ranges", "rb")) != NULL) {
+ fseek(fp, 4, SEEK_SET);
+ if (fread(buf, 1, sizeof buf, fp) == sizeof buf) {
+ peri_base = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3] << 0;
+
+ }
+ fclose(fp);
+ }
+
+ gpio_base = peri_base + GPIO_BASE_OFFSET;
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0)
{
@@ -83,7 +100,7 @@
if ((uint32_t)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);
- gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, GPIO_BASE);
+ gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, gpio_base);
if ((uint32_t)gpio_map < 0)
return SETUP_MMAP_FAIL;