Running Node.JS on Tizen 2.0

Node.JS is increasingly popular within the robotics community. A quick search on google or youtube brings up multiple nodecopters, and johnny-five implementations. A lot of these have node.js running on a smaller processor and not the original data center server where node.js is traditionally installed. As I was browsing the download site looking to upgrade my SDP to Tizen 2.2 , I happened upon a set of rpm files  and thought I'd try my luck at running some of them. After a few false starts I present here a method of getting node.js running on Tizen 2.0, including the tweaks you need to get npm, the node package manager working as well.                          

To get a Linux command prompt you can connect the phone via USB, and run the SDB tool. The default location for SDB in windows is the  c:\tizen-sdk\tools directory as part of the overall Eclipse-based IDE installation but Ubuntu and Mac-OSX installs also have SDB as a command line option.
 

Connecting to the SDP.

Open up a command window and type "sdb -d shell" to connect directly to the h/w, and to remain in the interactive shell.  Its a fairly standard linux prompt, but its missing command completion, and the cursor escape sequences are not enabled by default. Feel free to play around in this console, "cat /proc/cpuinfo" is interesting to try, especially if you compare it with the same command typed into the sdb shell when you are connected to the emulator. Another fun command to try is "/usr/bin/xeyes".

CPUINFO FOR THE RD_PQ SDP.       Four cores at 1.6Ghz

 

CPUINFO FOR THE EMULATED SDP.       A Pentium 4 at 1.5Ghz

Download your rpm file

For the SDP hardware you need to pickup the ARM little endian rpms. My SDP still has Tizen 2.0 installed, therefore I navigated to http://download.tizen.org/releases/2.0/tizen-2.0_20130219.4/repos/base/a...
I copied the file to my PC and then used SDB to push the rpm to the phone using the following command

sdb -d push nodejs-0.6.14-slp.1.1.armv7l.rpm /

If you start at http://download.tizen.org/releases/ you can find various versions, including "586" versions that will work in the Tizen emulator.
To install this file you can run rpm interactively from SDB, or through the SBD shell, for example the following runs the rpm command and then returns and exits sdb.
 
C:\tizen-sdk\tools>sdb -d shell rpm -i nodejs-0.6.14-slp.1.1.armv7l.rpm.
 
To check its installed correctly type "node -v" at your linux prompt to verify the version matches your rpm file.

 

Create a webserver

 

Copy the following code into a file called hello-world.js : its from an example in Learning Node by Shelley Powers

// load http module
var http = require('http');
// create http server
http.createServer(function (req, res) {
// content header
res.writeHead(200, {'content-type': 'text/plain'});
// write message and signal communication is complete
res.end("Hello, Tizen World!\n");
}).listen(8088);
console.log('Server running on 8088');

Push the file to the phone using the following command

"C:\tizen-sdk\tools>sdb -d push hello-world.js /" 

Remember to add the trailing / as that is the destination directory. The attachment hello-http.zip contains the webserver javascript file.

 
Start an SDB shell, "sdb -d shell" and find the phone's IP address using ifconfig, and run the webserver by typing "node hello-world.js" . The console log message " Server running on 8088" will be printed when it starts.  Note that the webserver port is not 8080, the regular node example port, because there is something running on that port already. At least there was on my phone.
 
 

Start up your browser and point it to your specific inet addr field, highlighted in the picture above, for the wlan0 interface and you will see the following message.

At this point node.js is working, but a few more tweaks are neccesary to get npm, the node package manager working. The sudo package is not installed, and npm command lines use that for installation, and also to find a users home directory. A quick fix is to set the $HOME envireonment variable to point to a writeable directory, in my instance I used /home/tizenapp. That allowed me to install "less" and "coffee-script". Both seem functional, but there's a problem with the coffeescript repl, that I plan to work on.

Next Steps

I want to get sudo installed, and I want to get a newer version of Node.js installed. At the time of writing this article version 0.8.19 is running on my windows bx and version 10.x is public. I also need to upgrade my SDP to version 2.2 of Tizen, and that's a good place to close this article. If you remember, I found this node.js rpm while I was looking for the 2.2 flash images.

I've also got node running on the Tizen Emulator, although I had to install a different binary as the emulator is not the ARM hardware in the phone but is emulating a Pentium class IA Processor.  Ping me on twitter @intel_stewart or @tizenapp if you want more info on that version.

 

 

 

AttachmentSize
Package icon hello-http.zip349 bytes
Device Type: