Page 1 of 1

UNIX-port and GPIO's?

Posted: Mon Sep 12, 2016 9:12 am
by Tetraeder
Hello everyone,

I have a NXP/Freescale Sabre Board with i.MX6 and I run Linaro.
Question:
Has someone tried to control a Pin or any other hardware function over the UNIX-port (controller no matter)?
Anyone a idea to get this working?

I read something about "Linux Device Tree", is that the right way?

thanks in advance

Re: UNIX-port and GPIO's?

Posted: Mon Sep 12, 2016 9:39 am
by deshipu
I think that in the true UNIX fashion, all those pins are exposed as files in the /dev subsystem, so you should be able to control them using regular file operations. Then again, not sure if this is the most efficient way of doing it.

Re: UNIX-port and GPIO's?

Posted: Mon Sep 12, 2016 11:44 am
by markxr
I've done it with non-micro python.

Under Linux, you write the ID of the GPIOs to export into /sys/class/gpio/export. In this context, "export" means from kernel-control to control of user processes.

Then files appear under /sys/class/gpio/gpioN (where N is the ID)

There are a bunch of other pseudo-files in there, which control the GPIO direction and output.

It's not the most efficient way, but it should work across different Linux GPIO implementations.

Re: UNIX-port and GPIO's?

Posted: Mon Sep 12, 2016 4:07 pm
by dhylands
You'll find documentation for sysfs access to gpio pins here:
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

Re: UNIX-port and GPIO's?

Posted: Mon Sep 12, 2016 5:27 pm
by pfalcon
Tetraeder wrote: Has someone tried
For example: http://forum.micropython.org/viewtopic. ... 137#p10744

Re: UNIX-port and GPIO's?

Posted: Tue Sep 13, 2016 1:05 pm
by Tetraeder
thanks for the hints!!
Regarding "GPIO Sysfs Interface":
Also a good reference for setting GPIO's from User Space http://falsinsoft.blogspot.nl/2012/11/a ... space.html
It's works with my other Board, Phytec phyBOATD-Wega-AM335x, with kernel version 3.12.61 but with my i.MX6 board i can't control the output state, only read out the input state is possible. Well I keep trying.

NOTE
example to calculate the GPIO ID:
In my case every port has 32 pin's
Port=3
Pin=6
Port number * 32 + Pin = 3 x 32 + 6 = 106 = ID