Thomas131 Posted July 28, 2017 Posted July 28, 2017 Hello! I installed a fresh Armbian (5.31; Server) on my Pine64 yesterday. Today I wanted to start playing around with GPIO ... And it seems like Pin 72 isn't working ... Doing the same on Pin 77, everything works fine ... For the secound test, I used https://github.com/databit/Pine64-CPP. I only added some Debug info to example.cpp. Spoiler Script started on Fri 28 Jul 2017 01:35:44 PM CEST root@pine64:/sys/class/gpio# echo "72" > export bash: echo: write error: Device or resource busy root@pine64:/sys/class/gpio# echo "72" > unexport bash: echo: write error: Invalid argument root@pine64:/sys/class/gpio# ls export gpiochip0 gpiochip1024 gpiochip352 unexport root@pine64:/sys/class/gpio# cd /opt/Pine64-CPP/ [Removed some lines where I was inserting debug info into example.cpp] root@pine64:/opt/Pine64-CPP# make g++ -fpermissive -Wall -o test *cpp sudo ./test Set GPIO pin directions Turn Led ON PinMode:1 Value:1 Turn Led OFF PinMode:0 Value:0 Turn Led ON PinMode:0 Value:0 Turn Led OFF PinMode:0 Value:0 Turn Led ON PinMode:0 Value:0 Turn Led OFF PinMode:0 Value:0 ^CMakefile:2: recipe for target 'default' failed make: *** [default] Interrupt root@pine64:/opt/Pine64-CPP# make g++ -fpermissive -Wall -o test *cpp sudo ./test Set GPIO pin directions Turn Led ON PinMode:1 Value:1 Turn Led OFF PinMode:1 Value:0 Turn Led ON PinMode:1 Value:1 Turn Led OFF PinMode:0 Value:1 Turn Led ON PinMode:0 Value:1 Turn Led OFF PinMode:0 Value:1 Turn Led ON PinMode:0 Value:1 ^CMakefile:2: recipe for target 'default' failed make: *** [default] Interrupt root@pine64:/opt/Pine64-CPP# cat example.cpp /* PINE 64 - C++ lib 1 Copyright (c) 2017 Daniele Contarino <daniele.contatino@studium.unict.it> i111i This library is based over work by: .ft .; .tf. Eric Ptak <trouch@trouch.com> ft. ,fft. .ff Stefan Mavrodiev @ OLIMEX LTD <support@olimex.com> 1fffffffffff1 Kamil Trzcinski <ayufan@ayufan.eu> ,LLf. ,fffffff, ,LLL, Permission is hereby granted, free of charge, to any person obtaining a copy of ,LLLLLLLi iLLLLLLL, this software and associated documentation files (the "Software"), to deal in ,LLL; 1LLLLLi ;LLL, the Software without restriction, including without limitation the rights to :LLLLLLLLLLLLLLL: use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies .LLL; 1LLLLLLLi ;LLL of the Software, and to permit persons to whom the Software is furnished to do :LLLLLLL: :LLLLLLL, so, subject to the following conditions: iLLf. :LLLLL, .LLL; The above copyright notice and this permission notice shall be included in all 1LLLLLLLLLLLLLi copies or substantial portions of the Software. :LLLLL: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR L IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, L FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <sys/resource.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <iostream> #include <sstream> #include "pinout.h" #include "gpio.h" #include "i2c.h" #include "spi.h" using namespace std; using namespace Pine64; int main (void) { GPIO* man = new GPIO(); if (man->setup()) { cout << "Failed to configure GPIO\n" << endl; return 1; } cout << " Set GPIO pin directions" << endl; man->pinMode(72, OUTPUT, PUD_OFF); while(1) { cout << "Turn Led ON "; man->digitalWrite(72, HIGH); cout << "\tPinMode:" << man->GPIOFunction(72); cout << "\tValue:" << man->digitalRead(72) << endl; man->delay(1000); cout << "Turn Led OFF"; man->digitalWrite(72, LOW); cout << "\tPinMode:" << man->GPIOFunction(72); cout << "\tValue:" << man->digitalRead(72) << endl; man->delay(1000); } cout << "Exiting....." << endl; return 0; } root@pine64:/opt/Pine64-CPP# exit Script done on Fri 28 Jul 2017 01:43:42 PM CEST When I looked at the Schematics of the Pine64 (http://files.pine64.org/doc/Pine A64 Schematic/Pine A64plus 2GB Rev C-20160113_Release.pdf), I noticed that according to Page 7, the Pine has eMMC on it and the whole Port C is connected to it ... I haven't found that somewhere else and couldn't find an eMMC-Chip on my Pine, too. Do you have an idea, why it doesn't work? A reboot didn't help, too ... Thanks in advance! Thomas
martinayotte Posted July 28, 2017 Posted July 28, 2017 GPIO72 is PC8, and on my side, I don't have any error trying to export it. So, on your side, something is using it and that is why you have "resource busy". Try to run the following command to see who is using it : cat /sys/kernel/debug/gpio Also, please mentioned which kernel/image are you using...
Thomas131 Posted July 28, 2017 Author Posted July 28, 2017 Thanks, this really helped!: me@pine64:~$ uname -a Linux pine64 3.10.105-pine64 #2 SMP PREEMPT Fri Jun 23 21:12:42 CEST 2017 aarch64 aarch64 aarch64 GNU/Linux me@pine64:~$ sudo cat /sys/kernel/debug/gpio [sudo] password for meroot: GPIOs 0-255, platform/1c20800.pinctrl, 1c20800.pinctrl: gpio-0 (? ) in lo gpio-72 (w1 ) in lo gpio-166 (1c0f000.sdmmc cd ) in lo gpio-231 (SPK ) out lo GPIOs 352-383, platform/1f02c00.pinctrl, 1f02c00.pinctrl: gpio-354 (wlan_regon ) out hi gpio-355 (wlan_hostwake ) in lo gpio-356 (bt_rst ) out lo gpio-359 (system_status ) out hi GPIOs 1024-1027, platform/pinctrl.2, axp-pinctrl: me@pine64:~$ exit After a search on the internet, I found out, that this is the 1-wire kernel module. I unloaded it with sudo modprobe -r w1-gpio. Now it works! To permanently prevent the module from loading, I added it to /etc/modprobe.d/blacklist.conf. Thanks! Your answer helped a lot!!!!
Recommended Posts