NixOS on ARM/Raspberry Pi 4: Difference between revisions
Add closing code tag |
m add udev rule for non-root access through libgpiod |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 94: | Line 94: | ||
over_voltage=6 | over_voltage=6 | ||
</nowiki>}} | </nowiki>}} | ||
=== USB boot === | === USB boot === | ||
| Line 186: | Line 185: | ||
The <code>extraRules</code> changes the owner of <code>gpiomem</code> and all other files needed for GPIO to work to <code>root:gpio</code> and changes the permissions to <code>0660</code>. | The <code>extraRules</code> changes the owner of <code>gpiomem</code> and all other files needed for GPIO to work to <code>root:gpio</code> and changes the permissions to <code>0660</code>. | ||
Therefore, the root user and anyone in the gpio group can now access the GPIO pins. | Therefore, the root user and anyone in the gpio group can now access the GPIO pins. | ||
Permissions on the <code>/dev/gpiochip*</code> devices are needed to support access through the newer '''GPIO character device''' interface (see [https://libgpiod.readthedocs.io/en/latest/ libgpiod]). | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
| Line 196: | Line 196: | ||
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'" | SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'" | ||
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'" | SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'" | ||
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /dev/gpiochip* && chmod 0660 /dev/gpiochip*'" | |||
''; | ''; | ||
| Line 234: | Line 235: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The the <code>spi0- | The the <code>spi0-0cs.dtso</code> file can be downloaded [https://github.com/raspberrypi/firmware/blob/master/boot/overlays/spi0-0cs.dtbo here]. | ||
You might have to change the <code>compatible</code> field to "raspberrypi" in the dtbo file. | You might have to change the <code>compatible</code> field to "raspberrypi" in the dtbo file. | ||