Hello community, here is the log from the commit of package mraa for openSUSE:Factory checked in at 2017-03-03 17:44:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/mraa (Old) and /work/SRC/openSUSE:Factory/.mraa.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mraa" Fri Mar 3 17:44:19 2017 rev:3 rq:460898 version:1.5.1 Changes: -------- --- /work/SRC/openSUSE:Factory/mraa/mraa.changes 2017-02-03 17:50:49.821325158 +0100 +++ /work/SRC/openSUSE:Factory/.mraa.new/mraa.changes 2017-03-03 17:44:20.682743428 +0100 @@ -1,0 +2,12 @@ +Tue Feb 28 12:22:00 UTC 2017 - cbosdon...@suse.com + +- Fix build for aarch64 + 0001-rpi-fix-PLATFORM_RASPBERRY_PI_ZERO-value.patch + 0002-examples-add-return-in-spi_max7219.c.patch +- Get mraa working on raspberry pi + 0003-arm-prefer-proc-device-tree.patch + 0004-rpi-use-proc-device-tree-compatible.patch + 0005-raspberrypi-add-3-model-B-support.patch + 0006-rpi-take-care-of-gpiochip-base.patch + +------------------------------------------------------------------- New: ---- 0001-rpi-fix-PLATFORM_RASPBERRY_PI_ZERO-value.patch 0002-examples-add-return-in-spi_max7219.c.patch 0003-arm-prefer-proc-device-tree.patch 0004-rpi-use-proc-device-tree-compatible.patch 0005-raspberrypi-add-3-model-B-support.patch 0006-rpi-take-care-of-gpiochip-base.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ mraa.spec ++++++ --- /var/tmp/diff_new_pack.8sFxQp/_old 2017-03-03 17:44:21.290657518 +0100 +++ /var/tmp/diff_new_pack.8sFxQp/_new 2017-03-03 17:44:21.294656953 +0100 @@ -25,6 +25,12 @@ Group: Hardware/Other Url: https://github.com/intel-iot-devkit/mraa Source: https://github.com/intel-iot-devkit/mraa/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch0: 0001-rpi-fix-PLATFORM_RASPBERRY_PI_ZERO-value.patch +Patch1: 0002-examples-add-return-in-spi_max7219.c.patch +Patch2: 0003-arm-prefer-proc-device-tree.patch +Patch3: 0004-rpi-use-proc-device-tree-compatible.patch +Patch4: 0005-raspberrypi-add-3-model-B-support.patch +Patch5: 0006-rpi-take-care-of-gpiochip-base.patch BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: java-devel @@ -141,6 +147,12 @@ %prep %setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 %build %cmake \ ++++++ 0001-rpi-fix-PLATFORM_RASPBERRY_PI_ZERO-value.patch ++++++ >From 44299aa69b7c7f173ce120e52ddc5bba32574d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdon...@suse.com> Date: Wed, 22 Feb 2017 10:04:33 +0100 Subject: [PATCH 1/6] rpi: fix PLATFORM_RASPBERRY_PI_ZERO value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change PLATFORM_RASPBERRY_PI_ZERO into an integer to avoid build error when comparing it to integer platform_detected. Signed-off-by: Cédric Bosdonnat <cbosdon...@suse.com> --- src/arm/raspberry_pi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arm/raspberry_pi.c b/src/arm/raspberry_pi.c index 84b35bf..1d675ac 100644 --- a/src/arm/raspberry_pi.c +++ b/src/arm/raspberry_pi.c @@ -46,7 +46,7 @@ #define PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1 5 #define PLATFORM_RASPBERRY_PI_A_PLUS_REV_1 6 #define PLATFORM_RASPBERRY_PI2_B_REV_1 7 -#define PLATFORM_RASPBERRY_PI_ZERO "Raspberry Pi Zero" +#define PLATFORM_RASPBERRY_PI_ZERO 8 #define MMAP_PATH "/dev/mem" #define BCM2835_PERI_BASE 0x20000000 #define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000) -- 2.11.0 ++++++ 0002-examples-add-return-in-spi_max7219.c.patch ++++++ >From 9358a19bfdb659eb3a00e63d688b71c0853691b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdon...@suse.com> Date: Wed, 22 Feb 2017 10:07:48 +0100 Subject: [PATCH 2/6] examples: add return in spi_max7219.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some compilers are raising an error if no value is returned in main. Add a return 0 in spi_max7219.c main to quiet them. Signed-off-by: Cédric Bosdonnat <cbosdon...@suse.com> --- examples/spi_max7219.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/spi_max7219.c b/examples/spi_max7219.c index 4c1ad06..276cff9 100644 --- a/examples/spi_max7219.c +++ b/examples/spi_max7219.c @@ -85,4 +85,5 @@ main(int argc, char** argv) mraa_spi_stop(spi); //! [Interesting] + return 0; } -- 2.11.0 ++++++ 0003-arm-prefer-proc-device-tree.patch ++++++ >From 869a5bab625171e67af5b61eac3a0f10c0fdbab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdon...@suse.com> Date: Wed, 22 Feb 2017 15:07:58 +0100 Subject: [PATCH 3/6] arm: prefer /proc/device-tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per Documentation/ABI/testing/sysfs-firmware-ofw, perfer /proc/device-tree over /sys/firmware/devicetree/base as this is the stable one. Signed-off-by: Cédric Bosdonnat <cbosdon...@suse.com> --- src/arm/arm.c | 10 +++++----- src/arm/banana.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) Index: mraa-1.5.1/src/arm/arm.c =================================================================== --- mraa-1.5.1.orig/src/arm/arm.c +++ mraa-1.5.1/src/arm/arm.c @@ -57,10 +57,10 @@ mraa_arm_platform() platform_type = MRAA_96BOARDS; } else if (strstr(line, "sun7i")) { - if (mraa_file_contains("/sys/firmware/devicetree/base/model", "Banana Pro")) { + if (mraa_file_contains("/proc/device-tree/model", "Banana Pro")) { platform_type = MRAA_BANANA; } - else if (mraa_file_contains("/sys/firmware/devicetree/base/model", "Banana Pi")) { + else if (mraa_file_contains("/proc/device-tree/base/model", "Banana Pi")) { platform_type = MRAA_BANANA; } // For old kernels @@ -77,9 +77,9 @@ mraa_arm_platform() /* Get compatible string from Device tree for boards that dont have enough info in /proc/cpuinfo */ if (platform_type == MRAA_UNKNOWN_PLATFORM) { - if (mraa_file_contains("/sys/firmware/devicetree/base/compatible", "qcom,apq8016-sbc")) + if (mraa_file_contains("/proc/device-tree/compatible", "qcom,apq8016-sbc")) platform_type = MRAA_96BOARDS; - else if (mraa_file_contains("/sys/firmware/devicetree/base/model", "HiKey Development Board")) + else if (mraa_file_contains("/proc/device-tree/model", "HiKey Development Board")) platform_type = MRAA_96BOARDS; } Index: mraa-1.5.1/src/arm/banana.c =================================================================== --- mraa-1.5.1.orig/src/arm/banana.c +++ mraa-1.5.1/src/arm/banana.c @@ -37,7 +37,7 @@ #define PLATFORM_NAME_BANANA_PRO "Banana Pro" #define PLATFORM_BANANA_PRO 2 #define MMAP_PATH "/dev/mem" -#define DT_BASE "/sys/firmware/devicetree/base" +#define DT_BASE "/proc/device-tree" #define SUNXI_BASE (0x01C20000) #define SUNXI_BLOCK_SIZE (4 * 1024) ++++++ 0004-rpi-use-proc-device-tree-compatible.patch ++++++ >From cb124266a5bd221894773beef046ce277e58feca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdon...@suse.com> Date: Wed, 22 Feb 2017 09:55:11 +0100 Subject: [PATCH 4/6] rpi: use /proc/device-tree/compatible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While some distributions have a modified /proc/cpuinfo including the board revision for raspberry pi, most distributions don't have this. In order to guess the raspberry pi version in such cases, use the /proc/device-tree/compatible content as a fallback solution. The values expected from this file have been taken from upstream kernel documentation: Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt Signed-off-by: Cédric Bosdonnat <cbosdon...@suse.com> --- src/arm/arm.c | 2 ++ src/arm/raspberry_pi.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) Index: mraa-1.5.1/src/arm/arm.c =================================================================== --- mraa-1.5.1.orig/src/arm/arm.c +++ mraa-1.5.1/src/arm/arm.c @@ -81,6 +81,8 @@ mraa_arm_platform() platform_type = MRAA_96BOARDS; else if (mraa_file_contains("/proc/device-tree/model", "HiKey Development Board")) platform_type = MRAA_96BOARDS; + else if (mraa_file_contains("/proc/device-tree/compatible", "raspberrypi,")) + platform_type = MRAA_RASPBERRY_PI; } switch (platform_type) { Index: mraa-1.5.1/src/arm/raspberry_pi.c =================================================================== --- mraa-1.5.1.orig/src/arm/raspberry_pi.c +++ mraa-1.5.1/src/arm/raspberry_pi.c @@ -219,10 +219,13 @@ mraa_raspberry_pi() size_t len = 100; char* line = calloc(len, sizeof(char)); + mraa_boolean_t tweakedCpuinfo = 0; + FILE* fh = fopen("/proc/cpuinfo", "r"); if (fh != NULL) { while (getline(&line, &len, fh) != -1) { if (strncmp(line, "Revision", 8) == 0) { + tweakedCpuinfo = 1; if (strstr(line, "0002") || strstr(line, "0003")) { b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1; platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1; @@ -267,6 +270,52 @@ mraa_raspberry_pi() } free(line); + // Some distros have a Revision line in /proc/cpuinfo for rpi. + // As this may not be the case for all distros, we need to find + // another way to guess the raspberry pi model. + if (!tweakedCpuinfo) { + // See Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt + // for the values + const char *compatible_path = "/proc/device-tree/compatible"; + if (mraa_file_contains(compatible_path, "raspberrypi,model-b")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1; + platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1; + b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-rev2")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2; + platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2; + b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,model-zero")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO; + platform_detected = PLATFORM_RASPBERRY_PI_ZERO; + b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,model-a")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2; + platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2; + b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-plus")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1; + platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1; + b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,compute-module")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1; + platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1; + b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,model-a-plus")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1; + platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1; + b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,2-model-b")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1; + platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1; + b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,model-b")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1; + platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1; + b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT; + } + } + b->aio_count = 0; b->adc_raw = 0; b->adc_supported = 0; ++++++ 0005-raspberrypi-add-3-model-B-support.patch ++++++ >From 7a14f6665dff23bba71ff3a0008e3d6c63bd004b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdon...@suse.com> Date: Wed, 22 Feb 2017 10:18:10 +0100 Subject: [PATCH 5/6] raspberrypi: add 3 model B support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Bosdonnat <cbosdon...@suse.com> --- include/arm/raspberry_pi.h | 1 + src/arm/raspberry_pi.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/arm/raspberry_pi.h b/include/arm/raspberry_pi.h index 5dc5fb6..a7f0528 100644 --- a/include/arm/raspberry_pi.h +++ b/include/arm/raspberry_pi.h @@ -37,6 +37,7 @@ extern "C" { #define MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT 41 #define MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT 41 #define MRAA_RASPBERRY_PI_ZERO_PINCOUNT 41 +#define MRAA_RASPBERRY_PI3_B_PINCOUNT 41 mraa_board_t * mraa_raspberry_pi(); diff --git a/src/arm/raspberry_pi.c b/src/arm/raspberry_pi.c index 278c011..ae2dd6e 100644 --- a/src/arm/raspberry_pi.c +++ b/src/arm/raspberry_pi.c @@ -39,6 +39,7 @@ #define PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1 "Raspberry Pi Model A+ Rev 1" #define PLATFORM_NAME_RASPBERRY_PI2_B_REV_1 "Raspberry Pi 2 Model B Rev 1" #define PLATFORM_NAME_RASPBERRY_PI_ZERO "Raspberry Pi Zero" +#define PLATFORM_NAME_RASPBERRY_PI3_B "Raspberry Pi 3 Model B" #define PLATFORM_RASPBERRY_PI_B_REV_1 1 #define PLATFORM_RASPBERRY_PI_A_REV_2 2 #define PLATFORM_RASPBERRY_PI_B_REV_2 3 @@ -47,6 +48,7 @@ #define PLATFORM_RASPBERRY_PI_A_PLUS_REV_1 6 #define PLATFORM_RASPBERRY_PI2_B_REV_1 7 #define PLATFORM_RASPBERRY_PI_ZERO 8 +#define PLATFORM_RASPBERRY_PI3_B 9 #define MMAP_PATH "/dev/mem" #define BCM2835_PERI_BASE 0x20000000 #define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000) @@ -255,10 +257,15 @@ mraa_raspberry_pi() b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1; platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1; b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT; - } else if (strstr(line, "a01041") || strstr(line, "a21041") || strstr(line, "a02082")) { + } else if (strstr(line, "a01041") || strstr(line, "a21041")) { b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1; platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1; b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT; + } else if (strstr(line, "a02082") || strstr(line, "a020a0") || + strstr(line, "a22082") || strstr(line, "a32082")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B; + platform_detected = PLATFORM_RASPBERRY_PI3_B; + b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT; } else { b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1; platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1; @@ -313,6 +320,10 @@ mraa_raspberry_pi() b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1; platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1; b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT; + } else if (mraa_file_contains(compatible_path, "raspberrypi,3-model-b")) { + b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B; + platform_detected = PLATFORM_RASPBERRY_PI3_B; + b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT; } } -- 2.11.0 ++++++ 0006-rpi-take-care-of-gpiochip-base.patch ++++++ >From b7c15c70f22be6bb4d63189b5ceab0433de3d1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdon...@suse.com> Date: Thu, 23 Feb 2017 15:20:48 +0100 Subject: [PATCH 6/6] rpi: take care of gpiochip base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gpio pins numbers aren't just matching the physical pin numbers... on some distros like raspbian, with a kernel explicitly setting the base to 0, it works, but for kernels using the first free slot it doesn't (see gpiochip_find_base() in kernel's gpiolib.c). To get the proper gpio pin value, we thus need to find the base for the corresponding gpiochip. For the raspberry pi, we search for the chip with a label containing 'bcm2835'. Signed-off-by: Cédric Bosdonnat <cbosdon...@suse.com> --- src/arm/raspberry_pi.c | 90 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/src/arm/raspberry_pi.c b/src/arm/raspberry_pi.c index ae2dd6e..e55295b 100644 --- a/src/arm/raspberry_pi.c +++ b/src/arm/raspberry_pi.c @@ -25,6 +25,7 @@ #include <stdlib.h> #include <string.h> +#include <dirent.h> #include <sys/mman.h> #include <mraa/common.h> @@ -213,6 +214,8 @@ mraa_board_t* mraa_raspberry_pi() { mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t)); + int pin_base = 0; + if (b == NULL) { return NULL; } @@ -353,6 +356,31 @@ mraa_raspberry_pi() return NULL; } + // Detect the base of the gpiochip, raspbian hardcodes it to 0 in the kernel + // while upstream kernel does not. + DIR* gpio_dir = opendir("/sys/class/gpio"); + if (gpio_dir == NULL) { + free(b->adv_func); + free(b); + return NULL; + } + + struct dirent* child; + while ((child = readdir(gpio_dir)) != NULL) { + if (strstr(child->d_name, "gpiochip")) { + char chip_path[MAX_SIZE]; + sprintf(chip_path, "/sys/class/gpio/%s/label", child->d_name); + if (mraa_file_contains(chip_path, "bcm2835")) { + if (mraa_atoi(child->d_name + 8, &pin_base) != MRAA_SUCCESS) { + free(b->adv_func); + free(b); + return NULL; + } + break; + } + } + } + b->adv_func->spi_init_pre = &mraa_raspberry_pi_spi_init_pre; b->adv_func->i2c_init_pre = &mraa_raspberry_pi_i2c_init_pre; b->adv_func->gpio_mmap_setup = &mraa_raspberry_pi_mmap_setup; @@ -368,7 +396,7 @@ mraa_raspberry_pi() strncpy(b->pins[3].name, "SDA0", MRAA_PIN_NAME_SIZE); b->pins[3].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }; - b->pins[3].gpio.pinmap = 2; + b->pins[3].gpio.pinmap = pin_base + 2; b->pins[3].gpio.mux_total = 0; b->pins[3].i2c.pinmap = 0; b->pins[3].i2c.mux_total = 0; @@ -378,7 +406,7 @@ mraa_raspberry_pi() strncpy(b->pins[5].name, "SCL0", MRAA_PIN_NAME_SIZE); b->pins[5].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 }; - b->pins[5].gpio.pinmap = 3; + b->pins[5].gpio.pinmap = pin_base + 3; b->pins[5].gpio.mux_total = 0; b->pins[5].i2c.pinmap = 0; b->pins[5].i2c.mux_total = 0; @@ -388,12 +416,12 @@ mraa_raspberry_pi() strncpy(b->pins[7].name, "GPIO4", MRAA_PIN_NAME_SIZE); b->pins[7].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[7].gpio.pinmap = 4; + b->pins[7].gpio.pinmap = pin_base + 4; b->pins[7].gpio.mux_total = 0; strncpy(b->pins[8].name, "UART_TX", MRAA_PIN_NAME_SIZE); b->pins[8].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; - b->pins[8].gpio.pinmap = 14; + b->pins[8].gpio.pinmap = pin_base + 14; b->pins[8].gpio.mux_total = 0; b->pins[8].uart.parent_id = 0; b->pins[8].uart.mux_total = 0; @@ -403,27 +431,27 @@ mraa_raspberry_pi() strncpy(b->pins[10].name, "UART_RX", MRAA_PIN_NAME_SIZE); b->pins[10].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 }; - b->pins[10].gpio.pinmap = 15; + b->pins[10].gpio.pinmap = pin_base + 15; b->pins[10].gpio.mux_total = 0; b->pins[10].uart.parent_id = 0; b->pins[10].uart.mux_total = 0; strncpy(b->pins[11].name, "GPIO17", MRAA_PIN_NAME_SIZE); b->pins[11].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[11].gpio.pinmap = 17; + b->pins[11].gpio.pinmap = pin_base + 17; b->pins[11].gpio.mux_total = 0; strncpy(b->pins[12].name, "GPIO18", MRAA_PIN_NAME_SIZE); b->pins[12].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[12].gpio.pinmap = 18; + b->pins[12].gpio.pinmap = pin_base + 18; b->pins[12].gpio.mux_total = 0; if (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_1) { strncpy(b->pins[13].name, "GPIO21", MRAA_PIN_NAME_SIZE); - b->pins[13].gpio.pinmap = 21; + b->pins[13].gpio.pinmap = pin_base + 21; } else { strncpy(b->pins[13].name, "GPIO27", MRAA_PIN_NAME_SIZE); - b->pins[13].gpio.pinmap = 27; + b->pins[13].gpio.pinmap = pin_base + 27; } b->pins[13].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; b->pins[13].gpio.mux_total = 0; @@ -433,12 +461,12 @@ mraa_raspberry_pi() strncpy(b->pins[15].name, "GPIO22", MRAA_PIN_NAME_SIZE); b->pins[15].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[15].gpio.pinmap = 22; + b->pins[15].gpio.pinmap = pin_base + 22; b->pins[15].gpio.mux_total = 0; strncpy(b->pins[16].name, "GPIO23", MRAA_PIN_NAME_SIZE); b->pins[16].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[16].gpio.pinmap = 23; + b->pins[16].gpio.pinmap = pin_base + 23; b->pins[16].gpio.mux_total = 0; strncpy(b->pins[17].name, "3V3", MRAA_PIN_NAME_SIZE); @@ -446,12 +474,12 @@ mraa_raspberry_pi() strncpy(b->pins[18].name, "GPIO24", MRAA_PIN_NAME_SIZE); b->pins[18].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[18].gpio.pinmap = 24; + b->pins[18].gpio.pinmap = pin_base + 24; b->pins[18].gpio.mux_total = 0; strncpy(b->pins[19].name, "SPI_MOSI", MRAA_PIN_NAME_SIZE); b->pins[19].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; - b->pins[19].gpio.pinmap = 10; + b->pins[19].gpio.pinmap = pin_base + 10; b->pins[19].gpio.mux_total = 0; b->pins[19].spi.pinmap = 0; b->pins[19].spi.mux_total = 0; @@ -461,26 +489,26 @@ mraa_raspberry_pi() strncpy(b->pins[21].name, "SPI_MISO", MRAA_PIN_NAME_SIZE); b->pins[21].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; - b->pins[21].gpio.pinmap = 9; + b->pins[21].gpio.pinmap = pin_base + 9; b->pins[21].gpio.mux_total = 0; b->pins[21].spi.pinmap = 0; b->pins[21].spi.mux_total = 0; strncpy(b->pins[22].name, "GPIO25", MRAA_PIN_NAME_SIZE); b->pins[22].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[22].gpio.pinmap = 25; + b->pins[22].gpio.pinmap = pin_base + 25; b->pins[22].gpio.mux_total = 0; strncpy(b->pins[23].name, "SPI_CLK", MRAA_PIN_NAME_SIZE); b->pins[23].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; - b->pins[23].gpio.pinmap = 11; + b->pins[23].gpio.pinmap = pin_base + 11; b->pins[23].gpio.mux_total = 0; b->pins[23].spi.pinmap = 0; b->pins[23].spi.mux_total = 0; strncpy(b->pins[24].name, "SPI_CS0", MRAA_PIN_NAME_SIZE); b->pins[24].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; - b->pins[24].gpio.pinmap = 8; + b->pins[24].gpio.pinmap = pin_base + 8; b->pins[24].gpio.mux_total = 0; b->pins[24].spi.pinmap = 0; b->pins[24].spi.mux_total = 0; @@ -490,7 +518,7 @@ mraa_raspberry_pi() strncpy(b->pins[26].name, "SPI_CS1", MRAA_PIN_NAME_SIZE); b->pins[26].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 }; - b->pins[26].gpio.pinmap = 7; + b->pins[26].gpio.pinmap = pin_base + 7; b->pins[26].gpio.mux_total = 0; b->pins[26].spi.pinmap = 0; b->pins[26].spi.mux_total = 0; @@ -505,21 +533,21 @@ mraa_raspberry_pi() strncpy(b->pins[29].name, "GPIO8", MRAA_PIN_NAME_SIZE); b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[29].gpio.pinmap = 8; + b->pins[29].gpio.pinmap = pin_base + 8; b->pins[29].gpio.mux_total = 0; strncpy(b->pins[30].name, "GPIO9", MRAA_PIN_NAME_SIZE); b->pins[30].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[30].gpio.pinmap = 9; + b->pins[30].gpio.pinmap = pin_base + 9; b->pins[30].gpio.mux_total = 0; strncpy(b->pins[31].name, "GPIO10", MRAA_PIN_NAME_SIZE); b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[31].gpio.pinmap = 10; + b->pins[31].gpio.pinmap = pin_base + 10; b->pins[31].gpio.mux_total = 0; strncpy(b->pins[32].name, "GPIO11", MRAA_PIN_NAME_SIZE); - b->pins[32].gpio.pinmap = 11; + b->pins[32].gpio.pinmap = pin_base + 11; b->pins[32].gpio.mux_total = 0; b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; @@ -567,7 +595,7 @@ mraa_raspberry_pi() strncpy(b->pins[29].name, "GPIO05", MRAA_PIN_NAME_SIZE); b->pins[29].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[29].gpio.pinmap = 5; + b->pins[29].gpio.pinmap = pin_base + 5; b->pins[29].gpio.mux_total = 0; strncpy(b->pins[30].name, "GND", MRAA_PIN_NAME_SIZE); @@ -575,17 +603,17 @@ mraa_raspberry_pi() strncpy(b->pins[31].name, "GPIO06", MRAA_PIN_NAME_SIZE); b->pins[31].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[31].gpio.pinmap = 6; + b->pins[31].gpio.pinmap = pin_base + 6; b->pins[31].gpio.mux_total = 0; strncpy(b->pins[32].name, "GPIO12", MRAA_PIN_NAME_SIZE); b->pins[32].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[32].gpio.pinmap = 12; + b->pins[32].gpio.pinmap = pin_base + 12; b->pins[32].gpio.mux_total = 0; strncpy(b->pins[33].name, "GPIO13", MRAA_PIN_NAME_SIZE); b->pins[33].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[33].gpio.pinmap = 13; + b->pins[33].gpio.pinmap = pin_base + 13; b->pins[33].gpio.mux_total = 0; strncpy(b->pins[34].name, "GND", MRAA_PIN_NAME_SIZE); @@ -593,22 +621,22 @@ mraa_raspberry_pi() strncpy(b->pins[35].name, "GPIO19", MRAA_PIN_NAME_SIZE); b->pins[35].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[35].gpio.pinmap = 19; + b->pins[35].gpio.pinmap = pin_base + 19; b->pins[35].gpio.mux_total = 0; strncpy(b->pins[36].name, "GPIO16", MRAA_PIN_NAME_SIZE); b->pins[36].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[36].gpio.pinmap = 16; + b->pins[36].gpio.pinmap = pin_base + 16; b->pins[36].gpio.mux_total = 0; strncpy(b->pins[37].name, "GPIO26", MRAA_PIN_NAME_SIZE); b->pins[37].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[37].gpio.pinmap = 26; + b->pins[37].gpio.pinmap = pin_base + 26; b->pins[37].gpio.mux_total = 0; strncpy(b->pins[38].name, "GPIO20", MRAA_PIN_NAME_SIZE); b->pins[38].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[38].gpio.pinmap = 20; + b->pins[38].gpio.pinmap = pin_base + 20; b->pins[38].gpio.mux_total = 0; strncpy(b->pins[39].name, "GND", MRAA_PIN_NAME_SIZE); @@ -616,7 +644,7 @@ mraa_raspberry_pi() strncpy(b->pins[40].name, "GPIO21", MRAA_PIN_NAME_SIZE); b->pins[40].capabilities = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 }; - b->pins[40].gpio.pinmap = 21; + b->pins[40].gpio.pinmap = pin_base + 21; b->pins[40].gpio.mux_total = 0; } -- 2.11.0