A “wasted” evening !

Yesterday I completed a long pending task. Something that I’d wanted to do for a very long time but never had the need, nor the compulsion to do it.

Over the past couple of days my router had been exhibiting DNS resolution issues. DNS resolution is the process of translating a URL like google.com to an ip address which a computer can understand.

This DNS resolution happens at multiple places:

1. Your internet service provider (ISP) has a DNS server. Which is like a constantly updating online table. Which maps URLs to ip addresses.

2. Your router (wifi modem) has another piece of software which stores (caches) the URL to ip mappings that the DNS server returns, so that it can get you to the URL faster.

3. Your computer (laptop or desktop) has software that caches the URL, ip mappings as well.

To identify the source of the problem I first connected the Ethernet cable that my ISP provides directly to my computer. All the URLs openednup fine. So the problem was not with my ISP’s DNS server. So problem with #1 is ruled out.
Some of you might not be able to follow this step signce your ISP gives you internet via a telephone cable which needs to go through a modem to connect to a computer.

Next, I cleared the DNS cache on my Mac (the command to do that is : dscacheutil -flushcache;sudo killall -HUP mDNSResponder) and tried to traceroute google.com , no change in latency. So, the only problem could be the DNS cache on my router.

So, I tried rebooting my router, Resetting it to factory settings, Flashing the latest firmware, to no avail.

Now, I had the motive, the will and the need to change the firmware of my router to dd-wrt. The open source router firmware running the latest linux kernel #superAwesome. After a couple of minutes of flashing the firmware and couple more to configure the settings I had the router working as new again !

Dd-wrt brings along with it, a bunch of goodies ! But that’s something I’ll leave for the dd-wrt website to explain.

Until next time ….
Kunal

[1] http://dd-wrt.com/site/content/about

Rare Insight ( Blinking an LED )

Just the other day I was going though my YouTube subscriptions and came across a recommendation for an Embedded Systems Programming course. Off late I had started taking interest in hobby electronics ( Arduino , Stellaris launchpad .et.al ) so the recommendation was quite welcome !

Quite a few lessons had already been delivered so I started catching up.

The first few lessons were pretty typical of an embedded systems programming course. You start with the target board ( in this case the stellaris launchpad ) setup your IDE, and brush up the fundamentals of C programming ( no C is not passé ;-) ) . The tutor ( Miro Samek ) also went over some number systems fundamentals ( binary , decimal , hexadecimal ).

Now it was time for the customary blinky program. The “Hello World” of embedded programming and trust me this version of hello world is much more satisfying !  Ah, the thrill of watching an LED blink :) . By now you must be wondering what is the “rare” insight to gain from all of this ? Hang on ;) we’re almost there.

Unlike most Blinky tutorials on YouTube, Instead of importing a standard header file and writing the LED toggling Logic ( LED on -> DELAY -> LED off -> DELAY ) inside a while loop. Miro started with the datasheet of the microcontroller and then gradually built up to the Blinky program ! I’d leave the explanation to the one who does it best. Below is the youtube video where Miro explains the Blinky program from “scratch”.

The “rare” insight gained from the above video is that, that’s exactly how Memory Mapped I/O happens ! I have read about it a million times but somehow, watching EXACTLY how it happens, makes so much more sense.

Also in his whole video series ( http://www.youtube.com/playlist?list=PLPW8O6W-1chwyTzI3BHwBLbGQoPFxPAPM) he always takes you from the basics and leaves you with a confidence that, given any development board you can find your way around , even if there are no standard header files provided with it ! ( As long as you have the datasheet ).

Overall, a great tutorial ! definitely worth the Time and Effort.

Python Buildout a beginner’s Guide

Eggs and Buildout Deployment in Python – Part 2 from Sergio de la Cruz on Vimeo.

 

This video is one of the few videos that i found online that goes step by step through using buildout.

What is BuildOut ?

“Buildout is a Python-based build system for creating, assembling and deploying applications from multiple parts, some of which may be non-Python-based. It lets you create a buildout configuration and reproduce the same software later.”

Pythonic HTTPS access

NOTE: Twitter Has Disabled Basic Auth as of August 31 2010 so this example will not work

I could have also named this post “Python HTTP POST with Basic Authentication?” But i wanted to keep it simple , and really this post is just meant for documentation purposes.

import urllib
import httplib2
import sys

if len(sys.argv) != 2:
    print "Please enter message"
    raise SystemExit

msg = sys.argv[1]

username = "user"
password = "pass"

http = httplib2.Http()
http.add_credentials(username, password)
response = http.request(
"https://twitter.com/statuses/update.xml",
"POST",
urllib.urlencode({"status": msg})
)

if response:
    print "Update OK!"
else:
    print "Error updating..."

The “bleeding edge” dilemma

The urge to run the latest trunk of KDE is too great ! but the fact that the trunk is not the most stable keeps a lot of us away from it. Our Friends over at project neon have done a great job trying to address the same issue.
But the problem is slightly bigger than this, imagine a scenario where you are working on two projects and for one piece of code to run you need to uninstall a few installed packages this breaks another piece of software that you need for another project.

Or another scenario would be , you are about to install an experimental piece of software. Do you leave your system in an inconsistent state if that experimental software doesn’t work ? Do you take a back-up ? or do you try to pull off a complex trick of lots of Alternate environments ?

The most embarrassing situation is when you go to your local Free Software User’s Group / LUG to give a talk about how great your OS and its applications are , and just when you are about to speak the app you were showcasing crashes , Damn !
How do you ensure that your apps don’t crash while giving the demo and also maintain your latest unstable hack to your favorite software without both getting into each others way ?

What is the solution to all of the above problems ?
I propose using Boot environments, on Open Indiana a.k.a Oi (Solaris) ( I have started to love this Distro , but my first love is always belenix.org :) )
Now supposing you have a clean install of you create a snapshot

