I accepted a position at Roku in Saratoga, CA last February (2/2014) working in their New Products division as a Senior Software Engineer. We’re doing some great systems software work. Its very interesting to work on video and streaming which I haven’t dealt with much in the past.

I recently graduated from UC Davis with a Ph.D. in Electrical and Computer engineering. Currently I am looking for a full-time position in Northern California in embedded systems and software. My Ph.D. work focused on adapting software to energy constraints and predicting smartphone battery life. I’m looking to join a exciting team in research or new product development. If you have any opportunities in embedded systems please review my CV and contact me directly.

I found a great little utility today for recording/playing back keyboard and mouse events in Linux: cnee. If you’re using Ubuntu just install the ‘xnee‘ package. There are many options so here’s an example which records and plays back mouse events and saves them at /tmp/xnee.xns:

cnee –record –mouse -o /tmp/xnee.xns

Then to replay the events you can use this command:

cnee –replay -f /tmp/xnee.xns

There are other options that are helpful such as the percent of real speed (-sp) and events to record (–events-to-record).

When working on embedded devices, the build system doesn’t work out of the box for the latest Linux distributions. This leads the developer to either choose to keep their whole system on the older version or attempt to patch all the problems that have crept in. It shouldn’t be that way, you can have your cake and eat it too.

The way you get around this conundrum is by creating a chroot environment to do your building in. The basic idea is you have a folder that contains all the Linux system file inside it and they you “change your root folder” to be that folder. You’re running the same kernel just a different filesystem. For Ubuntu, there is a nice tool called “schroot” to manage this process. See the Ubuntu wiki page for details.

Here some tips on how to get the source for a given Linux kernel that you would like to tweak. I needed to do this to play with the Android emulator. So when the kernel boots after decompression you’ll see a line like this:

I’ve highlighted in bold the bits we need. The first tells us the kernel version so we know what branch to look for, but really all we need is the second bit which is the SHA1 git hash for the tree containing the kernel. So if we go to the right kernel repository (See my previous entry about that) all we have to do is checkout that tree:

git checkout 24ee4d2

Lastly, we need the configuration for the kernel. Luckily the Android kernel usually has a copy in the /proc directory called /proc/config.gz. All we have to do is copy that to the kernel directory, gunzip it, rename it .config and run:

make oldconfig

This command will prompt for any new options that are not defined in the .config file so if we found the right kernel tree and config file, there will be no prompts. If there are prompts, keep searching because you haven’t found it yet. I’m not sure exactly what happens when you patch the kernel, build it, and don’t commit it in because there wouldn’t be a SHA1 generated. Let’s just hope the Android developers don’t do that… seriously, that’s bad…

So say you want to grab the Android linux kernel along with the rest of the project. By default the kernels are not included in the manifest to save bandwidth for the vast majority of developers that don’t need it. I like to add them back for convience and to track new code dumps automatically. There are a few kernel projects listed at the bottom of the AOSP page based on the SoC used. I’ve made a short list for reference:

common – Collects changes from each the platform variants

goldfish – Emulator

msm – Qualcomm

omap – Texas Instruments

samsung – Samsung

tegra – NVidia

So once you know which kernel(s) you want to add to your repo manifest. Here’s how you can do it (Note: $AOSP is the top directory of your Android tree):

Then you need to edit the default.xml manifest to add your kernel(s) between the tags:

By default you’ll get the master branch, which is empty. To find the one you really want, sync with repo then list all the branches available:
$ repo sync
$ cd $AOSP/kernel/$KERNEL_NAME
$ git branch -la

Then you need to edit the default.xml manifest again with the correct branch (called revision in manifest):

Now when you sync you’ll get the kernel tree. Since you just did a sync remotely, you can just a do a local sync to avoid going out to the internet to check for changes and speed it up:
$ repo sync -l

If all this works, then you should commit the changes to your default.xml and repo will merge them into new versions for you:
$ git commit -a -m "Added kernels to manifest"

If you have linux running in VMware Workstation and want to access one of the virtual terminals, you need to hit CTRL-ALT-SPACE and then let go of the SPACE (while continuing to hold the CTRL-ATL) and hit the virtual terminal you want to access (one of the function keys (F1-F12).

Getting started in systems development is tough. There are as many developers or nearly as many books, blogs, etc. to learn from. But if you make it up the curve the rewards are great. Not to mention you don’t have to worry about looks, just get it done. So here’s some tips I have for up-and-comers on getting going with Android systems development. If any readers have more tips, I’d love to add them to this post, please email me

So unfortunately there isn’t too much out there in the way of proper overviews. Systems developers generally have to consult the code, which once you get used to it is actually not as hard as it sounds. A few things to check out: