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.
Node is awesome, Phidgets are awesome. Syngergy. All I wanted to do was tweet the temperature of my house automatically…
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:
SSH to your Debian machine, and su root
1sudo mkdir /opt/codesourcery 2cd /opt/codesourcery 3wget http://www.codesourcery.com/sgpp/lite/arm/portal/package4571/public/arm-none-linux-gnueabi/arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 4tar -xvf arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2z2
1wget http://nodejs.org/dist/v0.6.7/node-v0.6.7.tar.gz 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
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
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
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/ld.so.conf 3ldconfig 4mkdir /opt/share/v8 5cp -a /media/{usb_stick_usb_path}/node/v8 /opt/share/. 6echo "/opt/share/v8" >> /etc/ld.so.conf 7ldconfig
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 http://nodejs.org/dist/v0.6.7/node-v0.6.7.tar.gz 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 [http://npmjs.org/install.sh](http://npmjs.org/install.sh) | sh
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