rwaldron / nino-io

Linino One & Arduino Yun IO Plugin for Johnny-Five
http://johnny-five.io
MIT License
8 stars 2 forks source link

Failed to export PWM #2

Open derekwheee opened 10 years ago

derekwheee commented 10 years ago

On an Arduino Yun with BusyBox v1.19.4 (2014-10-17 22:40:10 CEST), when running the Node script below, I get the output that follows.

Node script:

var Nino = require("nino-io");
var board = new Nino({
  layout: "Arduino Yun"
});

board.on("ready", function() {
  console.log("Ready.");

  var state = 0;
  var pin = 13;

  this.pinMode(pin, this.MODES.OUTPUT);

  setInterval(function() {
    board.digitalWrite(pin, (state ^= 1));
  }, 500);
});

Output:

root@yun:/opt/j5# node blink
Failed to export PWM: (ENOENT ENOENT, open '/sys/class/pwm/pwmchip0/export') { ENA: true,
  DEF: 'D3',
  TYP: 'digital',
  NUM: '116',
  MAP: 'D3',
  servo: null,
  pwm: 
   { ENA: true,
     DEF: 'P3',
     TYP: 'pwm',
     MAP: 'D3',
     BIT: '8',
     NUM: '0',
     TIM: { DEF: 'T0', SET: false, USE: [], SHARED: false },
     MAX: 4000000,
     RES: 15625 } }
Failed to export PWM: (ENOENT ENOENT, open '/sys/class/pwm/pwmchip0/export') { ENA: true,
  DEF: 'D5',
  TYP: 'digital',
  NUM: '114',
  MAP: 'D5',
  servo: 
   { ENA: true,
     DEF: 'P5',
     TYP: 'pwm',
     MAP: 'D5',
     BIT: '16',
     NUM: '4',
     TIM: { DEF: 'T1', SET: false, USE: [], SHARED: false },
     MAX: 32768000,
     RES: 500 },
  pwm: 
   { ENA: true,
     DEF: 'P5',
     TYP: 'pwm',
     MAP: 'D5',
     BIT: '16',
     NUM: '4',
     TIM: { DEF: 'T1', SET: false, USE: [], SHARED: false },
     MAX: 32768000,
     RES: 500 } }
Failed to export PWM: (ENOENT ENOENT, open '/sys/class/pwm/pwmchip0/export') { ENA: true,
  DEF: 'D6',
  TYP: 'digital',
  NUM: '123',
  MAP: 'D6',
  servo: null,
  pwm: 
   { ENA: true,
     DEF: 'P6',
     TYP: 'pwm',
     MAP: 'D6',
     BIT: '16',
     NUM: '5',
     TIM: { DEF: 'T2', SET: false, USE: [], SHARED: false },
     MAX: 16384000,
     RES: 64000 } }
Failed to export PWM: (ENOENT ENOENT, open '/sys/class/pwm/pwmchip0/export') { ENA: true,
  DEF: 'D9',
  TYP: 'digital',
  NUM: '105',
  MAP: 'D9',
  servo: 
   { ENA: true,
     DEF: 'P9',
     TYP: 'pwm',
     MAP: 'D9',
     BIT: '16',
     NUM: '1',
     TIM: { DEF: 'T3', SET: false, USE: [], SHARED: true },
     MAX: 32768000,
     RES: 500 },
  pwm: 
   { ENA: true,
     DEF: 'P9',
     TYP: 'pwm',
     MAP: 'D9',
     BIT: '16',
     NUM: '1',
     TIM: { DEF: 'T3', SET: false, USE: [], SHARED: true },
     MAX: 32768000,
     RES: 500 } }
Failed to export PWM: (ENOENT ENOENT, open '/sys/class/pwm/pwmchip0/export') { ENA: true,
  DEF: 'D10',
  TYP: 'digital',
  NUM: '106',
  MAP: 'D10',
  servo: 
   { ENA: true,
     DEF: 'P10',
     TYP: 'pwm',
     MAP: 'D10',
     BIT: '16',
     NUM: '2',
     TIM: { DEF: 'T3', SET: false, USE: [], SHARED: true },
     MAX: 32768000,
     RES: 500 },
  pwm: 
   { ENA: true,
     DEF: 'P10',
     TYP: 'pwm',
     MAP: 'D10',
     BIT: '16',
     NUM: '2',
     TIM: { DEF: 'T3', SET: false, USE: [], SHARED: true },
     MAX: 32768000,
     RES: 500 } }
