Using MAAS on OpenCompute – Setting up PXE for Serial Console

This article is using Ubuntu 13.10 (Saucy) as a base install.  One of the issues with using OpenCompute nodes is the fact that it is headless.  One of the issues that generally comes up with all tools, being it Cobler, Mirantis, or MAAS, is that the pxe config is not setup to actually show the serial information.  While playing with Ubuntu MAAS, I did figure out a way to redirect the console to serial to be viewed of SOL.

The first step is to install MAAS following the directions that are posted.  In this case I actually installed MAAS on a non-OpenCompute platform, in this case a laptop that I generally use as the controller.  The reasoning is that I don’t want to waste a power OpenCompute  node on what can easily be ran on a basic computer.

We are going to need to modify the templates that are located at /etc/maas/templates/pxe so that we can setup the bootloader and the kernel params so everything gets redirected to console.  If this is not setup, the lat thing you should see before funky characters would be:

Loading amd64/generic/saucy/xinstall/linux........
Loading amd64/generic/saucy/xinstall/initrd.gz.......................

We first will need to setup the boot loader on each image to redirect to the console.  This can be done by:

# cd /etc/maas/templates/pxe/
# sed -i '1iSERIAL 0 115200n8' config.commissioning.template
# sed -i '1iSERIAL 0 115200n8' config.install.template
# sed -i '1iSERIAL 0 115200n8' config.local.amd64.template
# sed -i '1iSERIAL 0 115200n8' config.local.i386.template
# sed -i '1iSERIAL 0 115200n8' config.local.template
# sed -i '1iSERIAL 0 115200n8' config.xinstall.template

The second piece we have to fix then is having the kernel direct to console also.  This is good for when MAAS does the automated install. This step is easier and what you need to do is go to the MAAS webpage, click on the gear on the top left, and scroll down to the “Global Kernel Parameters” section. Add “console=tty0 console=ttyS4,115200n8″ in the text box and click the “Save” button.

Controlling a RGB LED attached to a Raspberry Pi through Android

This was a bit of a project that I used to learn some new technology.  Note: I am not an EE and I am just learning how to do this.  Proceed with caution if you want to repeat.

Project Description

I need to be able to control turning on and off an RGB LED utilizing the Raspberry Pi.  I also should be able to turn it on and off using an Android device.


The design is made up to utilize three different components: Raspberry Pi / LED Hardware, Web Service, and Android device.

Raspberry Pi

All the gear that was used was:

  • Raspberry Pi – Model B
  • 5mm High Brightness Full-Color LED
  • Breadboard
  • Resistors
  • 3 x Transistors – 2N3904

Some of the constraints I also have to work with are:

  • Each of the 3.3V GPIO pins can handle a maximum current of 16mA.  They might be able to do more, but from what I read, it would not be for long.
  • The Pi takes about 700mA of the total power without anything plugged in (USB, HDMI, etc), so depending on the power adapter used, there might not be enough power.  In this case, I used a 2A plug.
  • Since each color will require more than 16mA of power to turn on, I need to utilize transistors and the 5V pin from the Pi.  I will use the GPIO to handle closing the circuit on an NPN transistor.  I believe I need to use NPN due to the fact that the LED has a common anode.

The R1 resistors are a complete bit of voodoo to me.  I just don’t know enough to do the calculations correctly, so I know they are under powered.  I also took readings and they are no where near high enough to be a concern.  The best I could come up with was that the β / H(fe) for each is about 60 or 54.  That is probably wrong though, but I’m not sure how to follow the white sheet correctly.  I also wasn’t sure what or how to find what the voltage drop is (I hear .7V or .9V), which goes into the calculation.  I checked with the multimeter afterwards and all pieces were very low.


Web Service

To handle allowing an android device to turn the LED on and off, I needed to create a web service that runs on the Raspberry Pi that would allow easy operations to occur.  Due to the fact that I needed to stay a little more light weight, not to mention I wanted to learn Python, I wrote the quick REST service using Python.  To get the work done, I used the following libraries / packages:

I utilized Flask to quickly prototype up a REST service and inside that service, I’m using the gpio-python to handle turning on and off the GPIO pins.

I did go through this quick, so the REST service really isn’t pretty.  It should handle cleanup still and also considerations if it is used in a multi-threaded fashion for keeping track of resource setup, teardown, and usage.

/led/<color>GETGet the status of the current LED color (On or Off)
/led/<color>/onPUTTurn the led color on
/led/<color>/offPUTTurn the led color off
/led/<color>/togglePUTToggle the LED from off to on or vise-versa.

