From owner-freebsd-arm@FreeBSD.ORG Sat Feb 28 10:24:07 2015 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8121B4E0 for ; Sat, 28 Feb 2015 10:24:07 +0000 (UTC) Received: from mailhost.netlabit.sk (mailhost.netlabit.sk [84.245.65.72]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1661F1BE for ; Sat, 28 Feb 2015 10:24:06 +0000 (UTC) Received: from zeta.dino.sk (fw1.dino.sk [84.245.95.252]) (AUTH: LOGIN milan) by mailhost.netlabit.sk with ESMTPA; Sat, 28 Feb 2015 11:18:53 +0100 id 00DCA802.54F1960D.00007C54 Date: Sat, 28 Feb 2015 11:18:52 +0100 From: Milan Obuch To: freebsd-arm@freebsd.org Subject: Raspberry Pi with PiTFT - some GPIO weirdness Message-ID: <20150228111852.15affe31@zeta.dino.sk> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; i386-portbld-freebsd10.1) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Feb 2015 10:24:07 -0000 Hi, today I found some time to play a bit with my little display attached to Rasoberry Pi, and I decided to test buttons connected to GPIO, as this should work on FreeBSD already. According docs, buttons are connected to GPIO lines 23, 22, 21 and 18, leftmost first. Using basic 'gpioctl -f /dev/gpioc0 -lv' command I found only first one, on line 23, reacts. It has value 1 normally and 0 when pressed. As I first verified this display with Rapbian, I decided to use button on line 23 as reset switch, using some kernel module to do it. It works this way. I tried other buttons with command sequence taken from some guide echo > /sys/class/gpio/export cat /sys/class/gpio/gpio/value for n in 22, 21 and 18, but I was still getting value 0, no matter whether any button is pressed or not. So it seems it does not work out of the box under Rasbpian too... however pressing button on line 23 makes system shutdown itself as expected. Next step was to try reconfigure this module to use other button, first 22 - and middle left button acted as shutdown button now, and I can see changes on gpio23 after export... strange. So I check with lines 21 and 18, and the latter one worked too. After some googling I found there is a difference in board connections between Revision 1 and Revision 2 board, so I should test with 27 instead of 21, and that worked too. So I was able to use any from those four buttons as shutdown button, and read button state for the other three buttons now. Then I put again SD card with my FreeBSD there, and, surprise, all four button states are now correct! I did not make any change in my setup, it just looks like something in SoC was programmed differently now, and it remains this way even after removing power (shutdown module in Raspbian just stops the system, you must remove power from board to restart it, I did not check if there is something like reset pin to start it again), and even after switching SD cards with systems. If anybody has any explanation what could make GPIO readings correct please tell me. Or if you have any idea for some more tests... I would like to understand this, maybe someone knows or found a bit more. Regards, Milan