Fork me on GitHub

Tom Gallacher

How to install Node.js on your Raspberry Pi;

Edit: for use with nodejs > 0.8 use this -> https://github.com/gflarity/node_pi

Disclaimer: I am not a unix god, and pretty much hacked this together to get working (and it does for me), so a more concise method might appear, so I you do find one let me know, also if you break your PI it is not my fault =] .

So you have just received your raspberry pi and are thinking about running nodejs on it, good. Lets get started.

I am assuming that you have pre-installed the debian flavoured distribution, have enough space and are up and running. If your having problems pop over to the Raspberry Pi Forums and they will be able to help you out!

First we need to install the OpenSSL dev libraries for SSL support, you can skip this step by using the --without-ssl flag when configuring.

$ sudo apt-get install libssl-dev

First we need to download the latest stable release v0.6.15 (Having problems compiling the unstable branch at the moment 0.7.X).

$ wget http://nodejs.org/dist/v0.6.15/node-v0.6.15.tar.gz
$ tar -xf node-v0.6.15.tar.gz
$ cd node-v0.6.15
$ export CCFLAGS='-march=armv6'
$ export CXXFLAGS='-march=armv6'

Now to edit the following file:

$ vim deps/v8/SConstruct

Or you can use nano if you prefer, first you need to adjust line 82 and 83 to match the following

 'all': {
   'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv6'],
   'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions', '-march=armv6'],
 },

Then you need to comment out lines 157-162.

Important: Make sure to remove the comma from the end of 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0']

 'armeabi:softfp' : {
   'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0']
  # 'vfp3:on': {
  #   'CPPDEFINES' : ['CAN_USE_VFP_INSTRUCTIONS']
  # },
  # 'simulator:none': {
  #   'CCFLAGS':     ['-mfloat-abi=softfp'],
  # }
 },


$ ./configure

The next step will take a while to finish ~40mins

$ make
$ make install

You will now have a working nodejs installation and also have access to npm nodejs’ package manager. If you are using ARM Arch linux then you can download a maintained tarball from http://archlinuxarm.org/arm/community/nodejs-0.6.15-1.1-arm.pkg.tar.xz or as @WarheadsSE pointed out use:

$ pacman -S nodejs

I am in the process of making some benchmarks to see how much this $35 computer can handle, I did get my personal website running last night pi.tomg.co and seemed to handle the traffic quite well. Such an amazing piece of kit!

If you make anything awesome then let me know on twitter @tomgco or email me me[at]tomg.co!

Here are some more semi-colons! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Here is a benchmark of Dis.io - my browser based distributed computing platform running with 4-8 clients.

Edit: May have made a mistake - but the comparison on completion time is accurate.

Here is a benchmark of Dis.io - my browser based distributed computing platform running with 4-8 clients.

Edit: May have made a mistake - but the comparison on completion time is accurate.

Last week of dissertation.

Wow, so where do I start…

The end is so close now, exams have been completed, final year project has been successfully designed and implemented - may I add it runs a treat, benchmarks coming up soon and maybe even a live version! All I have to do now is finish the writeup and graduate.

Scary stuff.

So what projects will I be working on next?

I have some epic ideas for some projects which I am going to implementing, and I will be on this like a rabbit in spring (I did google this to be technically correct, its February to October :] ). But the lot of you that a curious here are some ideas I have lined up: Littenote, Key-bind library (A really decent one for those ctrl+s’), discussions for twitter, iTunes search by album colour and of course dis.io!

And some epic Raspberry Pi stuff, so watch this space and the Linux User & Developer Magazine - I will be writing some awesome tutorials! ;]

Dissertation Update: dis.io

So, I have been keeping some sort of personal journal where I have been jotting down all my ideas, research and prototypes for my Dissertation because of this I haven’t really felt that it was possible or that I was able to document what I was doing without examples and giving too much away =], however I digress as I have now got to the stage where I have lots of different things to say. This blog will now be part of a weekly summary on current progress and generally interesting problems I have encountered.

Software Development Methodology

For the whole process of conceptualising, designing, building and testing my project I have decided to follow the V-Model. Now I have many reasons why I have chosen this over a more agile route such as scrum, however the main reason is that V-model is much easier to adhere to with a team of one, than choosing a model which requires a team to work well. Not to mention that the marks from using the V-model are much easier to nail down. [1-∞] If you are not familier with this then checkout wikipedia, or the image below:

Fig 1.

V-Model

FYI, I am skipping my requirements here.

Introduction to dis.io

So the main goal of my application, system, SaaS or whatever you want to call it is to be able to calculate computational complex tasks and distribute the processing of these tasks to clients. Where this differs from a traditional distributed computing platform such as (Folding@Home, BONIC) is the machines doing the leg work (Workers) are being utilised via the web browser using the WebWorkers API. The other main aspect of dis.io is the ad-hoc nature of each component of the system allowing it to be scaled by just spawning new processes. This means that dis.io should not have a single point of failure (lynchpin).

Components

Here is a breakdown of components:

  • Dashboard - Web interface for creating new tasks
  • Manager - Manages the Distributors for a task and sends a WorkUnit
  • Distributor - Distributes these WorkUnits to clients (Change of name likely)
  • Client - Runs the WorkUnits

I will start with how I find it easiest to explain, starting from the client facing code and work my way through the system design as it currently stands. (which possibly will not be that long!)

Clients will be be giving a WorkUnit when visiting a dis.io enabled website. The WorkUnit will contain a UserID, a distributor location, the actual code to run, the data to run against it and a deadline for a result to be produced. It will then be ran every time the user visits an enabled site.

