Opening GPIO: opening 'export': Permission denied [errno 13]

Dear,

I try desperately to use the GPIO port of my RockPI4B which runs under Armbian with Repetier-Server Pro 1.4.2 but without success, I always have the following message which is displayed "Opening GPIO: opening 'export': Permission denied [errno 13]", can someone help me to give the necessary permissions to 'export'?

Thank you in advance for your help.
Regards
Laurent

Comments

  • Access is file based from user repetierserver, so run
    ls -l /sys/class/gpio/gpiochip0/
    to see which group is allowed to access the pins. For pi it is group gpio which is no problem because repetierserver is member of that group. If your linux uses a different group for this you might need to add repetierserver to that group to get permission. 
  • Dear,
    Thanks for your help.
    With ls -l /sys/class/gpio/gpiochip0/ I have this: 
    laurent@rockpi-4b:~$ ls -l /sys/class/gpio/gpiochip0/
    total 0
    -r--r--r-- 1 root root 4096 Nov  9 17:38 base
    lrwxrwxrwx 1 root root    0 Nov  9 17:38 device -> ../../../ff720000.gpio
    -r--r--r-- 1 root root 4096 Nov  9 17:38 label
    -r--r--r-- 1 root root 4096 Nov  9 17:38 ngpio
    drwxr-xr-x 2 root root    0 Nov  9 17:31 power
    lrwxrwxrwx 1 root root    0 Nov  9 17:31 subsystem -> ../../../../../../class/gpio
    -rw-r--r-- 1 root root 4096 Nov  9 17:31 uevent

    I also add repetierserver in gpio and laurent groupe but without any success, same error "Opening GPIO: opening 'export': Permission denied [errno 13]".
    Hereunder the groupe list.
    laurent:x:1000:repetierserver
    polkitd:x:999:
    ssl-cert:x:122:
    xrdp:x:123:
    gpio:x:1001:laurent,repetierserver

    Regards
    Laurent

     
  • On a pi it looks like this:
    ls -l /sys/class/gpio/gpiochip0/
    total 0
    -r--r--r-- 1 root gpio 4096 Sep 10 07:57 base
    lrwxrwxrwx 1 root gpio    0 Sep 10 07:57 device -> ../../../fe200000.gpio
    -r--r--r-- 1 root gpio 4096 Sep 10 07:57 label
    -r--r--r-- 1 root gpio 4096 Sep 10 07:57 ngpio
    drwxrwxr-x 2 root gpio    0 Sep 10 07:57 power
    lrwxrwxrwx 1 root gpio    0 Sep 10 07:57 subsystem -> ../../../../../../class/gpio
    -rw-rw-r-- 1 root gpio 4096 Sep 10 07:57 uevent

    you see the second name in ls -l output is the group which is here gpio. On your linux these files belong to group root, which is why you get permission denied. You can test if assigning group root to repetierserver helps here. But as you see the group user has not write permissions to the files so I think it will not help. You would need to start server as user root to get access here or find out how to change group and group permissions.

    You can do so in service but note that updating server will overwrite your changes and you have to repeat them. The service file is
    /lib/systemd/system/RepetierServer.service
    and contains this:
    [Unit]
    Description=Repetier-Server 3D Printer Server
    After=network.target

    [Service]
    Type=forking
    PermissionsStartOnly=true
    LimitNICE=-20
    Nice=-20
    KillMode=process
    User=repetierserver
    Environment="LC_ALL=C"
    ExecStartPre=/bin/mkdir -p /var/lib/Repetier-Server
    ExecStartPre=/bin/chown -R repetierserver /var/lib/Repetier-Server
    ExecStart=/usr/local/Repetier-Server/bin/RepetierServer -c /usr/local/Repetier-Server/etc/RepetierServer.xml --daemon
    Restart=on-failure
    RestartSec=0
    TasksMax=infinity

    [Install]
    WantedBy=multi-user.target


    You need to change User and also the chown command to use root instead of repetierserver than server runs as root after service restart:
    sudo systemctl daemon-reload
    sudo service RepetierServer restart



  • Dear,

    Thanks for your help, the error message disappeared by following your instructions, thank you for your help.

    Question: If during the installation of Armbian, I set the user "PI" from the start, will this save me all these problems?

    Many thanks again for your help and responsiveness.
    Regards
    Laurent

  • I don't think that this would have helpered here. pi is not root as well and has nothing to do with user used by server.
Sign In or Register to comment.