$zfs create snapshot mydistro@firstInstall 

and now make this snapshot bootable

$beadm create -e mydistro@firstinstall FirstInstall 

Now go ahead and bork up your system :)
You may want to come back to the borked system again later, so you create a new snapshot and make it bootable.

$zfs create snapshot mydistro@borked
$beadm create -e mydistro@borked Borked 

now you want to boot into the borked Boot Environment next time.

$beadm activate Borked 

reboot, and in the OI grub you will find FirstInstall and Borked entries, select the one you want and continue working. FirstInstall lands you up
in the system before you borked it up. Enjoy hacking :)

more info about boot environments and beadm
That’s all for now! Give OI a try , you may switch over ;)
Until next time !
Kunal

First step to getting KDE on OpenIndiana : Boot OpenIndiana ;)

OpenIndiana is a project created from the ashes of OpenSolaris. When oracle decided to close the development of OpenSolaris, some brave folks forked the kernel and put together a user-space to form OpenIndiana (OI), Its a great distro ! Above all its got software innovations (ZFS , dtrace, crossbow etc) which the linux userland can just dream of :) (Though systemTap , btrfs are quite commendable as well.)

OK , so i have this great new distro and i love KDE so i want to see if my favorite softwares (Kate , amarok, digikam) work on OI or not. And sure they do ! (/me feels good here :)) the KDE – Solaris team has already created a repo with the latest KDE 4.6 packages. So , now i am convinced that i must start using OI. So i dump the dd image onto a USB stick and connect it to my laptop (a Dell Studio 1450). Now the fun stuff starts :) OI doesn’t boot !!!!

After reading countless blogposts and consulting people on IRC (DrLou on #openindiana apparently had the same problem as me , and we sat together for 3 days (with breaks ofcourse :) trying out everything that we could find) . In the mean time i had posted my problem to the OI discuss mailing list as well. Finally after a 2 day wait , i got replies from the OI gurus on the discuss mailing list. The message from Garrett D’Amore was particularly useful , he suggested me to add the -k option to the kernel line in grub and boot , this would fire up the In-Kernel Debugger the KMDB when i pressed “F1-A” during the boot process. But alas ! this didn’t work either :( Now i was desperately in need of some new ideas. Garrett’s post hinted me to check out more OI kernel flags. As it turned out, in an obscure wiki entry in BigAdmin (the solaris admin wiki) there was a mention of the flag “-B acpi-user-options=2″ i appended the kernel line with this option and presto ! OI booted !. Now this was after 3 days of “beating around the bush” debugging and it felt great :) . So, i headed over to #openindiana and told DrLou about my findings , and after a few tries even his laptop booted !! Yay ! (Supposedly this acpi bug comes to haunt users of solaris , from time to time :))

Now all that i had to do is to create a new beadm ( look up the solaris man pages , you will be amazed !) and add the bionicmutton repo to OI and that’s it, i have KDE 4.6 on OpenIndiana. OI Looks and Feels much better now ;)

This blog post is to document two things:
1. ” -B acpi-user-options=2″ might get OI to boot on your machine.
2. Never give up any problem , if you are facing it , you can be pretty sure someone else is facing it too ! stick to the problem and solve it.
(And after you solve it , in the Spirit of Good Will , share it with others by documenting it in your blog/wiki)

KDE solaris needs a lot of polish and could do with some more contributors. So if you have some spare time , drop by at #kde-solaris , #openindiana , #illumos on freenode.

That’s all for now ,
Until next time ;)
Kunal