I am trying to use the hardware PWM module on my pi 3 by writing to the /sys/class/pwm/pwmchip0
directory (which I think is just a symbolic link to sys/devices/platform/soc/3f20c000.pwm/pwm/pwmchip0
). When I do this using bash and sudo, everything works as expected. The problem is that I need to write to this same folder from within a C++ program which I cannot run as root. I have tried creating a group 'pwm', giving ownership of pwmchip0
to 'pwm', and changing permissions with chmod -R g+rw pwmchip0
, but when I try to write to the folder without sudo, I get "Permission denied". When I run ls -l
on the folder, I get the following permissions, which to be honest I do not really understand:
pi@raspberry:/sys/devices/platform/soc/3f20c000.pwm/pwm $ls -l pwmchip0
total 0
lrwxrwxrwx 1 root pwm 0 May 9 20:44 device -> ../../../3f20c000.pwm
--w-rwx--- 1 root pwm 4096 May 9 20:12 export
-r--rwxr-- 1 root pwm 4096 May 9 20:41 npwm
drwxrwxr-x 2 root pwm 0 May 9 20:41 power
drwxrwxr-x 3 root pwm 0 May 9 20:41 pwm0
drwxrwxr-x 3 root pwm 0 May 9 20:41 pwm1
lrwxrwxrwx 1 root pwm 0 May 9 20:44 subsystem -> ../../../../../../class/pwm
-rw-rwxr-- 1 root pwm 4096 May 9 20:41 uevent
--w-rwx--- 1 root pwm 4096 May 9 20:41 unexport
I was hoping someone else has been able to solve this problem and has some insight for me, or perhaps someone with a better understanding of permissions and groups can enlighten me. Thanks in advance for your help!