Cannot Control GPIOs for JP61

Hi,

I have a problem about controlling the GPIO in user space.
I found that I could not control the GPIO in JP6.1 but I can control the same GPIO in JP5.1.x.

For JP5.1.x, I can control the CAM_PWDN(GPIO_PH.06)

$ gpioinfo
gpiochip0 - 164 lines:
...
        line  43:      "PH.00"       unused   input  active-high
        line  44:      "PH.01"       unused   input  active-high
        line  45:      "PH.02"       unused   input  active-high
        line  46:      "PH.03" "camera-control-output-low" output active-high [used]
        line  47:      "PH.04"       unused   input  active-high
        line  48:      "PH.05"       unused   input  active-high
        line  49:      "PH.06"       unused  output  active-high
        line  50:      "PH.07"       unused   input  active-high
...

Then I can control it by gpiod:

$ gpioget 0 49
1
$ gpioset 0 49=0
$ gpioget 0 49
0
$ gpioset 0 49=1
$ gpioget 0 49
1

However, I run the same steps after upgrading to JP61
First, I got the same status by gpioinfo as well:

$ gpioinfo
gpiochip0 - 164 lines:
...
        line  43:      "PH.00"       unused   input  active-high
        line  44:      "PH.01"       unused   input  active-high
        line  45:      "PH.02"       unused   input  active-high
        line  46:      "PH.03" "camera-control-output-low" output active-high [used]
        line  47:      "PH.04"       unused   input  active-high
        line  48:      "PH.05"       unused   input  active-high
        line  49:      "PH.06"       unused  output  active-high
        line  50:      "PH.07"       unused   input  active-high

Then I run the same steps in JP61, but I cannot change the status for the GPIO(PH.06):

$ gpioget 0 49
0
$ gpioset 0 49=1
$ gpioget 0 49
0

I know I can control these GPIOs in kernel space but I need to control them in user space in my current testing case.

How to fix the problem and control the GPIOs in user space for JP6.1?

hello jerry.liu21023,

there’s camera device-tree overlay to define PH.06 by default.
as you can see… from jetson-orin-nano-devkit.conf.
OVERLAY_DTB_FILE+=**",tegra234-p3768-0000+p3767-0000-dynamic.dtbo"**
here’s the sources of the dtbo file.
$public_sources/r36.4.0/Linux_for_Tegra/source/kernel_src/hardware/nvidia/t23x/nv-public/overlay/tegra234-p3768-0000+p3767-0000-dynamic.dts
you’ll see it include IMX219 device tree by default, such as… #include "tegra234-p3768-camera-rbpcv2-imx219.dtsi"
and…
according to IMX219’s device tree, there’s definition for PH.06.
for instance,
$public_sources/r36.4.0/Linux_for_Tegra/source/kernel_src/hardware/nvidia/t23x/nv-public/overlay/tegra234-p3768-camera-rbpcv2-imx219.dtsi
#define CAM0_PWDN TEGRA234_MAIN_GPIO(H, 6)

do you have camera use-case to enable IMX219?
otherwise, please give it a try to exclude IMX219 device tree from dynamic.dts

Hi @JerryChang

I have already disabled the imx219 in device tree.
I can ensure there is not any driver using PH.06.
But I still cannot control the GPIO by gpioset for JP6.1.

$ sudo dmesg | grep imx219 # do not show any messages because I disabled imx219 driver

Then check GPIOs status

$ gpioinfo
gpiochip0 - 164 lines:
...
        line  43:      "PH.00"       unused   input  active-high
        line  44:      "PH.01"       unused   input  active-high
        line  45:      "PH.02"       unused   input  active-high
        line  46:      "PH.03" "camera-control-output-low" output active-high [used]
        line  47:      "PH.04"       unused   input  active-high
        line  48:      "PH.05"       unused   input  active-high
        line  49:      "PH.06"       unused  output  active-high
        line  50:      "PH.07"       unused   input  active-high
...

control fail for JP6.1

