This is a cache of https://discuss.96boards.org/t/node-js-gpio/131. It is a snapshot of the page at 2024-10-31T07:19:37.350+0000.
Node.js GPIO - DragonBoard410c - 96Boards Forum

Node.js GPIO

Hello,

I’m planning to use DragonBoard 410c with Ubuntu. Is it possible to use node.js and access and control GPIO via node.js?

Thank you,

I don’t see why not, anything that can read and write the filesystem can manipulate or read the state of gpio pins through device filesystem as long as you set the appropriate permissions.

hi,

i haven’t tried, but i don’t see any reason why it wouldn’t work… i suppose you want to use something like pi-gpio.js, which in turns simply uses /sys/class/gpio… so that should work, let us know!

of pi-pgio.js has hard coded mapping for the RPi PINs… that would need to be updated for DB410c

Thanks for the responses. I will try it as soon as I get a DragonBoard.

Node.js does work on the Dragonboard under Ubuntu, but there are no official packages (as of Oct 20, 2015) that support arm (specifically armv8). I believe that rasberrypi has a arm version, but it is armhf and doesnt seem to be the correct target.

Do not be confused with the v8 which is the javascript execution engine built for Google Chrome, and the ARM v8 which is the architecture that adds support for 64-bit.

The target that we are specifically looking for is arm64, which corresponds to aarch64

Binaries

It seems that since I last attempted this, there are now releases available for node, they can be found Index of /dist/

Building

Steps to build the binary

Prerequisites

Install all the packages required

$ apt-get install git gcc g++ python2.7 build-essential

Setup git as needed
We’re gonna store the source in /home/linaro/Documents

$ cd ~/Documents
$ git clone git@github:nodejs/node.git
$ cd node
$ ./configure
$ make
$ sudo make install

Appendix

Adding sources for apt-get

apt-get lists are stored at /etc/apt/
Modify sources.list to have:

deb-src Index of /ubuntu-ports vivid main universe

I created a new vivid.default.list to put in /etc/apt/sources.list.d to capture everything else
The contents of that file are:

# Main repo line
deb http://ports.ubuntu.com/ubuntu-ports vivid restricted

# Updates to the main line
deb http://ports.ubuntu.com/ubuntu-ports vivid-updates main restricted universe

# Newer software for older ubuntu releases
deb http://ports.ubuntu.com/ubuntu-ports vivid-backports main restricted universe

Nodejs is now available as a pre-built binary

Currently 4.1.1 (Oct 28, 2015)
https://nodejs.org/dist/v4.1.1/node-v4.1.1-linux-arm64.tar.gz

INSTALL

# you can choose a different place to put the binary
$ cd /home/linaro/Documents
$ wget https://nodejs.org/dist/v4.1.1/node-v4.1.1-linux-arm64.tar.gz
# extract the gz
$ tar xvzf node-v4.1.1-linux-arm64.tar.gz
# create the sym links to the files
$ sudo su
$ ln -s /home/linaro/Documents/node-v4.1.1-linux-arm64/bin/node /usr/local/bin/node
$ ln -s /home/linaro/Documents/node-v4.1.1-linux-arm64/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

Hello

Please try this library to access GPIO pins via nodejs on DB 410C

1 Like

Just in case someone like to make a try to this GPIO “lib” prerakrustaggi example… be prepared to fix the numerous errors.
Too much to list… but… still a good example to use just for an idea of how to implement it.