Distributors facilitate the clients with it’s associated WorkUnit and then queues the received results back to it’s manager. It is possible to have multiple distributors with the same WorkUnits, this will scale depending on the load and how many connections etc.

Manager’s will be the intelligence for the distributors, providing stats on what is queued, how many iterations of the WorkUnits should be carried out, amalgamating the results and verifying the integrity.

The dashboard will allow the user to upload the tasks and modify due dates and presents the data and the results back to the user.

Status

Well now you know roughly what my project, I have left out some fundamentals as I will be writing for hours. Currently I am starting to build some components which I have nailed down the design for and that I know will not change (apart from possibly minor things).

I have also built some WorkUnits, and the framework to run these, either in the browser / experimental support for a node cli version.

The work-units include:

  • Generating the nth digit of PI using BBP (Bailey-Borwein-Plouffe) method
  • a Smoke test
  • a potential performance indicator

Thanks for reading, have any questions send them to me on twitter (@tomgco), the next version should be out in a week hopefully =]

I am going Dvorak.

For this week I am going to change my keyboard layout from QWERTY to DVORAK.

DVORAK is an alternative keyboard layout patented in 1936 by Dr. August Dvorak. This was conceptualised to provide a keyboard which improves typing speeds. It manages this because Qwerty was invented to prevent type writers jamming.

Why?

Because I can. I think having useless skills is pretty cool, also it will force me to pay more attention to my typing :P

Something I have been working on

I just thought I should share something with you, my latest project:

Little Note

Currently in a closed beta email to get in, Little Note is a lightweight note application.

What sets this aside from other note apps is that notes are stored on your dropbox account, cutting our sever costs right the way down. All we do is host the API and client-side code.

So yeah check it out, and if you do sign up for the beta mention that you read it on my blog and you will get awesome geek cred - including the ability to talk to me over email! How 1999!

My Dissertation and Project

"A browser based distributed computing platform utilising idle cpu cycles on visitors computers when browsing certain websites"

Pretty happy with how that sounds.

Will be utilising NodeJS for the distribution server and JavaScript Web Workers to compute work units in the browser with the possibility to expand and create native plugins for the browsers.

Going to be a pretty brutal but fun build =P

Well my housemate (@kieranajp) wanted to be able to control two multiple inputs from different audio sources to one pair of speakers. Usually I would tell him to use a software solution however his other machine is a massive gamimg beast. Power consumption == £££ || $$$.

So basically we purchased the components soldered it together and chucked it in a box:

1 x Tripad Board

1 x DPDT switch

3 x 3.5mm sockets

1 x Ice Bluebox

As you can see from the final result… sexy!

Well my housemate (@kieranajp) wanted to be able to control two multiple inputs from different audio sources to one pair of speakers. Usually I would tell him to use a software solution however his other machine is a massive gamimg beast. Power consumption == £££ || $$$.

So basically we purchased the components soldered it together and chucked it in a box:

1 x Tripad Board

1 x DPDT switch

3 x 3.5mm sockets

1 x Ice Bluebox

As you can see from the final result… sexy!

Where have I gone?

Well I blame posterous for changing their backend and confusing me; however the real culprit is starting my final year at university…

I have been working on very small things such as a USB powered ghost, pumpkin carving and some software updates on the SYMA helicopter which will all be revealed at some point in the future. With the release of Battlefield 3 myself and my house mates have been engrossed in multiplayer.

Gzippo

I do have some sad news though - well good for you, bad for me news! With the release of Node.js 0.6 a new ZLib API has been introduced and as I thought gzipping will be added to the latest version of Connect and ExpressJS; This means that gzippo is reaching end of life… however I will still be maintaining gzippo and depending how good @tjholowaychuk’s implementation possibly new features, including the native node.js API.

New App in the making! (Hot off the press)

Myself and Chris Garbe (@5utekh) have also started thinking about a new and exiting app which we will be working on in our own time; it’s an exiting and simple product which we think will smash the market ;]

I will let more informational out at a later date!

Syma 107 Arduino Helicopter - Part two

Just a Quick One

Yesterday I received a a package, inside was my brand new Syma 107 IR Controlled Helicopter in red, before I even flew it myself I had to try and get my Arduino to raise and lower it. I open up my code into the Arduino IDE and uploaded, as normal it didn’t work first time, I ended up tinkering with the timings etc, until I got them right and the propellers spun up! It was game time.

The source for the proof of concept is available on Github, please feel free to fork, watch the project or even better follow me!

The Hard Stuff

As I have now got the device communicating with the Arduino the next step is to create a program which controls the helicopter, to begin with this will just emulate the controller which comes with the helicopter, I will be creating a framework so that you can have easy access to the Arduino.

I originally intended to write the whole package in Java (Cross Platform), however after pondering the pro’s and con’s I decided to write it in Objective-C (Mac OS X) only because I though I would benefit from learning more Objective-C - possibly something I will regret at a later date. Don’t fret though, I have got someone lined up to create a C# version for windows. Now if you are a linux user, which as you can tell from my site I do adore then you will be disappointed at the moment.

Both the ArduinoCopterS107 and the Arduino version are released under the MIT License, however I would like to know if you are going to use it (for self satisfaction =]). My next post will be a demonstration of the helicopter flying around whilst being controlled by my mac, in the mean time here is a little video to show you the helicopter rising out of shot and then crashing on my bed whilst being controlled by the arduino.

The Software

  - Arduino Code

  - Arduino Controller for Mac OS X