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:
Linux version 2.6.29-00177-g24ee4d2 (email@example.com) (gcc version 4.4.0 (GCC) ) #21 Thu Aug 6 20:39:45 PDT 2009
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:
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):
$ cd $AOSP/.repo/manifests # Goto manifests directory
$ git checkout -b with_kernel # Make a new branch to add kernel(s)
Then you need to edit the default.xml manifest to add your kernel(s) between the
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"
This is too useful to be so hard to find:
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).
Do you always find yourself going to the same directories in bash? Are you sick of hitting tab complete all the time to get there? Use bash bookmarks, it will save you so much time!
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:
- The linux kernel has a Documentation directory
- Android is a superset of embedded Linux so the book is quite helpful
- The Android Internals talk by Karim Yaghmour, author of the previously mentioned book, from this year’s Android Builder’s Summit is good: http://free-electrons.com/blog/abs-2011-videos/
- The Android Open Source Project (AOSP) website has a little info, but the mailing lists are even more helpful:
- The Embedded Linux wiki is great, but can often be outdated
So android.git.kernel.org is still down which has forced me to learn a few tricks on building AOSP:
If you only want to synchronize your working tree and NOT download the latest sources from the server (or in my case you can’t), just do a “local” sync:
$ repo sync -l
Seems to work much better to switch branches if you just use repo init to update your manifest (inside $AOSP/.repo) and then sync:
$ repo init -b <BRANCH_NAME>
$ repo sync -j16
If you want to build a specific version of Android without having to do new repo init (Thanks JBQ!). For example, say you want to build gingerbread which is API level 6.
$ repo forall -c git checkout korg/gingerbread
$ repo forall external/qemu sdk -c git checkout korg/tools_r6
Update: You also need this patch for $AOSP/external/jsilver:
diff --git Android.mk Android.mk
index ce1ab5c..2f0f83b 100644
@@ -24,4 +24,6 @@ LOCAL_MODULE := jsilver
LOCAL_JAVA_LIBRARIES := guavalib
LOCAL_JAVA_RESOURCE_DIRS := src
+LOCAL_MODULE_TAGS := optional