Archive for July, 2008

Posted on 07-23-2008 under howto, linux

I had been delaying this for a long time. Since I very rarely boot into Windows these days, it has been a real pain to access my phone’s memory card. I don’t have a card reader so I can’t do that either.

Earlier on I had looked into several ways I could do this, but nothing was clean and simple (like it should be). There was literally no way you could get away without having to put your hands right into the guts of the Linux OS and play around with devices and source code. And since, more often than not compiling source code fails because of some obscure dependency issues, I dropped the idea in favor of sanity.

Things have become a lot better since then. Thanks to Debian’s packaging system all you need to do is issue some commands and install something called openobex. I’m going to discuss what I did in order to get my Nokia 6630 to work with my Debian box using the USB cable that came with it. Start by updating your database and installing what we need.

# aptitude update# aptitude install obexftp obexfs

To check if your phone is being detected properly

# obexftp -u -l

Which should give you something like,

Found 2 USB OBEX interfaces
Interface 0:
          Manufacturer: Nokia
          Product: Nokia 6630
          Interface description: SYNCML-SYNC
Interface 1:
          Manufacturer: Nokia
          Product: Nokia 6630
          Interface description: PC Suite Services
Use '-u interface_number' to connect
Connecting...Segmentation fault

We need one piece of info from this list: the right interface. As you can see, Interface 1 describes itself as “PC Suite Service”, and this is what we will connect to.
Next we issue a command to list the parent directory on the phone.

# obexftp -u 1 -l
Connecting...done
Receiving "(null)"... <?xml version="1.0"?>
<!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd"
  [ <!ATTLIST folder mem-type CDATA #IMPLIED>
  <!ATTLIST folder label CDATA #IMPLIED> ]>
<folder-listing version="1.0">
   <folder name="C:" user-perm="RW" mem-type="DEV" label="Phone memory"/>
   <folder name="E:" user-perm="RW" mem-type="MMC" label="NO NAME    "/>
</folder-listing>done
Disconnecting...done

We got our folder listing!! … But its all in XML. You can make out the folder names C: and E: in the last few lines. These represent the phone’s memory and the memory card respectively.

You could now use obexftp to copy files to and from your phone (read the man page for more details). An example:

# obexftp -u 1 -c E:/Music -p Take\ A\ Message.mp3
Connecting...done
Sending "E:"... Sending "Music"... done
Sending "Take A Message.mp3".../done
Disconnecting...done

This is all well and good but not really what we’re looking for. As much as I love the command line, and swear by its efficiency, I do like to use a GUI interface to manage my files. Never fear, obexfs is here!
ObexFS allows you to mount your phone so that it behaves like a normal directory. You can then access the directory in any file manager you want. It does this by using a little something called Filesystem in User Space.
First you will have to load the fuse module

 # modprobe fuse

Create a directory

 # mkdir /media/phone

Then

 # obexfs -u 1 /media/phone

Where 1 is our interface number from before. Getting a file listing should show you the directories C and E.

 # ls /media/phone

Oh glee! But wait, we’re not finished yet. If you’ve noticed we’ve been logged in as root the whole time. If you log out and try to access the mounted filesystem, you will not be able to do so as normal user! We have to fix this now.
First you’ll have to add yourself to the fuse group.

# usermod -a fuse zohair

Replace zohair with your username, of course.
Then add the following lines to /etc/fstab. (Note how the spaces in the command line disappear in the fstab listing)

obexfs#-u1      /media/phone    fuse    allow_other   0       0

The allow_other option is needed because by default only the user issuing the mount command can view a fuse filesystem. But we want everyone to see it.

# mount /media/phone

Done. Log out of root and access the files as normal user. If you can read but not write change the file permissions of /media/phone (or wherever you choose to mount your phone). You might have to unmount it in order to do so.

# umount /media/phone
# chmod 775 /media/phone

I’m not entirely sure that an unmount is necessay. The chmod option gives the owner (root) and the group (normal user) read, write and execute access while letting others only read and write.


REFERENCES:

EDITS:

Posted on 07-22-2008 under general

 Has anybody been noticing the absolutely wonderful weather we’ve been having in Karachi the past couple of days? I just can’t believe it. Its just so … wonderful. After the humidity of the past couple of weeks, its a refreshing change. And surprisingly, the sunshine doesn’t sting as bad as Karachi’s usually does. Not to mention the beautiful sea breezes in the night.

I’m going to miss Karachi. Then again, I just can’t wait for my visa. I’m confused!! Aarghh! :\

Posted on 07-04-2008 under avr

As promised, here come the schematics.

Porgrammer Schematics v2 [pdf]

If you want to run this cable with PonyProg, in the Setup->Interface Setup dialog choose Serial. In the drop-down box choose SI Prog API. In the check-boxes below you’ll have to check all except RESET.

Pony Prog Settings

If you’re using avrdude, you’ll have to add the following to your avrdude.conf file.

# SIPROG Inverted programmer
# reset=!txd sck=rts mosi=dtr miso=cts

programmer
  id    = "siprogn"; 
  desc  = "Inverted Lancos SI-Prog “;
  type  = serbb;
  reset = ~3;
  sck   = ~7;
  mosi  = ~4;
  miso  = ~8;
;

More information on the programmer is in the README.

A shot of the cable is below. Its short, but thats because we had already converted the serial port signals to TTL. Of course this is really too short. You can make it a bit longer. Ideally of course, you the longer length should be before the level conversion stage. If you can get your hands on a serial cable, that would allow and instead of plugging the programmer into the computer, you plug it into one end of the cable, you can really extend its operating distance.

Programming Cable

REFERENCES:
LancOS’ site has a few nice serial schematics but all of them use discrete components to do level conversion, and frankly, I dont trust discrete components. At least, not the ones available in our maket. This schematic shows the pin connections on the serial port for the SI Prog programmer. Using this allows us to program using PonyProg.
This page uses a similar Max232 connection. We got the idea to use 10nf capacitors from here, thus reducing the size of the ciruit.

NEXT STEP:

USB. woo!! This is gonna be really easy actually because some circuits are already available online. One of these I really like is ladyada’s circuit. Although I think I can do away with the buffer. And I might have to replace the ATTiny with an ATMega8 because I might not be able to find it in the market.

EDIT [ 14th July, 2008 ] : Corrected a problem with the RESET circuit.

Posted on 07-03-2008 under avr

Our brand new office PCs didn’t have serial or parallel port in them. USB is great for normal people, but we NEED serial and parallel ports to do our work. We then have to buy extra hardware to add serial ports via USB.  Which is getting more and more expensive and less and less reliable.

For example, we bought a PCI parallel and serial port adapter which looked promising enough. Unfortunately it refused to budge. After much scratching of chins, and a lot of poking around, ranging from loading userspace drivers on Windows, to installing Debian and trying to access the port from there; we found that the chip on the board was faulty. Similar problems lie with almost all converters that are available in the market, or so I’ve heard.

We had to actually “make” a serial port by pulling lines directly from a header on the motherboard.

So we banged up a simple RS-232 programmer that uses the serial port to program an AVR. Simple and minimal, it uses only a MAX232, a transistor and diode, and a couple of resistors thrown in for good measure. Estimated price, under Rs. 100. See the pic below. (All the soldering is credited to Qaiser Hussain who is amazing with an iron).

Avr Serial Programmer Front

More details, including schematics and programming instructions coming soon :)