tag:blogger.com,1999:blog-73439122024-03-29T08:59:50.893+05:30Gerald NaveenGerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.comBlogger136125tag:blogger.com,1999:blog-7343912.post-84402070471359401042015-04-19T17:01:00.000+05:302020-01-28T18:47:27.784+05:30Arduino over Wifi via ESP8266 module<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<a href="http://www.arduino.cc/" target="_blank">Arduino</a> is pretty handy for low powered projects and is cost-effective (against Raspberry Pi). Not being able to connect to a network natively is a big challenge in applying Arduino for most use cases. While, Arduino has a <a href="http://arduino.cc/en/Main/ArduinoEthernetShield" target="_blank">Ethernet Shield</a> for quite a while, it is impractical to expect a Ethernet port at every point an Arduino would be required. I do have <a href="http://geraldnaveen.blogspot.in/2014/04/fixing-bricked-tp-link-ethernet-over.html" target="_blank">Ethernet-over-Power </a>(EoP) at home to extend its reach, but still didn't scale for me (the over all cost will also include a EoP adapter).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
ESP8266 is an effective way to connect Arduino to a Wifi network. It is not a Arduino specific shield. It is a general purpose module that could be mixed with any other micro controller unit/circuit. All you need is a UART communication support on the other end (which almost all micro controllers have built-in). The added advantage is the cost, form-factor (unlike other shields) and just uses 2 pins from the Arduino (RX/TX of UART). The ESP8266 module is pretty small, but does its job well.</div>
<div style="text-align: justify;">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK8XNrcS77NgpxHQy2_zfUUYLx4NuTn8frC3x0suZnktmXSUYKMiXT6jSexu0hJHASiUaRfboWhcz-5L1cX-73OzOY7QFtx5qTni_P1yNE-yWr0j7o5vweld9JGWEyeOvxSV_FOQ/s1600/esp8266-wifi-module-500x500.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="374" data-original-width="500" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK8XNrcS77NgpxHQy2_zfUUYLx4NuTn8frC3x0suZnktmXSUYKMiXT6jSexu0hJHASiUaRfboWhcz-5L1cX-73OzOY7QFtx5qTni_P1yNE-yWr0j7o5vweld9JGWEyeOvxSV_FOQ/s320/esp8266-wifi-module-500x500.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ESP8266 Wifi Module</td></tr>
</tbody></table>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Once powered appropriately, you could communicate with the ESP8266 module via serial communication (@9600 baudrate, at least my version of ESP8266). The Wifi configuration/data everything is then communicated via the extensions to a standard AT command set. This being UART based, its going to be imposing restrictions on the rate of transfer of data (but might not matter for most use-cases) -- just to highlight the difference against a USB or SoC based Wifi implementation.</div>
<div style="text-align: justify;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://rayshobby.net/wordpress/wp-content/uploads/2014/10/ESP8266_pinout.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://rayshobby.net/wordpress/wp-content/uploads/2014/10/ESP8266_pinout.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ESP8266 PinOut</td></tr>
</tbody></table>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The module does have a built-in TCP/IP stack, so we don't have to worry about that -- that's why we do get response to ping automatically (as shown in the video below). It is not full-fledged though; provides basic connectivity over Layer4 -- good enough. It does have its own DHCP client as well.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
There is a open-source library for ESP8266 for Arduino:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<a href="https://github.com/Diaoul/arduino-ESP8266">https://github.com/Diaoul/arduino-ESP8266</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This is what I used, except for few fixes that I had to do. Some of the AT commands were differently used in the library. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Refer to <a href="http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf" target="_blank">ESP8266_WiFi_Module_Quick_Start_Guide</a> for more up-to-date AT commands.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here is the video showing my project in action :) Arduino joins my home Wifi network; shows its own IP on the LCD; runs a TCP server at port 1555 and waits to accept new connections. I connect from my desktop Ubuntu and send a message which shows up correctly on the Arduino LCD.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/s_vi/MeZePLGo8pA/default.jpg?sqp=CLijzqkF&rs=AOn4CLAfNT9OzPv47E73n309DwigBS2Fpg" frameborder="0" height="266" src="http://www.youtube.com/embed/MeZePLGo8pA?feature=player_embedded" width="320"></iframe></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This is going to be a cool extension to my <a href="http://geraldnaveen.blogspot.in/2014/12/home-automation-arduino-controlled.html" target="_blank">geyser control project</a> now -- I should be able to control my geyser from anywhere and more importantly time it based on the needs. Some sort of security needs to be worked out.</div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com7tag:blogger.com,1999:blog-7343912.post-15415305846280084782015-02-08T11:21:00.000+05:302015-02-08T11:21:22.465+05:30How I troubleshooted a tripping MCB<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
A tripping MCB is nothing uncommon and I have troubleshooted the faulting device many times before, but this time was interesting and challenging; hence the post.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
We had this nagging issue of our master MCB tripping every time we turn on the ceiling fan in one of our bedrooms. To complicate the problem further, the fan is a designer fan and has 3 light bulbs and a built-in speed control (via hanging strings). So the faulting electrical component could be one of the bulbs, OR the speed-regulator inside the fan, OR one of the fan's electrical components (capacitor, coil etc.,), OR the speed-regulator on the switch board OR something that I didn't think of then.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The regulator on the switch board was the least of my suspects, as my first suspect was the bulbs (hunch!) or something in the fan. Removed the bulbs and tried, no use. Opened the fan's casing and looked for any obvious burns or something -- no sign of any electrical fault. This doesn't rule out a problem with the fan, but I wanted to cover all easy approaches before getting into disassembling a fan. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Just decided to checkout the switchboard. As I opened the switchboard, it was evident! As you see below, I could see a burnt regulator casing with some internal leakages.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhenmNRs_nUXVe-sF3TuBYMOwOXXte0wvVxGLdDuhkJ1XGKdAO3FngJZncuI3TG6_Q9T6x1I76bUewc2YrFEl2I8rSTKne_By9v8JSnrELqvExBDaU6Smx6V4GLCjT9rYAPPRcXug/s1600/Screen+Shot+2015-02-08+at+10.46.24+am.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhenmNRs_nUXVe-sF3TuBYMOwOXXte0wvVxGLdDuhkJ1XGKdAO3FngJZncuI3TG6_Q9T6x1I76bUewc2YrFEl2I8rSTKne_By9v8JSnrELqvExBDaU6Smx6V4GLCjT9rYAPPRcXug/s1600/Screen+Shot+2015-02-08+at+10.46.24+am.png" height="411" width="640" /></a></div>
<br />
It appeared like, this was the issue. Since our fan has a builtin regulator and I didn't have a spare one handy, I decided to short the regulator off the circuit and use the fan's strings to control the speed. Changed the wirings quickly and tried, and Viola! the fan is running normally without tripping the MCB. Even the fan's built-in regulator worked.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYVWP7eQ6IbXjNnlGC76fbXYUPehO0_dyC_zv_szt_yODt49tV2XVbqr63SQJP51_tAp-pzu5byI6mkPDtyEUB04AgudxeAWGHhF5SjUCAdCuR3Fnz_0O6DJep81Z99KrjlFNhMg/s1600/Screen+Shot+2015-02-08+at+10.48.02+am.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYVWP7eQ6IbXjNnlGC76fbXYUPehO0_dyC_zv_szt_yODt49tV2XVbqr63SQJP51_tAp-pzu5byI6mkPDtyEUB04AgudxeAWGHhF5SjUCAdCuR3Fnz_0O6DJep81Z99KrjlFNhMg/s1600/Screen+Shot+2015-02-08+at+10.48.02+am.png" height="640" width="324" /></a></div>
<div style="text-align: center;">
(Pic: had just taken the regulator off the circuit) </div>
</div>
<div style="text-align: justify;">
<br />
With sense of satisfaction, I switched off the fan and closed the switchboard completely and screwed it tight. All done, so wanted to try for one last time that all is well. I turn on the fan, and the MCB trips! Wow, that's something :) </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I had to stop for a while, as I couldn't come up with a theory for this. As you might know, the typical household switches control only one polarity (typically phase/line), the neutral goes to the appliance (fan) directly. The possibility of a short-circuit inside a switch board is pretty less (except if the switch board has a high amperage plug or something, that controls both polarities). And in this case, the MCB trips only when I turn on the fan. So it should be something related to the switch, but the switch has only one polarity! I was pretty sure, I'm missing something, because I couldn't explain the behavior.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The hint I got was the fact that, it all worked until I closed the switchboard. I just realized that our MCB also has <a href="http://en.wikipedia.org/wiki/Earth_leakage_circuit_breaker" target="_blank">Earth Leakage Protection.</a> So it's probably not a short, but earth-leakage. On a closer look at the wiring that goes off the switch, towards the fan, I could find this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrPvyE5SNX2Fw-0kypio0EFZ-_4i0xjEDZEKbHLZUPvkMubpqWUr9l1AMK2scYKG-OimATkZX0xMg2tOdH6GhMkC0p3ekIq2AuXwCX_NDqYod-bZlu-7pQ20Pu55MwbtwuvsFvMw/s1600/Screen+Shot+2015-02-08+at+10.47.31+am.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrPvyE5SNX2Fw-0kypio0EFZ-_4i0xjEDZEKbHLZUPvkMubpqWUr9l1AMK2scYKG-OimATkZX0xMg2tOdH6GhMkC0p3ekIq2AuXwCX_NDqYod-bZlu-7pQ20Pu55MwbtwuvsFvMw/s1600/Screen+Shot+2015-02-08+at+10.47.31+am.png" height="290" width="400" /></a></div>
<br />
In one of the joints, the insulation had burnt a bit, exposing few strands of the wire. When I closed the board tight, these strands came in contact with the metal casing inside the switch board, which is grounded. This triggers a leakage on the earth line and the MCB trips. I just had to redo the insulation with new tape, and that was it. The fan is running fine since then, without tripping the MCB.</div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com24tag:blogger.com,1999:blog-7343912.post-46493381162145672412014-12-14T12:51:00.000+05:302014-12-14T12:51:44.553+05:30Home Automation: Arduino controlled Geyser <div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
A long-pending post. I had built this project way back in May 2014, during the summer (in India). In one aspect, it seems better to have delayed this post, as my project has gone through a few bug fixes and enhancements, both in hardware & software -- so I can talk about the most recent version.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I had done a few other home automation stuff earlier like this one : <a href="http://geraldnaveen.blogspot.in/2013/04/diy-raspberry-pi-controlled-power-strip.html" target="_blank">DIY: Raspberry Pi controlled Power Strip - Part 1</a>. I was/am constantly on the look out for any opportunity to automate things at home. We have been wasting lots of energy, as our geyser almost runs till cut-off most of the times and we won't need so much hot water during summer. This was simply because we won't remember to turn it off on time. I wanted to fix this by building a timer controlled switch for the geyser using Arduino.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I had earlier used Raspberry Pi for home automation. This time, I wanted to use Arduino for a few reasons. Unlike the <a href="http://geraldnaveen.blogspot.in/2013/04/diy-raspberry-pi-controlled-power-strip.html" target="_blank">power strip</a>, which is completely network-controlled, this is a low power project and doesn't necessarily be network-controlled (I could actually snap in a <a href="http://arduino.cc/en/Main/ArduinoEthernetShield" target="_blank">Ethernet Shield</a> for Arduino and make this network-controllable -- remember, I have Ethernet running over my power lines anyway, so easy to get a network anywhere). I also wanted to explore Arduino as part of this, as Arduino is relatively low cost and very low power (< 1W). I buy Arduino/Raspberry Pi from Ebay India directly (though they could be cheaper by other channels).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here is the circuit:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRGVNHWP6wzd4vwuZC7Y2CMAO-CSIkLUyG-Cakrv6T4bCc0b8wSBpFC29j8wMo7uL4Jb_xPCYzsFPf-cAo1JlkE14WQfJhHhUS92fl8zt_rKAoCEQq-4xLHSwcgSzZuwoZi35CrA/s1600/Geyser-control.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRGVNHWP6wzd4vwuZC7Y2CMAO-CSIkLUyG-Cakrv6T4bCc0b8wSBpFC29j8wMo7uL4Jb_xPCYzsFPf-cAo1JlkE14WQfJhHhUS92fl8zt_rKAoCEQq-4xLHSwcgSzZuwoZi35CrA/s1600/Geyser-control.png" height="384" width="640" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This circuit was drawn using some online tool (that isn't perfect). The tool had bugs, so some of it didn't come out the way I want. Still conveys the idea.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The project is primarily, a relay (Relay2) driving the high power geyser (ours is around 2500W). The original plan was to drive this relay by a signal from Arduino. The high power relay that I procured, required a signal voltage of around 9V without which it couldn't really turn on the load. Arduino GPIO pins operate only at 5V. So I had to introduce another relay (Relay1) to supply the required 9V (external source), but on signal from Arduino. This also ensures, not much current is drawn directly from Arduino. Arduino Uno has a built-in voltage regulator (safe up to 12V), but I decided to be safe and use a custom voltage regulator using LM7805 (I wouldn't want to heat up Arduino or burn it -- lot cheaper to build an external voltage regulator - around Rs.70). I also have a 16x2 LCD to display the status/timer (see photos). The LCD is driven using the standard <a href="http://arduino.cc/en/Reference/LiquidCrystal?from=Tutorial.LCDLibrary" target="_blank">Arduino LCD library</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here is the voltage regulator (built separately and tested out):</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPbeMjiUbe_BHqaWIp5tUbOZh4UZXEYb_-PzJSK5YpldUXEQzaMKZbbRcHzsIMMBR_iErTx2EQV_PHGYwxc_F6RpyO_p3iO9DUTUIcqfWq1BXKc7-gv-_cbL317GsFcpGnPh5ueQ/s1600/2014-12-13+11.23.06.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPbeMjiUbe_BHqaWIp5tUbOZh4UZXEYb_-PzJSK5YpldUXEQzaMKZbbRcHzsIMMBR_iErTx2EQV_PHGYwxc_F6RpyO_p3iO9DUTUIcqfWq1BXKc7-gv-_cbL317GsFcpGnPh5ueQ/s1600/2014-12-13+11.23.06.jpg" height="400" width="397" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
It doesn't turn on the geyser instantly. It runs a 10 second timer before it turns it on. This is to ensure that any electricity interruptions don't turn on/off the geyser too quickly. Better for the geyser.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqfRt7SoYGD-RjE49jJee_umsDI5ruLU50_YTE8dYZO8HZDFBdo-hRk6k2arnxjfizxKaz21DHoE0ry18iiHqbYR1djTl4lJvztkJEjfrnaZAbTr7DpX-kaf3heSxfu8FYcP7V2A/s1600/20141116_105257.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqfRt7SoYGD-RjE49jJee_umsDI5ruLU50_YTE8dYZO8HZDFBdo-hRk6k2arnxjfizxKaz21DHoE0ry18iiHqbYR1djTl4lJvztkJEjfrnaZAbTr7DpX-kaf3heSxfu8FYcP7V2A/s1600/20141116_105257.jpg" height="225" width="400" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Showing the countdown to shutdown:</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL6_RyJkoEZbep5KD2ndq2cCn8Pv5KzT6lcmzH6dGi52e4MZfymCvXLnJFnG77zZ0QE6C0sWXTK1fG3SIzcEBSiQCIobaw7v6ONpmxMSYDSyYIF_Oh3WGlG_o70q30oxkE-LPkew/s1600/20141116_105245.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL6_RyJkoEZbep5KD2ndq2cCn8Pv5KzT6lcmzH6dGi52e4MZfymCvXLnJFnG77zZ0QE6C0sWXTK1fG3SIzcEBSiQCIobaw7v6ONpmxMSYDSyYIF_Oh3WGlG_o70q30oxkE-LPkew/s1600/20141116_105245.jpg" height="225" width="400" /></a></div>
<br />
The project in action (for the last 6 months). The USB cable connects to the data port of Arduino via a hole in the case -- this is used for software upgrades in-place; just connect my Mac and click on a button to flash it instantly with new code. eg., Once the winter started, I had to patch it to increase the timer a bit to get it to the right temperature. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJoyC8CPgNRx9r0q4DaFL8UflRIkAMNbwaFSncjHXrtjm6aR-PA0SYbzbU1cWy5ybn38ucRiteH-6xy4T72iwO5-BGlogvHpKX5oz7tcsXbZZq9bSvJyRMaijJPQRugtBvvj_KMA/s1600/geyser_fitted.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJoyC8CPgNRx9r0q4DaFL8UflRIkAMNbwaFSncjHXrtjm6aR-PA0SYbzbU1cWy5ybn38ucRiteH-6xy4T72iwO5-BGlogvHpKX5oz7tcsXbZZq9bSvJyRMaijJPQRugtBvvj_KMA/s1600/geyser_fitted.jpg" height="225" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This board is in series with the geyser, so turning on the physical switch doesn't turn on the geyser (expected). </div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com18tag:blogger.com,1999:blog-7343912.post-39994044595505555162014-04-17T13:27:00.000+05:302014-04-17T13:27:59.236+05:30Fixing a bricked TP Link Ethernet-over-Power Adapter<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Though I have Wifi coverage throughout my home, for better bandwidth and lower latency/packet loss, I also run a Ethernet over the electric line (230VAC) using the Ethernet-over-Power (EoP) adapters. I have been using this for few years for high-speed connectivity across different rooms without having to lay new Ethernet cables. (eg., my home theatre system connects to my NAS via EoP to play HD videos without jitter over network).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This is the exact model I use:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<a href="http://www.tp-link.com.au/products/details/?model=TL-PA211KIT">http://www.tp-link.com.au/products/details/?model=TL-PA211KIT</a></div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7yY9tcgD7zYhcFSD7YUyoI7MqggRzKTDUkt31jaWDzbc1ADHnOD-2BAWFt7kK9s9UgxakYZNBOi5d84OWNIoZGQRLvWBajJTcv5Cgo57u0Bp4SaNopipeTGZ0NiSUQWPgrXdGVA/s1600/TPLinkSample.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7yY9tcgD7zYhcFSD7YUyoI7MqggRzKTDUkt31jaWDzbc1ADHnOD-2BAWFt7kK9s9UgxakYZNBOi5d84OWNIoZGQRLvWBajJTcv5Cgo57u0Bp4SaNopipeTGZ0NiSUQWPgrXdGVA/s1600/TPLinkSample.jpg" height="213" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
One of them went dead last year, so I had to buy 2 more to provide enough coverage. They aren't that cheap and aren't available in India directly (though I could import via ebay or amazon). Few months back, another one went dead. When I say dead, it would not power on, when you connect to the power line; no LEDs will glow and will be functionally dead as well. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This wasn't scaling (I can't keep buying new ones) and I didn't know what was wrong so I can prevent this. As it was anyways dead I decided to break it open and figure out what had happened (maybe just a fuse blown?). That's where it all started.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Unfortunately I don't seem to have photos during the disassembly (not sure why I didn't shoot). This was one of the hardest disassembly ever, for me. It is meant not to be opened. There is one screw at the back (hidden under a sticker). Unscrewing that doesn't do much, although required. The packaging is very rigid, you can't even break it easily. I drilled a small hole on this, using a Bosch drilling machine to peek in a bit :D yes, it was a risky thing to do. The white cover is locked on to the black case with notches in the sides -- I had to peek into the the heat vents to figure this out. Using a thin screw driver as wedge, I could open the white cover revealing the mother board inside.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
It runs of a proper ARM-based Atheros chip, along with a (expected) RealTek chip for Ethernet support. I could only see the top of the board, and most of the board's soldering was not accessible at this point, so I couldn't test any of the circuitry for faulty parts. I had to take the board out. Be careful if you are doing this -- as I figured out later that the board had been glued to the black case below; so it wouldn't come off the case easily. You need to apply force along the sides and take it off. There is no other screw, I can tell you now (this was my biggest scare, that if I miss a screw, the force might break the board).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
With quite some struggle and care, I took the board off the case. This is how the back of the board looks:</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig4OO8ME3LW4EAvfuES_YD0E2ILeaKJOFZdzyTTZ7ZNgz8Qn-rE5P2dRGQKo1kRNJOjFZQCWw8UMry5_jiRxZZpGTUGS8Jeuj8rV9Q7bx0w58cbWplAnsAkhInv-BjnqEyLh0nLQ/s1600/20140322_102804.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig4OO8ME3LW4EAvfuES_YD0E2ILeaKJOFZdzyTTZ7ZNgz8Qn-rE5P2dRGQKo1kRNJOjFZQCWw8UMry5_jiRxZZpGTUGS8Jeuj8rV9Q7bx0w58cbWplAnsAkhInv-BjnqEyLh0nLQ/s1600/20140322_102804.jpg" height="360" width="640" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Arrows in yellow, show the gum that was holding the board to the case. At first, I even thought if this was some sort of leakage from the underlying components. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This is how the top side of the board looks (yellow wire was soldered by me to test the board outside):</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRMK0YALeEdw_f2eWIQz3H9MhzVJhvCe_FYWnuVVWpvg-ajvX7NdVUMgAzRRTQY9e5AKKQmLPQt7C8vs5fiJzugouKaos_HqQn4j5Z4XlYh3-IC5CWyzhTFLY64psrt3idNuhq7w/s1600/20140327_185419.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRMK0YALeEdw_f2eWIQz3H9MhzVJhvCe_FYWnuVVWpvg-ajvX7NdVUMgAzRRTQY9e5AKKQmLPQt7C8vs5fiJzugouKaos_HqQn4j5Z4XlYh3-IC5CWyzhTFLY64psrt3idNuhq7w/s1600/20140327_185419.jpg" height="360" width="640" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The arrow on the left points to the fuse. I tested for continuity and it looked ok. Then started testing each capacitor. The 3 capacitors at the bottom right were seeming to be faulty (short on DC). I was a bit surprised to see all 3 capacitors being blown -- on further investigation, they were in parallel in the circuit and even one faulty capacitor could project all 3 to be faulty. When I looked at the back side of the board (red-rectangle as in the backside-view picture), I could see some leakage on one of the capacitors. The capacitor also had a slight bulge at its top (no photo). I was more hopeful then. On soldering out the capacitor, off the board, the other two capacitors tested normal -- Good!</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This was the faulty capacitor:</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM4P_iKCl9Qo3DO25OLS9s_fwv6JiKmKaoWuL_PVpYR_vzbMkXEjGxyaKBR_vBe3jSj3afaQ9FAaG6RXVmoE54IaYSJn0zEgObpV07O3As3TU48QcT_e8HLsVdz0gO63nIN6VMxg/s1600/FaultyCap.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM4P_iKCl9Qo3DO25OLS9s_fwv6JiKmKaoWuL_PVpYR_vzbMkXEjGxyaKBR_vBe3jSj3afaQ9FAaG6RXVmoE54IaYSJn0zEgObpV07O3As3TU48QcT_e8HLsVdz0gO63nIN6VMxg/s1600/FaultyCap.png" height="320" width="229" /></a></div>
<br />
<div style="text-align: justify;">
</div>
<br />
<br />
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now I need to get a spare cap with the same spec. Ebay India came to rescue. Ordered 10 capacitors 1500uF/10V and were delivered in 3 days.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The above top-side picture actually shows the board with the new capacitor replaced. Packed it in and did one final round of testing before I packed it into its box.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5bW7rBw_peNpOUz4SPm91wBd7ue7S78Hvuow4PrBj6iXdyCgtxl0hb6hm2a9BsavqzcI1NHPLMJBHt0Jkyf-rhyphenhyphenEFkXSEDnNPM9nWbAVa7UyHisnfYp_64LzN5tD-qWjyDxaN3w/s1600/testing1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5bW7rBw_peNpOUz4SPm91wBd7ue7S78Hvuow4PrBj6iXdyCgtxl0hb6hm2a9BsavqzcI1NHPLMJBHt0Jkyf-rhyphenhyphenEFkXSEDnNPM9nWbAVa7UyHisnfYp_64LzN5tD-qWjyDxaN3w/s1600/testing1.png" height="640" width="456" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Test success. And here it is the final working version back in action:</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpwKxKhh7YgXBJCpMJvM-zllB2HEAC3SwykENKL8NDfvdR3t9psN8k4f2gnMaZjF6DKEMXX6k_Q1tBIGH8OD5MasxPgDkq04gpFO-08V2ygGE9zMYhw_CR3FPgOtqJQg7SOp6qIw/s1600/final.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpwKxKhh7YgXBJCpMJvM-zllB2HEAC3SwykENKL8NDfvdR3t9psN8k4f2gnMaZjF6DKEMXX6k_Q1tBIGH8OD5MasxPgDkq04gpFO-08V2ygGE9zMYhw_CR3FPgOtqJQg7SOp6qIw/s1600/final.png" height="310" width="320" /></a></div>
<div style="text-align: justify;">
</div>
<br />
<br />
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
And that's how I fixed a TP link EoP adapter for Rs.10 :)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
If you have one such dead one, give it a try. It is likely this cap issue.</div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com4tag:blogger.com,1999:blog-7343912.post-23582350744787584022013-11-10T20:54:00.000+05:302013-11-10T20:55:11.688+05:30Fixing Raspberry Pi filesystem corruption<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
While Raspberry Pi is a computer in its core, it is treated like an embedded device in most cases -- we can't expect a proper shutdown of Pi in most cases. This results in corruption of the / (root) file system (ext4) due to unclean unmount. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In case you have been reinstalling Pi on to the sdcard every time this happens, you don't really have to reinstall. In most cases, mount the card via a card reader and run </div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">sudo fsck.ext4 /dev/xxxx [xxxx the device file of the root partition]</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
(I assume linux by default). This should fix the / file system and the card will let your Pi boot now. If this doesn't help, try fixing the /boot partition:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">sudo fsck.vfat /dev/xxxx [xxxx - the device file of the boot partition]</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
That said, you don't really have to do this. The clean and guaranteed protection against this problem could be provided by mounting the filesystem as read-only. Thus the filesystem is completely intact and will have no chance of corruption. In most cases, this should be fine (unless you have a reason to persist something on to the root filesystem). If you still need to write something to disk, write it to a different partition so it doesn't prevent Pi from booting if that goes corrupted.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
How to mark the / and /boot partitions read-only:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
You could do this from Pi itself, or on a different machine. Just edit /etc/fstab and add 'ro' in the flags as shown below:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">/dev/mmcblk0p1 /boot vfat defaults,<b><span style="color: red;">ro</span></b> 0 2</span><br />
<span style="font-family: "Courier New",Courier,monospace;">/dev/mmcblk0p2 / ext4 defaults,<b><span style="color: red;">ro</span></b>,noatime 0 1</span></div>
<div style="text-align: justify;">
<br />
Now reboot the Pi and it should boot with both these mount points in read-only mode. You could do a mount to verify, it should look something similar to this:</div>
<div style="text-align: justify;">
<br /></div>
<div>
<span style="color: red;"><span style="font-family: "Courier New",Courier,monospace;"><b>/dev/root on / type ext4 (ro,noatime,data=ordered)</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">devtmpfs on /dev type devtmpfs (rw,relatime,size=216108k,nr_inodes=54027,mode=755)</span><br />
<span style="font-family: "Courier New",Courier,monospace;">tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=44876k,mode=755)</span><br />
<span style="font-family: "Courier New",Courier,monospace;">tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)</span><br />
<span style="font-family: "Courier New",Courier,monospace;">proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)</span><br />
<span style="font-family: "Courier New",Courier,monospace;">sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)</span><br />
<span style="font-family: "Courier New",Courier,monospace;">tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=89740k)</span><br />
<span style="font-family: "Courier New",Courier,monospace;">devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)</span><br />
<span style="color: red;"><span style="font-family: "Courier New",Courier,monospace;"><b>/dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022, dmask=0022, codepage=cp437, iocharset=ascii,shortname=mixed, errors=remount-ro)</b></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,size=89740k)</span><br />
<br /></div>
<div style="text-align: justify;">
<b>Note:</b> Some services (like apache2) might fail to start, because they can't write to disk. You might have to check individual services to figure out what they are trying to write and resolve it appropriately. For eg., apache2 writes log files /var/log/apache2. It is best to disable logging. If there is not too much logging, you could map the log folder to /tmp (tmpfs -- as shown in mount).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
as root:</div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;">mkdir /tmp/apache2 </span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;">chmod a+wx /tmp/apache2</span> </span> </span><br />
<span style="font-family: "Courier New",Courier,monospace;">cd /var/log</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">rm -rf apache2</span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;"></span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">ln -s /tmp/apache2 apache2</span></div>
<div style="text-align: justify;">
<br />
There is no worry of file system corruption any more. You could switch off Pi any time. I have been using this setup (in my <a href="http://geraldnaveen.blogspot.in/2013/02/home-automation-raspberry-pi-controlled.html">PowerStrip Project</a>) for many months now, without issues.</div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com15tag:blogger.com,1999:blog-7343912.post-27120868932081120242013-05-12T19:01:00.000+05:302013-05-12T19:01:10.426+05:30SSH to Raspberry Pi first time without keyboard/monitor<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Applies to "wheezy" version, not sure about other versions.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Raspberry Pi is mostly used as a remote machine and usually not tied up with any keyboard or a monitor, as in my case. Whenever you reimage a version of Raspberry Pi, connecting through ssh doesn't work.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Raspberry Pi's latest images come with "sshd" enabled by default. However, during first boot, "raspi-config" script (from /etc/profile.d/raspi-config.sh) kicks in and throws up a UI on the screen for the user to respond. This doesn't timeout and doesn't let the boot sequence complete; you would notice that Rsbpi has joined the network, but one cannot ssh to it (as the startup is stuck at this script and sshd is not started yet).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Workaround:</b></div>
<div style="text-align: justify;">
Once you reimage the SD card, mount the ext4 partition just created on the card. This will give access to the root (/) filesystem of the "wheezy" linux. Comment out the following line from /etc/inittab on that / filesystem:</div>
<div style="text-align: justify;">
<b><i><br /></i></b></div>
<div style="text-align: justify;">
<b><i>1:2345:respawn:/bin/login -f root tty1 </i></b></div>
</div>
/dev/tty1 2>&1 # RPICFG_TO_DISABLE<br /><div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This disables auto-login of root and raspi-config doesn't run until an interactive login happens as root. Now you can boot the SD card on Rsbpi and you should be able to ssh to it. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Worked for me!</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com0tag:blogger.com,1999:blog-7343912.post-40404198707696788242013-04-13T05:57:00.000+05:302014-12-14T12:51:58.785+05:30DIY: Raspberry Pi controlled Power Strip - Part 1<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
This post will cover some behind-the-scene details on what went behind making this power strip. Had been quite busy for a while, so couldn't make it earlier.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
There were few questions that I had to answer before I was sure I could build this:</div>
<ol style="text-align: left;">
<li>How do I control 220V AC from an electronic circuit, safely? Can I do it right the first time so I don't blow up the raspberry Pi? Being completely a software guy, this was a challenge. This was the first part of the problem I solved as shown in my earlier post on <a href="http://geraldnaveen.blogspot.in/2013/01/controlling-220v-bulb-using-raspberry-pi.html">Controlling 220v Bulb using Raspberry Pi.</a> </li>
<li>Can I fit this whole solution seamlessly into an existing power strip so it has a clean form-factor and intuitive to use? Finding one such power strip which had enough space to hold additional circuits was a challenge.</li>
<li>Building software so I can remotely control the power strip over any device. I decided to go the web interface route, so I can do it easily from any device. The software I eventually implemented is based on RESTful APIs, so it would also be easier for me to write an Android app or any other app over this interface.</li>
</ol>
<h3 style="text-align: justify;">
Controlling 220V AC from Raspberry Pi</h3>
<h3 style="text-align: justify;">
</h3>
<div style="text-align: justify;">
One of the foremost requirements for choosing Raspberry Pi was that it has programmable <a href="http://en.wikipedia.org/wiki/General_Purpose_Input/Output">GPIO</a> (General Purpose Input / Output) headers, without which any electronic interfacing would be pretty difficult and inefficient. Most micro-controllers (including modern microprocessors do provide GPIO pins) for interfacing with other low-level hardware peripherals. The voltage on a GPIO PIN can be controlled by instructing the micro-controller. Usually a TTL low/high is used to signal 0 or 1. But it is totally up to the interface to decide how to interpret it. Raspberry Pi uses 3V3 TTL, which means a 3.3V for high and 0V for low. Specially when you are using the GPIO pins for input, make sure the voltage doesn't exceed 3.3V. For the power strip, it is only in output mode.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Relay is another important component. It is an electro-magnetic switch that is used to turn on or off the high voltage. Relays require slightly higher voltages (>=12V) to work. When there is enough current flow, an electro-magnetic coil gets magnetized and pulls off a lever to turn on the switch. When the power is switched off, there is no magnetic field, and a mechanical spring pulls it back to its original position. Relay is a mechanical device and might suffer some latency and noise during its operation. It is not meant for high-precision control, but in my case this is good enough.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Since relays work on higher voltages and that it requires substantial current, a relay cannot be driven directly from a Raspberry Pi. It is very common to use a transistor as a switching device to turn on slightly higher voltages and/or when you need more current. This allows us to withdraw very less current (only the base current) from the controlling source (in our case Raspberry Pi) and to use a completely different power source (>=12V) for the controlled device (in our case, a relay). I have plugged in a 12V power adaptor which provides sufficient current to turn on/off the relay.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This is the circuit that drives a single relay: (The core idea of this circuit is a very common circuit that is used to control a relay via a transistor. I have customized it to appeal for the given use case.)</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdKCC7JozWcjPerB1Em8bHjZYZB2HNo2AwyQC6HZ6yNr8agTBGIptjwP1i8ecAJ6m91uCiHTCPuEItc9nZug5WxOnyeSxLuWS7Lz_FHrdZ6SqQQ5xNo0XM7divIhedq6zw1GlY0w/s1600/Circuit.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdKCC7JozWcjPerB1Em8bHjZYZB2HNo2AwyQC6HZ6yNr8agTBGIptjwP1i8ecAJ6m91uCiHTCPuEItc9nZug5WxOnyeSxLuWS7Lz_FHrdZ6SqQQ5xNo0XM7divIhedq6zw1GlY0w/s640/Circuit.png" height="464" width="640" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Remember that Raspberry Pi runs off USB power. Model B has a cap of 700mA in the inlet and this current is used for the complete functioning of Raspberry Pi. Any current that we draw out of this, is expensive and we need to be cautious. Specially if you are planning to drive a load (say a LED) directly, without using a different power source. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
WARNING: As I learned, there is no fuse of any sort behind the GPIO headers -- so any incorrect use might blow the micro-controller, thereby making a Raspberry Pi brick. Take extreme precautions and ensure that you are fine with the current you draw/sink from/into the GPIO.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The GPIO18 is just one of the many GPIO pins that could drive this transistor. To turn it on, my code will set a HIGH on that pin, thereby raising the voltage on that pin to 3.3V. With the required V-BE (the base-emitter voltage) at 0.7V to turn on, for the 4.7KOhm base resistor, the transistor will just draw around 0.5mA current from the raspberry Pi. Even when multiple relays are ON, there is no risk of over-drawing current from Raspberry Pi. The Diode D1 provides protection against any reverse current that could occur at the moment the relay is switched off.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Raspberry Pi has a <a href="https://pypi.python.org/pypi/RPi.GPIO">GPIO python library</a> that we can use to control the GPIO pins with ease. By being able to control from python, I didn't have to go through the pain of cross-compiling every time I modified any code.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Snip of code:</div>
<pre class="brush:python">#
#initialization
#
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) # use BCM pin numbering
GPIO.setup(gpio_pin_number, GPIO.OUT) # mark for output
#end of initialization; following could be called multiple times.
GPIO.output(gpio_pin_number, GPIO.HIGH) # output high / 3.3v
GPIO.output(gpio_pin_number, GPIO.LOW) # output low / 0v
#
</pre>
<div style="text-align: justify;">
As simple as that. Based on the command issued remotely, my power strip daemon would choose the right gpio_pin_number and set it to HIGH or LOW appropriately.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This post is getting long :). So, more about the packaging of the relay board, associated software design, in the subsequent posts.</div>
<!-- syntax highlighter -->
<script src="https://sites.google.com/site/geraldnaveen/scripts/public/syntaxhighlightloader.js" type="text/javascript"></script>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com6tag:blogger.com,1999:blog-7343912.post-11169710607392145572013-02-17T18:55:00.000+05:302013-02-17T19:07:53.786+05:30Home Automation - Raspberry Pi controlled Power Strip<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Watch my <a href="http://geraldnaveen.blogspot.in/2013/01/controlling-220v-bulb-using-raspberry-pi.html">previous post</a> on a prototype project using <a href="http://www.raspberrypi.org/">Raspberry Pi</a>. Now you would know what was that prototype for.<br />
<br />
Yes, I now have built a power strip that is completely controllable by a Raspberry Pi over network. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The idea of controlling a power strip over network is nothing new, but this is certainly a unique one and I needed this badly. I have built a power strip with more features than the off-the-shelf ones and they were at least twice as expensive as what it took me to build this one. I can fix any problem in this device from software to a relay to a resistor -- in case any of these is blown. Oh yeah, the happiness of building something yourself is invaluable :)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
To me, one of the driving factors for such a device is: We have Tata Sky+ HD at home and we record TV programs left and right. It has almost reached a point that we don't watch live content except news (for the time comfort and sake of skipping ads). Many interesting series do come in the night, for which, we leave the set-top-box (STB) on -- naturally for prolonged time (till morning) even if the recording is just for an hour or so in the midnight. Tata Sky+ HD STB consumes 20+W of power even on standby. I wanted to avoid this waste of power, by having the ability to turn on/off the power sockets using a rather low power device.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Raspberry Pi consumes just around 3.5W and has complete networking support. With abundant GPIO pins, I can use it to control at least 8 different sockets. This is one of the main reasons for me to choose a Raspberry Pi. While I had worked on AVR based micro controllers, but getting a AVR board on the network would have been much more difficult than this. Also the power of Linux, provides numerous software that were of great use to me while building this (<a href="http://www.python.org/">python</a>, <a href="http://httpd.apache.org/">apache2</a>, <a href="http://flask.pocoo.org/">flask</a> etc.,)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Some of the key features:</div>
<ul style="text-align: left;">
<li>Power Sockets are controllable via a web interface, so available from any device on the network. </li>
<li>Web service supports REST based interaction for easy integration with any app that I might write in the future (at least for the android phones).</li>
<li>Core web and daemon logic on python that avoids cross-compilation work for Rs Pi architecture. Rewrite code easily and just drop it for deployment. This was awesome! God bless interpretors!</li>
<li>Ability to control sockets from the Internet once I VPN into my home network. (this should let us do the recording even when we are on vacation; how cool is it that I can turn a socket in Bangalore on or off, from anywhere in the world)</li>
<li>Timer support, so I can schedule a On or Off event after a while. Say, I can turn on a socket at midnight 12am, run it for an hour and turn it off! There is a dedicated power daemon that runs in the background to take care of scheduling these requests when its time. </li>
<li>The power sockets are still controllable using their dedicated switches, so you don't have to hunt for a browser to turn on the sockets. </li>
</ul>
Here is the power strip in action:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='480' height='399' src='https://www.youtube.com/embed/CfKdlusW2Lk?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br />
I have also now installed the power strip for the real purpose I wanted for. See the demo where I turn OFF my Tata Sky+ HD Set Top Box using the mobile.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='480' height='399' src='https://www.youtube.com/embed/2qMgNN0V7Wg?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br />
I have taken photos all the way while I built this power strip. Stay tuned for lot more technical details (electronic circuits, hardware, software) with photos, on what went behind this power strip.<br />
<br />
Sneak peek:<br /><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho3cgcMQNlEbG5P08AqzhQmlWPhy0pknnPp8vyFKXjXyqJT3r18YM5ZAVBRU6RtG3VzTs-XfLDXAxAbrmAmQOgmRU3_oYSFepznUVbShEat6OXtdXTqjbqJxcGdr4fOsaCv4E2AQ/s1600/20130208_200119.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho3cgcMQNlEbG5P08AqzhQmlWPhy0pknnPp8vyFKXjXyqJT3r18YM5ZAVBRU6RtG3VzTs-XfLDXAxAbrmAmQOgmRU3_oYSFepznUVbShEat6OXtdXTqjbqJxcGdr4fOsaCv4E2AQ/s640/20130208_200119.jpg" width="640" /></a></div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com6tag:blogger.com,1999:blog-7343912.post-68826447701106831392013-01-31T20:05:00.000+05:302013-02-20T12:29:43.295+05:30 Controlling 220v Bulb using Raspberry Pi<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
I have always had this excitement to control high-voltage devices from electronics. I could never do one because of lack of hardware and/or the scare for dealing with high voltage and getting it right the first time. Finally, I now have a proof of concept project that controls a 220v bulb from a Raspberry Pi. More details, maybe in a later post. Right now, I need to build a better actual project with this :) </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Raspberry Pi runs on Raspbian Wheezy linux and the controlling code is written in Python. </div>
<br />
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/x3Ty4MTGqyw" width="560"></iframe> </div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com2tag:blogger.com,1999:blog-7343912.post-47318147151368924032012-12-13T21:28:00.000+05:302012-12-13T21:40:57.498+05:30WDTV Live -- Firmware Hacking Series -- Part 3<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
Patching custom rootfs onto existing firmware </h3>
<br />
<div style="text-align: justify;">
Once you have the serial cable built as mentioned in my <a href="http://geraldnaveen.blogspot.in/2012/12/wdtv-live-firmware-hacking-series-part-2.html">previous post</a>, it is possible to patch the current firmware installation with custom rootfs, without having to upgrade/reinstall the whole firmware with custom one.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
These are the high-level steps that we need to do:</div>
<ol style="text-align: left;">
<li>Discover the partition table and identify where the rootfs is stored in the flash storage.</li>
<li>Read the rootfs of the current firmware and push it to a different machine.</li>
<li>Modify the rootfs to your needs, on the other machine.</li>
<li>Upload it back to WDTV and write the flash partition appropriately.</li>
</ol>
<h3 style="text-align: left;">
Discovering the rootfs partition</h3>
<pre class="brush:bash">~ # mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
<span style="color: red;">/dev/sigmblockh on / type cramfs (ro)</span>
none on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
usb on /proc/bus/usb type usbfs (rw)
mdev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw)
none on /tmp type tmpfs (rw)
/dev/loop0 on /tmp/static_config type minix (rw)
</pre>
<br />
<div style="text-align: justify;">
Note the highlighted line. /dev/sigmblockh device is the one mounted as / partition. To confirm print the first 100 bytes on the device and you could notice the CRAMFS header.</div>
<br />
<pre class="brush:bash">~ # hexdump -c -n 100 /dev/sigmblockh
0000000 E = 315 ( \0 @ 021 003 003 \0 \0 \0 \0 \0 \0 \0
<span style="color: red;">0000010 C o m p r e s s e d R O M F S</span>
0000020 234 333 016 324 \0 \0 \0 \0 k & \0 \0 313 016 \0 \0
0000030 C o m p r e s s e d \0 \0 \0 \0 \0 \0
0000040 355 A 354 003 D 001 \0 d 300 004 \0 \0 355 A 354 003
0000050 354 \v \0 d 001 031 \0 \0 b i n \0 377 241 354 003
0000060 \t \0 \0 d
0000064
~ # </pre>
<div style="text-align: justify;">
We still need to know the exact flash disk and the partition to which this device points to.</div>
<br />
<pre class="brush:bash">~ # ls /dev/sigm* -l
brw-rw---- 1 root root 254, 0 Jan 1 2000 /dev/sigmblocka
brw-rw---- 1 root root 254, 1 Jan 1 2000 /dev/sigmblockb
brw-rw---- 1 root root 254, 2 Jan 1 2000 /dev/sigmblockc
brw-rw---- 1 root root 254, 3 Jan 1 2000 /dev/sigmblockd
brw-rw---- 1 root root 254, 4 Jan 1 2000 /dev/sigmblocke
brw-rw---- 1 root root 254, 5 Jan 1 2000 /dev/sigmblockf
brw-rw---- 1 root root 254, 6 Jan 1 2000 /dev/sigmblockg
<span style="color: red;">brw-rw---- 1 root root 254, 7 Jan 1 2000 /dev/sigmblockh</span>
brw-rw---- 1 root root 254, 8 Jan 1 2000 /dev/sigmblocki
brw-rw---- 1 root root 254, 9 Jan 1 2000 /dev/sigmblockj
brw-rw---- 1 root root 254, 10 Jan 1 2000 /dev/sigmblockk
brw-rw---- 1 root root 254, 11 Jan 1 2000 /dev/sigmblockl
</pre>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The highlighted line shows the major, minor numbers for this device. As you might know, the minor number is the partition number on the disk. In this case, the rootfs is stored in the 7th partition.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
To understand where is the 7th partition stored in the flash disk, we need to know the partition information of the internal flash disk. This could be obtained in two different ways. Either by looking at the logs during WDTV boot (via serial port) or by issuing the following command at the terminal (via serial again).</div>
<br />
<pre class="brush:python">~ # cat /proc/sigminfo
dev: size offset name CS
sigmblk0: 0ff80000 00000000 "CS0-Device" 0
sigmblk1: 00080000 00000000 "CS0-Part1" 0
sigmblk2: 00040000 00080000 "CS0-Part2" 0
sigmblk3: 00300000 000c0000 "CS0-Part3" 0
sigmblk4: 00300000 003c0000 "CS0-Part4" 0
sigmblk5: 01000000 006c0000 "CS0-Part5" 0
sigmblk6: 00800000 016c0000 "CS0-Part6" 0
<span style="color: red;">sigmblk7: 05a00000 01ec0000 "CS0-Part7" 0</span>
sigmblk8: 05a00000 078c0000 "CS0-Part8" 0
sigmblk9: 00020000 0d2c0000 "CS0-Part9" 0
sigmblk10: 00020000 0d2e0000 "CS0-Part10" 0
sigmblk11: 00020000 0d300000 "CS0-Part11" 0
</pre>
<br />
<div style="text-align: justify;">
We are almost there now. This shows the starting offset (0x01ec0000) and the size (0x05a00000) of the partition. That is a 90MB partition reserved for rootfs ie., the compressed cramfs partition cannot exceed 90MB.</div>
<br />
<h3 style="text-align: left;">
Read rootfs and export to different machine</h3>
<div style="text-align: left;">
<br />
<div style="text-align: justify;">
This is required as we need to patch the rootfs of the installed firmware. Press 0 (via the serial port) and restart WDTV Live. This will prevent loading the firmware and will stop boot at booloader YAMON. </div>
</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Follow my inline comments in the script below.</div>
<div style="text-align: left;">
</div>
<pre class="brush:bash"><span style="color: #666666;">[Gerald] Plugin an Ethernet cable connected to a valid network.
[Gerald] net init, initializes the interface and runs DHCP client.</span></pre>
<pre class="brush:bash">YAMON> net init
Ethernet driver for SMP86XX (v1.0)
(MAC 00:90:xx:xx:xx:xx)
em86xx_eth0 - full-duplex mode
em86xx_eth0 - 100 Mbit/s
em86xx_eth0 ethernet start
DHCP was successfully configured.
ipaddr: 192.168.8.104
subnetmask: 255.255.255.0
gateway: 192.168.8.2 </pre>
<pre class="brush:bash"><span style="color: #666666;">[Gerald] 'nflash read' command is used to read from the flash memory.
[Gerald] Based on the discovery earlier, the following command reads
[Gerald] first 0x1e00000 bytes into memory at 0x8400000.
[Gerald] syntax: nflash read flash_address memory_address size chip_select
[Gerald] chip_select (CS) is available in the partition info at /proc/sigminfo.
[Gerald] Note: Use only 0x84000000 as target. Other addresses didn't let me read
[Gerald] 0x1e00000 bytes at once.Even here, I couldn't read the complete 0x5a00000
[Gerald] bytes at once.</span>
YAMON> nflash read 0x01ec0000 0x84000000 0x1e00000 0
<span style="color: #666666;">[Gerald] Verify if this has indeed read the CRAMFS from flash. </span>
YAMON> dump 0x84000000 100
84000000: 45 3D CD 28 00 40 11 03 03 00 00 00 00 00 00 00 E=�(.@..........
84000010: 43 6F 6D 70 72 65 73 73 65 64 20 52 4F 4D 46 53 Compressed.ROMFS
84000020: 9C DB 0E D4 00 00 00 00 6B 26 00 00 CB 0E 00 00 .�.�....k&..�...
84000030: 43 6F 6D 70 72 65 73 73 65 64 00 00 00 00 00 00 Compressed......
84000040: ED 41 EC 03 44 01 00 64 C0 04 00 00 ED 41 EC 03 .A..D..d�....A..
84000050: EC 0B 00 64 01 19 00 00 62 69 6E 00 FF A1 EC 03 ...d....bin..�..
84000060: 09 00 00 64 ...d
<span style="color: #666666;">[Gerald] upload the file to a tftp server of your choice.
[Gerald] syntax: fwrite tftp_path memory_address size</span>
YAMON> fwrite tftp://192.168.8.101/sigh/sigh.dump.1 0x84000000 0x1e00000
About to binary write tftp://192.168.8.101/sigh/sigh.dump.1
Successfully transferred 0x1e00000 (10'31457280) bytes
<span style="color: #666666;">[Gerald] Read the next 0x1e00000 bytes from flash and upload to TFTP</span>
YAMON> nflash read 0x03cc0000 0x84000000 0x1e00000 0
YAMON> fwrite tftp://192.168.8.101/sigh/sigh.dump.2
About to binary write tftp://192.168.8.101/sigh/sigh.dump.2
Successfully transferred 0x1e00000 (10'31457280) bytes
<span style="color: #666666;">[Gerald] Read the next 0x1e00000 bytes from flash and upload to TFTP </span>
YAMON> nflash read 0x05ac0000 0x84000000 0x1e00000 0
YAMON> fwrite tftp://192.168.8.101/sigh/sigh.dump.3
About to binary write tftp://192.168.8.101/sigh/sigh.dump.3
Successfully transferred 0x1e00000 (10'31457280) bytes
YAMON> </pre>
<h3 class="brush:bash" style="text-align: justify;">
Modify the rootfs to your needs </h3>
<br />
<div class="brush:bash" style="text-align: justify;">
At this point, we have three 30MB files and concatenating them in order, should give a complete cramfs partition. You could now extract the cramfs partition (using modified cramfsck, as mentioned in my <a href="http://geraldnaveen.blogspot.in/2012/11/wdtv-live-firmware-hacking-series-part-1.html">earlier post</a>) and make the necessary modification.</div>
<div class="brush:bash" style="text-align: justify;">
<br /></div>
<div class="brush:bash" style="text-align: justify;">
I have the following section of script added to the /init script, that gets control to my USB script as root. This lets me run scripts on startup and modify them as required, without having to reflash anything. Don't forget to update the /md5sums.txt file with your updated md5sum.</div>
<pre class="brush:bash"># Gerald - update - start
if [ -f /tmp/media/usb/wdtv/gerald_init ]; then
/tmp/media/usb/wdtv/gerald_init &
# Gerald - update - end </pre>
<div class="brush:bash" style="text-align: justify;">
Use the modified mkcramfs (as mentioned in my <a href="http://geraldnaveen.blogspot.in/2012/11/wdtv-live-firmware-hacking-series-part-1.html">earlier post</a>) to repack the rootfs into a cramfs filesystem file. Split the file into three 30MB files (note: you may need to append zeros at the end to fill up to 30MB in the third part -- your cramfs filesystem is likely to be < 90MB).</div>
<br />
<h3 class="brush:bash" style="text-align: justify;">
Upload back to WDTV and write the flash partition appropriately </h3>
<div class="brush:bash" style="text-align: justify;">
<br />
Boot into YAMON. Use 'fread' to read from tftp to memory at 0x84000000. Use 'nflash write' to write the parts into their correct flash locations starting at 0x01ec00000. Once all 3 partitions are written, just reboot. Your new rootfs should be active.<br />
<br />
By now, you would no longer be worried about what to do if that doesn't boot. Good luck! </div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com18tag:blogger.com,1999:blog-7343912.post-67705808357033458182012-12-01T18:57:00.000+05:302012-12-01T21:10:19.190+05:30WDTV Live -- Firmware Hacking Series -- Part 2 <div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
</div>
<h3 style="text-align: left;">
Building serial cable for WDTV Live motherboard</h3>
<div style="text-align: justify;">
<br />
The motherboard has a serial port that could be used for directly interacting with the device (input and output). The official firmware doesn’t expose any means of terminal access via telnet, ssh etc., So as long as you are on an official firmware there is nothing much you could do with it. When booted, the serial port provides a root shell for directly interacting with the underlying linux. However, the prime use of the serial port is that, it provides input/output right from the time the device is powered on (for eg., once known you could interact with the boot loader etc.,) -- this is the piece that helps you unbrick or play around with much lower levels on the device.<br />
<br />
In this post, I will take you through the process of building my own serial cable for WDTV Live. First problem, this is a hardware. So you need to really build tangible things; maybe procure stuff.<br />
<br />
Here is the pin out for the serial socket on the motherboard.<br />
<br /></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaDJ8LglQOtfHtFeHq69Dy4ThaWgcDsGtP5BTsqJWW9stlXRTwY010WUaRxBroSFSBzGOH4lI4HcHhyqnOCy2PqFgt4l69K_W_Ro2KU9qTo0AqWhOgjhwHXAhPyokiRt7wmetdVQ/s1600/wdtv-serial-port.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaDJ8LglQOtfHtFeHq69Dy4ThaWgcDsGtP5BTsqJWW9stlXRTwY010WUaRxBroSFSBzGOH4lI4HcHhyqnOCy2PqFgt4l69K_W_Ro2KU9qTo0AqWhOgjhwHXAhPyokiRt7wmetdVQ/s1600/wdtv-serial-port.png" /></a></div>
</div>
<div style="text-align: justify;">
<br />
The white socket at the bottom of the picture is the serial port. As seen on the picture, the pins are +5V, RX, TX, Gnd in the same order.<br />
<br />
Before proceeding any further, one needs to understand the differences in voltage levels on various serial ports.<br />
<br />
PC/RS232 serial port (ones that you see at the back of your PC) uses +3V to +15V for logical 0 and -3V to -15V for logical 1.<br />
<br />
Most electronic serial adaptors (like the USB to serial convertors etc) and many micro-controller interfaces use 0V for logical 0 and +5V for logical 1 -- normally referred as TTL levels. The <a href="http://en.wikipedia.org/wiki/MAX232">MAX232</a> chips are typically used for RS232 to TTL level conversion so that a micro controller could read/understand the signals to/fro a PC serial port. See my earlier experiment: <a href="http://geraldnaveen.blogspot.in/2009/04/building-serial-port-logic-convertor.html">Serial port logic convertor</a>.<br />
<br />
There are some devices which operate in LVTTL (<a href="http://en.wikipedia.org/wiki/Transistor%E2%80%93transistor_logic">Low Voltage TTL</a>) levels wherein 0V for logical 0 and +3.3V for logical 1 is used. These convertors seem slightly uncommon (at least I could not easily find any convertors for LVTTL levels) and unfortunately WDTV Live operates at these levels on the serial port.<br />
<br />
So to interface WDTV Live’s serial port to our PC, we need a USB-to-LVTTL serial convertor. I actually gave a try with my normal USB to serial convertor (TTL) and I did not succeed. The interesting thing is that, I could see a lot of characters scrolling on the screen but all were junk. Basically the ones and zeros were wrongly interpreted by the computer due to the voltage level differences. There were some references on the internet to bring down the voltage by introducing some resistors, but they didn’t work either. I didn’t try to do too much experiments, as I was dealing with a higher voltage (5V) while the serial port on WDTV Live is expected to handle only 3.3V. Better not to blow up something :)<br />
<br />
In the internet, one cable that everyone talks about, for this use is Nokia CA-42 cable. Apparently, this cable from Nokia uses 3.3V LVTTL voltage levels to interface with the mobile phones. It looks like this (USB on one end, to the computer / proprietary socket on the the other end, to the phone).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzbT7JftUDF2DSpQC9oHMlq_wBcHpKBUstjB6OtNld9znjx5uqdpORT7GymVrv0IA2ABtpdjRBrtTKbY1LUO8S8PMt7s2sAbVC0duo2NbcnF4Y8BUks2o5TN9W8qdRBnQRcNf_ig/s1600/nokia-ca42.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Nokia CA-42 cable" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzbT7JftUDF2DSpQC9oHMlq_wBcHpKBUstjB6OtNld9znjx5uqdpORT7GymVrv0IA2ABtpdjRBrtTKbY1LUO8S8PMt7s2sAbVC0duo2NbcnF4Y8BUks2o5TN9W8qdRBnQRcNf_ig/s1600/nokia-ca42.jpeg" title="Nokia CA-42 cable" /></a></div>
After a lot of tries at various places, I got hold of this cable from ebay India. I could only get a “used” cable but I really wanted to give this a try. To be frank, these were really hopeless tries as I wasn’t sure what was ahead; there was a long way to go and lots of things needed to go right. When I received this parcel in my office in a dirty used box, some of my colleagues really thought I was going nuts with ebay that I was willing to pay for such dirty, used, old Nokia cable :) I really couldn’t explain all this stuff to them then. I didn’t have a compatible Nokia phone to test this cable; so until I got this whole thing to work I wasn’t even sure if the cable is in working condition. I had to confirm receipt on ebay even without testing, as I can’t test this in a day and to test this I was going to cut this cable anyways :)<br />
<br />
This <a href="https://sites.google.com/site/sleclire/ca-42-usb-to-ttl-serial-cable">web site</a> tells you about how to use a Nokia CA 42 cable to build a serial cable. Use it as a guide to get some useful info; it is not a bible to follow. Some of the details didn’t apply when I tested; These are the important gotchas that I figured out:<br />
<ul>
<li>CA-42 requires a driver and is available only for Windows. I used XP.</li>
<li>It does work over VM. I used <a href="https://www.virtualbox.org/">VirtualBox</a> on Ubuntu to run Win XP.</li>
<li>Important catch: CA-42 draws its power from the device, not from USB port (PC). This was very difficult for me to figure out. Some sites/forums explicitly mentioned not to make use of the +5V from the serial port of the WDTV. But unless you connect the +5V from WDTV’s serial port to the appropriate pin in the CA-42 cable and power on WDTV, CA-42 will not be detected on the computer. This was the most painful step.</li>
<li>I had to connect all the 4 pins of the WDTV serial port to make this whole thing work! +5V, RX, TX, Gnd.</li>
<li>Serial port settings → Baud: 115200, 8N1, no-flow-control, works.</li>
</ul>
That is all with the cable. Connect the cable, power on the device. Use HyperTerminal or <a href="http://www.emtec.com/zoc/">ZOC</a> (I prefer this), you are all set to interact directly with the WDTV.<br />
<br />
How and what did I do to patch my own changes permanently into the firmware? stay tuned... </div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com1tag:blogger.com,1999:blog-7343912.post-82659047479632771702012-11-25T11:39:00.000+05:302012-12-03T17:56:44.240+05:30WDTV Live -- Firmware Hacking Series -- Part 1<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="text-align: justify;">
I have had <a href="http://geraldnaveen.blogspot.in/2010/08/wdtv-live-hd-media-player.html">WDTV Live</a> for many years now. As with most devices at my home, the first thing I try to do is to upgrade to an unofficial firmware that gives more features and freedom. I was running it on <a href="http://geraldnaveen.blogspot.in/2010/09/installing-wdtv-live-unofficial.html">WDLXTV</a> (the most popular unofficial firmware for WDTV) for quite some time. <br />
<br />
I had scripts that run on startup to do various things including</div>
<ul style="text-align: justify;">
<li> Installing ntfs, wifi (<a href="http://geraldnaveen.blogspot.in/2010/12/custom-device-driver-for-linksys-usb.html">custom built for my usb wifi dongle</a>) drivers</li>
<li> Choosing the wired vs wifi networks based on its availability</li>
<li> WPA2 supplicant initialization</li>
<li> FTP based NAS share mounts</li>
</ul>
<div style="text-align: justify;">
etc.,<br />
<br />
WDLXTV hadn't been updated for more than a year now and there have been recent official updates from WD (<a href="http://www.wdc.com/">Western Digital</a>). I needed the latest WDTV core software with new features/bug-fixes but would like to keep all the hooks and privileges I enjoy with the unofficial firmware. So decided to build one myself based on the latest official firmware. That's where it started.</div>
<h4 style="text-align: justify;">
</h4>
<h4 style="text-align: justify;">
Firmware package layout</h4>
<div style="text-align: justify;">
The firmware is packaged with at least two files in it. The normal process is to put these two files in the root folder of a pen drive and plug it in. The current firmware (after it boots) will prompt for an upgrade if the new firmware is really newer (new version > old version).<br />
<br />
<b>wdtvlive.ver</b> -- txt file, with the version number of the firmware. This is what is used to decide whether an upgrade is available or not.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrt-hAKETbs0YgJ2SOpCXyS8wMzhfEn1fWjSav6NzBiGJqXi5GlSq_EfkNvucBEDYYNXPhMB1ETkAVl6YIbuGcY1pT2Yo4FgjVtFPjBBTaiTabkcg_D_smFAt7BSNQSazy7QwmhA/s1600/wdtv-version.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrt-hAKETbs0YgJ2SOpCXyS8wMzhfEn1fWjSav6NzBiGJqXi5GlSq_EfkNvucBEDYYNXPhMB1ETkAVl6YIbuGcY1pT2Yo4FgjVtFPjBBTaiTabkcg_D_smFAt7BSNQSazy7QwmhA/s1600/wdtv-version.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<b>wdtvlive.bin</b> -- the root filesystem of the linux. The filesystem is in <a href="http://en.wikipedia.org/wiki/Cramfs">cramfs</a> format to save space. Any writeable portion in the / filesystem is mounted on tmpfs filesystem (which is RAM based, and is lost on reboot).<br />
<br />
<b>wdtvlive.fff</b> -- Optional. Kernel upgrade. In most updates, we won't see this and is required only if the kernel needs an upgrade.<br />
<h4>
</h4>
<h4>
What it takes to customize</h4>
</div>
<div style="text-align: justify;">
In most cases it is more than enough to customize the root filesystem and provide hooks. For eg., I have modified the firmware to execute the script <i>/wdtv/gerald_init</i> if it finds one, on the USB drive. I can pack any software on the USB drive and make it run automatically on startup just by changing scripts on the pen drive, without really having to repack firmware.<br />
<h4>
</h4>
<h4>
There are two problems to solve</h4>
<ol>
<li>What is the customization required.</li>
<li>How to take the changes into the WDTV firmware and persist it across reboots. ie., How to rebuild a firmware for upgrade.</li>
</ol>
Problem 1 is highly subjective and is a common problem and is not specific to WDTV. It is just that any new binary that you bring in, needs to built for <a href="http://en.wikipedia.org/wiki/MIPSel">MIPSel</a> (the hardware architecture on WDTV). Toolchains are available from WD. I had built my own device driver earlier and it worked just fine.<br />
<br />
Problem 2 is what I'm mainly going to talk about. There are multiple ways to accomplish this. The easier the approach, the riskier it is (naturally).<br />
<br />
<h4>
Modify firmware - the easier approach</h4>
wdtvlive.bin is the root filesystem for WDTV Live and contains the complete filesystem that is live, post boot. There are few things you need to be aware to do this:<br />
<br />
1. wdtvlive.bin has a header and signature parts which are mainly used for error checks. So any change to the file will invalidate these. But they can be recomputed.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<b>wdtvlive.bin : < 32 byte md5sum header > < rootfs in cramfs format > < 16 byte signature ></b><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-NKK04Anohs0g1kGb3Yr02pFwkAX4ktXh4oYVrG9qOw3ZmNnxBLkm7J16tavo5-dGzwMzhSYeZa9gnS5wxSyaJLOwLaNgKCv1cdmey9X9dsiK3vagjyDDD2MDKPEyNmeHJ0YRkw/s1600/wdtv-bin.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-NKK04Anohs0g1kGb3Yr02pFwkAX4ktXh4oYVrG9qOw3ZmNnxBLkm7J16tavo5-dGzwMzhSYeZa9gnS5wxSyaJLOwLaNgKCv1cdmey9X9dsiK3vagjyDDD2MDKPEyNmeHJ0YRkw/s1600/wdtv-bin.png" /></a><cramfs rootfs="rootfs"><br /><br />2. You need a slightly modified version of <a href="http://sourceforge.net/projects/cramfs/">cramfsck and mkcramfs</a> to unpack/repack this cramfs image respectively. I had to download the open source cramfs package and make the changes. The main issue is with the block size being different on WDTV -- discovered by the author of WDLXTV. To know the exact changes required in cramfs for this block size change, look <a href="http://wdtvforum.com/main/index.php?topic=4500.0">here</a>. </cramfs><br />
<cramfs rootfs="rootfs"><br />3. There is a /md5sum.txt file at the root. You need to make sure that you update the md5sum of any file that you add or modify into the package; if not the package is not going to load. I see these checks during the system boot.</cramfs><br />
<br />
<cramfs rootfs="rootfs"></cramfs><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqwbjDq78p9-CAfLWcV4og3FHtEZTixtTJmwGyZMnOaDRxL3TtVGlJzVTOzolKxOEZK-Bml1qSfTuRw57HY_ye1miIlPymPTnGb7O5LscZr-ogl5PG30TN9QP7H_497MwbonoRvQ/s1600/wdtv-md5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqwbjDq78p9-CAfLWcV4og3FHtEZTixtTJmwGyZMnOaDRxL3TtVGlJzVTOzolKxOEZK-Bml1qSfTuRw57HY_ye1miIlPymPTnGb7O5LscZr-ogl5PG30TN9QP7H_497MwbonoRvQ/s1600/wdtv-md5.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<cramfs rootfs="rootfs"><br />So if you can unpack wdtvlive.bin, add your own mods and repack it as required, you have a custom root filesystem ready for upgrade (you might need to tweak wdtvlive.ver to pretend to be a higher version). All you need to do is put these 2 files in the root directory of the pen drive and boot WDTV -- you will be prompted for firmware upgrade.<br /><br />That sounds pretty straight forward, except that if we mess up anywhere in this process, there is a possibility of <a href="http://en.wikipedia.org/wiki/Brick_(electronics)">bricking</a> the device (at least to the users). Your player will no longer boot as there are issues with the root filesystem and you can't revert back to old firmware as it doesn't even complete boot. I have not tried with a faulty rootfs image -- so I'm not sure to what extent the protection is available before upgrade against invalid images. I doubt though. You could potentially brick the device (although not beyond repair).<br /><br />I wasn't comfortable doing this, as one mistake could cost the whole device. I don't know of anyone who can fix it for me. So decided to do it myself. I thought, If I could build the tools, knowledge to unbrick a WDTV, I could go ahead with a custom firmware upgrade. That is what I have done now and I have later realized that if I can unbrick, I could even write the customization directly into the flash memory at right locations. I have built my own serial cable for the WDTV mother board; I have also discovered the internals of the flash filesystem/partitions and their formats to patch them correctly. There is no need for WDTV's firmware update tool ie., I don't need the device to boot, to write its partitions -- the crux of unbricking.<br /><br />More details to come on the internals of how I did.. stay tuned..<br /><!--16--><!--16--></cramfs><!--32--></div>
</div>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com0tag:blogger.com,1999:blog-7343912.post-25520760387531701372012-02-14T15:41:00.006+05:302012-02-14T16:06:28.408+05:30Watching TV over network at home<div style="text-align: justify;">Last weekend, I managed to complete a long-pending project of mine. The idea was to setup an infrastructure at home so I could watch TV from anywhere in my home (ie., network streaming via Wifi). I missed this facility particularly when we have guests at home and we couldn't watch TV at our convenience (second TV? No, there are differences and I don't need a second one right now).<br /><br />Bottom line is, I now can watch TV anywhere in my house -- on my laptop, even on my mobile!! See this lenovo touch tablet showing Oreo Ad on Vijay TV:<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjT5FTWsbNXKheVLOTyXZv5CKl2V_izrMQTooVjzFV7AYP_JKv881oRCydelySRsY0EzikxrdfKW2Wo4-1SlwPYIZI58zB1nofUVBvjFUGDUixczyowds8f-eH6k8tPGWZzBzLaw/s1600/2012-02-12+11.59.33.jpg"><img style="cursor:pointer; cursor:hand;width: 400px; height: 300px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjT5FTWsbNXKheVLOTyXZv5CKl2V_izrMQTooVjzFV7AYP_JKv881oRCydelySRsY0EzikxrdfKW2Wo4-1SlwPYIZI58zB1nofUVBvjFUGDUixczyowds8f-eH6k8tPGWZzBzLaw/s400/2012-02-12+11.59.33.jpg" alt="" id="BLOGGER_PHOTO_ID_5708935120045404530" border="0" /></a><br /><br />I had always felt that I have everything I needed to do this, but it has not been that easy before I discovered all the right things. A simple way to put it would be: connect the video/audio output of the set-top-box to a TV tuner on a comp and stream it! But a number of questions need to be answered at every stage in this setup.<br /><br /><span style="font-weight: bold;">1. Video Output of Set-Top-Box: </span><br style="font-weight: bold;">I needed a video output that is in parallel to the one that connected to my TV. I don't want to plug out and plug in every time I need to stream TV content. Fortunately, I have been using the component video of the STB for my TV due to its greater clarity, so the composite video was idling anyways. Cool.<br /><br /><span style="font-weight: bold;">2. Audio Output of Set-Top-Box:</span><br style="font-weight: bold;">I had to use a splitter here, as the stereo audio output is connected to my home theatre already.<br /><br /><span style="font-weight: bold;">3. Connect it to the TV tuner:</span><br style="font-weight: bold;">It is this stage that took me a while to figure out!! I had a TV tuner that I <a href="http://geraldnaveen.blogspot.in/2009/06/fronttech-tv-tuner.html">used</a> and <a href="http://geraldnaveen.blogspot.com/2009/06/tvprogramguide-my-application-for-tv.html">hacked</a> long back. When it looked like everything was in place, I realized that the TV tuner only has a S-Video input and a RF antenna (cable) input. I would need a composite input socket and there is no easy conversion possible from composite to S-Video (ie., pin to pin mapping) due to the difference in the signals. I opened the TV tuner box and searched for any composite video input that probably didn't get exposed outside -- hoping I could solder them if required. This is the TV tuner motherboard:<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhriVkECbYj8cAsFnB7i41zyrUvCoYTY7fHHg0ImFIPIIFdSO6M35AQgvHp4Gyr8OfF94VcHGu5SW9Kia8GRzKQSoUczcvX35RBgG8dUMfSvjYN3nsl7wEa92_IKatqcXDgHaJUfQ/s1600/TV+Tuner+Motherboard.png"><img style="cursor:pointer; cursor:hand;width: 220px; height: 400px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhriVkECbYj8cAsFnB7i41zyrUvCoYTY7fHHg0ImFIPIIFdSO6M35AQgvHp4Gyr8OfF94VcHGu5SW9Kia8GRzKQSoUczcvX35RBgG8dUMfSvjYN3nsl7wEa92_IKatqcXDgHaJUfQ/s400/TV+Tuner+Motherboard.png" alt="" id="BLOGGER_PHOTO_ID_5708935335324358082" border="0" /></a><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5PeX4tUFp6en8-mC6W8s01-LV18Gw8xyIw9w7C0HRtx8V6d1XzwstUGwXVbxOulnWD4_0bFdSwL_jaXnSdAhrrBi4bX_OcUS4ywRyaWzPlBQ89nE8-Fk33CljHX8Upra-GK0hyA/s1600/trident_chip.jpg"><img style="cursor:pointer; cursor:hand;width: 160px; height: 160px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5PeX4tUFp6en8-mC6W8s01-LV18Gw8xyIw9w7C0HRtx8V6d1XzwstUGwXVbxOulnWD4_0bFdSwL_jaXnSdAhrrBi4bX_OcUS4ywRyaWzPlBQ89nE8-Fk33CljHX8Upra-GK0hyA/s400/trident_chip.jpg" alt="" id="BLOGGER_PHOTO_ID_5708935578703331122" border="0" /></a><br /><br />Could not find any socket/pin for composite video. I found the TV tuner chip on the motherboard ie., Trident TVMaster. On downloading the datasheet of the chip, I could confirm that the chip in deed supports Composite video as input. The pin diagram in the datasheet had clear indication of I/O pins available for composite input. When I traced those lines from the chip on the motherboard, it ended up in the existing S-Video socket. This kind of contradicts! How could S-Video port provide a composite input?! After lots of reading, the conclusion was simple : my TV tuner uses a non-standard 9 pin S-Video socket (while a standard S-Video socket is just 4 pins -- Y, C, Gnd, Gnd). The 9-pin socket is compatible with the 4-pin S-video socket, so the remaining 5 pins could be used for other inputs. Some hardware (like my TV Tuner) use this for simplicity in its form-factor. So all I needed was a conversion cable from composite video to 9-pin S-Video -- note: this is just pin mapping, no real signal conversion. Fortunately got this simple cable from ebay. I had reached this point months back and the project stalled :D<br /><br /><span style="font-weight: bold;">4. TV tuner works?</span><br style="font-weight: bold;">I had used this TV tuner against RF cable earlier, but never used/tested with composite video; and given all these conversion thingy, I wanted to first test if the TV tuner software works directly. And, yes it did!! I just had to configure the software to use the correct input signal. But TV tuner software doesn't stream, it just renders locally.<br /><br /><span style="font-weight: bold;">5. Stream it from VLC:</span><br style="font-weight: bold;">TV tuner device creates a video device on the computer and the tuner software uses the same. My tuner creates a Video device called 'Trident Analog Video'. VLC supports playing/streaming of video devices via DirectShow. I had streamed webcam's earlier, so wasn't anything new here for me. Things that required attention was how to configure via VLC, to use the correct input (Composite) -- as this device supports multiple inputs (RF antenna, S-Video, Composite etc). VLC has 'advanced options' while streaming that lets us configure the device. Input signal had to be set as '1' for composite. Used 'avi' as the container, 'divx' as video codec, 'aac' as audio codec. I have a Asus EEEBox on my setup that is already connected to the TV for other usage. Due to its proximity to the set-top-box, I used my eeebox for this purpose too. It connects to my home network via Wifi, so it could be reached from anywhere in my house.<br /><br /><span style="font-weight: bold;">6. Play it from VLC:</span><br style="font-weight: bold;">Now that the stream is on, all I need to do is connect to it via network. I used VLC again from a Lenovo touch tablet and connected to the eeebox via Wifi. Voila! I could now watch TV on my laptop. I'm yet to figure out an app for Android that could show multimedia stream over network -- given the small screen size, I am not that keen on watching TV on mobile. And as it has to go through the whole process of capture/encode/stream/network/decode/render, there is a delay of few seconds against the video on the live TV.<br /><br />Some of you might have already thought about this: the only missing thing is that I can't change channels remotely. But it is just because I don't have a network remote, yet! (I have been eye-ing on <a href="http://www.logitech.com/en-us/1225/8439">Logitech Harmony Link</a> for sometime :D).<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com4tag:blogger.com,1999:blog-7343912.post-49216360015682289312011-03-12T10:50:00.007+05:302011-03-12T11:33:12.575+05:30MyApp: Calendar Widget for Android 2.2 (Froyo)I had been looking for a decent home screen widget for the calendar(s) on my Samsung Galaxy S (currently on Froyo). Could not find one that is free, so wrote one.<br /><div style="text-align: justify;"><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAgJz0VaXcDkuFwrpZLj0L0wti0POx-LRIj704Z93oyZ6TH9sBzKRy7159e79fNNXcQnQ6zbbLG1P9-tjGR-2KJVPqGXRhFktItt_zMyAvXUcmKCebhiLCZpM379kYn5jbY_fkiw/s1600/snap20110302_193245.png"><img style="cursor:pointer; cursor:hand;width: 240px; height: 400px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAgJz0VaXcDkuFwrpZLj0L0wti0POx-LRIj704Z93oyZ6TH9sBzKRy7159e79fNNXcQnQ6zbbLG1P9-tjGR-2KJVPqGXRhFktItt_zMyAvXUcmKCebhiLCZpM379kYn5jbY_fkiw/s400/snap20110302_193245.png" alt="" id="BLOGGER_PHOTO_ID_5583065074530978290" border="0" /></a><br /><br /><span style="font-weight: bold;">Features:</span><br />* Includes events from all your calendars on the phone (personal, corporate etc., etc).<br />* Support for recurring events.<br />* Separate section for today's events and later events.<br />* Auto refresh in every 2 minutes (No, it doesn't wake up the phone, if sleeping -- so don't worry about battery).<br />* Occupies 3 (rows) x4 (columns) cells in home screen.<br />* Shows up to 6 events at a time.<br /><br /><span style="font-weight: bold;">Note:</span><br />* Apparently Google has deprecated the Calendar ContentProvider post Froyo. So this widget may not work post Froyo (including 2.2.1, I suppose). I only have a 2.2 phone and the emulators don't support Calendar (deprecated) -- so no idea.<br />* Tested only on Samsung Galaxy S on Froyo.<br /><br />When I get a firmware update to Gingerbread to my SGS next month (hopefully!), I shall try to port this to Gingerbread as well, if possible.<br /><br />Download the .apk installer <a href="https://sites.google.com/site/geraldnaveen/android/calendarwidget/GeraldCalendarWidget.apk">here</a> or point your phone to this QR code to download directly<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://qrcode.kaywa.com/img.php?s=6&d=https%3A%2F%2Fsites.google.com%2Fsite%2Fgeraldnaveen%2Fandroid%2Fcalendarwidget%2FGeraldCalendarWidget.apk%3Fattredirects%3D0%26d%3D1"><img style="cursor:pointer; cursor:hand;width: 180px; height: 180px;" src="http://qrcode.kaywa.com/img.php?s=6&d=https%3A%2F%2Fsites.google.com%2Fsite%2Fgeraldnaveen%2Fandroid%2Fcalendarwidget%2FGeraldCalendarWidget.apk%3Fattredirects%3D0%26d%3D1" alt="" border="0" /></a><br /><br />Developed and built using Eclipse Indigo on Ubuntu.<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com0tag:blogger.com,1999:blog-7343912.post-56539692688223336122011-02-21T14:59:00.002+05:302011-02-21T15:06:33.623+05:30Debugging Android apps remotely via Wifi<div style="text-align: justify;">Android has tonnes of cool features and this is just one of them. Now I don't need to search for my USB cable to start developing/debugging the apps. Also, poor Samsung, my WinXP BSODs whenever I plug out my phone from adb debugging. This was irritating and that's when I came across this useful tweak.<br /><br /><span style="font-weight: bold;">Requirements:</span><br />+ You need a root'ed Android phone. (I suppose, to start/stop services..)<br />+ You need a terminal emulator software on the phone (preferrably). Android market gives it free.<br />+ You should already have a working debugging setup from your PC to the phone via USB (I mean all those SDK's, tools, ADT plugin installed).<br /><br />Connect your phone via Wifi into a n/w that provides access to, from your PC.<br /><br />On the phone: (either via a 'terminal emulator' OR via 'remote ssh' OR via 'adb shell on USB')<br /><br /><span style="font-weight: bold;">$ su</span><br /><span style="font-weight: bold;"># setprop service.adb.tcp.port 6666</span><br /><span style="font-weight: bold;"># stop adbd</span><br /><span style="font-weight: bold;"># start adbd</span><br /><br />All set, now the adbd knows it is suppose to listen on TCP instead of USB.<br /><br />Disconnect the USB if connected.<br /><br />On the PC: (example on Windows)<br />C:\>adb devices<br /><br />if this shows your device connected, run<br />c:\>adb disconnect<br /><br />Then,<br /><span style="font-weight: bold;">c:\>adb connect mobile_ip_address:6666</span><br />Connected to device mobile_ip_address:6666<br />[not to mention, you can use any port other than 6666, but use the same in both places.]<br /><br />c:\>adb devices<br />[this should list your device.]<br /><br />All set. Use Eclipse and debug just like you would on a USB connected device.<br /><br />Note: This change goes off once you restart your phone. You can automate this in a number of ways.. left to you.<br /><br />Seeing my apps getting deployed wirelessly onto my phone and debugging and watching those variables remotely is really cool!! :)<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com5tag:blogger.com,1999:blog-7343912.post-34472860143948926702010-12-19T19:03:00.007+05:302010-12-19T20:30:55.186+05:30Custom device driver for Linksys USB Wifi on WDTV Live<div style="text-align: justify;">There is lot of specifics involved, so before I go any further, let me clarify the title more. This post is about using the Cisco (Linksys) USB Wifi G Adaptor WUSB54GC on your WDTV Live for network connectivity. If you need to do this on your WDTV live, you would need to have sufficient understanding of Linux and shell scripting. Also, you need to have Wifi network and with appropriate network shares available via SMB or FTP and understand how you configure stuff.<br /><br />WDTV Live has wireless network support, however it doesn't work on all USB Wifi network adaptors or chipsets. There is a defined list of USB Wifi adaptors that are compatible -- again this depends on which firmware you use. The stock firmware support (from western digital) might be different from the unofficial firmwares like wdlxtv. I use wdlxtv unofficial firmware but that doesn't support my linksys Wifi adaptor as well. I had bought this wifi dongle before WDTV live, so didn't want to buy another one. The result of trying to make this work on my WDTV is this post.<br /><br />Apparently, the particular linksys adaptor that I'm talking about (take a look <a href="http://geraldnaveen.blogspot.com/2010/03/cisco-linksys-wifi-client.html">here</a> if you want to know what I'm talking about) is based on Ralink Chipset 3070; in fact there are many other wifi dongles that are based on the same chipset. At least the unofficial firmware supports ralink 3070 chipset, however, it doesn't matter unless the device driver was built to support that particular device. ie., the device driver should have been compatible with the given vendor id and device id. This is where my device didn't work in spite of it being 3070 chipset.<br /><br />I had to then setup a total cross-platform toolchain for WDTV Live by downloading the appropriate kernel source from Western Digital website. WD has provided beautiful support for building stuff for WDTV live. The source code of device driver for Ralink 3070 chipset is available from Ralink's website. I tampered the source a bit to accommodate this Linksys device too (Vendor Id: 1737, Device Id: 0077), cross-compiled the device driver for WDTV Live on my desktop Linux. Viola, my driver got loaded for that device.<br /><br />This device driver was built for the kernel 'Linux WDTVLIVE 2.6.22.19-19-4'. Make sure this matches your kernel version too (this should be in line with the WDTV Live official firmware version 1.02.21).<br /><br />Also, if you have this USB dongle, you should see an entry like this when you do 'lsusb' on your WDTV Live:<br /><br /><span style="font-weight: bold;">Bus 001 Device 003: ID 1737:0077 Linksys</span><br /><br /><span style="font-weight: bold;">INSTRUCTIONS:</span><br />1. Download this <a href="https://sites.google.com/site/geraldnaveen/scripts/public/linksys_WUSB54GC_wdtvlive_1.02.21.zip">zip file</a> that contains (rt3070sta.ko, net.mounts, RT2870STA.dat, resolv.conf, wpa_supplicant.conf).<br />2. Create a folder named 'wireless' in the root of a pendrive and extract the contents to that folder.<br />3. Move/copy net.mounts from that folder to the root of your pendrive.<br />4. Edit the files net.mounts, RT2870STA.dat, resolv.conf, wpa_supplicant.conf and customize with your Wifi's SSID and WPA PSK as necessary. You can use wpa_passphrase on a desktop linux to create a encoded PSK and copy that to these files.<br />5. More customization is required in net.mounts script as per your network to mount the right share on startup. I use ftpfs, as that seems more robust than smbfs on WDTV live.<br />6. Plug-in this pen drive to your WDTV live along with your Linksys Wifi dongle and reboot, your WDTV Live should join your network and mount your network share seamlessly.<br /><br />I've this setup successfully working for almost 3 months now. Every time I start my WDTV live it joins the wifi network in around 30-45 seconds and the network shares are instantly available. You also don't have to worry about network interruptions, WDTV Live takes care of remounting the shares if the ftpfs breaks for some reason (note the 'xmount' in the script).<br /><br />Here is the net.mounts script that I use at home (with specifics removed):<pre name="code" class="python:nocontrols">#<br /># Original Author: Gerald Naveen A (http://geraldnaveen.blogspot.com)<br />#<br /># WDTV Live! net.mounts to use my custom built device driver for WUSB54GC<br /># on WDTV Live firmwares. This script uses the wpa_supplicant to configure<br /># WPA based authentication.<br />#<br /># Refer : http://geraldnaveen.blogspot.com/2010/12/custom-device-driver-for-linksys-usb.html<br /># for more info.<br />#<br /># COPY THIS FILE TO THE ROOT FOLDER OF YOUR USB DRIVE ON WDTV LIVE!<br />#<br /># License:<br /># You are free to modify/distribute/use for commercial/non-commercial/<br /># personal applications. Any modification to this code needn't be published.<br /># However, any publication of this code or the derivative of this code, should<br /># include the original author and this license text.<br />#<br />logger -t GERALD "$0 starting..."<br />if [ -f /tmp/gerald ]; then<br /> # make sure this script doesn't run more than once. Sometimes, net.mounts<br /> # gets called multiple times.<br /> logger -t GERALD "$0 already ran." <br />else <br /> touch /tmp/gerald<br /> config_tool -c DISABLE_ETHERNET_ON_STANDBY=NO<br /> config_tool -c USB_POWER_OFF=NO<br /><br /> # NOTE: change below line to cp from your USB wireless device<br /> cp /tmp/mnt/64BA-4243/wireless/* /tmp/<br /> cp /tmp/resolv.conf /etc/resolv.conf<br /><br /> WIFI_DEV=ra0<br /> insmod /tmp/rt3070sta.ko<br /> ifconfig $WIFI_DEV up<br /> sleep 5 ; # let the radio come up before scanning<br /> #discover the current channel number<br /> CHANNEL_NUMBER=`iwlist $WIFI_DEV scan | grep YOUR_WIFI_SSID -A 2 | grep Channel | cut -d\( -f 2 | cut -d\ -f 2 | cut -d\) -f 1`<br /> logger -t GERALD "Configuring $WIFI_DEV to Channel $CHANNEL_NUMBER"<br /> iwconfig $WIFI_DEV channel $CHANNEL_NUMBER<br /><br /> wpa_supplicant -i$WIFI_DEV -c/tmp/wpa_supplicant.conf -B<br /> # DHCP client has some issue and is inconsistent.<br /> #udhcpc -i $WIFI_DEV<br /> logger -t GERALD "Configuring IP Address for $WIFI_DEV"<br /> ifconfig $WIFI_DEV STATIC_IP_ADDRESS_OF_WDTV_LIVE netmask 255.255.255.0<br /> route add default gw YOUR_NW_DEFAULT_GW_IP<br /><br /> sleep 15 ; # let the n/w settle before mount<br /> logger -t GERALD "Pinging NAS via LAN..."<br /> ping -c 1 -W 2 NAS_IP_ADDR_HSPEED | grep -q "bytes from"<br /> if [ $? -eq 0 ] ; then<br /> logger -t GERALD "Ping successful for NAS via LAN. Now xmounting..."<br /> xmount "ftp://NAS_IP_ADDR_HSPEED" NAS_1Gbps ftpfs "-o user=movies:password"<br /> logger -t GERALD "xmount done for NAS."<br /> else<br /> # could not reach NAS via high speed n/w.<br /> # try to reach via Wifi.<br /> logger -t GERALD "Pinging NAS via Wifi..."<br /> ping -c 1 -W 2 NAS_IP_ADDR | grep -q "bytes from"<br /> if [ $? -eq 0 ] ; then<br /> logger -t GERALD "Ping successful for NAS via Wifi. Now xmounting..."<br /> xmount "ftp://NAS_IP_ADDR" NAS_Wifi ftpfs "-o user=movies:password"<br /> logger -t GERALD "xmount done for NAS."<br /> fi<br /> fi <br />fi ; # if already ran<br />logger -t GERALD "$0 complete."</pre><br />In case you find issues, check /tmp/messages.txt file on your WDTV Live for the relevant log messages to troubleshoot.</div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com8tag:blogger.com,1999:blog-7343912.post-20399112139475204792010-12-06T18:14:00.007+05:302010-12-06T18:45:44.262+05:30Video cable for Samsung Galaxy S<div style="text-align: justify;">Disclaimer: Although this should just apply for any other SGS, this has been tested only on SGS Vibrant, India model.<br /></div><div style="text-align: justify;"><br />If you didn't know how this cable looks, here it is. Note the 4 terminal stereo plug (stereo plug normally has only 3 terminals).<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmWdBAZc_-wZwQPjFgdKtx3o4iJlMFLAiI59x_CgZVL56mO5NHWiprfAfURQbLJLD4bZakmeEVQbNx-34Dmguj8iotDBxUMMGaIMHHT97qp5_3yyTxW-sZ3FFHz5ww2oTunW5DnA/s1600/rca1.JPG"><img style="cursor: pointer; width: 267px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmWdBAZc_-wZwQPjFgdKtx3o4iJlMFLAiI59x_CgZVL56mO5NHWiprfAfURQbLJLD4bZakmeEVQbNx-34Dmguj8iotDBxUMMGaIMHHT97qp5_3yyTxW-sZ3FFHz5ww2oTunW5DnA/s400/rca1.JPG" alt="" id="BLOGGER_PHOTO_ID_5547549878363337474" border="0" /></a><br />Although one can build a cable from scratch, it is usually cheaper or same to get a read-made cable like this, instead of trying to build our own cable with just the plugs. Ok, so what is there to be done if I get the ready-made cable -- the reason is that, all cables aren't compatible with SGS video output. This post anyway has all the info to build your own cable, if you are interested.<br /><br />The common confusion that prevails in the forums is that some cables work and some don't; so how do we buy the right cable. The answer is that, you don't have to worry as long as the terminals are exactly these (ie., 4 pin stereo on one end, RCA on the other end). I had bought one such cable from ebay India for just Rs. 100. You can search for "Camcorder RCA cable" and you might end up on one such item.<br /><br />If you get a camcorder cable, it most likely won't work. If it doesn't work in the normal configuration (ie., Yellow to Video, Red/White to Audio), try connecting the White to Video, and Yellow/Red to Audio. This should just work.<br /><br />Why?<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrAFJS107mcXWGjYkQ1XiPsdCtGptmPnXEGsFSSrxNHH5ZuirLmme8seLbkVZeri03j_es0muwf101kUXBpvo3_8XxEMfVwn8NF8eJBNc83riqbPLgifVkjQdAYc_8g_p_EVTP0g/s1600/rca_terminals.JPG"><img style="cursor: pointer; width: 274px; height: 147px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrAFJS107mcXWGjYkQ1XiPsdCtGptmPnXEGsFSSrxNHH5ZuirLmme8seLbkVZeri03j_es0muwf101kUXBpvo3_8XxEMfVwn8NF8eJBNc83riqbPLgifVkjQdAYc_8g_p_EVTP0g/s400/rca_terminals.JPG" alt="" id="BLOGGER_PHOTO_ID_5547553116972046946" border="0" /></a><br />This is how a 4-terminal stereo plug looks. Lets name the terminals as T1..T4 as in figure. The camcorder cables send T4 to Video, but the SGS sends out video on T2. On Camcorder cables, T2 is the Left/Mono Audio (White) -- thus swapping that for Video works.<br /><br />T1 is the Ground. As long as the ground is not changed, you should be able to convert any cable to be compatible with SGS video out. T1 usually gets in contact with the case/body of the device, so I would think it would be always ground on any such cables for consumer devices. I also don't see any reason for a cable to insert the video terminal between the two audio terminals. Going by these rules, it is most likely that, it is either T4 (T2, T3 are audio) or T2 (T3, T4 are audio) which is the video terminal.<br /><br />If you have a multimeter, just connect this cable to your phone, turn on Video out on settings and measure the DC voltage (0-20V range) on each of the RCA plugs (make sure the phone isn't playing any audio). Only the video plug will sense a voltage of ~1.5V at this point. This should identify the video plug safely without having to try out various plugs on the TV directly.<br /><br />To summarize, so you can build one if required. The SGS video output pin out is:<br /><br />T1: Ground<br />T2: Video<br />T3: Left/Mono<br />T4: Right<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com5tag:blogger.com,1999:blog-7343912.post-71395164562680236722010-11-29T12:12:00.001+05:302010-11-29T12:15:00.750+05:30Getting over problemsCourtesy: <a href="http://www.pravsworld.com/content/inspiration/55/getting-over-problems">Pravs World</a><br /><br />If you can't get through the mountain, Go around it. If you can't go around it, Go over it.<br /><br />If you can't go over it, sit down and ask yourself, if getting to the other side is all that important? If it is, set about digging a tunnel.<br /><br />For every problem, there are many solutions. Whatever the problems in life are, you have to find ways to get over it.Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com1tag:blogger.com,1999:blog-7343912.post-65434474523113261942010-11-13T12:51:00.013+05:302012-11-21T20:42:18.931+05:30MyApp: Spb Wallet to KeePass convertor<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<a href="http://spb.com/products/wallet/">Spb Wallet</a> is one of the best wallet applications that I've used across various mobile platforms. However, it isn't available on all mobile platforms and it isn't free either. Once I moved on to Android, I hit a road-block because Spb Wallet isn't available for Android (yet). I'm sure you would understand how painful it is to not have a wallet app, once you are used to.<br />
<br />
<a href="http://keepass.info/">KeePass</a> is the alternate. KeePass is an open-source software for password management. To be fair, KeePass isn't as great as Spb Wallet, but does its job. Being open-source, it is available on almost all platforms including desktops.<br />
<br />
The pain here is the conversion. I have tonnes of data on Spb Wallet that manually entering them on KeePass is a no-go. Unfortunately, and mostly intentionally, Spb Wallet doesn't export to any well known format for import into KeePass. There weren't any handy tools to convert either. Thankfully Spb Wallet had a text export and KeePass had many import options. But it isn't directly compatible, because Spb Wallet doesn't have any proper structure to the exported TXT file and the grammar is quite ambiguous. KeePass has a well defined XML structure for import (found it by doing a sample XML export from KeePass). I wrote this python script to convert the Spb Wallet TXT export file into the XML format that KeePass can understand. In reality, Spb Wallet has more "specific" fields than KeePass, so there isn't always a direct mapping. Any non-mappable field (Account Number for example) will be appended in the notes section of KeePass so no information is lost.<br />
<br />
This script is a simple parser that understands and converts the Spb Wallet TXT export file. It maintains the internal state of parsing and learns dynamically about what the current token is -- some times even looking ahead into the file to resolve ambiguities.<br />
<br />
This script is probably not so robust on errors. But this did the job for my Wallet export which is reasonably big.<br />
<br />
<span style="font-weight: bold;">If you find any bug on this script that you want me to fix, report here. I *MAY* fix it for you.</span><br />
<br />
Here is the source:<br />
<pre class="brush:python">#
# Code to Convert Spb Wallet TXT export file to KeePass XML import file.
#
# Original Author: Gerald Naveen A (http://geraldnaveen.blogspot.com)
#
# License:
# You are free to modify/distribute/use for commercial/non-commercial/
# personal applications. Any modification to this code needn't be published.
# However, any publication of this code or the derivative of this code, should
# include the original author and this license text.
#
import sys
def mywrite(f, str):
f.write("{0}\n".format(str));
def main():
print "\nSpb Wallet to KeePass Convertor v 1.0 by Gerald Naveen\n";
print "Report bugs at http://geraldnaveen.blogspot.com/2010/11/myapp-spb-wallet-to-keepass-convertor.html\n";
if len(sys.argv) < 3:
print "Usage: spb_wallet_to_keepass.py <spb_txt_export_file> <keepass_xml_import_file>";
print "\nWhere,\nspb_txt_export_file: path to the TXT file exported from Spb Wallet.";
print "keepass_txt_import_file: path to the output XML file, that shall be imported into KeePass.";
return;
try:
ifile = open (sys.argv[1], 'r');
except:
print "Could not open input file", sys.argv[1];
return;
try:
ofile = open (sys.argv[2], 'w');
except:
print "Could not open output file", sys.argv[2];
return;
FOLDER_NAME_TOKEN=1;
ENTRY_NAME_TOKEN=FOLDER_NAME_TOKEN+1;
BEFORE_NOTES_TOKEN=ENTRY_NAME_TOKEN+1;
NOTES_TOKEN=BEFORE_NOTES_TOKEN+1;
INVALID_VALUE='invalid';
next_token=ENTRY_NAME_TOKEN;
folder_name = INVALID_VALUE;
entry_name = INVALID_VALUE;
user_name = INVALID_VALUE;
password = INVALID_VALUE;
url = INVALID_VALUE;
notes = INVALID_VALUE;
valid_entry = False;
mywrite(ofile, '<?xml version="1.0" encoding="utf-8" standalone="yes"?>');
mywrite(ofile, '<pwlist>');
try:
for line in ifile:
line = line.strip('\r\n');
if len(line) == 0:
# empty line
if valid_entry == False:
# entry name found after folder name
folder_name = entry_name;
entry_name = INVALID_VALUE;
else:
# found the last line of the entry..dump
mywrite(ofile, '<pwentry>');
if folder_name != INVALID_VALUE:
mywrite(ofile, '<group>{0}</group>'.format(folder_name));
mywrite(ofile, '<title>{0}</title>'.format(entry_name));
if user_name != INVALID_VALUE:
mywrite(ofile, '<username>{0}</username>'.format(user_name));
if password != INVALID_VALUE:
mywrite(ofile, '<password>{0}</password>'.format(password));
if url != INVALID_VALUE:
mywrite(ofile, '<url>{0}</url>'.format(url));
if notes != INVALID_VALUE:
notes=notes.replace('\n', '&#xD;&#xA;');
mywrite(ofile, '<notes>{0}</notes>'.format(notes));
mywrite(ofile, '</pwentry>');
user_name = INVALID_VALUE;
password = INVALID_VALUE;
url = INVALID_VALUE;
notes = INVALID_VALUE;
valid_entry = False;
next_token=ENTRY_NAME_TOKEN;
else:
if next_token == ENTRY_NAME_TOKEN:
entry_name = line;
next_token = BEFORE_NOTES_TOKEN;
else:
valid_entry = True;
if next_token == BEFORE_NOTES_TOKEN:
if line.startswith('User Name:'):
user_name = line[len('User Name:'):].strip(' ');
elif line.startswith('Password:'):
password = line[len('Password:'):].strip(' ');
elif line.startswith('Web Site:'):
url = line[len('Web Site:'):].strip(' ');
elif line.startswith('Notes:'):
if notes == INVALID_VALUE:
notes = line[len('Notes:'):].strip(' ');
else:
notes += '\n' + line[len('Notes:'):].strip(' ');
next_token = NOTES_TOKEN;
else:
# any unknown params should go as notes.
if notes == INVALID_VALUE:
notes = line;
else:
notes += '\n' + line;
elif next_token == NOTES_TOKEN:
# any thing from the notes section.
notes += '\n' + line;
except:
print "Unknown error occured while processing the input file.";
mywrite(ofile, '</pwlist>');
ifile.close();
ofile.close();
print "Success. Now import {0} in KeePass as KeePass XML".format(sys.argv[2]);
if __name__ == "__main__":
main()</pre>
Download <a href="https://sites.google.com/site/geraldnaveen/python/spb_wallet_to_keepass.py">spb_wallet_to_keepass.py</a><br />
<br />
Update [26-Nov-2010]: <br />
<br />
If the script ran successfully, but the output XML file didn't work on import, it could most likely be a CRLF issue. Try this in such cases:<br />
<br />
Lets assume your file is test.txt.<br />
<br />
1. Open test.txt in Notepad<br />
2. "Save as" another file, say test2.txt (Note: select Utf8 as Encoding).<br />
3. Use test2.txt as input</div>
</div>
<!-- syntax highlighter -->
<script src='https://sites.google.com/site/geraldnaveen/scripts/public/syntaxhighlightloader.js' type='text/javascript'></script>
Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com39tag:blogger.com,1999:blog-7343912.post-846023890515282052010-10-11T18:29:00.004+05:302010-10-11T19:21:58.762+05:30Asus RT-N16 -- my new home Wifi routerThis is a long pending post. I had bought this router for my home a month back and never got to write about it.<br /><div style="text-align: justify;"><br />Picture first:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK7ZvQnuSb4prWCocROXBDDMcQoEB1osG-H8ZEMUMVAQPjRFKlusjvYZ9QdUjwBiysJxbZdFujb0lLqphW74MTrjiZXHuYLAiInF5uArnFYwG8HTRChwX2gzbfclGui8Cfvr6v7Q/s1600/asus_rtn16_router.jpg"><img style="cursor: pointer; width: 400px; height: 319px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK7ZvQnuSb4prWCocROXBDDMcQoEB1osG-H8ZEMUMVAQPjRFKlusjvYZ9QdUjwBiysJxbZdFujb0lLqphW74MTrjiZXHuYLAiInF5uArnFYwG8HTRChwX2gzbfclGui8Cfvr6v7Q/s400/asus_rtn16_router.jpg" alt="" id="BLOGGER_PHOTO_ID_5526781602353070754" border="0" /></a><br /><br />I had been looking for a Wifi router at my home before I could narrow down on this. Here were my requirements:<br /><ol><li><span style="font-weight: bold;">Good range:</span> The current wifi router that came with my Internet connection can barely cover 25% of my house. I needed something that can cover every corner of my duplex flat. Otherwise the exercise is of little use.</li><li><span style="font-weight: bold;">Thirdparty-firmware:</span> I was mainly eying at dd-wrt for the firmware. It *has* to be <a href="http://www.dd-wrt.com/site/index">dd-wrt</a> compatible so I can play around with the firmware and add services to it. dd-wrt has multiple versions of the firmware based on the flash size available. Most routers these days have <=4MB flash (some of them only 2MB). Those will need to run mini or micro versions of dd-wrt which have limited capabilities and extensions. I was looking at a router with at least 8MB flash, so the mega version of dd-wrt fits. </li><li><span style="font-weight: bold;">802.11n:</span> I wanted 802.11n draft support. I was actually more inclined towards simultaneous dual-band vs just dual-band. Also, I was fine with 2.4GHz 'n' if 5.8GHz 'n' isn't available. </li><li><span style="font-weight: bold;">USB mass storage: </span>I wanted the router to also be my NAS. So I can just attach a USB HDD to the router and can access it anywhere else in the house. Currently my EEEBox does this for me, but that's one more device to run. </li></ol>Selecting a good range was the difficult task because there is no benchmark that fits all for this. When some one says *good* it is relative and not absolute. That doesn't help me in anyways to select mine. As it was an important factor me, I had to overshoot my expectation and get a really good one. <br /><br />Eventually, I narrowed down on 2 routers: <br /><ol><li><a href="http://reviews.cnet.com/routers/linksys-wrt610n-simultaneous-dual/4505-3319_7-33132573.html">Cisco Linksys WRT610N</a> </li><li>Asus RT-N16 </li></ol>Both seem to claim very good range. WRT610N has 3 internal antennas, whereas the RT-N16 has 3 external antennas. Anytime, the external ones are more powerful. The Cisco one looks really cool though. No, but range was more important. Both are of similar price range (~10K INR). Both have USB support. Both are supported by dd-wrt. The biggest differentiating factor between these two that helped me decide, is the hardware. RT-N16 has an awesome processor at 533MHz, 128MB of RAM and more importantly 32MB of flash. The Cisco one has just 8MB flash. 32MB flash is too good that I don't have to worry about space while enhancing the router for other tasks. The powerful processor should also come in handy to support multiple operations in parallel. There are more comparisons on the specifications, but that's too much to be here.<br /><br />Went ahead and bought RT-N16. Even though I didn't intend to use the official firmware, the Asus official firmware for RT-N16 is pretty good (except for the NAS part). In fact the official firmware supports 1TB disks and NTFS file system. Even the dd-wrt doesn't have proper support for NTFS (yes, ntfs-3g driver is available, but is still error-prone on large partitions, that I had to move to ext3 for my NAS). Any time a journal'ed file system like ext3 is better for NAS. Anyways, in 2 days, I upgraded the firmware to the unofficial dd-wrt. It's very handy, specially as it exposes the whole Linux underneath. The extra flash memory can be mounted via JFFS2 file system and that's the place to make wonders. <br /><br />This router has served all my purposes. It has terrific range that my earlier mobile (ASUS P320) which is the weakest Wifi client I have, connects from the farthest point within the house. Before I could wink, I already have 8 wifi devices at home -- enjoying the n/w all around my house. It's an useful luxury!<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com1tag:blogger.com,1999:blog-7343912.post-13227662333064183872010-09-19T10:52:00.003+05:302010-09-19T11:35:11.139+05:30Installing WDTV Live Unofficial Firmware<div style="text-align: justify;">As of this writing, the latest stable official firmware version for WDTV Live is 1.02.21.<br /><br />There is also an unofficial firmware for WDTV Live that opens up the whole linux underneath along with several other services. The unofficial firmware 0.4.2.2 is based on the official firmware 1.02.21 and is around 80MB while the official firmware is just around 32MB. The difference in size includes a whole bunch of additional services like SMB server, FTP, telnet, dropbear (ssh), torrents, apache etc., to name a few. But not to worry much, the unofficial firmware provides total control to us to configure not to start any of these services that aren't of interest to us.<br /><br />The unofficial firmware can be downloaded from <a href="http://wdtvhd.com/index.php?showtopic=19072">WDTV Forums</a>. (you need a registered account, its free).<br /><br />Upgrading to the unofficial firmware isn't really a big deal; I am writing about this only to complete the context for a lot more posts that I intend to write over the unofficial firmware (I've already done quite a bit of things on this, including building a custom device driver for WDTV Live, modifying their scripts etc). With little bit of caution, one can safely upgrade to the unofficial firmware. Most importantly, the unofficial firmware is totally safe in terms of the functionality (I mean the media player functionality..) because, the unofficial firmware hasn't re-written the complete functionality -- rather it is just an extension to the existing firmware. Someone smart out there, has just unpacked the <a href="http://en.wikipedia.org/wiki/Cramfs">cramfs</a> image of the official firmware and customized/extended the scripts, added more apps etc., and made it a full-fledged linux box that can do much more than just media playing. I felt very comfortable going ahead with the upgrade when I read about this. Not just theory, but I upgraded the same day I unboxed my WDTV Live; ever since I've been running on the unofficial firmware without any issues -- playing heavy full-HD with DolbyDigital / DTS. It is also possible revert back to the official firmware in case it didn't workout for you, nevertheless.<br /><br />Tip: WDTV doesn't upgrade to a firmware, if the new firmware's version is not greater than the current firmware version. So, if you are already on official 1.02.21 (like I was), you cannot theoretically upgrade to the unofficial firmware (in spite of it being very different). Fortunately, the version of the new firmware is read from a separate .ver file that comes with the firmware update pack, which can be easily tweaked around. This tip is also important specially when you want to downgrade your firmware or revert to the official firmware. <br /><br />The firmware has generally 2 files : wdtvlive.ver, wdtvlive.bin. The .ver file has the version of the firmware and the also points to the wdtvelive.bin. It looks something like this:<br /><br />VERSION='1.02.21'<br />LOCATION='wdtvlive.bin'<br /><br />Sometimes you might need to play around with the version string as pointed out earlier. Put these two files (.ver, .bin) in the root directory of your USB drive attached to the WDTV and start it. Once started, WDTV should show you a menu item for 'Firmware upgrade'. It's straight-forward from there on.<br /><br />IMPORTANT: The upgrade itself doesn't take very long, but make sure the power doesn't go off during the upgrade. If possible, run the player on UPS during the upgrade. However, the first boot after the "unofficial" firmware upgrade takes pretty long (actually many minutes) and there won't be any video signal to your TV during that time -- so don't panic (until later :P) that you had bricked your device.<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com0tag:blogger.com,1999:blog-7343912.post-7244233019104296032010-09-03T13:33:00.001+05:302010-09-03T13:35:44.943+05:30Jump for Challenges<p>Courtesy: <a href="http://pravstalk.com/jump-for-challenges/">Pravs World</a><br /></p><p>Instead of avoiding challenges, jump into them.<br />Beat the heck out of them. Enjoy the game.<br />If your challenges are too large, do not give up.</p> <p>Failing makes you tired. Instead, reorganize.<br />Find more determination, more knowledge and more help.<br />And then, Just go for it!</p>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com0tag:blogger.com,1999:blog-7343912.post-8211200896927225572010-08-29T19:47:00.004+05:302010-08-29T20:42:30.463+05:30WDTV Live - HD Media Player<a href="http://www.wdtvlive.com/">WDTV Live!</a> is the new entry into my home.<br /><div style="text-align: justify;"><br />It is a full-HD (High-definition, 1080p) Media Player that can play most Video/Audio formats and codecs available today. <a href="http://geraldnaveen.blogspot.com/2010/02/asus-eeebox-b202.html">My EEEBox</a> was in this place earlier to me but EEEBox (B202) struggles to play anything more than 720p video (some frames in even 720p video also stutter if there is too much of a change from the previous frame). I really couldn't enjoy the half/full-HD videos using that. Also, I had to control my EEEBox from my mobile phone via VNC -- this did the job, but wasn't as comfortable as a TV remote. So decided to buy this player.<br /><br />The choice was between <a href="http://www.xtreamer.net/">XStreamer</a> and WDTV Live! but I was convinced that I should go with WDTV Live for my needs (Why? is a different topic altogether, that I'm not touching right now).<br /><br />This is how it looks:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjbioaP_zpeX4yw2EqpoYDXnqtitb6BaX_jvFossYHIs5Vg1T5JeN1A2RSy3K3Z75IaGHfM6pqV4EnlAhzAS8_qTcFdAqb9Uj_ujzXe9k6tzcTXJIwo1vMKCOTw9eVa_aopSWVsw/s1600/wdtv.JPG"><img style="cursor: pointer; width: 300px; height: 300px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjbioaP_zpeX4yw2EqpoYDXnqtitb6BaX_jvFossYHIs5Vg1T5JeN1A2RSy3K3Z75IaGHfM6pqV4EnlAhzAS8_qTcFdAqb9Uj_ujzXe9k6tzcTXJIwo1vMKCOTw9eVa_aopSWVsw/s400/wdtv.JPG" alt="" id="BLOGGER_PHOTO_ID_5510845993185596658" border="0" /></a><br />Although small, this is a real monster. I did realize its power only after I played the full-HD (high data rate) version of Avatar (11 GB for 2 hours of video with DTS audio). It flawlessly played the full-HD movie without any glitch, while my EEEBox would hardly render a frame of it. It is connected to my home-theatre receiver via the optical digital audio connectivity (<a href="http://en.wikipedia.org/wiki/S/PDIF">S/PDIF</a>). It transmits the digital audio via the optical interface and the home theatre plays it well (<a href="http://en.wikipedia.org/wiki/Dolby_Digital">Dolby-digital</a> or <a href="http://www.blogger.com/en.wikipedia.org/wiki/DTS_%28sound_system%29">DTS</a>). Watching Avatar full-HD with DTS sound was a new experience at home! For those who don't have a home theatre or that doesn't support Dolby Digital or DTS, WDTV Live has a down-mixing support that converts high-end audio to Stereo.<br /><br />WDTV Live uses the <span style="visibility: visible;" id="main"><span style="visibility: visible;" id="search">Sigma 8655 chipset, which gives it all its power. </span></span><span style="visibility: visible;" id="main"><span style="visibility: visible;" id="search">Btw, the most interesting thing is that it runs on Linux, but for you to enjoy a Linux node, you need to mod it to the unofficial firmware that exposes telnet. From then on, it's a whole linux box that one can play around with. </span></span><br /><span style="visibility: visible;" id="main"><span style="visibility: visible;" id="search"><br />It can play media from a USB storage attached to it (no, it doesn't have built-in storage) or from a network. It supports Wired Ethernet and some fixed set of Wifi adaptors. I currently have a Linksys Wifi-adaptor, but that's not supported :(. Due to the lack of Wifi, I had to do some network-bridging to transparently connect my WDTV to my home network, so other devices also can access my WDTV and vice-versa (eg., I can remote-login into my WDTV's linux from my laptop). Media via network was the key thing to me. However, it supports only SMB (samba) based network shares (the unofficial firmwares do support other types; I'm already playing via a FTP share from my NAS).<br /><br />The remote looks a bit less responsive to me. The UI looks really cool. A cold boot takes around 20-25 seconds (official firmware) and a warm boot takes less than 5 seconds (actually only the UI goes down when the device is powered off via remote).<br /><br />This device has redefined my TV experience at home! Although I had Dolby Digital/DTS setup earlier, lack of full-HD was definitely a setback. Ah, that's past :)<br /></span></span></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com3tag:blogger.com,1999:blog-7343912.post-27997235084970563112010-08-15T18:59:00.004+05:302010-08-15T19:06:56.767+05:30Heavy rain in Bangalore<div style="text-align: justify;">Heavy rain lashed eastern Bangalore today noon. I was driving on the Marathahalli outer ring road then. Visibility was terribly low. My car's wiper could barely manage even at its full speed swing. I could barely see anything beyond 50 meters. Every car was crawling at 30kmph while the normal speed would be around 70-80kmph (the speed limit is 60kmph btw).<br /><br />See the photoes. It was shot near Kadubeesanahalli junction, Marathahalli Outer Ring Road, Bangalore (15-Aug-2010, 2.10 pm.).<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT2xjh2BozXjBtEGKbUkk0GgrRxN_L0wZDGavZm7tbMLF64NxeMn0bgp3hIOS9TSvBYWOf008t-uMTpKTR5C2dB11PU7c3ICb0H51YM71jk9pUcSG95m4gow6766TPF5YG7KYf1g/s1600/IMG015.jpg"><img style="cursor: pointer; width: 400px; height: 300px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT2xjh2BozXjBtEGKbUkk0GgrRxN_L0wZDGavZm7tbMLF64NxeMn0bgp3hIOS9TSvBYWOf008t-uMTpKTR5C2dB11PU7c3ICb0H51YM71jk9pUcSG95m4gow6766TPF5YG7KYf1g/s400/IMG015.jpg" alt="" id="BLOGGER_PHOTO_ID_5505629765997841442" border="0" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg08YPXq9jdxJ6C7b3Bymv_J59za0M-LSiv4ZA8UCwc8Xh7GkbsSCKGWShOpNcN6tRy5XCVAbpVyfOag4XZTBZtHzAz9X4Z7LdY-s9Y4UeNZGk96hUcv7zZof8FjQrYb8WfmgSrYQ/s1600/IMG016.jpg"><img style="cursor: pointer; width: 400px; height: 300px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg08YPXq9jdxJ6C7b3Bymv_J59za0M-LSiv4ZA8UCwc8Xh7GkbsSCKGWShOpNcN6tRy5XCVAbpVyfOag4XZTBZtHzAz9X4Z7LdY-s9Y4UeNZGk96hUcv7zZof8FjQrYb8WfmgSrYQ/s400/IMG016.jpg" alt="" id="BLOGGER_PHOTO_ID_5505629765082873586" border="0" /></a><br /><br />It was fun!! I've never driven earlier in such a heavy rain. It lasted at least 20 minutes like this.<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com0tag:blogger.com,1999:blog-7343912.post-18534795435400100772010-07-22T20:55:00.009+05:302010-07-24T20:38:08.803+05:30Dual boot Meego with Windows XP<div style="text-align: justify;">After quite a bit of hesitation, last week I managed to install Meego onto my hard disk on EEEBox along with Windows XP. The success stories on getting dual boot on Meego aren't many (in fact none that was satisfactory to let me confidently try). Anyways, it was a pain to boot the live version on USB and reconfigure every time.<br /><br />This wasn't smooth. There were at least 2 times when I thought I just lost one or more Windows partitions!! I wasn't sure how good is Meego's installer's partition manager, so did all the partitioning on Windows.<br /><br />/boot -- primary partition; better to keep this primary (ext3)<br />/home -- logical partition (ext3)<br />/ -- logical partition (btrfs) - recommended by Meego for /<br />swap -- logical partition (swap)<br /><br />Obviously, formatting was done during the Meego installation. The first time I started the install and configured all the mount points, filesystems etc., and let the installer to proceed. The installer failed half-way while formatting my / partition! Not sure if that's related to btrfs or whatever. But it failed and the installer exited. Huh! The first thing I did then was to boot into Windows and check my data (and they were in tact). Although I was actually hopeless to retry, the second try just worked! This time, I didn't have to format /boot, /home, swap as they were already formatted in the previous try - not sure if that means anything here.<br /><br />Okie, the Meego install was super-fast. Takes less than 5 minutes. I believe they just copy the live image as-is to the disk and just do some post configuration. The post configuration has the boot loader part. It detected my Windows and asked about the default option etc., Sadly there is no option to configure the boot loader timeout. I purposely let Meego as my default boot, so I can fix the boot loader if some thing goes wrong (it helped). Renamed the "Other" option to "Windows" and completed the install.<br /><br />When EEEBox restarted, I couldn't have even a glimpse of the boot loader. Meego was quickly on its way. I had read about this timeout issue earlier in other forums. The boot loader does not wait enough by default. The boot loader config file is in /boot/extlinux/extlinux.conf. Edit the file as root and fix the 'timeout' configuration to 100 (means 10 seconds). Also comment the "menu hidden" line by prefixing with #.<br /><br />timeout 100<br />#menu hidden<br /><br />I didn't know that a shocker was waiting. I rebooted the EEEBox and tried entering into Windows, just to see the notorious error : "NTLDR missing". I was quite scared if Meego just blew up my Windows partition. Thankfully, I vaguely remembered that during the boot loader configuration (in install), I noticed that my Windows partition was identified as /dev/sda2. I had doubted that right at that time, but I hoped Meego would do it right. Actually my Windows was on /dev/sda1 (and most Windows installations would be). But the extlinux.conf file doesn't have any mention of /dev/sda2; for that matter even "sda2". The Windows boot is done by chain.c32 and the boot partition is an argument to this image.<br /><br /># this is how the conf file looked<br />kernel chain.c32<br />append boot 2<br /><br />Here, the boot parameter means /dev/sdx2. As it doesn't say the disk id, it looks to me if Meego can detect only other OSes on the same disk as where Meego is installed. Hmm..<br /><br />Changed the config to 'append boot 1' and got into Windows successfully. Sigh!<br /><br />Though there were hickups, Meego didn't make any damage beyond repair - Happy about that at least. Now Meego automatically logs into my home Wifi without any additional config. Installed gcc, cpp, kernel-headers, kernel-source etc., It has been a week since then; never got back to it :D<br /></div>Gerald Naveenhttp://www.blogger.com/profile/18255818071617217134noreply@blogger.com1