Correct way replacement of 'config-pin' command on Debian 13 with kernel 6.19

I have old application with these interfaces: UART, SPI and GPIO ports.

Old application used uboot_overlay_addr in /boot/uEnv.txt and call config-pin script in user application.

How can I solve upgrade of this application to new OS and kernel?
What is correct way?

Just build an overlay for your final pin configuration.

Regards,

Thank you. I will try that.

What about setting and reading the PIN? I used the read/write file ‘/sys/class/gpio/gpio42/value’.

Is this correct now?

for ouput’s use gpio-led this will give you a stable

echo 0 > /sys/class/leds/<your label>/brightness
echo 1 > /sys/class/leds/<your label>/brightness

Thank you Robert.

Should I also make LEDs for the inputs?

I know I’m a little late to the party, but if you’re modernizing your application,
you really should consider moving away from /sys-files
and have a look at libgpiod instead.

No, for inputs you need to do keys instead.

I added

leds {
	pinctrl-names = "default";
	pinctrl-0 = <&bb_sx0_pins>;

	compatible = "gpio-leds";

	pin@923 {
		label = "P9_23";
		gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>;
		default-state = "keep";
	};
};

gpio_keys {
	compatible = "gpio-keys";
	pinctrl-names = "default";
	pinctrl-0 = <&bb_sx0_pins>;

	pin@926 {
		label = "P9_26";
		gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
	};
};

I can control output with echo 1 > /sys/class/leds/P9_23/brightnessand read input with gpioget "P9_26 [uart1_rxd]". But I cannot control output with gpioset “P9_23”=1.

gpioset: unable to request lines on chip ‘/dev/gpiochip0’: Device or resource busy

Any idea?

Once the LED driver has claimed possession of the pin,
gpioset obviously can’t control it any more.

The two options are mutually exclusive.

Thank you. It seems that libgpiod and device tree is solution.

Steps for dts compilation on BBB:

git clone https://github.com/beagleboard/BeagleBoard-DeviceTrees/tree/v6.19.x

cp  BB-mr-majak-client-00A0.dtso \~/BeagleBoard-DeviceTrees/src/arm/overlays/BB-mr-majak-client-00A0.dtso

cd \~/BeagleBoard-DeviceTrees

make
make src/arm/overlays/BB-mr-majak-client-00A0.dtbo

./build_n_install.sh

DTS and code example in dts_cpp_example.tar.gz. The code is not compilable, only snippets…

dts_cpp_example.tar.gz (5.3 KB)