GPIO failed: No such file or directory

1,490 views
Skip to first unread message

not you

unread,
Nov 3, 2018, 6:48:41 AM11/3/18
to BeagleBoard
I keep running into this error when running a code after booting up.  The code write to certain GPIO under /sys/class/gpio.  It complains:

No such file or directory

I reset the BBB and run `ls` inside /sys/class/gpio.  Apparently, the selected GPIO's are not there.  After the aforementioned code is executed (and the same errors are thrown), I run `ls` again.  This time, the required GPIO's are there.  Could someone explain to me why they do not initially exist, and what makes them show up afterwards?  Thank you in advance.

Yiling Cao

unread,
Nov 3, 2018, 7:55:56 AM11/3/18
to beagl...@googlegroups.com
Have you turned off GPIO options in kernel settings?

This is the TI official guide (assuming you are running Linux): http://processors.wiki.ti.com/index.php/Linux_PSP_GPIO_Driver_Guide

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/aa24f687-2c91-40c6-a1b2-023660306104%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Philip Munts

unread,
Nov 5, 2018, 1:28:53 AM11/5/18
to BeagleBoard
It is a race condition. The GPIO pin files don't exist until the pin is exported by writing the pin number to /sys/class/gpio/export. The pin files are created neither instantaneously nor synchronously.

Your code or library is trying to open one of the pin files after exporting but before the pin file is ready.

Phil

Message has been deleted

not you

unread,
Nov 8, 2018, 4:21:52 AM11/8/18
to BeagleBoard
Phil,
I use a loop to retry the write operation up to 10 times, each with a pause of 5s if the initial write fails.  However, that doesn't seem to help.  The last retry is 50s after the export operation.  This is a vast amount of time for the export operation to complete.  Obviously, it just didn't work.  How can I fix this?  

not you

unread,
Nov 8, 2018, 8:50:17 AM11/8/18
to BeagleBoard
After many more tries, I figure out the error.  The GPIO's  are already available on boot up.  The code tries exporting them again, causing the opposite effect (unexport).  This causes the `No such file or directory` error.  Anyways, any idea why this opposite effect is there?  Shouldn't it do nothing instead?  We already have unexport for that purpose.
Reply all
Reply to author
Forward
0 new messages