Friday, December 31, 2010

Introducing Antipasto Hardware Wiki

Over the past two months, Chris, Will, Nick, and I have stealthily upgraded and migrated all of the Liquidware wiki content over to a new wiki... the Antipasto Hardware Wiki.

I decided it was finally time to upgrade the wiki to a higher end system, and using pbwiki seemed like a pretty decent choice. It'll still take some time to finish the migration, but until then, the benefits are quite nice - the new wiki has a lot more features than the original Liquidware Wiki (which technically was an upgrade from the formerly-original wiki, over at the www.liquidware.org site, which doesn't even exist any more).

Not a big deal, but thanks for all the help - and hopefully this will help address all those emails about folks wanting more help finding reference specs and documents for Liquidware hardware.



Cheers!

Wednesday, December 29, 2010

Writing Hello World on the Android with Eclipse

I've gotten several dozen (!) emails in the past few days from DIY'ers, engineers, hackers, etc. asking for a very simple tutorial - a "hello world android" if you will. It then occurred to me that most of these emails are from people that just got an Android kit for Christmas (thanks to all the help from Matt and Will and Mike to get everything out the door in time).

So here goes. These instructions are summarized over at the wiki on this page.

Step 1: Install Eclipse
Download Eclipse Galileo-SR2 for Mac OS X-32bit  or Windows-32bit or Linux-Ubuntu-32bit, and install it to the desktop or some location inside Documents.

Step 2: Install the Android SDK
This is the trickiest step... Download Android SDK Tools for Mac OS X-32bit or Windows-32bit or Linux-Ubuntu-32bit, and extract the archive into the /eclipse/plugins folder. Open Eclipse, select Help > Install New Software... Click Add, in the top-right corner.When the Add Repository dialog that appears, enter the following:
  1. Name: ADT Plugin 
  2. Location: https://dl-ssl.google.com/android/eclipse/ 
  3. Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

Click OK and then in the Available Software dialog, select the checkbox next to Developer Tools. Click Next. Then click through to the end until you're done, and then shut down and restart Eclipse.

Then, click the Eclipse -> Preferences Menu, click the Android category, and browse for SDK location: /eclipse/plugins/android-sdk-2.1_r1. Click OK to apply, and the Target, Vendor, Platform, and API columns should have values, then click OK again.

Step 3: Configure ADB
If you're running on Mac, you're already done. If you 're running on Windows, you have to do a couple extra steps. First, download the SDK from Liquidware - this one is specifically designed to work with the Android DIY Starter Kit and the Android Hardware Development Kit. To install the USB driver, just plug a mini-USB cable into the BeagleBoards USB OTG port, and manually install the driver from your_sdk_path/google-usb_driver into rowboat gadget.
Step 4: Create an Android App
Select File->New Project, and click Android->Android Project. You have options at this point - you can "Create a new project in workspace" and call it whatever you want. This will make a "hello world" template application. Or! You can select "Create project from existing source", and select SkeletonApp. I recommend you do this, and select SkeletonApp. If that doesn't work, then try to default app.
 
Now, plug in Android, select the main source file (in the left panel, under src -> com.example.android.skeletonapp -> SkeletonActivity.java) and press the Go button (the Green arrow on the top line of the menu bar), and you're ready to go.


Step 5: Customize
The most obvious thing to do is change the "Hello World" text. That's probably the safest way to go to start, just to make sure things are compiling properly. I've changed it to "Hello, inthebitz!" and voila - here it is, functionally working on the Android Embedded Hardware Development Kit:
Turns into this:

Bingo! Dino DNA!

Monday, December 27, 2010

Android vs. the Embedded Programmer Mindset

Eclipse Apps Roasting on an Open Android
ADB nipping at your serial bus.
Yuletide GUIs being compiled through XML,
And freakin' complicated data reference schemes that make you call even a single string from an outside standalone strings.xml file by @string/hello or R.string.hello.


Everybody knows a compiler and some global vars,
Help to make coding simple and fast.
Local functions with their scopes all aglo(bal).
Will find it much easier than dereferencing every gosh-darn string text variable.

What the helloworld, Google! Whatever happened to:

