Monday, January 09, 2012

OpenUI - An I/O interface for headless Linux computer

For most of the embedded applications, micro-controllers are well suited for its low cost and hardware design simplicity. But, as soon as you have the need to add networking capability on a MMU-less processor, hardware would become expensive and complex, hence we feel the need for a processor with MMU and OS to support basic networking and file management stuff.

Technology enthusiasts,geeks, h/w hackers and DIYers, who are always on a mission with various embedded stuff, finds it difficult to use PC like motherboards which are expensive, bigger and power hungry for their tiny embedded needs, its like using an elephant to kill the ant.

Over the couple of years, we see a shift in DIY community moving from micro-controller based h/w to Linux based single board computers. As we see, these da
ys mobile market is driving a whole lot of semiconductor companies and software giants with a fierce competition for building a low cost yet powerful and energy efficient handheld devices. As a result we see a bunch of different SoCs capable of running Linux are being sold at a 5 to 10 dollar price range.

For Hobbyists and DIYers this is a good news as none of us want to re-invent the wheel by investing time and money for development of Linux capable hardware. As we know these days we find a lot of cheap commercial products running open source Linux(In-fact, sometimes
its hard to find a networking device that is not running Linux).

OK enough with the preaching,
Here is a small list of various devices running open source Linux with a price range from $35 to $150
1) Beagleboard($150)
2) Beagleboard xM($150)
3) Buffalo Linkstation Live(~$150)
4) Asus RT-N16($90),
5) Beaglebone($89)
6) Sheevaplug(~$85)
7) Seagate Dockstar(~$55)
8) Linksys WRT-54GL($50),
9) TP-Link MR3220($35)
10)Raspberry PI($35)

Except Beagle, Sheeva and Raspberry, most of these devices are Off-the-shelf commercial products running open source Linux and are designed for a specific task, If you notice, most of them are headless computer units without any user I/O interface like keyboard or monitor(mostly the interface is provided through web pages). Obviously there is no need for a tiny embedded device to have the monitor and keyboard for their specific task.

Apart from user I/O, embedded solution needs other connectivity options like GPIO, I2C, UART etc for interfacing peripherals like sensors, motors and controls.

In order to bridge the gap between Off-the-shelf commercial Linux box and missing I/O interface, I have built this tiny USB device called OpenUI using Atmel's attiny2313 acting as a USB HID device for the headless computer box. As we know most of the Linux boxes(shown above) are having built-in USB port for connecting peripherals, hence building an USB powered OpenUI h/w makes sense that can be useful for h/w hackers planning to use cheap Linux boxes for their mission.

H/W design of OpenUI is based on Dick Streefland's usbtiny project, the only limitation of usbtiny project is a missing I2C bus for peripheral devices. Hence I tweaked his design and built an all-in-one solution for headless Linux boxes.

Features of OpenUI hardware,
1)An IR Remote receiver acting as a user input device (keyboard)
2)Option to mount 16x2 line LCD acting a
s a user output device (display)
3)I2C bus interface for peripheral chips.
4)I2C based RTC chip with battery backup
5)5x2 Male header for programming AVR or ex
tending i2c bus to external devices.
6)5V supply for openUI is drawn from host usb connector.

How to build attiny2313 firmware for OpenUI Hardware?
1) sudo apt-get install gcc-avr binutils-avr avr-libc avrdude
2)Prepare a cheap avr programmer called ponyser from here.
1)Download Dick Streefland's usbtiny-1.6 sources from this location or from here.
2)Download the openui patch for usbtiny-1.6 from here.
3)Run the following commands on your Linux machine to build and program hex file for openUI h/w.
mkdir openUI
cd openUI
cp /path/to/downloaded/usbtiny-1.6.tar.gz .
cp /path/to/downloaded/usbtiny-1.6.openui-0.1.diff .
tar -xvf usbtiny-1.6.tar.gz
cd usbtiny-1.6
patch -p1 < ../usbtiny-1.6.openui-0.1.diff
make clean
make all
cd ir
avrdude -p attiny2313 -P /dev/ttyUSB0 -c ponyser -U flash:w:main.hex
avrdude -p attiny2313 -P /dev/ttyUSB0 -c ponyser -U hfuse:w:0xdb:m
avrdude -p attiny2313 -P /dev/ttyUSB0 -c ponyser -U lfuse:w:0xef:m
4)Now your attiny2313 is ready to run on OpenUI hardware.

How to prepare headless Linux computer to work with OpenUI Hardware?
1) you need to build lircd along with lirc_dev.ko and lirc_igorplugusb.ko for your Linux box.
2)before starting lircd make sure lirc_dev.ko and lirc_igorplugusb.ko drivers are loaded.
3)check if /dev/lirc device node exists.
4)check if /var/run/lirc folder exists.
5)start the lircd with this command '/usr/sbin/lircd --device=/dev/lirc /etc/lirc/lircd.conf'
6)Please not that, In the above command, /etc/lirc/lircd.conf is the config file of your Remote.
6)After starting lircd, start the OpenUI daemon with this command '/path/to/openui &'
7)If everything goes well, you will see message on the OpenUI's LCD.

Eagle Schematic, Layout and Gerber files can be found here.

OpenUI in action

OpenUI daemon source code can be found here

OpenUI Android app source can be found here(excuse me for my noobness in writing my first android app, in fact its my first java program;-)