node.js running on a Phidgets SBC2 board!

javascript node.js 
↞ See all posts

After almost 15 hours or compile-try-fail-repeat, I’ve figured out the formula for compiling nodeJS on a Phidget SBC2 board!

This combination of Node and Phidgets creates what is, in my opinion, the best sensor prototyping platform for under $250. This makes use of my previously mentioned NPM package for connecting node.js to phidgets.

This was possible only with the help of the friendly people at Phidget, Github, and numerous sites stumbled upon via Google. Get Hacking!!!

I made a small nodeJS app which reads in the temperature of my house every minute and Tweets it… Because I can.

  • One of the harder steps of this process was cross-compiling V8. I’ve saved off my v8 compiled for Phidget SBC2 (armv4tl compatible) for you to skip a few steps in the process (and so you don’t need to also install Debian somewhere) (no longer works :( )
  • Detailed steps of this process are copied below, but also here on a GitHub gist
  • A lot of people helped me out, specifically these folks I am linking here.

Node is awesome, Phidgets are awesome. Syngergy. All I wanted to do was tweet the temperature of my house automatically…

What you will need:

  • A computer (or a virtual machine) running a full version of the Debian operating system
  • I used Debian 6.0.3, 64bit
  • A 1GB (or more) USB memory stick
  • The phidgetsbc2 doesn’t have enough ram to compile node, so we will be using this memory stick as swap space… which is likely to destroy the memory stick
  • Internet connectivity for both your Debian computer and the Phidget board

Cross-Compile V8 Locally

The v8 stack simply won’t compile on the fidget board. I think that it has to do with floating point precision, but I can’t be sure. Either way, we are going to compile an ARM binary on our "big" Debian computer and copy it over:

Get codesourcery

SSH to your Debian machine, and su root

1sudo mkdir /opt/codesourcery 2cd /opt/codesourcery 3wget 4tar -xvf arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2z2

Get Node and build it for the Phidget board

1wget 2tar -xvf node-v0.6.7.tar.gz 3cd node-v0.6.7/deps/v8 4export TOOL_PREFIX=/opt/codesourcery/arm-2009q1/bin/arm-none-linux-gnueabi 5export CXX=$TOOL_PREFIX-g++ 6export AR=$TOOL_PREFIX-ar 7export RANLIB=$TOOL_PREFIX-ranlib 8export CC=$TOOL_PREFIX-gcc 9export LD=$TOOL_PREFIX-ld 10export CCFLAGS="-march=armv4 -mno-thumb-interwork" 11OR>> export CCFLAGS="-march=armv4 -mno-thumb-interwork -mtune=xscale -mno-thumb -mfloat-abi=soft -mfpu=maverick" 12export ARM_TARGET_LIB=/opt/codesourcery/arm-2009q1/arm-none-linux-gnueabi/libc 13 14scons armeabi=soft wordsize=32 snapshot=off arch=arm library=shared mode=release 15scons armeabi=soft wordsize=32 snapshot=off arch=arm library=shared mode=release sample=shell

Copy the entire v8 directory to the memory stick

I was running Debian in a virtual machine on my OSX machine, so I rSync’ed it

1rsync -avz root@{remote_host_ip}:/root/node-v0.6.7/deps/v8 /Volumes/{memory_stick}/node

Update the Phidget Board

New Firmware

Config (via web interface)

Local Configuration (via SSH) on the Phidget board

1ssh root@phidgetsbc.local 2apt-get update 3apt-get -u upgrade 4apt-get install gcc wget python openssl make scons libssl-dev libax25 libfile-copy-recursive-perl openbsd-inetd tcpd update-inetd python-software-properties pkg-config htop git subversion

Copy over and configure V8

Plug in the USB drive. I kept the now-compiled V8 source in /node/v8 on the memory stick

1export PATH=$PATH:/opt/bin 2echo "/opt/lib" >> /etc/ 3ldconfig 4mkdir /opt/share/v8 5cp -a /media/{usb_stick_usb_path}/node/v8 /opt/share/. 6echo "/opt/share/v8" >> /etc/ 7ldconfig

Add more RAM

This is likely to destroy the memory stick after a lot of use (USB hates random I/O). Create a swap file and configure it (will take ~10 min)

1dd if=/dev/zero of=/media/usb0/swapfile bs=1M count=256 2mkswap /media/usb0/swapfile 3swapon /media/usb0/swapfile


1export JOBS=1 2export CC='gcc -march=armv4 -mfloat-abi=soft' 3export CCFLAGS='-march=armv4 -mfloat-abi=soft' 4export CXX='g++ -march=armv4 -mfloat-abi=soft' 5export GCC='-march=armv4 -mfloat-abi=soft' 6wget 7tar -xvf node-v0.6.7.tar.gz 8rm node-v0.6.7.tar.gz 9cd node-v0.6.7 10./configure --shared-v8 --shared-v8-libpath=/opt/share/v8 --shared-v8-includes=/opt/share/v8/include --without-snapshot 11 ## If the configuration isn't all green, something is wrong 12make 13make install

Note: For me, a few times various parts of the 35 steps make preforms will crash with a segmentation fault. I guess this has to do with ram? Make will resume where you left off last, so just run it again


1curl []( | sh

Contributors to this guide:

Hi, I'm Evan

I write about Technology, Software, and Startups. I use my Product Management, Software Engineering, and Leadership skills to build teams that create world-class digital products.

Get in touch