config-pin for gpio output

663 views
Skip to first unread message

Mark A. Yoder

unread,
Jun 3, 2020, 9:16:05 AM6/3/20
to BeagleBoard
In the day I did:

config-pin P9_11 out

to make it a gpio output.  Now it appears I have to do:

config-pin P9_11 gpio

But how do I make it an output?  Must I do:

echo out > /sys/class/gpio/gpio30/direction  ?

--Mark

Robert Nelson

unread,
Jun 3, 2020, 9:45:00 AM6/3/20
to Beagle Board, Mark Yoder

Mark A. Yoder

unread,
Jun 3, 2020, 10:15:08 AM6/3/20
to BeagleBoard
So is,  
 echo out > /sys/class/gpio/gpio30/direction

The proper way to set it to output?

--Mark

On Wednesday, June 3, 2020 at 9:45:00 AM UTC-4, RobertCNelson wrote:

Robert Nelson

unread,
Jun 3, 2020, 10:27:38 AM6/3/20
to Beagle Board
On Wed, Jun 3, 2020 at 9:15 AM Mark A. Yoder <mark.a...@gmail.com> wrote:
>
> So is,
> echo out > /sys/class/gpio/gpio30/direction
>
> The proper way to set it to output?

The proper way is to use libgpiod tools such as gpioset ;)

sudo gpioset gpiochip0 30=1

But that old way still woks.

Mark A. Yoder

unread,
Jun 4, 2020, 10:19:39 AM6/4/20
to BeagleBoard
Well, my solution, for now, was to write a wrapper[1] for config-pin that uses gpioinfo when 'in' or 'out' are used.

--Mark

[1] https://github.com/MarkAYoder/PRUCookbook/blob/v2.0/docs/common/config-pin.sh

On Wednesday, June 3, 2020 at 10:27:38 AM UTC-4, RobertCNelson wrote:

TJF

unread,
Jun 5, 2020, 12:58:49 AM6/5/20
to BeagleBoard
Am Mittwoch, 3. Juni 2020 16:27:38 UTC+2 schrieb RobertCNelson:
The proper way is to use libgpiod tools such as gpioset ;)

The proper way is to use libpruio and do pinmuxing single source in the code ;)

Drew Fustini

unread,
Jun 5, 2020, 7:06:48 AM6/5/20
to Beagle Board
How does the library change the pinmux during runtime?

Does it use /sys/devices/platform/ocp/ocp:P9_11_pinmux/state? (which
is created by bone-pinmux-helper)

thanks,
drew

Daniel Kulp

unread,
Jun 5, 2020, 4:44:11 PM6/5/20
to BeagleBoard

The GPIO utils in FPP use a combination of /sys/devices/platform/ocp/ocp:%s_pinmux/state and /sys/class/gpio/gpio%u/ locations to configure the pin in various ways.   See:


Some of it is a bit complex as some pins may need to boot up in i2c mode but then be flipped to gpio/out. 

The idea of using libgpiod is "ok" but doesn't allow configuring the internal pull ups for the input (at least until kernel 5.4 and a newer version of libgpiod)

Dan

TJF

unread,
Jun 5, 2020, 5:40:24 PM6/5/20
to BeagleBoard
Am Freitag, 5. Juni 2020 13:06:48 UTC+2 schrieb Drew Fustini:
How does the library change the pinmux during runtime?

It contains a LKM (loadable kernel module) that can set any pin configuration (ie. PRU-GPIO with pull-[up,down] at SD card slot) at run-time. All members of system group "pruio" have pinmuxing access from user space. This concept saves lots of kernel memory and more than six seconds boot-time.

Check out the documentation.

Regards
Reply all
Reply to author
Forward
0 new messages