How to control GPIO in Jetpack 6.0 with Linux 36.3 with device tree overlay

Hello everyone,
I saw a lot of posts concerning the control of GPIO from the 40 pin header using the Jetpack 6.0. The only working solution than I found in the forum was to re-flash the jetson, which I did not want to do. After a few research, I found another solution that consist of writing a device tree overlay. I am going to explain here how I managed to control the GPIO01 (PQ.05) as an output with a device tree overlay, hoping that it will help the next person trying to do it.

You can list the available hardware overlay for your target using the command /opt/nvidia/jetson-io/config-by-hardware.py -l. Unfortunately, the list doesn’t contain an overlay configuring the GPIO01 as an output. So we need to add one to it. So we are going to:

  1. Create a DTS file
  2. Build it into a .dtbo
  3. Copy it to /boot directory
  4. Load it to extlinux.conf
mkdir workdir
touch my-overlay.dts
// Content of my-overlay.dts
/dts-v1/;
/plugin/;

/ {
    overlay-name = "My Jetson Overlay";
    jetson-header-name = "Jetson 40pin Header";
    compatible = "nvidia,p3768-0000+p3767-0003";

    fragment@0 {
        target = <&pinmux>;

        __overlay__ {
           pinctrl-names = "default";
           pinctrl-0 = <&jetson_io_pinmux>;

           jetson_io_pinmux: exp-header-pinmux {
               hdr40-pin29 {
                   nvidia,pins = "soc_gpio32_pq5";
                   nvidia,function = "rsvd0";
                   nvidia,pull = <0x00>;
                   nvidia,tristate = <0x00>;
                   nvidia,enable-input = <0x00>;
                   nvidia,io-high-voltage = <0x00>;
                   nvidia,lpdr = <0x00>;
               };
            };
        };
    };
};

Note: the name of the pin, and the function were found using the pinmux excel script… I could not find an easy way to find those values without using excel on Windows…

# build it
dtc -I dts -O dtb -o my-overlay.dtbo -@  my-overlay.dts
# copy it
cp my-overlay.dtbo /boot
# check that it is now present in the list
/opt/nvidia/jetson-io/config-by-hardware.py -l
# load it
/opt/nvidia/jetson-io/config-by-hardware.py -n "My Jetson Overlay"

If everything happend properly, a new entry should have appeared in /boot/extlinux/extlinux.conf. The great advantage of device tree overlay is that if your new overlay is wrong and that your target does not boot, you will be able to use the primary overlay again (there will be an option to select with the keyboard during boot sequence). By default, it will use the new overlay.

But do not reboot already, in my case it did not work out of the box… The new entry in extlinux.conf file was missing the APPEND ${cbootargs} .... which caused the jetson not to boot anymore. I simply had to copy the line APPEND from the primary label to the new label in extlinux.conf for it to work.

After a successful reboot, I was able to control the GPIO01 using libgpiod !

gpioset 0 105=1
gpioset 0 105=0

Hope this will help someone!

2 Likes

Hi antoine.gennart,

Thanks for sharing this workflow to help people who has the requirement to use the pin as GPIO output w/o flash.