Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOARD PIN MODE ERROR - Check Pin Mode: EINVAL, invalid argument #2

Open
rwaldron opened this issue Oct 22, 2014 · 19 comments
Open

BOARD PIN MODE ERROR - Check Pin Mode: EINVAL, invalid argument #2

rwaldron opened this issue Oct 22, 2014 · 19 comments

Comments

@rwaldron
Copy link
Contributor

var linino = require("ideino-linino-lib");
var board = new linino.Board();
var led = board.pin.digital.D13;

board.connect(function(){
  board.pinMode(led, board.MODES.OUTPUT);
  board.digitalWrite(led, board.HIGH);
});

Result:

root@rachet:/opt/ideino-linino# node blink.js
2014-10-22T18:44:17.111Z - info: Connecting to the Board Linino One...
2014-10-22T18:44:17.343Z - error: BOARD PIN MODE ERROR - Check Pin Mode: EINVAL, invalid argument
@rwaldron
Copy link
Contributor Author

After updating to all the latest versions of the ideino-linino, lininoIO, etc. the error looks like this:

root@rachet:/opt/ideino-linino# node blink.js
2014-10-22T19:19:31.036Z - info: Connecting to the Board Linino One...
2014-10-22T19:19:31.257Z - error: BOARD PIN MODE ERROR - Check Pin Mode: ENOENT, no such file or directory '/sys/class/gpio/IO13/direction'

@rwaldron
Copy link
Contributor Author

And now this...

oot@rachet:/opt/ideino-linino# node blink.js
2014-10-22T19:23:34.479Z - info: Connecting to the Board Linino One...
2014-10-22T19:23:34.700Z - error: BOARD PIN MODE ERROR - Check Pin Mode: EBUSY, resource busy or locked

@rwaldron
Copy link
Contributor Author

Are there special aliases, because that gpio path doesn't look correct, which I confirmed:

root@rachet:/sys/class/gpio# ls
MAGI         export       gpio21       gpio22       gpio23       gpiochip0    gpiochip100  unexport

@quasto
Copy link
Contributor

quasto commented Oct 23, 2014

The problem is your outdated version of lininoOS, not compatibile with the ideino-linino-lib. please update your lininoOS to the latest version (at the moment is 14 Oct). before start is recommended to make a backup of your own files.

connect via ssh to the board and download it.

> ssh root@<board-name>.local
.... 
> cd /tmp

if you have an arduino yun board:

> wget http://download.linino.org/linino_distro/lininoIO/latest/lininoIO-generic-linino-yun-squashfs-sysupgrade.bin

otherwise, if you have the linino one:

> wget http://download.linino.org/linino_distro/lininoIO/latest/lininoIO-generic-linino-one-squashfs-sysupgrade.bin

then, if you installed ideino ide, open the sysupgrade configuration file:

> vi /etc/sysupgrade.conf

and add these lines

/etc/init.d/ideino
/etc/init.d/ideinoautorun
/usr/lib/lua/luci/view/linino/homepage.htm
/www/luci-static/resources/linino/ideino.js

load the serial terminal in the mcu (used in case of problems during the upgrade):
arduino yun:

> run-avrdude /etc/linino/YunSerialTerminal.hex

linino one:

> run-avrdude /etc/linino/LininoOneSerialTerminal.hex

upgrade arduino yun:

> cd /tmp
> sysupgrade -v lininoIO-generic-linino-yun-squashfs-sysupgrade.bin
...

upgrade linino one:

> cd /tmp
> sysupgrade -v lininoIO-generic-linino-one-squashfs-sysupgrade.bin
...

after few minutes the board will automatically reboot itself and you can reconnect to it via ssh. then install the bathos and reboot again (same for arduino yun and linino one):

> run-avrdude /etc/linino/bathos-mcuio.hex
> reboot && exit

now your system is updated. finally you need the latest version of the ideino-linino-lib. download it and replace your.

if you have also installed the ideino ide, run these commands to enable it to start at boot

> /etc/init.d/ideino enable
> /etc/init.d/ideinoautorun enable

quasto

@rwaldron
Copy link
Contributor Author

The problem is your outdated version of lininoOS, not compatibile with the ideino-linino-lib.

Where would I have found this information documented?

finally you need the latest version of the ideino-linino-lib. download it

From where? I can't npm install ideino-linino-lib.

@quasto
Copy link
Contributor

quasto commented Oct 24, 2014

The problem is your outdated version of lininoOS, not compatibile with the ideino-linino-lib.

Where would I have found this information documented?

we are aligning documentation and repositories

finally you need the latest version of the ideino-linino-lib. download it

From where? I can't npm install ideino-linino-lib.

in this moment you need to clone this repository and manually move it to the file system of the board.

let me know if you are able to go ahead with the issue of the GPIO names.

@rwaldron
Copy link
Contributor Author

I followed all of the upgrade instructions above, everything completed without a failure.

in this moment you need to clone this repository and manually move it to the file system of the board.

I tarred the latest version of this repo and then locally:

scp ideino-linino-lib.tar.gz [email protected]:/opt/ideino-linino/node_modules/

Now, ssh'ed to the board:

