Difference between revisions of "EBC Exercise 42 udev"
(Initial info) |
m |
||
Line 2: | Line 2: | ||
{{YoderHead}} | {{YoderHead}} | ||
− | Here's how to setup udev to set the permissions when a device is brought up. | + | Here's how to setup udev to set the permissions when a device is brought up. In my case it's setting up permissions so /sys/class/remoteproc doesn't need sudo. |
+ | Here are the permissions before the udev rule: | ||
+ | bone$ '''cd /sys/class/remoteproc/remoteproc1''' | ||
+ | bone$ '''ls''' | ||
+ | 0 lrwxrwxrwx 1 root root 0 Jul 16 16:28 device -> ../../../4a334000.pru | ||
+ | 0 -rw-r--r-- 1 root root 4096 Jul 16 16:28 firmware | ||
+ | 0 drwxr-xr-x 2 root root 0 Jul 16 16:28 power | ||
+ | 0 -rw-r--r-- 1 root root 4096 Jul 18 08:05 state | ||
+ | 0 lrwxrwxrwx 1 root root 0 Jul 16 16:28 subsystem -> ../../../../../../../../class/remoteproc | ||
+ | |||
== Clone the BeagleBoard repo == | == Clone the BeagleBoard repo == | ||
Line 8: | Line 17: | ||
bone$ '''git clone https://github.com/rcn-ee/repos''' | bone$ '''git clone https://github.com/rcn-ee/repos''' | ||
bone$ '''cd repos/bb-customizations/suite/buster/debian''' | bone$ '''cd repos/bb-customizations/suite/buster/debian''' | ||
+ | |||
+ | == Find some rules that are like what you are doing == | ||
bone$ '''ls''' | bone$ '''ls''' | ||
10-of-symlink.rules 85-gpio-noroot.rules install | 10-of-symlink.rules 85-gpio-noroot.rules install | ||
Line 16: | Line 27: | ||
82-gpio-config-pin.rules copyright zz-uenv_txt | 82-gpio-config-pin.rules copyright zz-uenv_txt | ||
83-eqep-noroot.rules generic-board-startup.service | 83-eqep-noroot.rules generic-board-startup.service | ||
+ | |||
+ | In this case <code>81-pwm-noroot.rules</code> is a good example. | ||
+ | |||
+ | bone$ '''cat 81-pwm-noroot.rules''' | ||
+ | # /etc/udev/rules.d/81-pwm-noroot.rules | ||
+ | # | ||
+ | # ReWritten by: Matthijs van Duin | ||
+ | # Corrects sys PWM permissions on the BB so non-root users in the pwm group can | ||
+ | # manipulate pwm along with creating a symlink under /dev/pwm/ | ||
+ | # | ||
+ | SUBSYSTEM=="pwm", ACTION=="add", \ | ||
+ | RUN+="/bin/chgrp -R pwm '/sys%p'", \ | ||
+ | RUN+="/bin/chmod -R g=u '/sys%p'" | ||
+ | |||
+ | # automatically export pwm channels | ||
+ | SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="add", ATTR{export}="0" | ||
+ | SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="add", ATTR{npwm}!="1", ATTR{export}="1" | ||
{{YoderFoot}} | {{YoderFoot}} |
Revision as of 04:44, 18 July 2019
Embedded Linux Class by Mark A. Yoder
Here's how to setup udev to set the permissions when a device is brought up. In my case it's setting up permissions so /sys/class/remoteproc doesn't need sudo. Here are the permissions before the udev rule:
bone$ cd /sys/class/remoteproc/remoteproc1 bone$ ls 0 lrwxrwxrwx 1 root root 0 Jul 16 16:28 device -> ../../../4a334000.pru 0 -rw-r--r-- 1 root root 4096 Jul 16 16:28 firmware 0 drwxr-xr-x 2 root root 0 Jul 16 16:28 power 0 -rw-r--r-- 1 root root 4096 Jul 18 08:05 state 0 lrwxrwxrwx 1 root root 0 Jul 16 16:28 subsystem -> ../../../../../../../../class/remoteproc
Clone the BeagleBoard repo
bone$ git clone https://github.com/rcn-ee/repos bone$ cd repos/bb-customizations/suite/buster/debian
Find some rules that are like what you are doing
bone$ ls 10-of-symlink.rules 85-gpio-noroot.rules install 60-omap-tty.rules 86-remoteproc-noroot.rules postinst 80-eeprom-noroot.rules changelog rtl8723bu-blacklist.conf 80-gpio-noroot.rules compat rules 81-pwm-noroot.rules control ti_pru_firmware 82-gpio-config-pin.rules copyright zz-uenv_txt 83-eqep-noroot.rules generic-board-startup.service
In this case 81-pwm-noroot.rules
is a good example.
bone$ cat 81-pwm-noroot.rules # /etc/udev/rules.d/81-pwm-noroot.rules # # ReWritten by: Matthijs van Duin # Corrects sys PWM permissions on the BB so non-root users in the pwm group can # manipulate pwm along with creating a symlink under /dev/pwm/ # SUBSYSTEM=="pwm", ACTION=="add", \ RUN+="/bin/chgrp -R pwm '/sys%p'", \ RUN+="/bin/chmod -R g=u '/sys%p'" # automatically export pwm channels SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="add", ATTR{export}="0" SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="add", ATTR{npwm}!="1", ATTR{export}="1"
Embedded Linux Class by Mark A. Yoder