"EACCES: permission denied, open '/sys/class/gpio/gpio19/value'"

I am trying to get a Nodejs program I wrote for my Raspberry Pi 2 to run on my BPi-M64. The program uses fivdi/onoff library to read and write to the GPIO of my RPi2 w/o issue. But when I try to run the program on my BPi-M64 I get the error;

Unable to parse revision information in /proc/cpuinfo
Unknown board revision , assuming Raspberry Pi Zero/2/3 pinout. Unless you are running a compute module or very old RPi this should work fine. Please report this board revision in a GitHub issue at https://github.com/nebrius/raspi-board.
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
Error: EACCES: permission denied, open '/sys/class/gpio/export'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at new Gpio (/home/pi/reefbuddy-server/node_modules/onoff/onoff.js:96:10)
    at Object.<anonymous> (/home/pi/reefbuddy-server/reefbuddy.js:9:22)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)

I’ve seen some on the Raspberry Pi forums report similar issues and say that they were able to resolve them by adding rules to the udev directory but I haven’t had success with this.

How can I grant permission non root user to access the GPIO on the BPI-M64?

OS:Debian 9(Stretch) Node version: 8.16.1 kernel: 3.10.105

Not sure I would use udev for that. Did you try something like

Did you check if you run the progam with the gpio user group, as well as if the (pseudo) filesystem is accesible for that user group?

sudo ls -al /sys/class/gpio/export

If not you could try

sudo chown root:gpio /sys/class/gpio/export; sudo chmod 770 /sys/class/gpio/export

to give write/read permissions to the gpio user group, and then run your program with the gpio user group?

PS: You should try to use a more recent kernel, as 3.10 is even predating Debian 8 (Jessie)

Thanks @sisyphos!

sudo ls -al /sys/class/gpio/export 

returned root:root

so I ran the chown chmod commands and that changed it to root:gpio

Please excuse me if this is a noob question but how would I go about updating the kernel? I’m presuming that is the kernel the unit shipped with. What is the latest stable kernel you would recommend updating to?

Something else I’ve ran into is when running my Node program with sudo it does run but is giving me a Module version mismatch. Expected 46, got 57. error.

I installed Node via NVM when I try to install a different version I get an error about low memory and the install doesn’t finish. Disk usage analyzer shows filesystem capacity is 14.6GB and that I’m using 13.5GB with 1.1GB remaining. I’m presuming that is memory on the board itself because I have a 32GB microSD card that I used to install the OS. I’m not sure what to make of all this so if you have any advice on that it would be appreciated.


I haven’t tinkerd with Linux since a very long time, so I am also a bit of a noob on some stuff, so others might correct me if I am wrong here :wink:

The kernel is the base operating system, the part that is directly communicating with your hardware and on top of which all the applications are running. Currenlt the BananaPi is mainly relying on custom build kernels. You might take a look at the blog FW-Web - Wiki of frank-w about how to build your ownt (in this case for the R2).

Or you take an existing build like

The kernel has roughly 4 parts:

  1. The core kernel that you boot in, which is in /boot
  2. Compiled library files in /usr/lib/linux-image-*
  3. Modules for different hardware (e.g. sound card, usb, wifi, …) in /lib/modules/*-kernel
  4. Sources in /usr/src/linux-headers-*

There might be an additional bootloader (u-boot) involved which is responsible to jump start the system. It essentially is telling the board where to look for the kernel. But if you have already a system up and running you may leave that as is.

Normally they come packed together in files like:

  • 4.4.89-BPI-M64-Kernel.tgz (2+3)
  • BOOTLOADER-bpi-m64-linux4.4.tgz
  • BPI-BOOT-bpi-m64-linux4.4.tgz (1)
  • linux-headers-bpi-m64-linux4.4.tgz (4)

So to get a new kernel installed can be as easy to just extract them over to the destination. @spikerguy mentioned in Can I burn any ARM64 install ISO on my SD? that he might have a more detailed how-to.

I personally would start of burning one of the images mentioned above (preferable 4.19) on a SD card and try to get the system up and running on the card. Afterwards moving everything just over to the internal memory (keep your existing stuff on a separate SD card as backup!). I wouldn’t necessarily go for the latest 5.x kernels announced here yet, as they may need some tweeking first.

The other question is an entirely different topic. Node is a javascript environment and npm a package management system for java script libraries. They are usually operating on the javascript source, which are basically just text files but can have a huge dependency tree. If you installed it from scratch it will usually come with a bunch of usefull tools and libraries packaged along. As such one easily can blow several megabytes away, which isn’t an issue on a PC or Mac with a disk, but on those little boards memory space is a premium.

I don’t know which minimum version of node your application need. I would have tried to install it actually via the debian package manger instead.

see: https://linuxconfig.org/how-to-install-nodejs-on-debian-9-stretch-linux

For your application, again, try to get it up and running on an SD card first (eventually you may need to resize the working partition if not all space of your card is available). Or even on a desktop using the same node version that is on your Pi. Then try if you could compile and pack the node application and dependencies together for deployment (there are some tools that will essentially remove all the parts that are not needed).

PS: regarding this error check out https://github.com/fivdi/pigpio/issues/84 While not the exact same error the issue behind may be a version mismatch of NodeJS and one of the modules. So you may either need to upgrade/downgrade NodeJS or the module you want to use.

However for those kind of question taht are outside of Banana Pi, I would probably go on https://stackoverflow.com/