ubuntu@ubuntu-desktop:~$ gpioget 0 49
0
ubuntu@ubuntu-desktop:~$ gpioset 0 49=1
ubuntu@ubuntu-desktop:~$ gpioget 0 49
0
ubuntu@ubuntu-desktop:~$ sudo gpioset 0 49=1
ubuntu@ubuntu-desktop:~$ gpioget 0 49
0

hello jerry.liu21023,

is it due to this pin does not keep high after gpioset command?
please try adding --mode=wait for keeping the pin state, i.e. $ sudo gpioset --mode=wait gpiochip0 49=1
you may also arrange hardware resources to probe the pin state for checking.

Hi @JerryChang

Yes, it can keep the pin state by adding --mode=wait but I don’t want to do that.

I control the gpio state when I’d like to change it to control my device. I don’t want to keep the state by keeping a process.

it is not convenient for me and I cannot check gpio pin state because the gpio device will be busy during running the keeping state process.

hello jerry.liu21023,

please see-also Topic 301171 to apply the fixes for verification.

Hi @JerryChang

I tried the patch, and it can work, but there are some problems about GPIOs.

Here is my result:
First I can’t detect my i2c device address (0x3d) because the reset pin is low.

$ sudo i2cdetect -r -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- 54 55 -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Then I set PH.06 to high and I can detect my device like below:

$ sudo gpioset 0 49=1
$ sudo i2cdetect -r -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- 3d -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- 54 55 -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

However, I found PH.06 will be low when I tried to get the status and could not detect my device after getting the GPIO status by gpioget.

$ sudo gpioget 0 49
0
$ sudo i2cdetect -r -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- 54 55 -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I think the patch only resolves gpioset problem but gpioget still exist some issues.

hello jerry.liu21023,

Please also note that gpioget might cause its direction changed to input.

The answer cannot help me to resolve my problem.

For Jetpack 5.1.x, there are not the same GPIOs issues.

I do not think it is correct and the issue makes it hard to check the status of GPIOs by gpiod.

1 Like

Hi JerryChang,

I can control PH.06 and get the status of GPIO by gpio_sysfs now.

Here is my result:

root@ubuntu-desktop:/sys/class/gpio# echo 397 > export
root@ubuntu-desktop:/sys/class/gpio# ls
export  gpiochip316  gpiochip348  PH.06  unexport
root@ubuntu-desktop:/sys/class/gpio# cat PH.06/direction
out
root@ubuntu-desktop:/sys/class/gpio# echo 1 > PH.06/value
root@ubuntu-desktop:/sys/class/gpio# cat PH.06/value
1
root@ubuntu-desktop:/sys/class/gpio# i2cdetect -r -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- 3d -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- 54 55 -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

But it does not support GPIO_SYSFS for defconfig. I hope you can resolve the problem about gpioget.

I updated the kernel and it still did not work, so it is missing something much deeper. Just made the decision to use jp5.1.4 the pwm and cam will work when set with jetson-io.py. I need to make an ovelay but have not had much luck.

Used the pinmux spreadsheet and it broke and will not boot. I assumed the sheet as downloaded was the default dtb config, it must not be. Going de-compile some of them and see if the base has any gpio configured, if that is the case a simple overlay should work without doing a major .dtb revision.

Since pwm is broken in 6.x it might be a waste of time. Many are in the same position as you and I and nothing official is being posted by the mods…or a clear path to turning on some pins.

note, it is due to the operational specifications of gpiod.

Hi Jerry Chang,

The default libgpiod version is v1.6.3; it cannot get the correct status and could cause GPIOs to change the status.

$ gpioget -v
gpioget (libgpiod) v1.6.3

So I tried to upgrade libgpiod to v2.1.3:

$ gpioget -v
gpioget (libgpiod) v2.1.3

It can work normally for me and I can get the correct status of GPIOs without changing the status of GPIOs.

$ gpioget -a --numeric -c /dev/gpiochip0 49
1

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