[BeagleBone Black] How to set gpio pin when booting

Hi

I think I have followed this whole discussion quite thoroughly and everything seems clear, but I have to go back to the basic question posed by taek8461: “How to set gpio pin when booting” but, I would like to use the pin bindings created in /sys/class/gpio/ (I wouldn’t want to use the script and systemd for this). I saw that is possible write a device-tree overlay to create such a structure in /sys/class/gpio/ at boot time. Could you please give some hints on how to write .dts or give an example. Below is my sample:

/dts-v1/;
/plugin/;

/ {
  compatible = "ti,beaglebone", "ti,beaglebone-black";
  part-number = "cape-gpio";
  version = "00A0";

  exclusive-use =
    "P9.42";

  fragment@0 {
    target = <&am33xx_pinmux>;
    __overlay__ {
      P9_42_default_pin: pinmux_P9_42_default_pin {
        pinctrl-single,pins = <
          0x164 0x17
        >;
      };
      P9_42_pin: pinmux_P9_42_pin {
        pinctrl-single,pins = <
          0x164 0x2f
        >;
      };
      P9_42_pu_pin: pinmux_P9_42_pu_pin {
        pinctrl-single,pins = <
          0x164 0x37
        >;
      };
      P9_42_pd_pin: pinmux_P9_42_pd_pin {
        pinctrl-single,pins = <
          0x164 0x27
        >;
      };
    };
  };

  fragment@1 {
    target = <&ocp>;
    __overlay__ {
      P9_42_pinmux {
        compatible = "bone-pinmux-helper";
        status = "okay";
        pinctrl-names = "default", "gpio", "gpio_pu", "gpio_pd";
        pinctrl-0 = <&P9_42_default_pin>;
        pinctrl-1 = <&P9_42_pin>;
        pinctrl-2 = <&P9_42_pu_pin>;
        pinctrl-3 = <&P9_42_pd_pin>;
      };
    };
  };
};`

Regards
Daniel