The LED colors are red, green, or blue.  The response code is just plain old text.

Source Code

Android Device

Nothing special here.  Just used the Android SDK and Eclipse.  I then used a Nexus 7 to handle playing with it.  Again, this should have been done a little different if real life, but for now it was quicker to use AsyncTask.  As long as I don’t turn it before I get a response (really hard to do), then I am fine.  There are different opinions on the correct way, which is either an invisible fragment or using a command system to a service running in the background (I prefer the latter, but more complex).




Setting up TomatoUSB for VLANs and Ubiquiti AP

So after getting a quarter of the way through a comment to a question somebody had on my Ubiquiti APs, TomatoUSB, VLANS, and Linksys e3000 post, I realized it would probably work better as a post instead. Christoph’s question was:

How did you wire everything? I’m trying to do the same and had no luck. I only have one UAP, but if I turned on tagging for the Port I used for each bridge, I wouldn’t even get an IP.
I would like Management and Home to be one vlan, and guest another, so my setup is simpler. Maybe knowing how you wired it will help.

I’m going to walk essentially through what steps I remember taking to get up that far.


  • VLAN 2: Home / Management
  • VLAN 3: DMZ
  • UAP plugged into Port 1
  • Admin Computer plugged into Port 4
  • Management / Home network is
  • Guest network is
  • You have a VLAN edition of Toastmans TomatoUSB mode

