eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.37k stars 614 forks source link

[up board] All of GPIO Pins can not be used #815

Closed wanghongjuan closed 7 years ago

wanghongjuan commented 7 years ago

Hello,

I am use this up board with Ubuntu 16.04, but blocked when invoke GPIO with mraa (javascript version), test code as below:

led.js

var m = require('mraa'); //require mraa

var myLed = new m.Gpio(7); //LED hooked up to digital pin 7
myLed.dir(m.DIR_OUT);      //set the gpio direction to output
var ledState = true;       //Boolean to hold the state of Led

function periodicActivity()
{
    myLed.write(ledState?1:0);           //if ledState is true then write a '1' (high) otherwise write a '0' (low)
    ledState = !ledState;                //invert the ledState
    setTimeout(periodicActivity,500);    //call the indicated function after 1 second (1000 milliseconds)
}

periodicActivity(); //call the periodicActivity function

Error occurred when running node led.js whether using role admin(root) or general user: run-code

Journalctl log as below: journalctl

I tried all pins as this mapping, but all of them got same error as above.

Software Info:

Node.js: V6.11.2 Npm: V3.10.10 Mraa: V1.7.0

arfoll commented 7 years ago

Looks like a permission issue to me - try it as rot - you're getting permission denied.

wanghongjuan commented 7 years ago

Thanks for your quickly response, I tried it as root, unfortunately, got same result as above

arfoll commented 7 years ago

@nicolalunghiemutex any ideas? Do you know if there's a bios issue or something on up1 that would cause this? seems liek gpio4 just won't export itself from sysfs

nicola-lunghi commented 7 years ago

Dear @wanghongjuan

  1. what kernel are you using? (uname -a) for gpio to work you need to install the up kernel. Instruction about how to install it here

https://up-community.org/wiki/Ubuntu#Installation

  1. Can you try do execute the following command: sudo -i echo 4 > /sys/class/gpio/export and report back the result?

  2. Can you try do execute the following command: sudo ls /sys/kernel/debug/pinctrl and report the result?

Best Regards Nicola Lunghi

wanghongjuan commented 7 years ago

Hi, @nicolalunghiemutex thanks for you reply, please see below information:

  1. The kernel that I am using is:
    $ uname -a
    Linux up2 4.10.0-33-generic #37~16.04.1-Ubuntu SMP Fri Aug 11 14:07:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  2. The result is:
    root@up2:~# echo 4 > /sys/class/gpio/export
    -bash: echo: write error: Invalid argument
  3. The result is:
    yunfei@up2:~$ sudo ls /sys/kernel/debug/pinctrl
    INT33FF:00  INT33FF:01  INT33FF:02  INT33FF:03  pinctrl-devices  pinctrl-handles  pinctrl-maps

For the up board kernel, I will install it later.

nicola-lunghi commented 7 years ago

Dear @wanghongjuan without the Up Linux Kernel the GPIO on the board simply doesn't work. Please install our kernel from the PPA then try again.

Regards Nicola Lunghi

alext-mkrs commented 7 years ago

Closing for no activity and solution provided, feel free to comment if you need to reopen it.

Jianfengusa commented 3 years ago

Hi I am having a similar issue, image

I believe that I am using upboard kernel, can someone help?

image