Bug Labs: Hacks and Apps

Alicia Gibb

Issue #183, July 2009

Use Bug Labs' modular, open-source system for building devices and find out what you can do with a fully integrated device development platform.

You may have read about Bug Labs, the open-source modular gadget company, in Mike Diehl's article in the August 2008 issue of Linux Journal (see Resources). We're back to tell you a bit more! In this article, I fill you in on some general information about BUG, including our latest news, and then provide some ideas about what you can do with BUG.

BUG is a modular, open-source system for building devices. Four modules can be snapped into the BUGbase, which has an ARM 1136 MX31 embedded processor. BUG runs a 2.6.27 version of the Linux kernel and a distribution customized from Poky Linux, which is derived from the OpenEmbedded distribution. OpenEmbedded is a distro specifically for embedded systems. It cross-compiles the JVM and other language runtimes. In addition, thousands of other packages (applications, libraries and so on) are available and can be compiled for BUG using the BitBake program.

At BUG, open source doesn't mean only source code, but also flexibility and the power to choose. As Mike Diehl wrote in his previous article, it's easy to ssh into BUG. After logging in, you'll be at the BusyBox shell, and from there, you can get into the filesystem, install and run software, killall and more (though we don't recommend that last one).

We want users to be able to choose the language they prefer, the interface they favor and the modules that accomplish their goals. The modules currently for sale are the BUGview (full-color touchscreen LCD), BUGmotion (motion sensor/accelerometer), BUGlocate (GPS), BUGsound (audio) and BUGvonHippel (our breakout board with serial, general I/Os, I2C, SPI, DAC, ADC and more). BUGvonHippel was named after Dr Eric von Hippel of MIT for his contributions in the Open Source movement and his book called Democratizing Innovation.

Coming out in the next few months will be the BUGwifi (which also includes Bluetooth), BUGbee (802.15.4 protocol) and BUG3g GSM (3G), to be followed by the BUGprojector (pico) module. Additional specifications for our current modules are located on our Web site (see Resources).

To connect all these modules and communicate with the kernel, we export I2C, SPI, UART, I2S, camera and display interfaces in our own BMI (Bug Module Interface) wrapper to make the device as flexible as possible. You then can put any module into any slot (and yes, they're hot-swappable), creating your own open-source gadget or prototyping platform, bottom-up style.

BUGs are also flexible with what language you can use to code. We support Java, C, Python and Ruby on BUG, but you can write in any language you want, so let us know when you've got brainfork working.

Although we encourage other languages, you also should be prepared to dig around for packages or write a few libraries. One of our developers recently wrote a tutorial on our Community Blog (see Resources) for building C/C++ programs on the BUG. This example uses a Python program called BitBake, along with build description files called recipes, to generate executable programs and other artifacts meant for a specific computer architecture. Recipes are the metadata about how a program is built and provide a way for all packages to be deployed consistently. Finally, this allows for the BitBake program to create an image containing the entire operating system.

When installing new packages on BUG, you can use the ipkg program to install from BUG's shell. Ipkg is analogous to yum or apt-get in other Linux distributions and provides a simple way of installing new software on BUG. We maintain a repository of programs for BUG on our Web site (see Resources).

What else can you do with BUG? Technically speaking, you can do anything you want with a BUG; it's a fully programmable embedded computer. We realize that's a little vague. Because BUG is open-source, imagine morphing any handheld device into your own open-source version running on Linux, allowing you more options than its closed-source counterpart.

Another use is the ability to create hardware without having to solder or go through numerous manufacturing headaches. You can use the BUG as a prototyping system to create and re-create solutions to your problems. And, of course, you can create a new device that isn't available from your local Best Buy or Radio Shack.

Our apps page (see Resources) includes Java apps uploaded by our community and the Bug Labs team. Looking through the current applications is the best way to get an idea of what can be done with BUG. Although many of these apps are proof of concept, these examples show off some of BUG's possibilities. Finally, BUG has a growing community of users who have defined new BUG capabilities both within hardware and software. A handful of community members even have created their own modules, made with our schematics and CAD files found on our Resources and Documentation wiki (see Resources).

Each module has a Hello World app as well as many proof-of-concept applications. These are useful for seeing what each module is capable of. For example, BUGmotion can store the data it gets from three different axes (X, Y and Z) and detect motion in various programmable ranges. Simply by using this module with a BUGbase, you could program BUG and toss it into your luggage before a flight to chart the data from each axis as it gets jostled around. Keep in mind the rechargeable battery life is currently three to four hours without AC power.

BUGview is useful, for example, if you'd like to check out a terminal directly on your BUG, although the keyboard is difficult to type on without tiny fingers, so we recommend using a Bluetooth keyboard via the BUGwifi or USB via BUGvonHipple.

You also can program BUGview to act as one large button that can send data to other modules and change color as feedback that the button has been pressed.

BUGlocate can be used to gather data about wherever your BUG is or stowed in your car to monitor your teenager's driving patterns (though that seems a bit Big Brother for us).

BUGsound can play files saved on the SD card. Coupled with the accelerometer, it can make different noises when held in different positions. Search for the Phunky app on our apps page for more details.

BUGwifi opens up many options, from connecting different devices via Bluetooth to sending messages to your Twitter account when motion is sensed.

BUG3g GSM also will broaden the horizons of data transferring capabilities. Data can be sent to or from your phone or other devices. Imagine your doctor writing you a prescription on a BUG and having the data immediately sent to your patient file and your pharmacist—with encryption of course!

Figure 1. Instant root Access in the BUG's Terminal (Photo Credit: Brian Ballantine)

A lot of interesting apps come about due to networking capabilities. BUG comes with its own Web server and allows you to query each module's data by accessing the corresponding Web service. For example, you can connect your BUG to your network, put http://10.10.10.10/service/picture (default IP address of BUG) in your browser, and see a JPEG format picture taken with BUGcam2MP. BUG uses RESTful Web services and HTTP operations to manipulate the resources it provides. Making data available in this way is important as applications rely more and more on different devices communicating.

In addition to using the existing Web services, you can implement your own Web service or Web front end using Java servlets. For example, we recently made a BUGbot—BUG with wheels attached. We created a Web page served from the BUGbot that could control the direction and speed of the device. We then used the BUGbot to drive around the office snapping pictures. The BUGbot was easy to make. We attached a motor shield to the BUGvonHipple module, hooked that up to some wheels, put a tripod on the wheels and a BUG on the tripod. With the Wi-Fi module (BUGwifi) attached, this BUGbot also can upload the captured images to Flickr or Twitter.

Many familiar libraries have been ported to BUG, allowing for the type of functionality you'd expect on any Linux machine. For example, the popular open-source computer vision library OpenCV runs on BUG. OpenCV allows for applications to gather and analyze data from images and video streams. With OpenCV, you can use BUG for blob detection and tracking for physical computing applications. OpenCV also enables BUG to do face, figure and motion detection for security applications.

Our sysadmin at BUG got a SIP phone running on his BUG and wrote about the possibilities with IPv6 and BUG on our Community Blog: IPv6 allows for host-to-host communication. Host-to-host can mean BUG-to-BUG, PC-to-BUG, BUG-to-PC, BUG-to-(other device), (other device)-to-BUG, BUG-to-(some Web service) and, of course, (some Web service)-to-BUG. Maybe more. The BUG SIP phone consists of a BUG and the BUGvonHippel module with a headset attached through the USB port on the BUGvonHippel. To have a BUG SIP phone, you'll need a SIP software client, a SIP provider and the open-source Asterisk PBX. With enough network bandwidth, the quality is clear with little to no lag time.

While we're on the topic of data communication, R-OSGi was created by Jan Rellermeyer and Michael Duller, and it stands for Remote OSGi. This application allows servers to connect via remote access transparently. Bundles are able to move through the network as if they were a local service. This application is not only important to BUG, but to the Java community as well. A Bug Labs developer used R-OSGi to create a camera app that could bind to any camera on the local network dynamically. R-OSGi allows this to occur in a general way, so that any application's dependencies can be provided transparently by another R-OSGi-speaking device.

Music server is an application that uses BUGwifi and BUGsound. Music files are stored on the BUG's miniSD card and can be accessed via an IP address. You can point your phone or another computer to the BUG's IP address and choose a song to play from across the room or possibly (configured correctly), across the continent. Integrated audio/MP3 support doesn't exist in phoneME, so it uses madplay, a command-line MP3 player. Songs can be played directly through the audio module connected to speakers or headphones—the audio module contains a line-in, line-out, mic and headphone jack.

Another useful app that was created by a member of our community is the GPSAlarmClock. This app is programmed to make a sound when a destination is reached rather than a certain time. This uses the PositionHelper class with an OSGi service to help with its accuracy. The GPSAlarmClock can be helpful if you have a long train commute or road trip (provided you're not driving).

Chris Wade, an active community member also known as cmw, ported Quake to his BUG. He hacked it together using QuakeSDL. The full instructions are available on his Web site (see Resources), but it's as simple as downloading the binary and extracting it, then executing it. He recently added mx31 support to QEMU, which allows us to run the BUG in a fully virtualized environment. Unfortunately, QuakeSDL doesn't support joysticks, so Wade took matters into his own hands by hacking the guitar from Guitar Hero to run as a joystick for Quake. Rumor has it Ms PacMan is coming next.

Bug has been learning a lot from the Open Source community, so we understand the importance of giving back to that community. We give back in a few ways. We're active in the OpenEmbedded community, and our art director even created the new look for the OpenEmbedded Project. Our head of software is an Eclipse contributor, and many of our engineers participate in the Eclipse community. We expose and discuss all of our code (all available in our svn repository), projects and hacks openly in hope that someone else runs across answers to their questions. We open-source all the driver work we do, contribute code to the Concierge OSGi Project and submit defect reports for a number of open-source projects. We also have given back to various Linux project communities, such as the Linux wireless community Libertas. Many of our engineers can be found posting and responding to discussions about FOSS Java on ARM with topics on OpenJDK with Tarrent and the phoneME JVM in Jalimo.

Another way Bug Labs gives back is through our Test Kitchen. This is a small electronics lab located at our office in New York, open to the public from 12pm–7pm, Monday–Friday. Folks are welcome to bring their own projects (whether it involves BUG or not), use the various microcontrollers in the lab or just show up to play with a BUG. We also encourage groups like Make:NYC and other similar groups to use the Test Kitchen for their events. The purpose of an open space for hacking and tinkering is to promote collaboration and creativity, share thoughts and learn from each other. We ask that you schedule a time when planning to come in by sending e-mail to alicia@buglabs.net.

If you have any further questions about BUG, we're on IRC daily at #buglabs on Freenode. Our dev team is ready to help, and our community members probably will chime in with their advice as well. Check back with us often; updates occur regularly.

Bug Labs Team Member Alicia Gibb is a researcher and rapid prototyper. As Bug Lab's Gadget Wrangler, she administers the Test Kitchen for exploring the innovations available with modular technology components. She recently took a UNIX class where the guy/girl ratio was 2:6. Back up. Reread. Girl Power!