Migrating from Debian 10 → 13 broke GPIO switch on P9_19

Board: BeagleBone Black
Old image: Debian 10 (P9_19 toggled fine but with config-pin)
New image: Debian 13 (P9_19 won’t toggle)
What I need: treat P9_19 as a generic GPIO I can set 0/1 in userspace.


What works vs what doesn’t

  • P8_33 (another GPIO I also use): works on Debian 13 and I can toggle it normally.
  • P9_19: does not move on the logic analyzer on Debian 13 (it used to on Debian 10).

I used the same .c to configure them, so I suspect pinmux on P9_19 in Debian 13.


Userspace API I’m using (libgpiod v2)

// exactly what my app does today
chip_RS485_RTS = gpiod_chip_open_by_number(3);
line_RS485_x_RTS = gpiod_chip_get_line(chip_RS485_RTS, 13);
ret = gpiod_line_request_output(line_RS485_x_RTS, "RS485_1_RTS", 0);

/* later */
int rc = gpiod_line_set_value(line_RS485_x_RTS, 1);
rc = gpiod_line_set_value(line_RS485_x_RTS, 0);

Is there any problem with this API on Debian 13? (Again: this same code works for P8_33 on Debian 13, and P9_19 on Debian 10.)


gpioinfo (Debian 13) — gpiochip3

gpiochip3 - 32 lines:
  line  9:  "P8_33 [lcd d13]"  output consumer="RS485_2_RTS"
  ...
  line 12: "P9_20 [i2c2_sda]"  input
  line 13: "P9_19 [i2c2_scl]"  output consumer="RS485_1_RTS"
  line 14: "P9_26 [uart1_rxd]" input
  line 15: "P9_24 [uart1_txd]" input
  ... 

Even though P9_19 shows up as output, I doesn’t change polarity like P8_33.


Quick tests I tried

  • gpioset (options first, as required by my version):
systemctl stop app_manager.service
killall gpioset || true
gpioset -z -c /dev/gpiochip3 13=0
gpioset -z -c /dev/gpiochip3 13=1

→ nothing on the logic analyzer (P9_19 stays flat).

  • Through sysf:

sysfs mapping on this image shows:

/sys/class/gpio/gpiochip608 -> ...44e07000.gpio (GPIO0)
/sys/class/gpio/gpiochip512 -> ...4804c000.gpio (GPIO1)
/sys/class/gpio/gpiochip544 -> ...481ac000.gpio (GPIO2)
/sys/class/gpio/gpiochip576 -> ...481ae000.gpio (GPIO3)

So P9_19 = GPIO0_13 = 608 + 13 = 621. Forcing via sysfs:

echo 621 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio621/direction
echo 0   > /sys/class/gpio/gpio621/value
echo 1   > /sys/class/gpio/gpio621/value

→ still no movement on the logic analyzer.


Boot overlays I’m using (U-Boot)

uEnv.txt has (summarized):

enable_uboot_overlays=1
uboot_overlay_addr0=/lib/firmware/BB-UART2-00A0.dtbo
uboot_overlay_addr1=/lib/firmware/BB-UART4-00A0.dtbo
uboot_overlay_addr2=/lib/firmware/BB-UART1-00A0.dtbo
uboot_overlay_addr4=/lib/firmware/GTW-UTN-00A0.dtbo
uboot_overlay_debug=1

I wrote a tiny custom overlay that just sets P9_19 pad (I2C2_SCL at offset 0x17C) to mode7 (GPIO):

/dts-v1/;
/plugin/;
/{
  compatible = "ti,beaglebone", "ti,beaglebone-black";
  fragment@0 {
    target = <&am33xx_pinmux>;
    __overlay__ {
      rts_p9_19_pins: pinmux_rts_p9_19_pins {
        pinctrl-single,pins = <0x17C 0x07>; /* P9_19 as GPIO */
      };
    };
  };
};

Compiled with:

dtc -@ -I dts -O dtb -o /lib/firmware/GTW-UTN-00A0.dtbo GTW-UTN-00A0.dts

Even with this DTBO listed in uEnv.txt, after reboot P9_19 still looks like [i2c2_scl] input and won’t toggle physically. (I also tested a variant with a gpio hog using &gpio0 13, and another that disables &i2c2 — still no change on the pin.)


