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.

This could be useful in cases where you have deployed the Edison and is not easily accessible physically or you are too lazy to connect to the Edison using wires and you want to develop some application on Edison.

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

[caption id="attachment_407" align="aligncenter" width="413"]Cloud 9 IDE runnig on Edison Cloud 9 IDE running on Edison[/caption]

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. 
You can refer to this post if you want to boot 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 c9 
cd c9

Install the Cloud 9 with following command:(Warning: Running this script will replace Node v0.10.0 on Edison with version v0.12.0 and also installs a different version of the "ps" program)

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.

The script will take 4-5 hours complete.

Start the server with following command:


Stop the server by pressing ctrl-c in the console.

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 -a $USR_NAME:$PSWD -w $WKS

There are two things that are configurable in the script:

  • WKS: Workspace path - This is where all the files created will be stored

  • USR_NAME, PSWD : User name and password : When specified, you will be prompted to enter these when the Edison is accessed from the browser

You will find these variables at the very beginning of the script.

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


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 and also you get access to the console.

You can start this script every time the Edison boot up using cron.

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.

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.


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

No comments:

Post a Comment