Adventures with an Onion Omega2Pro

Introduction #

I love development boards and single board computers for how versatile they are. Among development boards I have a few favorite ones; one of which is a Tessel 2, and the other being an Onion Omega 2. Both of these boards run a distribution of Linux based on the OpenWRT project. The Onion Omega 2 is newer than the Tessel 2 and has more RAM, but it’s surprising how similar these boards are.

I like the mission of both boards. They strive to make building products easy, by greatly lowering the barrier to entry to build stuff because you can bring your own runtime. Don’t like writing C / C++ ? use Python, Rust, JavaScript (on Node) with full access to GPIO, I2C and SPI peripherals. This is what makes the IoT ecosystem far more approachable.

The Omega2 Pro #

Recently Onion announced a new development board called the Omega2Pro. The reason why this board intrigued me was that it had a lot more storage out of the box, and that it had 512MB of Memory (128 MB RAM and 384 MB of flash memory for swap). This was going be very useful for a project I had in mind.

The Project #

When building new things, one of my go to programming languages is JavaScript. When building web apps, I have the luxury of using full blown development tools built in to the browser (Chrome DevTools). However, when using Node.js running on the Omega2Pro, I can’t use DevTools and all it’s goodness. I have to typically resort to logging extensively and I lose the ability to look at stack / heap allocations or to take heap snapshots etc. I desperately wanted to get DevTools to work with Node.js running on my Omega2Pro.

The good news is that the Node.js runtime (based on V8) has support for the Chrome DevTools protocol (which in turn is used by the developer tools frontend) starting release 6.15. So as long as I used a reasonably new version of Node, I would be okay. All I had to do was to compile a version of Node.js from source to run on the Omega2Pro using their toolchain with the inspector feature turned on.

The Process #

Building Node.js from source is something I had never done. So I spent a few days to understand some of the moving parts in the Node.js build system (node-gyp). Building Node.js is not that hard, as long as you have the right setup. The compiler would have to target the mips architecture (because the Omega2Pro runs a MIPS based chipset). This meant that I was going to have to cross compile Node.js for MIPS, given I was using an Intel core-i7 Ubuntu 18.04 (x64). For this, I had to setup the Onion Omega2Pro’s toolchain. Omega2Pro’s toolchain is open source. I used the openwrt-18.06 branch to set things up. I broadly followed these instructions, which I am summarizing below

Onion Omega2Pro’s default feeds’ include a Node.js package (v8.10). Unfortunately for me, this did not include the support for Chrome DevTools protocol. I also wanted to use the latest LTS (long term support) release of Node which is version 8.14 .

Thankfully the internet is awesome, and the good folks at nxhack/openwrt-node-packages already publish a feed with ready to use Node.js packages for OpenWRT. This tracks the latest stable version of Node 8. So I decided to use that. All I had to do was:

Now, the Fun Part #

Now, all I had to do to get Chrome DevTools to work was to add support for the Chrome DevTools inspector protocol. I read this wiki and I figured out the next steps.

none is what gets passed in when building Node.js without making any modifications to the Makefile. I think this is being done to minimize the size of the eventual binary.

Here is the gist which should make it very clear.

Testing & Demos #

Add IP Address for the Omega2Pro


Now read this

Day 12

Took lots of photos walking though San Francisco today. Started off at China Town, walked though the Piers and the Embarcadero, Presidio and finally to the Golden Gate Bridge. According to my Apple watch Steve and I walked around 12... Continue →