Setting up TomatoUSB

  1. In the Tomato Web Interface, Advanced -> VLAN, make sure you have VLAN 2 and 3 setup. To add each VLAN, just click the “Add” button and fill in the VLAN and VID so they match. (Fuzzy memory alert) You want to make sure that the existing bridge, br0, is attached to VLAN 2, and make sure that Port 4 has “Yes” for LAN (br0) and Tagged is blank. I set VLAN 15 to WAN. For VLAN 3, the bridge will be set to “none”. Click Save.
  2. Now navigate to Basic -> Network. Under LAN, click to add a new bridge LAN 1 (br1). Make sure DHCP is enabled, IP address is, and netmask is Change the IP Range to whatever range you would like the DHCP server to give out in that ip subnet (so – Scroll down and click Save.
  3. Now go back to Advanced -> VLAN, for the bridge for VLAN 3, now select LAN1 (br1). Click the OK button and then click the Save button at the bottom of the page.
  4. At this point, you will want to setup your ports how you want them (assigned VLAN or tagged). On port 1, you will make sure that both VLAN 2 and VLAN 3 are set as Tagged (will fix later).
  5. Now we need to telnet (or SSH if enabled) into the router to fix port 1 so that VLAN 2 is not tagged, but VLAN 3 is tagged. Follow the steps in the earlier post. Use the “# nvram show | grep vlan2ports” command to which ports are setup on VLAN 2 and with tagging. Just copy those values over into the “nvram set vlan2ports=””” section, and then change 4t to just 4. The ports go in reverse of their name. Click enter, run “nvram commit”, and then “reboot”.
  6. When you go back into Advanced -> VLAN, you should see that Port 1 has VLAN 2 blank in tagged column, but VLAN 3 has Yes.
  7. If you want to allow access from one network to another, go to Advanced -> LAN Access. In there you basically handle a basic firewall access by allowing all access from one vlan to another, or one ip address on a vlan to another ip on another vlan or the entire vlan. Unfortunately, it does not do firewally at a port level. You will need to use the command line in Tomato to do that if you need it. This is only for firewalls between VLANs though, as port forwarding from the outside is done the traditional way.

Setting up Ubiquiti AP
When setting up Ubiquiti, your home network SSID should not be assigned to a VLAN (leave it blank). Your guest network SSID should be assigned to VLAN 3. At this point, if all went well, your AP should pick up an IP and clients on each SSID should get assigned to the correct subnet.

Compiling Intel’s Data Center Manageability Interface on 64-bit

I needed to use Intel’s Data Center Manageability Interface program to interface with IPMI that does not have a dedicated controller, so we needed to use software emulation. Two issues that we had were:

  1. The binaries provided on their website didn’t work due to needing older libraries that had deprecated functions in them.
  2. Source code didn’t compile because of those same libraries that were missing.

I’m including a patch for DCMI_Conformance.cpp that will allow it to compile on Ubuntu 12.04 64-bit. The source came from ipdc-1-5-0-31-0-src.tar.gz, which was downloaded from Intels site. Just make sure that you have the dev libraries installed for ncurses and libssl.

RocketRaid 622 Driver (rr62x) for Ubuntu Linux Kernel 3.8

More of a reference for myself so that I don’t have to go through this again, but I put together the patches people had in multiple places so that I can install rr62x-dkms on my 12.04 system. Probably a better way to do this, but I’m tired and just wanted to get the system up.

File: rr62x-dkms_1.1_all-3.8.deb

Resources Used

Ubiquiti APs, TomatoUSB, VLANS, and Linksys e3000

Try not to get too shocked, but this actually an article about networking.

Back story, I picked up some Ubiquiti AP’s for a good price to install around the house. While I have these nice enterprise AP’s, I decided to redesign my home network utilizing VLANs to provide a management vlan, home vlan, dmz vlan, and a guest vlan. I set out to do this utilizing gear that I had laying around that consisted of:

To start off, I decided that I was going to utilize my two e3000’s as a router and a smart switch. I decided to continue to use the TomatoUSB ROM on those routers, but upgrade to the Toastman version (1.28.7502.7) that had experimental VLAN support.

The Design
In the end, I wanted to have four different vlans:

  • VLAN2 – Management
  • VLAN3 – Home Use
  • VLAN4 – DMZ
  • VLAN5 – Guest

In addition, I wanted to have multiple SSIDs on the Ubiquiti AP’s that mapped to specific VLANS:

  • Home – VLAN3
  • Automation – VLAN4
  • Guest – VLAN5

The nice thing about the Ubiquiti AP’s is that they allow multiple SSIDs to be set and also it will add tags to the packets. The only gotcha was that the non-vlan SSIDs and AP needed to be setup on a non-tagged vlan or native vlan.

The Problem
After many hours of trying to get Tomato to work correctly, it turns out that the problem is that I needed to have VLAN2 setup as non-tagged, while VLAN3-5 needed to have tagging on. The GUI had an option for setting the default, but that did not work and packets were ignored. The other issue was that the gui didn’t allow you to set VLAN’s that were tagged for a port and then add an untagged VLAN on that same port. It was either all VLANs were tagged or it would only let you select one untagged VLAN and no other VLANS.

The Solution
After many hours of trying to figure out what was going on, I realized that the firmware wasn’t handling untagged traffic correctly. The solution was that I needed to telnet into each of the routers and update the nvram values directly to specify that the port should be used, but not tagged, while the other VLANS would be tagged.

To do that, I started off by going through the gui and marking all the VLANS on that port connected to the AP as tagged. I then telneted into the router and did a
# nvram show | grep vlan2ports
which presented me with
lan2ports=3t 4t 8*
The problem was that the second port needed to be updated to not allow tags, so it was as simple as removing the “t” from “3t”. I then reloaded the updated line into nvram, commited it, and then rebooted.
# nvram set vlan2ports="3 4t 8*"
# nvram commit
# reboot

When it came back up, the Ubiquiti software controller found the AP on the correct port and configured it correctly. Then the clients started to reconnect and went to the correct VLAN depending on the SSID assigned.

Now when I go to the admin page for VLANs, I see this:

Sound on Dell XPS L702X in Linux

After getting the sound working on the laptop, I was still running into issues with distorted sound and the sub woofer not working. The sound chipset that is in it is Intel, as can be seen by:

00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 05)

The fix was by adding some additional commands to the snd-hda-intel module:

echo "options snd-hda-intel model=ref index=0" >> /etc/modprobe.d/sound.conf
echo "options snd-hda-intel model=6stack-full" >> /etc/modprobe.d/sound.conf

Accessing your eBook collection managed by Calibre without Calibre Server

This post is about how I’ve been going about enabling access to my eBook purchases that are managed with Calibre without actually using the built in Calibre Server.  All of this is running on Linux, with my eBooks and Calibre Library sitting on a remote Linux File Share.

The reason that I’m not using the Calibre Server to do the distribution is because:

  1. I actually store all the eBooks and the Calibre database on a Linux file share that is then shared on my network using Samba.
  2. I use multiple computers to interact with that Calibre database (not at the same time).  They are all setup to open the database on the samba share.
  3. The file share is headless and does not have X installed

So to do this, the first thing I had to do was setup the directory on my file share and then setup samba to share it out to the network.  Once that was done, I then mounted the share on my client computer.  With that done, when I started Calibre for the first time, I just change the configuration to use the samba share directory.  Now whenever I open Calibre, all the eBooks and database files are now stored and shared internally on my file share.

That was great and all, but I also wanted to be able to easily browse the collection inside and outside my network.  To do that, I figured the best way is using a web browser.  After looking around very quickly, I decided to use a software called, “Calibre PHP Server“, since the file server already had Apache and PHP installed on it.  I do have to warn, it’s not the best software out there and the design choices aren’t the best, but it is functional and I was able to get it up and working without having to write it myself.

To get it working with Apache, I created a new sub-domain to put it under, something like  At that point, the configuration for it was very simple.

<virtualhost *:80>
        DocumentRoot "/var/www/"
        <directory "/var/www/">
                AllowOverride All
                Allow from All

After that, I just followed the instructions that came with the software for setting it up.  I also added the optional section, which restricts who can access the books, so that only my wife and I have access to our library.  As I mentioned, the interface isn’t the best, but it is functional.  One area that I ran into issues with was the configuration files.  The first one was the “$config[‘smarty’]” option, which when you install smarty in Ubuntu, you will use, “$config[‘smarty’] = ‘/usr/share/php/smarty';”  The other issue is with the, “$config[‘smarty_dir’]”.  I found that no matter what value you enter into it, it won’t work unless you create an additional directory by hand under it called, “smarty_templates_c”.  So for example, if you specify it as “$config[‘smarty_dir’]=’/tmp/smarty'”, then you will then need to create the additional directory as so, “# mkdir /tmp/smarty/smarty_templates_c”.

Now my wife doesn’t have to ask me to put eBooks on her Nook Color anymore, but knows to go to that website when she wants to get one of her books and just download it that way.  It will basically work with any browser and shows all the different file contents it contains.  In our case, we have some PDF’s and epubs.  It works flawlessly.

The next step that I want to take when I have time is to come up with an additional way to use access the library with the source being a OPDS server.  There are two pieces of software that I’m currently looking at, but haven’t had time to play around with them to see which way I like best.  Until then though, this solution is working good for us both.

Subversion diff from url to local directory working copy

For some reason there is some bad information out there on comparing a local working copy in a branch to that of a subversion url.  In this case, I really wanted to know how far off this branch code that wasn’t commited is from the trunk.  To do that, you just need to use the ‘–old’ and ‘–new’ flags.

$ cd ./branches/one
$ svn diff --old=svn://server/Project/trunk --new=. > working.diff

Then all that needs to be done to update a branch of trunk to that is:

$ patch -p0 -i workingdiff.diff

My IOIO for Android is here

The IOIO for Android that I recently purchased has shown up!!!  I haven’t had time to play with it or even know much about how to start playing with it, but I will be figuring it out quickly.  If you’re not sure what it is, a quick description from their website is:

The IOIO (pronounced “yo-yo”) is a board specially designed to work with your Android 1.5 and later device. The board provides robust connectivity to an Android device via a USB or Bluetooth connection and is fully controllable from within an Android application using a simple and intuitive Java API - no embedded programming or external programmer will ever be needed!

So setup as it’s default use, it’s not using the new Google Open Accessory (ADK) protocol, which is what I really want to develop with once I get far enough along in Android programming and being able to do some prototypes on the board.  I figure once I get far enough along, that I’ll be turning on blinking LED’s, and from there the worlds the limit, even though I do know what I want the end result to be with it.

The bad news at this point is that the ADK firmware on it is still very beta.  Even to update the device, I need a PIC programmer capable of programming PIC24FJ128DA206.  So that means until it comes out of beta, I can’t use it for the ADK protocol or I ask some EE friends if they have one laying around.  Even if I take the friend route to update it to the beta, it still has the following problematic caveat:

Due to problems with the accessory library implementation (i.e. the Android OS code supporting the protocol) – the IOIO connection will not be properly closed when pausing (and exiting) your IOIO app. When the app is resumed (restarted) it will hang. The current workaround is to physically disconnect and reconnect the IOIO (or power-cycle it).

This is because of a problem in the Android OpenAccessory library preventing the app from gracefully closing the ADK connection. To work around this problem, detach and re-attach the IOIO when that happens (or power-cycle it). Another option is to force-close the app.

Not something that I would call usable in a real life situation.  Hopefully it does get resolved though.  At this point though, since my original plan is for a single use at this point, if all else fails, I’ll just use their implementation of the communication protocol for the initial project.  Either library I use in the end, both will be good learning experiences on making and developing for new accessories to work with Android.