Jump to content

NixOS on ARM/Raspberry Pi 4: Difference between revisions

no edit summary
imported>Fstuess
No edit summary
imported>Fstuess
No edit summary
Line 225: Line 225:
</nowiki>}}
</nowiki>}}


==== Gpio and 1-wire ====
==== Gpio ====
Add gpio group and change permission for all users in new gpio group.
Add gpio group and change permission for all users in new gpio group.
Additionally, an example of putting in a device tree snippet. 1-wire without pullup in this case.
Now all users in gpio group have access to /dev/gpiomem and to gpio pins via sysfs.
Now all users in gpio group have access to /dev/gpiomem and to gpio pins via sysfs.


Line 252: Line 251:
   };
   };


# insert device tree snippet for 1-wire
  hardware.deviceTree = {
  enable = true;
  overlays = [
      {
        name = "w1-gpio-overlay";
        dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target-path = "/";
__overlay__ {
w1: onewire@0 {
compatible = "w1-gpio";
pinctrl-names = "default";
pinctrl-0 = <&w1_pins>;
gpios = <&gpio 4 0>;
rpi,parasitic-power = <0>;
status = "okay";
};
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
w1_pins: w1_pins {
brcm,pins = <4>;
brcm,function = <0>; // in (initially)
brcm,pull = <0>; // off
};
};
};
__overrides__ {
gpiopin =      <&w1>,"4",
<&w1_pins>,"brcm,pins:0";
pullup =        <&w1>,"rpi,parasitic-power:0";
};
};
        '';
      }
    ];
  };
</nowiki>}}
</nowiki>}}


Anonymous user