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
Here

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;-)

Saturday, December 10, 2011

Cheap, hackable Linux box for Robotics, home automation and other DIY H/W stuff

Over the past few years I have been studying several low cost open source h/w platforms to be used for various home automation activities.

During my quest for finding a cheap linux board(right photo: my h/w collection), I have journeyed through several available solutions in the market as listed below,

Beagleboard($150)
Beagleboard xM($150)
Beaglebone($89)
Sheevaplug($85)
Seagate Dockstar($50)
Buffalo Linkstation Live(~$150)
Linksys WRT-54GL($50),
Asus RT-N16($90),
TP-Link MR3220($35)
Raspberry PI($35)

In this h/w list, Only few of them are found to be truly open in terms of hardware and software. Rest of them are commercial products with an option to run open source Linux.


Among all the available options, my main objective was to find
1) A cheap h/w with a decent processor+RAM+Flash.
2) An easily available/off-the-shelf product from local market(in India).
3) A Hardware costing less than 2000 Rupees(<40USD).
4) A Hardware which can support open source Linux distribution.
5) A Light weight Hardware with low power consumption,
6) A Hardware with an easy option to extend I/O peripheral access.

with these requirements, I finally narrowed down to TP-Link MR3220 wifi router which seems perfect solution for my needs(though raspberry Pi is the perfect solution with powerful h/w in terms of processor+graphics+ram+SD @35USD, but as of now, its not easy to get hold of this board due to heavy demand among the DIY community).

One of the good reasons for choosing a wi-fi router was,
Normally everyone has an ugly and cheap ADSL modem/router provided by the ISP which is simply acting as a Internet gateway and on top of it, everyone needs a powerful wireless N router(with an opensource firmware like openwrt/dd-wrt/tomato) for home connectivity between PCs,laptops,phones,tablets,NAS and other home-networking devices.

Adding basic home automation capabilities for such a router with 'little' added cost (which can also save you from deploying 24/7 power hungry and noisy desktop )is a best bargain considering its price of 35$USD(~1850Rs).

For enthusiasts,hobbyists and students interested in embedded Linux, Robotics ,home automation, DIY hardware and microcontroller, I would definitely recommend you to try your hands on with MR3220+openwrt(or any other buffalo or asus router with USB port).

This way you can directly jump start your design by skipping the h/w development time and start focusing on your firmware/software on open source Linux platform.

Ok that's it, lets come to the point,
Here is my work based on MR3220 and AVR attiny2313 based USB h/w(I named it openUI). Following video shows my first Android app controlling LED's through wi-fi.

Best part of this h/w hack is, your router's warranty is not going void, you dont need to open your wi-fi router, openUI h/w is an USB add-on board to your router.


photo of openUI h/w
openUI h/w spec is as follows,
1)AVR attiny 2313 acting as a USB HID device
2)LCD display
2)RC5 IR receiver
3)PCF8563 RTC with i2c interface and battery backup.
4)I2C connector for different i2c peripherals.
5)In-circuit programming connector for attiny2313








Here you can find the schematic,layout and source code of OpenUI hardware and software.

Happy hacking.

Friday, October 15, 2010

Rooting Spice MI-300

Warning:
The process of Rooting your phone may brick your device and may void the manufacturer warranty, I hereby advise readers to be sure about what they are doing and I am not liable for any damage caused to your phone in this process.



NOTE:

  • Before Starting the Rooting process, I assume that you have updated your Spice MI-300 with official Android release 2.1 from Spice, and necessary data backup is done(rooting will erase all your phone data - but not the SDCARD data).
  • There are two different flavors of Custom ROMs available at Boston Mania, you can choose the suitable flavor either FiretrapVanilla or FiretrapSuger. Following Rooting procedure uses FiretrapSuger.

Simplest Method to root your Android Spice MI-300:
  1. Download the zipped nb0(Custom ROM) file from this link.
  2. Unzip the downloaded .rar file(using WinRAR) and rename firetrapSugar.nb0 to firmware.nb0
  3. Copy firmware.nb0 to your phones SDCARD under root directory(not anywhere in any folder).
  4. Switch OFF the phone.
  5. Press and hold volume_up+camera buttons, while holding these two buttons, also press and hold Power button(next to 3.5mm audio jack) for about 15 Seconds.
  6. Phone will boot and stay in "Android system recovery mode".
  7. Using trackball, scroll down to "Download nb0 from sdcard" and push trackball to start updating firmware.
  8. Wait for the phone to update firmware this may take 2-3 minutes.
  9. After the update, phone will reboot with new splash screen "Android"


Now you will have shiny Android flavor "firetrapSuger" with root access and some inbuilt applications.... Go-on and buy/download some nice apps like SetCPU/RootExplorer/QuickSSHD/CacheCleaner/WebSharing/Astro/Skype


SetCPU is a Paid Application using which you can set the speed of your cpu between 122Mhz to 600Mhz(try finding some free app for CPU clock from android market)


TIPS for your Rooted MI-300:
  • When Root Applications are invoked, Permission for root access will prompt user to confirm for access, you can check "always allow" for the needed applications to avoid re-confirmation every time.
  • Turn your camera flash to a Torch using a widget SwitchPro available in firetrapSuger.
  • Instead of adb through USB, Install QuickSSHd to gain shell access through wi-fi of your phone.
  • Using QuickSSHd, you can copy files and folders to your phone over wi-fi using winScp.

After Rooting, I also advise you to take the backup of all data partitions of Flash memory, follow these steps and keep the backup files somewhere safe:
  1. Login to your phone using adb or ssh/putty(for this you need QuickSSHd on your phone)
  2. If you login using adb, do 'su' and check your phone for super user confirmation and allow the root access
  3. Now you will have root permission to read your mtd partitions, run the following 11 linux commands to take the backup of all NANDFlash partitions(brief summary of Flash partitions of your phone can be viewed using 'cat /proc/mtd' command)
  • cat /dev/mtd/mtd0 > /sdcard/bkup.mdt0.boot
  • cat /dev/mtd/mtd1 > /sdcard/bkup.mdt1.misc
  • cat /dev/mtd/mtd2 > /sdcard/bkup.mdt2.splash
  • cat /dev/mtd/mtd3 > /sdcard/bkup.mdt3.recovery
  • cat /dev/mtd/mtd4 > /sdcard/bkup.mdt4.ftm
  • cat /dev/mtd/mtd5 > /sdcard/bkup.mdt5.hidden
  • cat /dev/mtd/mtd6 > /sdcard/bkup.mdt6.dgbmask
  • cat /dev/mtd/mtd7 > /sdcard/bkup.mdt7.system
  • cat /dev/mtd/mtd8 > /sdcard/bkup.mdt8.misc2
  • cat /dev/mtd/mtd9 > /sdcard/bkup.mdt9.cache
  • cat /dev/mtd/mtd10 > /sdcard/bkup.mdt10.userdata
Though you may not need the backup all partitions, but boot and recovery partitions are important, you can copy all these files from SDCARD and keep them safe somewhere on your PC.

There is one last important note:
In case if you want to go back to the official release to claim the warranty from spice, just update rooted phone with 'Software Update Tool' provided by Spice and your phone will be back to normal as it was.


Monday, October 11, 2010

Spice Mi-300

Being a Linux enthusiast, I have had this though of buying a phone on which I can try my programming skills apart from using it as a normal phone. For sure Android was my favorite candidate for its open source development platform.

Recently when i saw an ad from Spice on their new android touch phone for 10k, I couldn't hold myself from exploring this phone offering attractive hardware specification.

Initially I was bit skeptical due to limited information and review of this device on the web, some how i went ahead and took the chance to keep my 10k at stake(later on I found tons of information when I searched with different model number-Vibo A688).

Following is the list of pros and cons which i have felt after using it for several weeks,


Pros:
  1. Excellent touch response(much better than any other branded phone)
  2. Size and thickness are comparable with any other branded phone
  3. Fairly good quality picture(if taken at a good distance and good ambient light condition)
  4. Android 2.1 update is available.
  5. Active Android community providing custom ROMs(even Android 2.2 update is already under testing by the community).
  6. Fairly a good amount of hacking info available in the android community.
  7. If you are a Hacker, this is a best option to try your android development skills

Cons:
  1. Poor Built quality with plastic body
  2. Poor battery life(dont expect more than 1 to 1.5 days)
  3. camera is unable to focus for the photos taken at a shorter distance(ex: document scan)

Hardware:
Basically this phone is known with the model name Vibo-A688/Z71 among the android community and as per the android wiki, it is made by Taiwan based company Commtiva. Following list shows different model numbers of same hardware sold in different countries,
  1. Apanda A60(China):http://www.apanda.com.cn/
  2. ChinaVision Excalibur
  3. Cincinnati Bell Blaze f800
  4. Commtiva Z71
  5. Muchtel A1(Taiwan):http://www.muchtel.com/products/muchtel-a1.html
  6. Nexian Journey A890(Indonesia):http://www.nexian.co.id/index.php/product.html
  7. Orange Boston
  8. Spice Mi-300: http://www.spiceglobal.com/SpiceMobiles/Model.aspx?Id=167
  9. Vibo A688(Taiwan):http://www.vibo.com.tw/CWS/Consumer_Netcard,2c9681c62913f646012959ee62a500a0,,,.html#top
  10. Wellcom A88(Thailand):http://www.wellcommobile.com/th/a88.html
  11. Videocon is selling the same hardware with modified body called evolve-V7500
Even Motorola is selling the similar hardware called Motorola Quench XT502(see spec from gsm-arena)

After I got the 2.1 update from spice, I was bit disappointed to see that CPU Clock was reduced to 480Mhz from 600Mhz(for improving the battery backup), but I decided Root and update with new ROM called firetrap Sugar 1.1 from boston-mania
Warning: Rooting the phone or updating custom ROM may void manufacturer warranty, dont try this if you dont know what you are doing!!!!!!

Once you root your phone, you are open to the wonderful world of Linux open-source and full control over your phone, as a developer you can do several different things as listed below
  • setting the cpu clock(with different cpu clock profiles, you can conserve battery)
  • using camera flash as torch
  • using ssh to login to phone's commandline access
  • using phone's 3G to provide internet access to other computers(wi-fi teathering)
  • running your own scripts writtne in ruby, python,pearl, java script etc.. for different automation purpose
  • write your own C program and compile with arm-toolchain and run on your phone

Here are some interesting apps which I have installed on my phone and got better control over many things
  • Root Explorer(paid app)
  • QuickSSHD(paid app, you dont need usb-cable and adb to get linux shell access, use putty to login to your phone and winscp/pscp to copy files from your computer to mobile over wi-fi)
  • SetCPU(paid app, its great having control over your cpu speed)
  • Cache Cleaner(free app)
  • Alarm Clock Plus(free app)
  • WebSharing(paid version allows more features)
  • Astro(free file browser)
  • skype(save money at home/office, use wi-fi and talk using voip)
  • Picture Viewer (nice app for picture viewing)
  • Talking Tom(funny app for your kid)
  • Lookout(phone securing app for tracking your phone in case of lost/stolen mobile)
  • Barnacle Wifi Tether(turn you phone as a wifi router to serve internet for other PCs).
Here are the pictures of my android phone and screen shots, Hope you are happy to know amazing things possible with your 10k phone, Wish you Happy Hacking and watch-out for more android tips and tricks ;-)