Failed to export PWM: (ENOENT ENOENT, open '/sys/class/pwm/pwmchip0/export') { ENA: true,
  DEF: 'D11',
  TYP: 'digital',
  NUM: '107',
  MAP: 'D11',
  servo: 
   { ENA: true,
     DEF: 'P11',
     TYP: 'pwm',
     MAP: 'D11',
     BIT: '16',
     NUM: '3',
     TIM: { DEF: 'T3', SET: false, USE: [], SHARED: true },
     MAX: 32768000,
     RES: 500 },
  pwm: 
   { ENA: true,
     DEF: 'P11',
     TYP: 'pwm',
     MAP: 'D11',
     BIT: '16',
     NUM: '3',
     TIM: { DEF: 'T3', SET: false, USE: [], SHARED: true },
     MAX: 32768000,
     RES: 500 } }
Failed to export ADC: (ENOENT ENOENT, open '/sys/bus/iio/devices/iio:device0/enable') 
Ready.

fs.js:524
  binding.write(fd, buffer, offset, length, position, wrapper);
          ^
TypeError: Bad argument
    at Object.fs.write (fs.js:524:11)
    at Pin.write (/opt/j5/node_modules/nino-io/lib/nino-io.js:853:6)
    at Nino.digitalWrite (/opt/j5/node_modules/nino-io/lib/nino-io.js:452:23)
    at null.<anonymous> (/opt/j5/blink.js:16:11)
    at wrapper [as _onTimeout] (timers.js:261:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

The paths on line 42 and line 43 don't exist on my Yun. Are we running different versions of OpenWrt?

rwaldron commented 10 years ago

This is great, thank you.

rwaldron commented 10 years ago

The paths on line 42 and line 43 don't exist on my Yun. Are we running different versions of OpenWrt?

Could be, let's walk throught it.

From the board:

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

Once that's complete, run this:

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

After the restart, try the script again.

derekwheee commented 10 years ago

I ran these:

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

Got "Upgrade completed" and the board then rebooted, but the network connection never came back up. I uploaded the YunSerialTerminal sketch and hit YUN RST, this is far as the boot sequence gets: https://gist.github.com/frxnz/b87ba47c0710727e225f

rwaldron commented 10 years ago

Ok, thanks. My Yun was delivered to our old address, so I'm heading over in a cab to pick it up. Stand by :)

framlin commented 9 years ago

Servus, I have the same problem. Runing the code above ends with

pwm: { ENA: true, DEF: 'P11', TYP: 'pwm', MAP: 'D11', BIT: '16', NUM: '3', TIM: { DEF: 'T3', SET: false, USE: [], SHARED: true }, MAX: 32768000, RES: 500 } } Failed to export ADC: (ENOENT ENOENT, open '/sys/bus/iio/devices/iio:device0/enable') Ready.

fs.js:513 binding.write(fd, buffer, offset, length, position, wrapper); ^ TypeError: Bad argument at Object.fs.write (fs.js:513:11) at Pin.write (/opt/node_modules/nino-io/lib/nino-io.js:986:6) at Nino.digitalWrite (/opt/node_modules/nino-io/lib/nino-io.js:467:23) at null. (/opt/src/j5tst/run.js:16:23) at wrapper as _onTimeout at Timer.listOnTimeout as ontimeout

is there any solution for this faiulure?

derekwheee commented 9 years ago

@framlin Currently the only solution for this is to install LininoOS on the Yun. Neither me nor @rwaldron have been successful getting LininoOS installed, and Rick has bricked a few Yuns trying. @aabm00 has had some success in #4 but it's not an easy process by any means.

framlin commented 9 years ago

and since I have done all I have read here I am not able to connect to the yun any more nor via wlan neither via usb/arduino-ide :( does anyone know how to do a factory-reset without usb or wlan-connection?

fivdi commented 9 years ago

@framlin sorry to hear about that. While installing LininoOS and LininoIO on a Linino One I ended up in a situation where it was no longer possible to talk to the Linino One via ethernet / wlan. What did work was using the Linux screen utility as follows screen /dev/ttyACM0 115200. It was also necessary to hit ~1 and ~2 to toggle between 250000 and 115200 baud. I somehow managed to get things sorted out over the serial port.

@rwaldron @frxnz The readme mentions that LininoOS is required, but makes no mention of LininoIO. AFAIK, both are actually needed. After installing LininiOS on a Linino One, it looked to me as if everything required was there, so I went and directly did the Node.js installation. However, important pieces ended up being missing, for example /dev/i2c-0. Only after reinstalling LininoOS, upgrading to LininiIO, and then installing Node.js did things function correctly.

rwaldron commented 9 years ago

The readme mentions that LininoOS is required, but makes no mention of LininoIO. AFAIK, both are actually needed.

Ugh, you're absolutely right. Sorry about that :(

Can you make a PR?

fivdi commented 9 years ago

Will do.