GPIO export on linux - Invalid argument


#1

Hi,
I’m trying to blink an LED connected to the GPIO pins of my Dragonboard, on linux.
I logged as root by sudo -i, entered the /sys/class/gpio folder, and did “echo 938 > export”, to access my LED which is on the pin 23.
The command doesn’t work and the output is "-bash: echo: write error: Invalid argument

Is the command wrong? How can I access the pins? Thanks.


#2

Hello,

The 938 looks wrong for Linux. I think it is only Android that has the high offset numbers. You might want to have a look at David Mandala’s very good blog where he does a similar experiment to what you are looking to do:

There is also a further blog by David where he talks about the different libraries for accessing the GPIO’s:

Hope that helps move things forward for you.

Regards,
Barry


#3

Hi,

Thanks for your answer, I followed these guides but while the output seems to be sent to the GPIOs (which I can see by doing cat value), my LED won’t get on/off. Is there a different offset value for the pins on Linux? What am I missing?


#4

Well that is progress! :slight_smile:

Are you sure the circuit is right for the LED? I got caught out by the fact that the GPIO on the Dragonboard is only 1.8v. Depending what type of LED you have there might not be enough voltage to light the LED.

I ended up doing an experiment to demonstrate this:


#5

Hi Barry,
Thanks :slight_smile: I’m using a red LED so it should be working. It lights up when I put it on the pin36 for example. But I’m still unable to light it on the GPIO pins.


#6

OK, seems like I’m not helping at this point…

Just wanted to check one thing about your reply for my own sanity. I’m not exactly sure what you are referring to when you say ‘pin36’ and ‘GPIO pins’

Here is a useful diagram that I use as reference.

Seems like connector pin 35 would be the pin to test that your LED is working with 1.8v. and the GPIO 36 for testing the commands.


#7

Just to confirm, you are using “echo 36 > export”? What about “cd gpio36; echo out > direction”?


#8

@barryb With the LED on the pin 35 the result is the same, the LED doesn’t light on.

@vchong Yes. I’m doing:

sudo -i
cd /sys/class/gpio
echo echo 35 > export
cd gpio35
echo out > direction
echo 1 > value

Any idea?


#9

The pin number is not the same as the gpio number. Pin23 is gpio36 for db410c linux, so you need to first connect the negative(-) leg of the LED to ground. Then connect the positive(+) leg of your LED to pin 23, that is, based on barryb’s pinout (https://az835927.vo.msecnd.net/sites/iot/Resources/images/PinMappings/DB_Pinout.png), the 12th hole from the top on the inside column (the column towards the inside of the board).

Then do:

sudo -i
cd /sys/class/gpio
echo 36 > export
cd gpio36
echo out > direction
echo 1 > value


#10

Hi @greenh,

I don’t have a DB410c in front of me at the moment but I think the voltage is higher than 1.8v on connector pin 36.

It seems to me that if your LED doesn’t work on connector pin 35 then it isn’t going to work on GPIO 35 (connector pin 31).


#11

@vchong I have done that and didn’t get any error message but my red LED still won’t light on…


#12

Then as barryb said you might want to check the voltage rating of your LED to make sure you have one that works with 1.8v. Or if you have a multimeter you can maybe try to measure the voltage on the pin to see if it goes up and down when you set the gpio value to 1 and 0. Or maybe try one of the mezzanine boards (http://www.96boards.org/products/mezzanine/) that has built-in level shifters to give you 3.3 or 5v, but obviously it will cost more than an LED.


#13

Thanks. I’ll try to measure the voltages once I find a multimeter, or look for another LED :slight_smile: