OpenWRT and Scripting Languages, Part 1


The RGB wall light project is currently on hold due to a massive lack of time. Still, I’m taking little steps of preparation for the second phase of the project, the software intended to control the RGB matrix. I could use the gcc cross compiler for the job, but using a scripting language to develop directly on the device promises to be far more comfortable. I’d like to narrow this down to languages readily available as packages for OpenWRT which leaves me with Erlang, Lua, Ruby, Perl, and Python. Since I feel like trying something new I’m going to rule out Perl for now.

Make Room

The installation of the bleeding edge OpenWRT version called “Attitude Adjustment” on the TL-MR3220 leaves about 1MB of space for additional packages to be installed – which isn’t even close to being enough for this purpose. So, the first step is to extend that space and the currently recommended way to do this is to move the overlay mount to an external USB device:

  • Find a USB flash drive, create an ext3 formatted partition on it using a Linux box and insert it into the USB port of the router.
  • Boot the router and install the packages needed to access the device and to move the overlay file system:
opkg install kmod-usb-storage
opkg install kmod-fs-ext4
opkg install block-mount
  • Temporarily mount the partition on the USB drive and copy the current contents from the /overlay directory:
mount /dev/sda1 /mnt/sda1
tar -C /overlay -cvf - . | tar -C /mnt/sda1 -xf -
  • Edit /etc/config/fstab to configure the USB partition as the new overlay:
config mount
        option target           /overlay
        option device           /dev/sda1
        option fstype           ext3
        option options          rw,sync
        option enabled          1
        option enabled_fsck     0
  • Reboot.

Ruby

Now that I had almost 4GB of space to install OpenWRT packages I decided to give Ruby the first shot.I started out by installing the following ruby packages from the current OpenWRT trunk:

opkg install ruby ruby-core ruby-gems ruby-dl ruby-enc

Next, I tried to install additional Ruby libs using gem – but gem just complained “no such file to load — zlib“. Investigating this, I discovered that the ruby-zlib package that opkg installed as a dependency was actually empty.  This is currently a known issue that affects OpenWRT trunk as well as the Backfire release candidates 5 and 6. I was able to work around this by installing the ruby-zlib package from Backfire RC4 instead:

wget http://downloads.openwrt.org/backfire/10.03.1-rc4/ar71xx/packages/ruby-zlib_1.9.1-p376-3_ar71xx.ipk
opkg --force-downgrade install ruby-zlib_1.9.1-p376-3_ar71xx.ipk

But still Ruby would refuse to function properly. When trying to open an HTTP connection, it would fail with a new error message: “ruby: can’t resolve symbol ‘getipnodebyname’ ” This turned out to be another known issue that could be worked around by replacing the socket.so library installed by the ruby-core package with the one from the last Backfire release candidate.

It was only then that I discovered that there is no ruby-serialport package in the current OpenWRT trunk. Installing the serial port library using gem  wouldn’t work either since it requires native binary compilation. Maybe I can find the package in some older OpenWRT distribution — but this was the point that I gave up for now and switched to plan B.

(…to be continued…)

, , ,

  1. #1 by Jens on December 22, 2012 - 3:32 pm

    Did you find an alternative solution for this yet?

(will not be published)