GPIO50 file/directory deleted

Trying to turn on external LED in series with resistor connected to P9-14 . Did a web search and found the the following: Getting Started With the BeagleBone Black

I determined that pin P9-14 is located at /sys/class/gpio50. Based on the example, I executed the following command:

    root@BeagleBone:/sys/class/gpio# echo 50 >/sys/class/gpio/export

Got the following error: bash: echo: write error: Operation not permitted

Did the following:

    root@BeagleBone:/sys/class/gpio# ls /sys/class/gpio/export -l
    - -w--w---- 1 root gpio 4096 Jun 24 19:39 /sys/class/gpio/export

Now if I do:

    root@BeagleBone:/sys/class/gpio# ls gpio50 -l
    ls: cannot access 'gpio50': No such file or directory

Did I trash my system?

$ groups

You need to be a member of gpio

$ sudo usermod -aG gpio $USER

If I read his clips correctly, he’s already root, so the usermod won’t do much.

Can you try to do a ls -al /sys/class/gpio/ and list the files, if any?

You can also try gpioinfo to examine just what is available gpio-wise.

You might not even have to export; if it’s exported already, doing it again can mess it up…

Thanks for the replies.

Yesterday logged into root. Set current working directory to : /sys/class/gpio

Prior to: echo 50 >/sys/class/gpio/export

 root@BeagleBone:/sys/class/gpio# ls gpio50 -l
 lrwxrwxrwx 1 root root 0 Dec 31  1999 gpio50 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4804c000.target-module/4804c000.gpio/gpiochip1/gpio/gpio50

After: echo 50 >/sys/class/gpio/export

 root@BeagleBone:/sys/class/gpio# ls gpio50 -l
  ls: cannot access 'gpio50': No such file or directory

Powered off BBB yesterday and powered on this morning. Based on Iranders suggestion, tried the following:

root@BeagleBone:/sys/class/gpio# ls -al /sys/class/gpio/gpio50
lrwxrwxrwx 1 root root 0 Dec 31  1999 /sys/class/gpio/gpio50 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4804c000.target-module/4804c000.gpio/gpiochip1/gpio/gpio50

root@BeagleBone:/sys/class/gpio# ls -al /sys/class/gpio/gpio50/

total 0
drwxrwxr-x  3 root gpio    0 Dec 31  1999 .
drwxrwxr-x 22 root gpio    0 Dec 31  1999 ..
-rw-rw-r--  1 root gpio 4096 Dec 31  1999 active_low
lrwxrwxrwx  1 root gpio    0 Jun 24 21:49 device -> ../../../gpiochip1
-rw-rw-r--  1 root gpio 4096 Dec 31  1999 direction
-rw-rw-r--  1 root gpio 4096 Dec 31  1999 edge
-r--r--r--  1 root gpio 4096 Dec 31  1999 label
drwxrwxr-x  2 root gpio    0 Dec 31  1999 power
lrwxrwxrwx  1 root gpio    0 Jun 24 21:49 subsystem -> ../../../../../../../../../../class/gpio * -rw-rw-r--  1 root gpio 4096 Dec 31  1999 uevent
-rw-rw-r--  1 root gpio 4096 Dec 31  1999 value
I have two questions and one comment.

1. What just happened?

2. Did some research found: [https://www.kernel.org/doc/Documentation/gpio/sysfs.txt](https://www.kernel.org/doc/Documentation/gpio/sysfs.txt)
 Paraphrasing content: 

  THIS ABI IS DEPRECATED: .... Refer to the examples in tools/gpio/* for an introduction to the new character device ABI. [The New Character Device Idea?](https://www.beagleboard.org/projects/the-new-character-device-idea)

3.  So, I should not use the methods outlined in:  [Getting Started With the BeagleBone Black](https://www.linux.com/training-tutorials/getting-started-beaglebone-black-1ghz-arm-linux-machine-45/), but try to learn what is in [The New Character Device Idea?](https://www.beagleboard.org/projects/the-new-character-device-idea)

Can you share what image you are using?

cat /etc/dogtag

root@BeagleBone:/sys/class/gpio# cat /etc/dogtag
BeagleBoard.org Debian Bullseye IoT Image 2023-09-02

The gpio50 directory reappeared after the reboot.

Yes, that means it was already exported for you; do not double export or you break it.

If you do the gpioinfo I got the feeling it’s going to show a [used] next to it,
which should mean that one of your loaded overlays has claimed it already; ADC maybe?

In that case, it’s very likely that the PINMUX isn’t set for GPIO and that “poking” value will do nothing.

Something to try could be gpioset 2 18=[0/1] to wiggle the pin and see if the LED reacts.

root@BeagleBone:/sys/class/gpio/gpio50# gpioinfo | grep P9_14
        line  18: "P9_14 [ehrpwm1a]" "P9_14" input active-high [used]
root@BeagleBone:/sys/class/gpio/gpio50# gpioset 2 18=[0/1]
gpioset: invalid offset<->value mapping: 18=[0/1]

P9_14 is in gpiochip1. Looked at man page; it was not very helpful. Tried the following:

root@BeagleBone:/sys/class/gpio/gpio50# gpioset 1 18=[0/1]
gpioset: invalid offset<->value mapping: 18=[0/1]

Oops, yes, you’re right. 1 18 is correct.

The command then becomes gpioset 1 18=1 and gpioset 1 18=0.

Btw, this should work:

UPDATED with gpiofind "P9_14 [ehrpwm1a]"

#Set low
gpioset $(gpiofind "P9_14 [ehrpwm1a]")=0

or

#Set high
gpioset $(gpiofind "P9_14 [ehrpwm1a]")=1

and a read is:

gpioget $(gpiofind "P9_14 [ehrpwm1a]")

Regards,

1 Like

Neato! Did not know about the gpiofind command.

crap i think we screwed up here…

debian@23-am335x-bbb:~$ gpioinfo | grep 9_14
	line  18: "P9_14 [ehrpwm1a]" "P9_14" input active-high [used]
debian@23-am335x-bbb:~$ gpioget $(gpiofind P9_14)
gpioget: gpiochip must be specified

so gpiofind looks for “P9_14 [ehrpwm1a]”

Yeap… we screwed up when pushing to mainline…

debian@23-am335x-bbb:~$ gpioinfo | grep 9_14
	line  18: "P9_14 [ehrpwm1a]" unused input active-high 
debian@23-am335x-bbb:~$ gpioget $(gpiofind P9_14)
gpioget: gpiochip must be specified
debian@23-am335x-bbb:~$ gpioget $(gpiofind "P9_14 [ehrpwm1a]")
0

At-Least they are in stone, so will never change: am335x-boneblack.dts « omap « ti « dts « boot « arm « arch - kernel/git/stable/linux.git - Linux kernel stable tree

Our goal was, P9_14 would work on any device…
gpioget $(gpiofind P9_14)

Regards,

I have a CZH-LABS.COM D-1323 VER 1.0 CAP.
Since the pin is used, will setting it to 1 (with the suggested commands) case harm?
Probably best if i find an non used pin.

Wow the discussion at the end is way over my head :roll_eyes:

Google just shows me a screw-terminal board. That shouldn’t be dangerous…

If this isn’t correct, please send a picture of the contraption! :smiling_face:

That expansion board just connects the pin directly to a screw terminal.

So what should happen, when running:

gpioset $(gpiofind "P9_14 [ehrpwm1a]")=0

P9_14 should be GND/0…

So what should happen, when running:

gpioset $(gpiofind "P9_14 [ehrpwm1a]")=1

P9_14 should be 3v3…

So as long as what-ever you have connected to P9_14 can deal with that, it’s fine. Just remember, the i/o on the am335x is low ttl current. so make sure you are driving something small or have a transitor/etc…

As far as complicated, our goal was to make io easy, so we set the labels:

debian@23-am335x-bbb:~$ gpioinfo | grep P8
	line   7: "P8_42A [ecappwm0]" "P9_42" input active-high [used]
	line   8: "P8_35 [lcd d12]" "P8_35" input active-high [used]
	line   9: "P8_33 [lcd d13]" "P8_33" input active-high [used]
	line  10: "P8_31 [lcd d14]" "P8_31" input active-high [used]
	line  11: "P8_32 [lcd d15]" "P8_32" input active-high [used]
	line  22: "P8_19 [ehrpwm2a]" "P8_19" input active-high [used]
	line  23: "P8_13 [ehrpwm2b]" "P8_13" input active-high [used]
	line  26:      "P8_14"      "P8_14"   input  active-high [used]
	line  27:      "P8_17"      "P8_17"   input  active-high [used]
	line   0: "P8_25 [mmc1_dat0]" "P8_25" input active-high [used]
	line   1: "[mmc1_dat1]" "P8_24" input active-high [used]
	line   2: "P8_5 [mmc1_dat2]" "P8_05" input active-high [used]
	line   3: "P8_6 [mmc1_dat3]" "P8_06" input active-high [used]
	line   4: "P8_23 [mmc1_dat4]" "P8_23" input active-high [used]
	line   5: "P8_22 [mmc1_dat5]" "P8_22" input active-high [used]
	line   6: "P8_3 [mmc1_dat6]" "P8_03" input active-high [used]
	line   7: "P8_4 [mmc1_dat7]" "P8_04" input active-high [used]
	line  12:      "P8_12"      "P8_12"   input  active-high [used]
	line  13:      "P8_11"      "P8_11"   input  active-high [used]
	line  14:      "P8_16"      "P8_16"   input  active-high [used]
	line  15:      "P8_15"      "P8_15"   input  active-high [used]
	line  29:      "P8_26"      "P8_26"   input  active-high [used]
	line  30: "P8_21 [emmc]" "P8_21" input active-high [used]
	line  31: "P8_20 [emmc]" "P8_20" input active-high [used]
	line   1:      "P8_18"      "P8_18"   input  active-high [used]
	line   2:       "P8_7"      "P8_07"   input  active-high [used]
	line   3:       "P8_8"      "P8_08"   input  active-high [used]
	line   4:      "P8_10"      "P8_10"   input  active-high [used]
	line   5:       "P8_9"      "P8_09"   input  active-high [used]
	line   6: "P8_45 [hdmi]" "P8_45" input active-high [used]
	line   7: "P8_46 [hdmi]" "P8_46" input active-high [used]
	line   8: "P8_43 [hdmi]" "P8_43" input active-high [used]
	line   9: "P8_44 [hdmi]" "P8_44" input active-high [used]
	line  10: "P8_41 [hdmi]" "P8_41" input active-high [used]
	line  11: "P8_42 [hdmi]" "P8_42" input active-high [used]
	line  12: "P8_39 [hdmi]" "P8_39" input active-high [used]
	line  13: "P8_40 [hdmi]" "P8_40" input active-high [used]
	line  14: "P8_37 [hdmi]" "P8_37" input active-high [used]
	line  15: "P8_38 [hdmi]" "P8_38" input active-high [used]
	line  16: "P8_36 [hdmi]" "P8_36" input active-high [used]
	line  17: "P8_34 [hdmi]" "P8_34" input active-high [used]
	line  22: "P8_27 [hdmi]" "P8_27" input active-high [used]
	line  23: "P8_29 [hdmi]" "P8_29" input active-high [used]
	line  24: "P8_28 [hdmi]" "P8_28" input active-high [used]
	line  25: "P8_30 [hdmi]" "P8_30" input active-high [used]
debian@23-am335x-bbb:~$ gpioinfo | grep P9
	line   2: "P9_22 [spi0_sclk]" "P9_22" input active-high [used]
	line   3: "P9_21 [spi0_d0]" "P9_21" input active-high [used]
	line   4: "P9_18 [spi0_d1]" "P9_18" input active-high [used]
	line   5: "P9_17 [spi0_cs0]" "P9_17" input active-high [used]
	line   7: "P8_42A [ecappwm0]" "P9_42" input active-high [used]
	line  12: "P9_20 [i2c2_sda]" "P9_20" input active-high [used]
	line  13: "P9_19 [i2c2_scl]" "P9_19" input active-high [used]
	line  14: "P9_26 [uart1_rxd]" "P9_26" input active-high [used]
	line  15: "P9_24 [uart1_txd]" "P9_24" input active-high [used]
	line  20:     "P9_41B"      "P9_41"   input  active-high [used]
	line  30: "P9_11 [uart4_rxd]" "P9_11" input active-high [used]
	line  31: "P9_13 [uart4_txd]" "P9_13" input active-high [used]
	line  16:     "P9_15A"      "P9_15"   input  active-high [used]
	line  17:      "P9_23"      "P9_23"   input  active-high [used]
	line  18: "P9_14 [ehrpwm1a]" "P9_14" input active-high [used]
	line  19: "P9_16 [ehrpwm1b]" "P9_16" input active-high [used]
	line  28:      "P9_12"      "P9_12"   input  active-high [used]
	line   0:     "P9_15B"       unused   input  active-high 
	line  14: "P9_31 [spi1_sclk]" "P9_31" input active-high [used]
	line  15: "P9_29 [spi1_d0]" "P9_29" input active-high [used]
	line  16: "P9_30 [spi1_d1]" "P9_30" input active-high [used]
	line  17: "P9_28 [spi1_cs0]" "P9_28" input active-high [used]
	line  18: "P9_42B [ecappwm0]" "P9_92" input active-high [used]
	line  19:      "P9_27"      "P9_27"   input  active-high [used]
	line  20:     "P9_41A"      "P9_91"   input  active-high [used]
	line  21:      "P9_25"      "P9_25"   input  active-high [used]

So as long as the pin isn’t used by something else… you can grab the 3rd column name in your script:

	line  18: "P9_42B [ecappwm0]" "P9_92" input active-high [used]

aka: "P9_42B [ecappwm0]"

Regards,

i’ve actually been playing with that same adapter for ci stuff.

You have too many toys Robert! :smiling_face: :+1: