Use FORCE_RECOVERY as GPIO

Hi,

we try to read the value of a pushbutton connected to FORCE_RECOVERY signal of Xavier NX at runtime.
So we try to export gpio_336 as described in GPIO Programming: Using the sysfs Interface | ICS, but for 336 it is not working.
We get following error:
nvidia@nx:~$ echo 336 >/sys/class/gpio/export
-bash: echo: write error: Device or resource busy

we also tried with sudo.
If we try same with other gpios it’s working fine.

if we take a look at:
cat /sys/kernel/debug/gpio
we can see the current value of our pushbutton
“gpio-336 ( |force-recovery ) in hi”

We also checked Pinmux Table: FORCE_RECOVERY, is set to Customer Usage GPIO3_PG.00.

Are we missing something? Is it not intended to export this pin?

Best regards

Michael

hello hudmic,

please refer to pinmux changes session to change the pinmux configuration applied by the software.

Hello JerryChang,

thanks for your reply.

I don’t understand, why should we change pinmux?
Our board schematic doesn’t differ from that for Jetson Xavier NX Developer Kit board in this case.
If we take a look at pinmux configuration, FORCE_RECOVERY should be a GPIO.
We could otherwise just set it to unused in pinmux configuration

Best regards

Michael

hello hudmic,

please ignore my previous comments…

this is occupied, you cannot export it for usage.
as you can see… this is defined as gpio-keys,

        gpio-keys {
                forcerecovery {
                        label = "force-recovery";
                        gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(G, 0) GPIO_ACTIVE_LOW>;
                        linux,code = <BTN_1>;
                };

Hello JerryChang,

what does it mean, that this gpio is defined as gpio-keys? What is this gpio used for?
We tried uncommenting these lines and reflashing the device tree, but this did not change the behavior.

Best regards

Michael

hello hudmic,

it meant this pin, GPIO3_PG.00 is used by software as gpio-keys.
may I know what’s your use-case? also, how you re-flash the device tree.

Hello JerryChang,

we want to use the same pushbutton while boot as recovery button and at runtime as control element.
We already do this with our TX2 device. Here we are able to export the recovery pin as gpio.

Okay I understand it’s used as gpio-keys by software. Does this mean there is a running software which is using it already? Or that it can be used as gpio-key by software? Does gpio-key means it is handled like a keyboard input? I couldn’t find any good explanation to what “gpio-keys” describes.

That’s how we re-flash the devicetree:
sudo ./flash.sh -r -k kernel-dtb jetson-xavier-nx-devkit-emmc mmcblk0p1

Best regards

Michael

hello hudmic,

you may check this as see-also.
it also demonstrate the code to receive gpio-keys messages.
for example, Implementation of input subsystem (GPIO keys) driven by linux

Hello JerryChang,

sorry for my late response.
This example helped, so now we are able to see if the key is pressed.
Thank you!

The only downside is that now we have to implement a special solution for it.
Is it also possible to remove this GPIO from the gpio-keys in the devicetree?

Best regards

Michael

hello hudmic,

you may update device tree for your own use-case, thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.