root@rachet:~# cd /opt/ideino-linino/node_modules
root@rachet:/opt/ideino-linino/node_modules# rm -r ideino-linino-lib
root@rachet:/opt/ideino-linino/node_modules# tar -xzf ideino-linino-lib.tar.gz
root@rachet:/opt/ideino-linino/node_modules# cd ..
root@rachet:/opt/ideino-linino# node blink.js
2014-10-24T15:57:37.653Z - info: Connecting to the Board Linino One...
2014-10-24T15:57:37.942Z - error: BOARD PIN MODE ERROR - EINVAL, invalid argument

Here's the program:

var linino = require("ideino-linino-lib");
var board = new linino.Board();
var led = board.pin.digital.D13;

board.connect(function(){
  board.pinMode(led, board.MODES.OUTPUT);
  board.digitalWrite(led, board.HIGH);
});

@quasto
Copy link
Contributor

quasto commented Oct 24, 2014

did you reboot the board after bathos-mcuio.hex loading? try to power off and power on the board. if the problem persists, run these commands and let me know the output:

ls /sys/class/gpio/
uname -v

@rwaldron
Copy link
Contributor Author

did you reboot the board after bathos-mcuio.hex loading

Yes. I followed every step of the instructions.

try to power off and power on the board

The board was powered off completely overnight.

root@rachet:~# ls /sys/class/gpio/
export     gpio21     gpio22     gpio23     gpiochip0  unexport
root@rachet:~# uname -v
#1 Tue Oct 14 15:28:09 CEST 2014

@quasto
Copy link
Contributor

quasto commented Oct 24, 2014

root@rachet:~# uname -v
#1 Tue Oct 14 15:28:09 CEST 2014

your lininoOS is up to date.

root@rachet:~# ls /sys/class/gpio/
export     gpio21     gpio22     gpio23     gpiochip0  unexport

seems that the bathos is not loaded correctly. you should see something like this:

root@linino:~# ls /sys/class/gpio/
export       gpio21       gpio22       gpio23       gpiochip0    gpiochip100  unexport

you missing gpiochip100. try to reload the bathos and eventually post the log of the run-avrdude command:

root@linino:~# run-avrdude /etc/linino/bathos-mcuio.hex
root@linino:~# reboot && exit

@rwaldron
Copy link
Contributor Author

root@rachet:~# run-avrdude /etc/linino/bathos-mcuio.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFB"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFB:
avrdude: load data efuse data from input file 0xFB:
avrdude: input file 0xFB contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "/etc/linino/bathos-mcuio.hex"
avrdude: writing flash (32748 bytes):

Writing | ################################################## | 100% 19.13s

avrdude: 32748 bytes of flash written
avrdude: verifying flash memory against /etc/linino/bathos-mcuio.hex:
avrdude: load data flash data from input file /etc/linino/bathos-mcuio.hex:
avrdude: input file /etc/linino/bathos-mcuio.hex contains 32748 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 15.97s

avrdude: verifying ...
avrdude: 32748 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

root@rachet:~# ls /sys/class/gpio/
export       gpio21       gpio22       gpio23       gpiochip0    gpiochip100  unexport
root@rachet:~# reboot && exit
Connection to 192.168.2.3 closed.

...After reboot...

root@rachet:~# ls /sys/class/gpio/
export       gpio21       gpio22       gpio23       gpiochip0    gpiochip100  unexport
root@rachet:~# cd /opt/ideino-linino/
root@rachet:/opt/ideino-linino# node blink.js
2014-10-24T20:43:39.635Z - info: Connecting to the Board Linino One...
2014-10-24T20:43:39.897Z - error: BOARD PIN MODE ERROR - ENOENT, no such file or directory '/sys/class/gpio/IO13/edge'
root@rachet:/opt/ideino-linino# ls /sys/class/gpio/
D13          export       gpio21       gpio22       gpio23       gpiochip0    gpiochip100  unexport

So I tried this...

var linino = require("ideino-linino-lib");
var board = new linino.Board();
var led = board.pin.digital.D12;

board.connect(function(){
  // board.pinMode(led, board.MODES.OUTPUT);
  // board.digitalWrite(led, board.HIGH);
});

Which shouldn't have that failure because I'm not initializing any pins, right? I added some logging to the internals of lib/gpio.js to see what was passing through and narrowed it down to the call to that.blink(50, 1500, 'D13'/*,true*/); in Board (./board.js).

Sidenote: nearby the call to that.blink(50, 1500, 'D13'/*,true*/); I found a completely pointless call to setInterval(function(){},60 * 1000) (it looks almost like whoever wrote it intended it to act like a delay, which is wrong).

Both files are full of race conditions and process blocking IO. Anytime an fs Sync function is used, the entire process is being blocked. I appreciate your help, but at this point I've determined that I cannot use this library code as a the baseline for a Johnny-Five IO plugin on this platform.

@telno
Copy link

telno commented Nov 19, 2014

This is still an issue - appreciate if you'd reopen it.

I have a fresh update of both Ideino and LininoIO and my results are the same as above. Node scripts all fail during connect with a failure due to that.blink() line.

@quasto
Copy link
Contributor

quasto commented Nov 19, 2014

This problem occurs when the board is not restarted after the loading of the firmware. So please run this command and let me know the version of you LininoOS

uname -v

if you version is

Tue Oct 14 15:28:09 CEST 2014

your LininoOS is up to date to the latest version. Then try to reload the bathos mucio firmware and reboot the board:

run-avrdude /etc/linino/bathos-mcuio.hex && reboot

if the firmware is loaded correctly, running this command:

ls /sys/class/gpio

you should see this:

export gpio21 gpio22 gpio23 gpiochip0 gpiochip100 unexport

if you see gpiochip100 folder, means that the firmware is loaded and LininoIO are working correctly. Try to run again your node.js application with ideino-linino-lib.

quasto

@quasto quasto reopened this Nov 19, 2014
@telno
Copy link

telno commented Nov 19, 2014

Everything checks out, which is why I requested to reopen this issue.

My results are:

root@linino:~# uname -v
#1 Tue Oct 14 15:28:09 CEST 2014

root@linino:~# run-avrdude /etc/linino/bathos-mcuio.hex && reboot
[...] success, re-login

root@linino:~# ls /sys/class/gpio
D13 gpio21 gpio23 gpiochip100 export gpio22 gpiochip0 unexport

However, running a simple script always fails:
root@linino:~# node lininoexample.js
2014-11-19T17:57:02.419Z - info: Connecting to the Board Linino One...
2014-11-19T17:57:02.684Z - error: BOARD PIN MODE ERROR - Check Pin Mode: ENOENT, no such file or directory '/sys/class/gpio/IO13/direction'
root@linino:~# node lininoexample.js
2014-11-19T17:57:02.419Z - info: Connecting to the Board Linino One...
2014-11-19T17:57:02.684Z - error: BOARD PIN MODE ERROR - Check Pin Mode: EBUSY, resource busy or locked

I'm running the 6-line example from http://www.linino.org homepage. However, it repros with even a simple call to connect which means it's having a problem with the that.blink(50, 1500, 'D13'/*,true*/); call in board.js.

@quasto
Copy link
Contributor

quasto commented Nov 20, 2014

From the title of this issue, I thought there was an error of type EINVAL, which can be solved in the way explained above.

Anyway your problem is caused by an old configuration file. This file contains the pin layout of the boards. To solve it I suggest to download the latest version (at the moment) of ideinoIO from here:

https://github.com/ideino/ideino-linino-dist/releases/download/0.1.0/ideinoIO_0.1.0-9_ar71xx.ipk

and then install it:

opkg install ideinoIO_0.1.0-9_ar71xx.ipk -d mnt

In the next days we'll release a newer version that will improve some functionality.
let me know...

@telno
Copy link

telno commented Nov 20, 2014

How could I have an old configuration file when I just did a clean install of IdeInoIO by following the instructions here http://wiki.linino.org/doku.php?id=wiki:nodejscript

Do you mean that opkg install ideinoIO -d mnt installs a known-bad build with known-old config?

@telno
Copy link

telno commented Nov 20, 2014

BTW, I installed ideinoIO_0.1.0-9_ar71xx.ipk and confirmed it's working now

@scenaristeur
Copy link

@rwaldron
i got my Yun working with nodejs / socket / express.
what is the result when you type

lininoio -s

if it tells you it's "disabled" , try (with ssh) :

lininoio start

this should run 'run-avrdude /etc/linino/bathos-mcuio.hex'

and create some new folders in /sys/class/pwm/pwmchip0/ corresponding to the arduino pin

see : http://wiki.linino.org/doku.php?id=wiki:upgradetolininoio

@scenaristeur
Copy link

scenaristeur commented Jan 4, 2018

Reinstalling a new card, I had the same issue.
I think this is because the first run of lininoio start did'nt succed,
( I ran it before send linino> setenv bootargs 'console=spicons board=linino-yun mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),14656k(rootfs),1280k(kernel),64k(nvram),64k(art),15936k@0x50000(firmware) mem=64M rootfstype=squashfs,jffs2 noinitrd'
to u-boot, and before installing libs with :
opkg install node node-express node-socket.io node-serialport ideino ideinoIO node-ideino-linino-lib )

so I went back with lininoio stop , with reboot, then rerun lininoio start and it is OK for me now.

Hope this could help, I can now run blink.js :

/***
 * file: blink.js
 * version: 3.0
 * author: https://github.com/quasto
 * license: mit
 * description: in this example the board led on digital pin 13 will 
 *      blink every 1 second .
 ***/
 
var linino = require('ideino-linino-lib'),
    board = new linino.Board();

var pin13 = board.pin.digital.D13,
    ctrl = true;
    
board.connect( function(){
    board.pinMode(pin13, board.MODES.OUTPUT);
    
    setInterval(function(){
        if(ctrl){
            board.digitalWrite(pin13, board.HIGH);
            ctrl = false;
        }
        else{
            board.digitalWrite(pin13, board.LOW);
            ctrl = true;
        }
    },1000);
});

or
multiple nodejs apps : https://github.com/scenaristeur/lininoapps/tree/master/root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants