Jan 142011

I holed up in my cave with a Beagleboard XM rev B and spent the day learning how an ARM board boots. After a few hours of aimless wondering, misdirection, ill-conceived notions, and deep tangents, I am happy to say I managed to boot a minimal Yocto image on the Beagleboard XM!

beagleboard login: root
root@beagleboard:~# uname -r

From dvhart's blog

The key difference (in terms of booting) between the Beagleboard and the Beagleboard XM is the lack of NAND. This changes the boot process slightly. Specifically, it requires an X-Loader and a u-boot binary on the MMC (as opposed to having them in NAND) – or something along those lines. I am thrilled that in a single day (not even a very long one) I was able to get Yocto booted on an architecture I have exactly zero experience with.

I will be spending next week tweaking poky recipes to generate the proper binaries and user boot scripts. The linux-yocto meta-data for the Beagleboard will also need to be updated for the new ethernet inteface on the XM. For those of you eager to boot Yocto on your Beagleboard XM, you won’t have to wait long!

And in case you are wondering how your Kindle can help you with Beagleboard development, here are two ways. First, it can read the Beagleboard manual if you email it to your kindle account. And second, its power supply with the proper mini-usb cable provides adequate voltage and more current than my laptop and is able to power the Beagleboard XM, while my laptop could not source quite enough current, resulting in a kernel panic, oddly enough.

Oct 282010

Shuttleworth’s recent announcement that Unity will be the default shell for Ubuntu 11.04 may have just tipped the scales in Fedora’s favor.

I’ve been a very happy Ubuntu consumer for several years. But as Canonical moves away from just being a fantastic integrator and tries to muscle its way into UI design, I find myself less and less content with their distribution. The recent themes and blurred graphics of the last two releases are far too garish (dark gray, purple, and orange – really?) to have general acceptance (just flat-out-dog-ass ugly in my opinion).

The windicators push has never made sense to me. Moving the window controls to the left to make room for the windicators…. uhm… what’s wrong with the space on the left? Are you too good for the left? I’ve also not heard of a single use-case for windicators that makes any sense at all. A shopping-cart? Really? Do you plan to get ebay, amazon, and the other 50 billion internet retailers to hook into it? If not, you’re left with yet another inconsistent user experience.

And now Unity. I blogged on my initial experience with Unity and am sad to say that things have only gotten worse. Part of the problem is clearly that it simply wasn’t ready to be part of an official release. The file-manager is useless, infuriating my wife as she tried to copy a file to her USB drive (requiring my intervention). The family has announced their dislike for the shell and a downgrade to 10.04 is on my todo list until such time as MeeGo gets multi-user support.

And how about quality? With all the attention on UI design, it is my opinion that the 10.10 Maverick release fell significantly shy of Canonical’s fairly stellar integration and QA standards. Since the upgrade to 10.10 both my ThinkPad x201 and our family Toshiba NB-305 netbook must have the nm-applet manually killed and restarted after a resume as the icon disappears from the panel, and it won’t reconnect to the wireless access point. My x201 suffers from some dbus error which I avoid by running the Lucid kernel.

Come on Canonical, you’re better than this! Your consumers expect better from you. By all means, expand your horizons, apply your vast resources to innovation, improve the Linux Desktop user experience, but please, don’t neglect what made you great – a polished distribution that brought Linux to the masses.

Oct 272010

The first question I received (and indeed the first one I asked a few weeks ago) regarding the Yocto Project was, “Yet another Linux distribution?” We certainly have plenty of those, adding one more would really only serve to further fragment the embedded space.

So no, Yocto is not a distribution (like Fedora and Ubuntu) and it is not a platform (like MeeGo and Android). The Yocto Project is a workgroup (as described in the Linux Foundation Announcement) and the core bit of software behind it is the Poky build system which has its roots in OpenEmbedded. So, the Yocto Project is targeted at making it easier to create your own Linux distribution. It also serves as an umbrella project to collect things like BSPs all in one place.

The ultimate goal is to provide a common collaboration point from which we can reduce the chaos in this space and make it easier for people to bring Linux based devices to market.

If you’re still not convinced, please take a look at the Quick Start Guide and even the Reference Manual which will introduce you to the sorts of things you can do with the Yocto Project.

Oct 272010

After weeks of barely being able to contain myself while being probed about what I’m working on at Intel (my new job as of about 6 weeks ago), I can finally share all the details publicly. We’re proud to announce the initial public release of The Yocto Project!

Check out all the buzz about Yocto:

I am personally working on the Linux kernel itself. I’ve spent the last few weeks learning the system, fixing a few bugs wherever I ran into them, and preparing the live demo for the CELF conference.

Oct 102010

I was thrilled with Ubuntu 10.04 Netbook Remix. It made excellent use of the small screen and the single-full-screen application usage model. It had its warts. You had to leave your application to access the menu. Some dialogs didn’t work well on small screens, making it difficult to get at the buttons on the bottom. But all in all, it worked really well. I was particularly fond of the menu system’s use of the desktop to display icons – with the caveat that it would have been nice to be able to get at things without completing obscuring your current application.

Enter Ubuntu 10.10 (Maverick) Netbook Edition with the new Unity interface. I was expecting a polished up version of 10.04 – what I got was… lost. The new menu system displays icons on the left-most column, and maximized windows do not obscure it. So far, so good in my opinion. But wait… where did the menu organization go? You know “Internet” “Graphics”… etc. You have to scroll down to the “Applications” icon (mouse hover is the only way to be sure that’s what it is) which brings up a menu system reminiscent of the 10.04 menu, except without much in the way useful organization. There are some breadcrumb style categories at the top, but all those that I would expect. Figuring there must be some preferences to adjust this sort of thing, I started looking for preferences… … … not a preferences category in sight – OK, I used the handy search bar. That brought up some plausible settings programs. Clicking on one of them brought up… the application installer! The search showed me preferences tools for applications that were not even installed!

Once an application is found, I expected to be able to add it to the menu as a favorite, or some other similar model. No such luck, right click is impotent, although it is used to remove icons from the menu. As it happens you can only add it to the menu by launching the application and then right clicking on the newly added icon on the menu and selecting “Keep in Launcher”. I found the “+” around the icon in 10.04 to be a much more discoverable mechanism.

Besides objections to its design, I ran into some implementation annoyances as well. The Application and System launchers took long enough to load that I was tempted to press them again. Perhaps this is do to time spent searching the package manager for applications I haven’t installed? The mouse-hover descriptions of the menu icons would occasionally stick – leaving “Firefox Web Browser” obscuring the browser itself.

Perhaps things will “click” and I’ll fall madly in love with Unity – but I doubt it. For now, I must bide my time until my better half logs into her account on this netbook and looks up at me with that knowing glare that says, “You just couldn’t resist could you? WTF is my browser?”

Aug 272010

You’ve received that email, “Please print, sign, scan, and return.” Possibly it said FAX – but like me, you just can’t wrap you’re head around using a FAX in 2010. So you fire up gimp (or xsane), scan a page, crop it, save it; repeat for N pages; then spend 10 minutes reading the absurdly obfuscated ImageMagick man pages to finally stitch the images together into a PDF, and return to sender. You do this once, and the memory of it provides a very significant mental barrier to ever repeating the process.

I had to do this again today for a pair of documents. The Simple Scan tool caught my eye and I gave it a try. It’s pure genius, in an “OMFG why did it take 10 years for this to appear?” kind of way. Simple Scan handles the intermediate files behind the scenes, crops all the pages to the same size, displays a thumbnail of each page you scan, and finally saves the document as a PDF. Like, wow. Thanks Simple Scan!

Aug 242010

I just got back from a trip to Best Buy to fondle a wide selection of laptops. Considering they don’t carry the “business” line from HP or others, there is a giant gap between the consumer laptops and the Mac Book Pro. It would be like going to a car dealer that sold Kias and BMWs (no offense to all the Kia drivers who wait with baited breath for my next awe-inspiring blog post). I spent about an hour typing on some 20 keyboards and testing the flex of the chassis and keyboard. Most were Chiclet style keyboards, which turns out to be a sub-optimal design (in my opinion) if you use more than two fingers to type.

The Toshiba Portege R705 wins the worst-keyboard-ever-manufactured-in-the-history-of-bad-keyboards award. The keys are glossy plastic and flop left to right due to the incredible amount of slop in the design. They don’t depress like… well, a keyboard… they sort of click with a very unsatisfying travel distance. In fact, my 4 year-old son’s toy Cars laptop from Radio Shack has a much better tactile response! The chassis was thin plastic and the keyboard, the palmrest, and the screen all flexed a great deal under only minimal force. Considering it’s $900 price tag (about $1,800 with a respectable amount of RAM and an SSD), I found the keyboard and chassis to be remarkably bad.

The 13″ ThinkPad Edge’s newly designed chiclet version of the ThinkPad keyboard is surprisingly good, and by far the best of the chiclets I’ve tried. The laptop is a very nice blend of consumer features and professional construction, but it’s closer in design to a consumer laptop, and I’m concerned it wouldn’t hold up to the daily abuse of heavy user. The glossy screen is also a drawback for extended use as glare can be a real problem in certain environments (Best Buy doesn’t carry the ThinkPad line, I tested this one at Office Depot).

And the 13″ Mac Book Pro gets an admirable-job-implementing-a-sub-optimal-type-of-keyboard aware. In all honesty, I’m pretty sure I could get used to the Mac’s keyboard – despite the very shallow travel of the keyboard. The Mac shines in chassis design. The MacBook unibody is a truly incredible piece of engineering. It is very rigid, light, and incorporates only minimal machining to allow for the required ports, vents, etc. In terms of pure industrial design, nothing comes close to a Mac Book Pro.

The ThinkPad x201s sports a tried and true ThinkPad design and traditional keyboard. With a 12.1″ screen, it is the smallest of this group (as the x301 is now outdated, gets terrible battery life, and is absurdly expensive), but shares the same 1280×800 screen resolution of the 13″ Mac Book Pro. I haven’t got my hands on one of these yet, but I’ve seen them in the wild and they meet all the expectations of a ThinkPad. Rugged, no-frills, business focused workhorse.

It’s now abundantly clear to me, there are only two choices when it comes to quality professional grade notebooks: Lenovo ThinkPad and Mac Book Pro. My second discovery is that my belief that Macs were overpriced is completely false. You can’t compare a Mac to a Dell or an Acer (not even an HP consumer grade machine), you have to compare it to the top of the line Lenovo ThinkPads (T510, x201s, x301, etc.) and then, feature for feature, the Mac is competitively priced. Damn.

Aug 202010

Red Black trees are a critical data-structure in the Linux kernel. I’ve often wondered what made them unique to other trees, but ignored the impulse to dive into it much beyond reading the excellent Wikipedia article on red black trees.

An rbtree achieves O(log n) time complexity for search, insert, and remove. The key properties of an rbtree are as follows:

  1. A node is either red or black.
  2. The root is black. (This rule is used in some definitions and not others. Since the root can always be changed from red to black but not necessarily vice-versa this rule has little effect on analysis.)
  3. All leaves are black.
  4. Both children of every red node are black.
  5. Every simple path from a given node to any of its descendant leaves contains the same number of black nodes.

I finally manned-up and decided to write a sample red black tree in python. Despite having covered binary trees ad nauseam in college, I was surprised how challenging it was to write a completely functional red black tree. After a few nights of “free time” dedicated to the project, I finally have something to show for it.

$ ./rbtree.py 
***** Populating Red Black Tree with 1000 Nodes *****
***** Test Insert Complexity O(log N) *****
***** Test In-Order Traversal *****
***** Test Search Complexity O(log N)*****
***** Test Remove Functionality *****

The source comes with a built-in self test that inserts the values 1-1000 in random order, locates them all, then removes them in random order. It verifies the 5 properties of the rbtree at each step, and prints the results.

While I am glad to have done it, I am truly embarrassed at how long it took me to complete. On the bright side, the principles I had to dust off to get this done are now painfully fresh in my head. If you’d like to see the source, it’s available here: rbtree.py

Lastly, there is a clever interactive demo here (requires java):
Red Black Tree Demonstration

Next up… python metaclasses, and why Guido is an evil bastard.

Aug 182010

I’ve been twice bitten by this subtlety of the python __cmp__() method, I thought I’d try to save you the same pain (and perhaps by writing it down I won’t repeat it… again).

When dealing with objects, it’s often useful to be able to compare these objects:

if mySwartz > yourSwartz:
    print "Suck it."

An obvious (and wrong) __cmp__() method would be:

def __cmp__(mine, yours):
    if mine.val < yours.val:
        return -1
    if mine.val > yours.val:
        return 1
    return 0

Looks good right? Well, what if some yahoo tries to compare two totally disimilar things, i.e:

if mySwartz > yourForce:
    print "Neener Neener."

Such a comparison clearly makes no sense, so let’s update __cmp__() to check for similar data types:

def __cmp__(mine, yours):
    if not isinstance(yours, Swartz):
        return -1
    if mine.val < yours.val:
        return -1
    if mine.val > yours.val:
        return 1
    return 0

Good right? WRONG. Consider the following ridiculous scenario:

mySwartz.val == yourSwartz.val

While I’m sure no such thing could happen, let’s imagine for the sake of argument that two objects might be compared on an internal value that just might not be unique across all instances of the object. What would happen if you had to retrieve your object from a container?

storage = []
# time passes
for sw in storage:
    if sw == mySwartz:
        print "I found my Swartz!"
        print "...wait... this is your Swartz... gah!"

Yeah yeah, you could rewrite this to yada yada, that’s not the point. The point is while the values of the objects are the same, they are not the same objects and python uses the __cmp__() method for both less than, greater than, equality, AND identify comparison if you’re used to thinking of your objects as pointers!

If you’re faced with a situation where you want to be able to easily sort objects, but still need to be able to identify them uniquely when they share an internal value, augment your __cmp__() routine to check for id as well:

def __cmp__(mine, yours):
    if not isinstance(yours, Swartz):
        return -1
    if mine.val < yours.val:
        return -1
    if mine.val > yours.val:
        return 1
    if id(mine) < id(yours):
        return -1
    if id(mine) > id(yours):
        return 1
    return 0

If you’re a python guru and think I’m missing something, please share, otherwise:

if mySwartz > yourSwartz:
    print "I see my Swartz is bigger than yours..."

Jul 152010

I finally got tired of lack specifiers in “git grep” and the cscope ncurses interface. I spent a few minutes and setup the vim cscope plugin using this mighty fine tutorial:


The one gotcha I ran into was having to disable my vim setting that automatically changed the working directory to that of the open file – it broke the cscope plugin relative filenames.

" automatically switch the cwd to that of the file in the buffer
" This breaks cscope plugin
" autocmd BufEnter * :cd %:p:h

Very, VERY VEERRRYYY nice. Now if only I could get a full call graph out of it…