Wednesday 29 July 2015

Running Wetty.js in MIPS platform


The objective of this post is to explain the step-by-step procedure on bringing up wetty node-module in a linux OS based on MIPS architecture.


About Wetty


Wetty is a web based tty. It allows us to open a tty (text terminal) session in a web browser to access the remote machine. Normally we use a standard tty client such as putty or Xshell to access the remote machine. Wetty gives us the flexibility of accessing remote machine from a browser without the need of any other software.

Wetty is a node.js module and it runs on top of node.js


Prerequisites:

  1. Download node.js source code (https://nodejs.org/download/); v0.12.7 is the current version during the time of writing
  2. Clone wetty (https://github.com/krishnasrinivas/wetty)
  3. Host Linux (virtual) machine for cross compiling
  4. MIPS toolchain
I prefer to run a virtual machine in vagrant environment, it is so easy to configure and bring up a VM in vagrant. And file sharing between virtual machine and host is also so simple.

Cross compiling Node.js


|> Download node.js source code and prepare the build folder

# mkdir -p /usr/venkateshm/source/nodejs
# cd /usr/venkateshm/source/nodejs
# curl -O https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz
# tar xvf node-v0.12.7.tar.gz
# cd node-v0.12.7

|> Set the necessary terminal variables

# export TC_PATH=/usr/venkateshm/toolchain/stbgcc-4.5.3-2.4/bin
# export CC=$TC_PATH/mipsel-linux-gcc
# export AR=$TC_PATH/mipsel-linux-ar
# export CXX=$TC_PATH/mipsel-linux-g++
# export LINK=$TC_PATH/mipsel-linux-g++

|> Configure the make; the configuration for node.js is written is python so python 2.5 or 2.6 is required before running the below command

# ./configure --dest-cpu=mipsel --dest-os=linux --prefix=/usr/local/nodejs --without-snapshot
# vi config.gypi

|> Add following entry under variables 

'mips_arch_variant': 'mips32r1'

|> Make

# make
# make install



copy out/Release/node and put it in /usr/local/bin folder of MIPS machine


Installing wetty in MIPS



Most of the nodejs modules are platform independent as they will be written in javascript. But few modules like websocket are dependent on platform as they use platform specific implementation. 

Wetty is platform independent but its dependencies modules websocket and pts.js are platform dependent. 

Node.js ships with a utility called node.gyp to handle the cases like machine dependent node-module, this utility builds the node-module and generates .node file.

The easy approach is to install wetty first in host virtual machine

# git clone https://github.com/krishnasrinivas/wetty.git
# cd wetty
# npm install

Now all the dependencies of wetty are successful downloaded and can be found inside node_modules folder.

Now download the source of websocket and pty.js node-module

# git clone https://github.com/theturtle32/WebSocket-Node.git
# cd WebSocket-Node
# npm install nan
# /usr/venkateshm/source/nodejs/node-v0.12.7/deps/npm/bin/node-gyp-bin/node-gyp --arch mipsel configure build


If the build is successful, copy the generated build folder and replace it in wetty/node_modules/websocket/build

Similarly steps for pty.js

# git clone https://github.com/chjj/pty.js.git
# cd pty.js
# npm install nan
# /usr/venkateshm/source/nodejs/node-v0.12.7/deps/npm/bin/node-gyp-bin/node-gyp --arch mipsel configure build

No comments:

Post a Comment