What I’m asking

  1. Is the pinmux offset/mode for P9_19 correct on AM335x? (I2C2_SCL = 0x17C, mode7 = 0x07).
  2. Is there a standard overlay (DTBO) in current Beagle Debian 13 that already sets P9_19 as GPIO (mode7) while keeping UART1 (P9_24/26) active? If yes, what’s its name so I can just drop it into uboot_overlay_addrX=?
  3. Could any built-in overlay/device be re-applying I²C2 on P9_19 after my DTBO, effectively winning the mux? If so, what’s the proper order or recommended override to make P9_19 stay as GPIO?
  4. Is uEnv.txt reliably read from /boot/uEnv.txt on these images, or should I edit /boot/firmware/uEnv.txt instead? (I set uboot_overlay_debug=1; the boot log claims my DTBO loads.)
  5. Any known gotchas on Debian 13 that would prevent P9_19 from being driven as GPIO from userspace, while P8_33 in the same app still works?

Thanks! I’m happy to post boot logs / gpioinfo dumps if needed. Once P9_19 muxes to GPIO again, the rest of my application works as before.

2 Likes

P9_19 and P9_20 used to be used for Capes for the beaglebone black. They were always listed as I2C.

Now, with updated versions of the BBB and kernels, I am not 100% sure but I can test to see.

This Cape functionality was for Capes people make and for beagleboard.org Capes.

Seth

P.S. I am sure someone out there knows how to override this functionality. Not me, I always just assumed it was only for Cape additions. Also, there was a set of functions for handling cape_universal. Sorry. I am not sure if this is still part of the uEnv.txt file and fs but if you have many DTS files for setting up your BBB, then one could simply comment out (#) the cape_universal function and write DTS files for handling the board (BBB).

2 Likes

It was overridden before. But

  1. It was overriden with config-pin p9.19 gpio
  2. Which doesn’t work anymore
  3. And this was on the fly. That can’t be done anymore.

I’m searching ways of creating my own Device Tree Overlay, at least for P9_19, but I’m having a hard time finding out how to do it (there’s a lot of obsolet information popping on). I know it’s not impossible, otherwise no one would be able to make one’s own project, but would be limited to the capes functionalities.

1 Like

The cape_universal selection that is not commented out (#) with the hashmark equals 1.

So:

enable_cape_universal=1 was a way I saw that used to work. Anyway, if you want to write your own .dtsi and .dtbo DTS files, I think that is okay but…

  1. Using the older model cape_universal needs to be commented with the hashmark (#).
  2. Without the cape_universal functionality from what I saw in the past, which may not account for anything right now or in the future, other things in the .dtb may break along with what is already working.
  3. So, in this excursion and without my assistance (sorry), thinking of the future is good and help teach you DTS and syntax but you may have to flash over and over to get things right the last time.

I say all that because there is no guarantee the mix of syntaxes will work, i.e. hence flashing once more. I tried this beforehand and since then, I have not tried it. I accept that there is a way to configure the P9.19 and P9.20 pins for other use cases outside of I2C.

I hope you can find it because this fellow here, me, is out of luck on the i2c front for now.

I remember how easy config-pin was to mux pins and change them.

Seth

P.S. There is or was a GSoC mention I read not too long ago about a beagle-config that gained steam during 2022 or maybe a year prior.

I have not run beagle-config on the command line in some time. Can you get to github at BeagleBoard.org · GitHub and look over their section for what is available online or would you like to handle things all on the board itself? The reason I ask is this:

a. /opt/source/ used to have some files for what kernel you hold.
b. in those files was a list of other files. Those listed files were the syntax I discussed earlier.
c. They have tons of .dtsi and .dts files to review. The reason I asked about you accessing the web and github was to let you know that read-only revisions of these files are listed.

Good luck and I will check back. I saw also that Debian with specific kernels handles the fs differently. Which and what…no clue. I would have to plug in and test. Sole memory over here and online resources at the plenty. Let me try to find the link and the next one especially:

To tell you the truth, I am not sure how you actually configured muxing the p9.19 and p9.20 pins as something other than i2c (ever). I really never went down that route with success.

1 Like

@oivato ,

Hey. bb-beagle-config is or was current in the repos-armhf from the links I listed.

Try. beagle-config at the command line or another way. It may be helpful?

Seth

P.S. Dang it.

Update One

bb-beagle-config is outdated by two years but may work if you can get it to work that way.

Update Two

Update Three

GitHub - SAtacker/bb-config: Configure your beagle device is the older source for handling the GUI in the command line with another set up of ideas. The other set up of ideas is this one with bazel: GitHub - ArthurSonzogni/FTXUI: 💻 C++ Functional Terminal User Interface. ❤ .

I have always had trouble with bazel. Who knows? Maybe one or the other person knows of something to handle my typing tirade. All jokes aside, this was one of the those GSoC projects I liked for a bit. I even learned how to do it outside of their set up of ideas. Now, not so much. I have not kept up with the builds. Good luck.

2 Likes

Hi Silver!! Thanks A LOT for all the info you brought up. I’ve read all of them and I’ll start with bb-config. While searching a little bit more, I found this .pdf which was released 2 days ago

I’ll try it out and comeback to tell my results.

Still, I want a guide on how to configure my own.dst file.

Something with the wi-fi isn’t helping while installing the bb-Config

[ 76%] Building CXX object CMakeFiles/bb-config.dir/src/ui/panel/wifi/wifi_impl.cpp.o
/usr/bb-config/src/ui/panel/wifi/wifi_impl.cpp: In member function 'void ui::{anonymous}::WpaImpl::restart_wpa_wlan0_service()':
/usr/bb-config/src/ui/panel/wifi/wifi_impl.cpp:656:10: error: 'props_proxy' was not declared in this scope
  656 |     if (!props_proxy) {
      |          ^~~~~~~~~~~
/usr/bb-config/src/ui/panel/wifi/wifi_impl.cpp: In member function 'void ui::{anonymous}::WpaImpl::restart_wpa_service()':
/usr/bb-config/src/ui/panel/wifi/wifi_impl.cpp:695:10: error: 'props_proxy' was not declared in this scope
  695 |     if (!props_proxy) {
      |          ^~~~~~~~~~~
make[2]: *** [CMakeFiles/bb-config.dir/build.make:247: CMakeFiles/bb-config.dir/src/ui/panel/wifi/wifi_impl.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:400: CMakeFiles/bb-config.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

I just wanted to switch a pin on and off, but it looks like so hard to find a way to do it. Isn’t configuring the pinout something basic or I am asking for something really complicated?

Just P9_19 you want to turn on and off? Oh i see part of rts… which uart?

Regards,

1 Like

Toggling P9_19 is the only thing i couldn’t do.

All others pins are working fine (I guess the default setting of pinmux + /boot/uEnv.txt overlays generates the correct configuration I need).

enable_uboot_overlays=1

###Overide capes with eeprom

uboot_overlay_addr0=/lib/firmware/BB-UART2-00A0.dtbo

uboot_overlay_addr1=/lib/firmware/BB-UART4-00A0.dtbo

uboot_overlay_addr2=/lib/firmware/BB-UART1-00A0.dtbo

uboot_overlay_addr3=/lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo

...

###Cape Universal Enable #enable_uboot_cape_universal=1

p9.19 is used as the RTS of UART1. The configuration/toggle is as described in the topic.

All pins/peripherals I’m using:

UARTs used:

  • UART1 (Tx: P9.24, Rx: P9.26) → RTS in P9.19 (not working)

  • UART2 (Tx: P9.21, Rx: P9.22) → RTS in P8.33 (toggle by software the same way P9.19 and working)

  • UART4 (Tx: P9.13, Rx: P9.11)

GPIOs used:

  • Inputs: P9.28
  • Outputs: P9.25, P9.27, P9.29, P9.30, P9.31, P9.19 (UART 1 RTS), P8.33 (UART 2 RTS)

All GPIOs above are binary (on and off)

And eMMC

It is an older project. So, it may not work. I think @RobertCNelson knows more on how to disable then port your UART for p9.19.

Seth

P.S. Sorry to drag you to a two year old project.

It’s fine, It was a worth try. I guess I’ll have to learn how to write a .dst file.
hope @RobertCNelson can help me with this one :slight_smile:

if you look up BeagleBoard-DeviceTrees online, they have many examples.

Depending on your image and kernel, there may be differences and some with better explanations.

Seth

P.S. I will get the read-only link from github for you: BeagleBoard-DeviceTrees/src/arm/overlays at v6.12.x-Beagle · beagleboard/BeagleBoard-DeviceTrees · GitHub

There is where you can find many ideas on .dtso and .dts files and overlays.

Update

So, I think I brought you to overlays. Aw. Those are for using in a file extlinux.conf or uEnv.txt, i.e. depending on your kernel and image. Here you will find the main board and chip files in DTS format: BeagleBoard-DeviceTrees/src/arm/ti/omap at v6.12.x-Beagle · beagleboard/BeagleBoard-DeviceTrees · GitHub

Also…

Here is where I find the line(s) in question: BeagleBoard-DeviceTrees/src/arm/ti/omap/am335x-boneblack-uboot.dts at 0bf4ab478673d7ded367a2a962ad071fbfcb5cda · beagleboard/BeagleBoard-DeviceTrees · GitHub

P9.19 is i2c2_scl but I always thought it was i2c0_scl. So, things are changing without me researching them tremendously. I can keep trying but rcn-ee may beat me to it.

/dts-v1/;
/plugin/;
/{
  compatible = "ti,beaglebone", "ti,beaglebone-black";
  fragment@0 {
    target = <&am33xx_pinmux>;
    __overlay__ {
      rts_p9_19_pins: pinmux_rts_p9_19_pins {
        pinctrl-single,pins = <0x17C 0x07>; /* P9_19 as GPIO */
      };
    };
  };
};

So, line rts_p9_19_pins: pinmux_rts_p9_19_pins { looks okay but then the line below it may need some changes. Mode is correct for GPIO, i.e. 7. Now, are you trying to make this GPIO or rts UART. If UART, try 0x96c.

Update

I find this line, #define P9_19(mode) AM33XX_IOPAD(0x097c, mode) /* D17: uart1_rtsn */ , at this file BeagleBoard-DeviceTrees/include/dt-bindings/board/am335x-bone-pins.h at v6.12.x-Beagle · beagleboard/BeagleBoard-DeviceTrees · GitHub but on other files, something changed. I guess the cape_universal and/or bone_buses spec. may alternatively changed things. I am just not sure as of now. Sorry. I can keep trying and we can try to work together or I can cease my research now. Up to you, I guess. I will have time later, too.

My kernel is 6.16.5-bone16, so I’ll use BeagleBoard-DeviceTrees/src/arm/overlays at v6.16.x · beagleboard/BeagleBoard-DeviceTrees · GitHub as my models, right?

Also, the headers used in the .dst file:

And:

6.16.x kernels and DTS should match well. I think that is a safe bet.

So, your DTS and kernel for -bone kernels may help you. Also, if you go to the beagleboard.org Linux kernel on github or gitlab, you can gain some insights too.

I will look up kernel 6.16.x-bone shortly. I will see what is available and what may need to happen to get i2c0 as a GPIO or uart-rts pin. I still do not know what pin type you need for P9_19, i.e. i2c, gpio, uart, and etc.

I see your DTS file. It says gpio but is listed as UART.

Seth

I need P9_19 to be a gpio, so I can togle it on and off

1 Like

Okay. I will test it later on the BBB and then report back. If no one has answered or come to a conclusion, I will keep testing.

Seth

P.S. GPIO on P9.19 is something I never tried. This may be fun!

1 Like

P9_19 is a RTS for my UART, it uses a RS485 line. But the program that I’ve made toggles it on everytime it needs to send a message and off back again. I know there is an automatic RTS configuration (which I suposed let the job to turn on and off the line for the peripheral), but I guess it will be more difficult to config P9.19 in this mode.

See here. My understanding is this:

  1. GPIO is for GPIO in DTS
  2. UART is for UART in DTS

I am now and was unaware of using GPIO within this context. I thought you can only turn on and off GPIO but the UART protocol is different (way different). So, I am guessing now but you have a UART module attached to the BBB on P9.19 and need it to be GPIO?

Why can you not use another, already muxed, GPIO pin that is available? Well, anyway.

I probably have a million questions when you want answers, e.g. so I will try this out later today hopefully if no one else chimes in. I am off for now. See you later on this forums!

Seth

3 pins:

  1. UART1 Tx: P9.24
  2. UART1 Rx: P9.26
  3. ”Enable” or RTS pin: P9.19

Whenever my program wants to transmit data through P9.24 it turns on P9.19, transmits the data and then turns off P9.19. I need it to be a GPIO to togle it on and off.

P9.19 “1” → Transmits data through P9.24P9.19 “0”

There’s a way to make uart1 toggle it automatically, but let’s keep it simple. Just make it gpio and turn it on and off with gpiod_line_set_value()