GPIO binding: handling of the non-standard pin names on the cubieboard

378 views
Skip to first unread message

Baramykov Alexandr

unread,
Jul 14, 2014, 3:40:39 AM7/14/14
to ope...@googlegroups.com
In the cubieboard GPIO pins in sysfs are named using gpio<pin_number>_p<port> pattern. E.g. it is
/sys/class/gpio/gpio2_pb19 instead of /sys/class/gpio/gpio2
/sys/class/gpio/gpio10_ph14 instead of /sys/class/gpio/gpio10
etc.
I tried to find how to change this, but all I found are unanswered questions:


Since gpio addon requires standard addressing like /sys/class/gpio/gpio2 - it is not working on the cubieboard.
I locally patched io.gpio addon and hardcoded pin_num->pin_name dictionary for the cubieboard, so I can use it now, but maybe there is a normal way to handle such a situation with gpio?

dpsl...@gmail.com

unread,
Jul 14, 2014, 9:08:30 AM7/14/14
to ope...@googlegroups.com
No, currently there is no way to handle this kind of non-standard GPIO driver implementation except custom patch as you did. I'm thinking to implement some kind of translation service for pin number, in this way we can use more friendly names instead of raw kernel numbers. Originally I was thinking it to be simple mapping file with two columns: name, pin. Some other people already pointed this issue with AllWinner driver and I'm thinking to add third column - sysfs name, but still not convinced should we introduced this change just for one driver which not follows standards :-)

Baramykov Alexandr

unread,
Jul 14, 2014, 3:07:54 PM7/14/14
to ope...@googlegroups.com, dpsl...@gmail.com
Thank you for your responce.
Will hope that I haven't broken add-on while patching it :)

muchacho...@gmail.com

unread,
Aug 22, 2014, 3:48:33 AM8/22/14
to ope...@googlegroups.com


On Monday, July 14, 2014 10:40:39 AM UTC+3, Baramykov Alexandr wrote:
Hi Oleksander
I'm quite new in openhab. Please tell me where this io.gpio  is placed?

alexandr....@gmail.com

unread,
Aug 22, 2014, 4:53:31 AM8/22/14
to ope...@googlegroups.com
Hi,

It's a openhab add-on that implements gpio transport: something like org.openhab.io.gpio-1.5.1.jar. It can be downloaded as a part of the add-on pack on the openhab download page. You should place it and another one, that exactly implements binding (org.openhab.binding.gpio-1.5.1.jar) to the %OPENHAB_INSTALLATION_DIR%/addons directory to use gpio binding.


22.08.2014 10:48, muchacho...@gmail.com пишет:
--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/Q7iSnvjawiQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

muchacho...@gmail.com

unread,
Aug 22, 2014, 5:35:26 AM8/22/14
to ope...@googlegroups.com
Ok. It's clear. I should place both addons in my openhab. But you said that you have also manually changed io.gpio file? How does addon find my port gpioX_pgY ?! As I understand it is looking for gpioX

muchacho...@gmail.com

unread,
Aug 23, 2014, 5:35:03 AM8/23/14
to ope...@googlegroups.com
Alexandr, please reply. Sorry for disturbing.

alexandr....@gmail.com

unread,
Aug 23, 2014, 5:53:43 AM8/23/14
to ope...@googlegroups.com

Ok, seems like I didn't fully understand your previous question.
Do you want me to share patched version of the io.gpio add-on that I built locally because you have the same issue with cubieboard? I've attached it. As far as I remember - I've built it from 1.5.1 sources, but it's named 1.5.0, I don't know why. In any case it's working on openhab 1.5.1.

To enable cubieboard-like gpio addressing - replace io.gpio add-on by attached jar file and change start.sh (or start.bat, whatever you use to run openhab): at last line, find something like this:
java -Dosgi.clean=true  -Declipse.ignoreApp=true -Dosgi.noShutdown=true ... < lots of other arguments there>
and insert text "-Sgpio.altAddr=true" (without qutes) after "java" word to get something like this:
java -Sgpio.altAddr=true -Dosgi.clean=true  -Declipse.ignoreApp=true -Dosgi.noShutdown=true ... < lots of other arguments there>

That's all. Ask questions if something isn't clear.


22.08.2014 12:35, muchacho...@gmail.com пишет:
org.openhab.io.gpio-1.5.0.jar

alexandr....@gmail.com

unread,
Aug 23, 2014, 6:19:59 AM8/23/14
to ope...@googlegroups.com

I'm also attaching a patch for the case if someone want to see what it changes exactly. It should be applied to the GPIOLinux class.



22.08.2014 12:35, muchacho...@gmail.com пишет:
Ok. It's clear. I should place both addons in my openhab. But you said that you have also manually changed io.gpio file? How does addon find my port gpioX_pgY ?! As I understand it is looking for gpioX
GPIOLinux.patch

muchacho...@gmail.com

unread,
Aug 28, 2014, 10:39:30 AM8/28/14
to ope...@googlegroups.com
Hi Alexandr. Thank you again for response. I found out that cubieboard2 doesn't want to accept script.bin file configuration if your gpio defined not consistently. Like:

[gpio_para]
gpio_used = 1
gpio_num = 3
gpio_pin_1 = port:PH20<1><default><default><1>
gpio_pin_2 = port:PH21<1><default><default><1>
gpio_pin_17 = port:PG09<1><default><default><1>

So I should define it like:
[gpio_para]
gpio_used = 1
gpio_num = 3
gpio_pin_1 = port:PH20<1><default><default><1>
gpio_pin_2 = port:PH21<1><default><default><1>
gpio_pin_3 = port:PG09<1><default><default><1>

In this case you patch wont work. So I have modified io binding to read gpio configuration from file. See my version if interesting. I also attached compiled binding. You should also define parameter -Dgpio.altAddrFile=path_to_config_file in your startup script(btw I run openhab as deamon so I should use -S key). Config file also attached
GPIOLinux.java
org.openhab.io.gpio_1.6.0.201408281640.jar
pins.conf

Baramykov Alexandr

unread,
Aug 29, 2014, 4:32:32 PM8/29/14
to ope...@googlegroups.com
Yes, when I was patching - I havent't planned to publish it, so made a hardcode.

Your patch looks fine, good job. The only confusing thing is for every used pin configuration file is re-read.

muchacho...@gmail.com

unread,
Sep 1, 2014, 10:58:45 AM9/1/14
to ope...@googlegroups.com
Yes, you are right, not good. I am going to fix it

muchacho...@gmail.com

unread,
Oct 9, 2014, 7:17:04 AM10/9/14
to ope...@googlegroups.com, muchacho...@gmail.com
If you still interesting, I changed gpio binding and now it initialize alternative gpios only once at start.
org.openhab.io.gpio_1.6.0_alt_pins.jar
GPIOLinux.java

Boris Holscher

unread,
Dec 18, 2014, 6:33:34 AM12/18/14
to ope...@googlegroups.com, muchacho...@gmail.com
Hi Muchacho, hi Alexandr,

First of all thanks a lot for your adaptation to the new way of GPIO numbering. I have read that with new sunxi kernels, this is the standard way of numbering. I am using a Olinuxino-A20 and have the same numbering (GPIO1_PG0, GPIO1_PG1, ... ). So I gratefully downloaded your io.gpio file and replaced the original "org.openhab.io.gpio-1.6.1.jar". Then I added to the /etc/default/openhab the startup argument -Dgpio.altAddrFile=/etc/openhab/configurations/pins.conf (that's my location of pin definitions). Unfortunately, I must have made a mistake or I have still forgotten something else, because the binding does not seem to work. Do you have any ideas? Thanks a lot in advance!

Greetings, Boris

Boris Holscher

unread,
Dec 18, 2014, 3:29:30 PM12/18/14
to ope...@googlegroups.com, muchacho...@gmail.com
Hi Muchacho,

I've got some more (hopefully useful) information: When debug is active, I get the message:
[DEBUG] [penhab.io.gpio.linux.GPIOLinux:70   ] - Alternative pins file isn't set

So apparently I don't put the startup argument in the correct place. I'd be very grateful if you could help me here!

Boris Holscher

unread,
Dec 18, 2014, 3:56:41 PM12/18/14
to ope...@googlegroups.com, muchacho...@gmail.com
Thanks again, Muchacho and Alexandr! I finally made it. I put the argument (-Dgpio.altAddrFile=/etc/openhab/configurations/pins.conf) into the init.d script and now it's working (don't know why it didn't work in the /etc/default/openhab). Just great to see the litte test LED turn on and off. I wonder if this GPIO patch shouldn't make it into the GIT repository? It should work with either type of board, Raspberry Pi and sunxi kernel boards, shouldn't it?

Dancho Penev

unread,
Dec 19, 2014, 3:47:49 AM12/19/14
to ope...@googlegroups.com, muchacho...@gmail.com

FYI, a couple of days ago I created a poll request with some enhancements to GPIO binding, one of them addresses the issue with All Winner devices. I introduced a new map file originally for creating aliases for pin numbers, in this way you could use more user friendly names in the configuration instead of raw kernel numbers. I also added an optional third column for sysfs suffix in this map. The poll request isn't merged yet to master branch, if you want to play with new functionality you have to compile the code yourself. Clone https://github.com/dpslavov/openhab.git and build the packages in usual way. To configure the pin map create a new directory named "pinmaps" in openHAB's "configurations" directory and create a file with extension .pinmap there. It should contains three columns, the first one is user friendly name which will be used in item configuration file instead of number, the second one is the corresponding pin number and the third one is sysfs suffix. The fields can be separated with any number of spaces and/or tabs. To use this pinmap file add option "gpio:pinmap=BOARD" (where BOARD is the name of the file without its extension) in GPIO section of "configurations/openhab.cfg". If you are tested it please provide some feedback, also you can share your pinmap file to be included in the distribution. 

Thomas Eichstädt-Engelen

unread,
Dec 19, 2014, 11:48:47 AM12/19/14
to ope...@googlegroups.com
Hi Dancho, all,

will have a look at the PR, soon!

Thanks for all the efforts,

Thomas E.-E.



--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages