Hello, I am having a hard time figuring out how to access GPIO pins from linux. According to the documentation, you need to first export pin using; \ = ((\ - 1) * 32 ) + \ In the documentation, as an example, it uses GPIO1_IO_25; \ = ((1 - 1) * 32) + 25 = 25; Now I am trying to export pin 13. I believe this is the pin connected to the orange led. Pin 13 according to the document is GPIO_102. using the formula; (0-1) * 32 + 102 = 70 After this, I can do, echo 70 > /sys/class/gpio/export which will create a new folder callged gpio70. trying to print the "value" of this pin returns either 0 or 1. it is not consistent and it doesn't relate to the actual value of the pin. I have the arduino send LOW to this pin, and reading this value gives 1 at times and 0 the other. Any idea what I am doing wrong here?
You can't export pin 13 because is used by M4. Internal pins are for Arduino, external ones for Linux. So you can't export it. Take another look at the guide, everything's explained better there. We plan to make the pinmuxing easier by the way, if you are looking for a way to "mess it up" a bit.
If that is the case, If i want to export A3 (GPIO_IO_143) do i need to export it as ((0 - 1) * 32) + 143 = 111? I just want to make sure that I am getting 0 for (0 - 1) correct.
Every peripheral, to be accessible from a core, should be assigned to it. It's all decided at boot in the kernel. So at runtime you just can't now. You should recompile the kernel. Obviously our plan is to make it easy, we don't want you to have to recompile the kernel for this, but since the software is still a beta this is what you can do right now.
I am confused then. The document you linked here says that i can export pins. so this is not ready yet?
I think the documentation is really poor in this area. The formula doesn't seem to make any sense. Here is some help, maybe: You can use this diagram to see the position of A3 in the box that the Neo was sent in (sorry for the quality): 36 The corresponding GPIO to 36 would be GPIO_177 So I guess 177 is the answer? I don't have any breadboard or anything to confirm this unfortunately. If you can try it and come back to me, that would be neat.
Yes, that's the correspondent pin. A3 located in the internal row is assigned to Cortex-M4 (Arduino), so by default you can't export it under Linux. 36 located in the external row is assigned to Cortex-A9, so you can export it as GPIO 177.
Then I understand you simply have to read the figure for the corresponding GPIO number. So what's the formula for?
Here's something that may come in handy (part of a node library I'm working on) Code: function pinToGpio(pinNumber) { if (16 > pinNumber || pinNumber > 47) { throw new Error("Invalid pin number."); } var gpios = [106, 107, 180, 181, 172, 173, 182, 124, 25, 22, 14, 15, 16, 17, 18, 19, 20, 21, 203, 202, 177, 176, 175, 174, 119, 124, 127, 116, 7, 6, 5, 4]; return gpios[pinNumber - 16]; }
@Julien: my colleagues tell me to tell you GREAT! The formula is the one in the docs http://www.udoo.org/docs-neo/Hardware_&_Accessories/Gpio.html
The function seems to be working properly. It looks like you export whatever GPIO_xxxx you see in the diagram. So what is the point of the formula?
As root: echo 177 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio177/direction echo 1 > /sys/class/gpio/gpio177/value cat /sys/class/gpio/gpio177/value returns : 0 What am I doing wrong?
If you read the document it says; If you put an LED on that pin out, you can actually see that the led will turn on.