Raspberry Pi with PiTFT - some GPIO weirdness

Milan Obuch freebsd-arm at dino.sk
Sat Feb 28 10:24:07 UTC 2015


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 <n> > /sys/class/gpio/export
cat /sys/class/gpio/gpio<n>/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


More information about the freebsd-arm mailing list