Saturday, August 22, 2015

Cloud 9 IDE on Edison


One of the things I like about the BeagleBone(Black) is that it comes with Cloud 9 IDE off the shelf which means that you do not need to install any kind of software (other than a browser) on your host system to start developing something on the board.
In this post we are going to talk about bringing the cloud 9 IDE experience onto the Edison.


What is Cloud 9 IDE?
Cloud 9 IDE wikipedia enrty reads "Cloud9 IDE is a freeware online integrated development environment. It supports more than 40 programming languages, including PHP, Ruby, Python, JavaScript with Node.js, and Go". While the online service is freeware, the IDE component used in the service is open source (GPL'ed) and this was wikipedia says of the IDE component "It is written almost entirely in JavaScript, and uses Node.js on the back-end. The editor component uses Ace".
By following the instructions on this blog, we will have Edison hosting the Cloud 9 IDE using which you will be able to write and execute code from your browser.

The remainder of this post talks about how I went about setting up and preparing the Edison to setup the Cloud 9 IDE.

Preparing the Edison:
The preparation process involves downloading and compiling certain packages which can easily take up the allocated space for the root file system on eMMC of the Edison so you'll have to boot from the SD card to complete this process. 
Refer to this nice document written by friend +Ghanashyam Prabhu on instructions for booting from SD card.

Installing the Cloud 9 IDE:
First thing to do is update the repo list, if you have not done already. Refer to this link if you want to add the repos.We need to install git once the repos are added:

opkg update 
opkg install git

Then clone the repo onto your directory in Edison:

git clone https://github.com/navin-bhaskar/Cloud9-on-Intel-Edison.git c9 
cd c9

Install the Cloud 9 with following command:

sh Setup_Cloud9_On_Edison.sh install 

During the process of installation, you'll be prompted to enter your choice if you want to install "ps" program with full set of options, as opposed to installed busy box version on the Edison. It is strongly recommended that you accept the default and install the suggested "ps" without which the IDE would not identify the spawned process and will not be able to stop it.

Start the server with following command:

sh Setup_Cloud9_On_Edison.sh 

Stop the server with ctrl-c.

Your workspace will be placed in directory "/home/root/c9wks" by default.

What does the script do?
If "install" argument is passed:
The Clod 9 SDK expects node v0.12.0. The node that is shipped with Eidson is v0.10.0 so the first thing it does is, gets the node source, compiles and installs it on Edison.Then libevent and tmux packages are installed. While the default LD path on Edison is /usr/lib, we also need to export the lib path /usr/local/lib where the libevent will be installed and tmux config file for some reason is only able to detect it from this path and passing the libevent location to config din't work. The Edison already comes with slightly older version of libevent so you will now have two versions of libevent.

If the script is not passed any argument:
Then the server is started with following command:
./server.js -p 8080 -l 0.0.0.0 -a : -w $WKS

What do I do next?
Start up the browser and navigate to your board with 8080 as port:

http:<Edison's_ip_address>:8080

You can use ifconfig to know the IP address of the Edison or read the log message printed out when you started the Cloud 9 server in the previous step.


Here you can type and execute code and also can debug Javascript files.

Why not on Galileo?
If you have been following my blog for some time, you might have noticed the trend that I tend to do same project on both the Galileo and Edison. I started out with Galileo on this one but soon discovered that the node 0.12.0 version required by c9sdk cannot be installed on Galileo since node does not work on non SSE2 and CMOV architectures (on Intel based processors). Need to explore if c9sdk can still be used with older version of node.

Demo:
So now is the time for demo. In video below you can see me running a python script and debugging a javascript file both of which are meant to blink LED connected to port5.


Instructable:
You can find step by step instructions for setting up the Cloud 9 IDE on Edison here.

No comments:

Post a Comment