char gButtonText[] = "Option On";

function mytoggle( void) {
  strcpy(gButtonText,"Option Off")
}

Sure, it's ugly code. There's a better way to do it. But it's fast, easy, and simple, and intuitive to the C programmer's mindset. Welcome to the wonderful world of Java-inspired coding on Android. Everything is an object, and needs it's own varspace. Programming Android is like programming in Ruby on Rails' MVC stack. You aren't really writing a standalone app, you're just given the honor - and privilege if I say so - to glue on some function code on top of an existing framework. Programming Android is like programming Java - instead of thinking about building the app from the ground up, you're essentially writing a "diff" file on top of a massive mountain of existing code and functionality. The baseline app already does a bunch of stuff perfectly fine, thank you.

It's as if Android is constantly saying to me, "Oh, what, you want it to do something different? Overload my already perfectly-written function, why don't you. Pffft. I already thought of that. I have a better idea: why don't you *not* write your function, and instead use one of mine, and decrease the surplus population of crappy code!"

Bah humbugtracking
Programming in Android, like Java, I am constantly reminding of how little I know, because someone's already thought of that function, and it already exists - I just have to inherit and object and parent a class, @override a base class, and unprotect a final public method.

Want to make a toggle button change it's text? Duh:

android:textOff="Option Off"
android:textOn="Option On"

Herein lie the central difference in mindset between the Embedded Programmer and the Android Programmer:

Embedded (Arduino) Programming Mindset
In embedded land, we are trained to start from void main(void) and #include math.h and work upwards. From function control, application execution, to variable space definition, everything trains you to think about in a device-first mentality. You're thinking to yourself, "I have a device with XX megs of RAM, a YY MHz CPU, and a ZZ pixel screen." Optimization is the name of the game, efficiency matters, and resources are at a premium so it's worth taking the time to think them through.

Stretching the metaphor a bit for a minute, embedded coding is like heliocentrism - with the device at the center of the world:



Android Programming Mindset
In Android land, you are trained to start from a base, and extend some Activity class. You're writing diff code, pulling objects and their nested functions only when you need them. You are really writing *code*, you're just pulling and gluing together bits and pieces of functionality that were already written for you. The device doesn't matter, and why should it, because you're writing an app that might run on a tablet or a hand-held or an on-screen emulator. God only knows how many megs of RAM, CPU MHz, and pixels you'll have, so you'd better write your code abstractly and cross your fingers that it runs. Everything trains you to think about a user-first mentality.

All things considered, this isn't easy for an embedded programmer to embrace. Dare I say embracing and learning Android coding is the equivalent to the Copernican Revolution:



Device-first vs. User-first
Embedded programmers are more likely to build a new hardware device layer to push the performance envelope of a given piece of hardware. Android programmers are more likely to deliver a fantastic user experience that connects web-to-handheld-to-sensors first and foremost, and who cares if it sits and hangs for a few seconds while it calculates? The user will be stunned by the drop-shadowed jelly buttons, he won't even mind :-)

And the truth is... after several weeks of hacking my Android DIY Starter Kit, I don't mind either. I've found myself converting to a new religion, in the name of developing super-sleek looking GUI's in no time at all, it's really something. Doing the same in Linux would take weeks, maybe months (but that's another discussion for another time). Take my "void main( void)" from me, and give me my "public class extends Activity" any day of the week! But there are some downsides.

One major downside is the need for massively large reference manuals, or the need to constantly be connected to the web, for documentation, specs, and references. Try coding a rails webapp without access to the internet - impossible. On the other hand, all you need to code Arduino is a little cheatsheet - since you're essentially building everything up from scratch out of C primitive functions, all you need is the list of those functions. So what if you re-invent the wheel a few times? On Android, like Rails, you constantly need to know the top-down bigger picture. You need to have in your frame of mind the major high-level code objects, which you then reference down with the . dot-operator until you get to the method/function you were looking for. This means needing large amounts of documentation, and examples that are typically on the web.

Not better, not worse, mostly just different.

Saturday, December 25, 2010

Have Yourself a Merry Little Android ADB Rootkit

Quite a few people have emailed me about the post "The End of The Open Source Hardware Cambrian Age", and Chris had a few interesting observations and dialog about it on the Amp Hour - thanks (also a great set of casts in general)! Thank you... consider this the first installment of hackery to come :-)

It's one thing to have an Android. It's fun to download apps and whatnot, but at some point, you want to actually change the functionality of something, or make your own. That's the situation I found myself in recently, and so I've been hacking quite a bit on the Android DIY Starter Kit that I carry around.
 

The first thing anyone does when they get the Starter Kit or the Android Hardware Development Kit (more aimed at embedded programmers and engineers looking to learn Android) is... rootkit it, of course! I can honestly say that every device I have ever owned, I test on the basis of how quickly I can root it.
Now I just plug in the USB B mini cable into the side of the BeagleBoard. There's a USB B mini port on the BeagleTouch too, but don't plug into that one, since that's the serial debug port for the BeagleTouch.
 Here's proof that it works, and it's powered on:
 Now, it's as simple as popping up the "adb" debugger. Although I've mostly been a Windows/Linux guy up until now, I've been convinced recently to try out a lot of my development on Mac. One of the reasons, is illustrated here - all I have to do after I install the "adb toolkit". ABD is the Google set of command line utilities that allow you to communicate with an Android device at the low level - effectively "rooting it". Here's a link that describes what adb can do.

 And that's it. This is a little windows showing the results of running:
./adb shell
ls
You can see the command line interface shows the root set of directories, including my personal favorite, "sdcard" which is a symlink to the sd card storage space on Liquidware Android port. Another fun thing to do is to plug in the Android DIY Starter Kit, plug in the usb cable to the Mac, reboot, and type:
./adb shell
logcat
"Logcat" is the debugging interface, which shows all of the details of the boot-up process, for those that are hacker inclined. It's 100% pure fun - and especially helpful given you can also do things like:
./adb logcat | grep usb
From the Mac command line shell, running this command let's you see any startup debug messages associated with usb. Powerful, if I do say so myself.

Try that on an iPod or iPad :-)

Tuesday, December 21, 2010

The End of The Open Source Hardware Cambrian Age


This is the first time in almost 3 weeks I'm evenly lifting my head up to breath, after the massive chaos of Black Friday. Now, on to the fun stuff... my project back log, which I've been dying to blog about :-) But first, I spent some time browsing around the web at some recent OSHW projects, and I had a few thoughts I wanted to share...

Two years ago, Justin and I made a prediction… that the recent round of Open Source hardware was a re-invention of the same phenomenon that happened about 15-20 years ago, with the creation of DIY homebrew electronic computers. The recent round of open source hardware seemed to have been triggered by the advent of the ever-popular microcontroller, the Arduino.

Along with this trend came the replacement of the old guard, the Basic STAMP, with the new guard, the Arduino. For the past two and a half years, it’s been chaotic, emergent, collective, and exciting. The modularity introduced by the simple decision to fix the headers on the Arduino led to an explosion in the number of “shields” that fit those pins (including that ridiculous but essential, non-standard “gap” along the digital IO side which prevents someone from accidentally inserting a shield backwards). Arduino drove a reinvention of Open Source Hardware, from an artistic perspective, and allowed projects and hacking to occur faster than ever before...

Open Source Hardware >= Arduino!

But “open source hardware” is not synonymous with “Arduino” … it stands for much more than a "breakout board" for an Atmel chip. It represents the lowering of transaction costs, cheaper hacking, faster physical computing prototyping. It’s much more. But I've noticed an increasingly disturbing trend: companies are moving in for the kill. Noticing the success of the recent Open Source Hardware movement led by Arduino, the "old guard" is striking back - but they're striking back with the same out-dated tools that made them irrelevant on the web over the past few years... proprietary tool-chains, Windows-only custom IDE's, serial debugging interfaces (not USB), and special ROM flashing hardware.

Are you kidding me? This is a complete reversion back to the horrible life we all knew hardware to be 5 years ago, before Arduino came along. I will argue a strong point: Embedded Companies Just Don't Get It(TM). ECJDGI(TM)? They don't understand the web, they don't understand what Arduino is, why it succeeded, where it is headed. They just look at Arduino, and say, "I wish that was my silicon chip on there, and not Atmel's" and *POOF* they cram out yet another crappy dev board that no one is ever going to build anything with. Shame on them. The world doesn't need more Arduino clones. I think it needs more kick-ass projects.

So I would argue that two and half years ago, we saw the Cambrian Explosion of Open Source Hardware. New shields came out regularly, expanding the Arduino platform and the system. They were sloppy, inefficient, unoptimized, and *that was the point*. That inefficiency was good - it promoted hacking, and tinkering. It forced you to NOT follow directions. And yet the entire time, the Arduino remained a bedrock platform, and projects spawned and reproduced, remixed, recombined. All was open, collaborative, and expressive.


But to what end?

The Cambrian Explosion of biological diversity came to an end (eventually - thank goodness) as the Paleozoic Era marched onward. And when it did, life forms evolved - some of them were smaller, simpler, and potentially (arguably) less diverse and more optimized in their use of energy (metabolic optimization, anyone?). Others, meanwhile, grew larger and more complex, monstrous if you will.

Is the same thing happening to Open Source Hardware?

Have we left the era of massive experimentation and entered an era of consolidation? I think so… unfortunately. I say unfortunately, because every growth spurt must steady and end, and with that end comes reduced inventiveness, less innovation, and … optimization and efficiency. Shields continue to be made, and built, and as DIY'ers venture into the world of running businesses (like my friends Limor at Adafruit and Nate at Sparkfun), they are stumbling into the dreaded theories of economics that have haunted 1000's of hardware companies before them: cost optimization. You can see this right now in the Arduino world ... instead of DIY'ers building crazy new shields that do new things, the "old guard" and "cost cutters" are moving in to mass produce the shields they think are the most profitable.

Don't get me wrong, cheaper and cheaper shields available to more people - that's FANTASTIC news! It means that the Open Source Hardware market is maturing - early innovation is being replaced with volume, efficiency, mainstream acceptance. We WON!!!


Out with the New, In with the Old

The Old Guard of embedded companies is back, and they're here to stay, displacing the temporary uber-innovative dystopian imbalance created for a brief period of time by the rowdy bands of individual DIY'ers. Open Source Hardware has reached it's full modern cycle, albeit faster than it did last time. Embedded companies, Chinese board houses, off-shore CAD designers, the industry is now in full bloom. Three years ago, I posted my first Arduino blog article - "Arduino, here I come!". I can barely believe it. The world has changed dramatically since that first article. Once a lonely, rogue band of hackers who once met in art space in the meat-packing district in NYC, the Open Source Hardware community now has a Summit, a massive annual Fair, and hundreds of suppliers and vendors!

But not everyone likes the "marketization" and "re-industrialization" of Open Source Hardware. Although costs of shields are plummeting, and a good dev board can be had for $5-10 dollars (!), not everyone is motivated just by low cost boards. Sure, many people are, but that's not the point. Just because you can get a 99 cent whopper doesn't mean you suddenly hate the taste of a char-broiled $10.50 Angus Beef burger.

Some people are motivated by kick-ass hacks, not mainstream projects.
Some people are motivated by ridiculousness, not rationality.
Some people like aesthetic design and balance, not just raw functionality.
Some people are driven by the thrill of the challenge, not just the systematization of the status quo.
Some people HATE rules and order.

Like me.

Bring on the Char Broiled Angus Beef Burgers!


Maybe I'm just hungry, but I’m going down with a fight. I don’t accept the end of Open Source Hardware innovation as the 99 cent whopper dev board. If the whole vision of OSHW just turns out to have created another excuse for a bunch of lowsy Windows-only dev boards with proprietary toolchains, horrible tech support hotlines, and mysterious libraries that have no documentation, I will be very sad.

I insist on fighting back, and making something new and different, and weird, strange, and unpredictable. That’s what makes Open Source Hardware fun and challenging to me. In fact, I think the fight itself is what it's about: constant reinvention, and pushing boundaries.

Now that that's out in the open, it's time to get back to doing what I enjoy most... hacking.

And that's what I'm all about.